[Scummvm-git-logs] scummvm master -> 100ea9ff0e2517d9c61dccd8378e74333b91cb2a

sev- sev at scummvm.org
Tue Sep 3 17:36:15 CEST 2019


This automated email contains information about 1000 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
cf7c1f35e6 HDB: Remove 'Process Gettable Item' stub
76d2426613 HDB: Complete cineUse stub in lua-script.cpp
6341309b60 HDB: Add ai-inventory.o to module.mk
79023f0f9e HDB: Pass correct variable into warning()
a9a2ee0479 HDB: Add getStringOffStack()
1c268c03bb HDB: Add initAllEnts()
ba78805c92 HDB: Call initAllEnts() after map is loaded
b449bd6fe2 HDB: Hid some annoying STUB warnings
2dd40d79a2 HDB: Add stubs for caching graphics and LaserScan
15d964afec HDB: Add _actionMode and its getter-setters
71e735e101 HDB: Add Entity Speed constants
16740814d0 HDB: Add spawn()
5e9dba2aff HDB: Scan all icons and process them in Map::load
4a7980c8cc HDB: Add GfxCache struct
898d32e1de HDB: Add _gfxCache to store cached graphics
f6fe88bab9 HDB: Add getGfx to get and cache Gfx files
96e37fdf47 HDB: Add AnimFrame constants and extend AIEntity
65ca4062e3 HDB: Add additional player frames
deaa694591 HDB: Add cacheEntGfx()
266bcfb97a HDB: Remove Cache Gfx stub from spawn
8810def2b2 HDB: Add debug output to C_SETENTITY
641c2a9179 HDB: Added Lua print stack utility function
e7c72d0580 HDB: Fixed nu,ber of parameters when calling Lua functions
d6852227e8 HDB: Add Waypoint data
b0f714cb25 HDB: Add clearWaypoints()
e473c1d489 HDB: Add stopEntity()
e39f5c361f HDB: Add cineLockPlayer() and cineUnlockPlayer()
2868423cd3 HDB: Process cineLockPlayer() + cineUnlockPlayer()
b2d1bbf5f5 HDB: Remove cineLockPlayer + cineUnlockPlayer stub
054a9a5530 HDB: Add setEntityGoal()
3a8a79f2cc HDB: Add cineMoveEntity()
89ceed2798 HDB: Process cineMoveEntity()
0aee0d4ebc HDB: Remove cineMoveEntity stub
157bd54fc3 HDB: Add cineEntityFace()
dfdcbd8b4f HDB: Process cineEntityFace()
28e8f3d789 HDB: Remove cineEntityFace stub
3fc0cb74b1 HDB: Remove 'Cache Graphics for Inventory' stub
11685a6ba1 HDB: Add animLuaEntity()
511ec64e0c HDB: Remove animEntity stub
f813145808 HDB: Clear Waypoint data in AI::init()
b0cd169cb9 HDB: Clear Player Graphics in restartSystem()
6c8dce6c17 HDB: Fix member variables names
630c6b44f8 HDB: Clean up Lua stack after script execution
629ba37616 HDB: Add debug output to findFirstData()
6e34039153 HDB: Fix waypointGfx DataType
ae876db69c HDB: Fix special1Gfx data type
1b25f846a1 HDB: Fix switch-case warnings
dcc30b45ac HDB: Fix type of loaded
f1344e261d HDB: Add constructors to all structs
46918c917e HDB: Compilation fixes
949f27872a HDB: Add constructors to Tile and Picture
15c2a946d1 HDB: Modify _inventory to an array of InvEnt*
5c2cfac209 HDB: Add clearInventory()
f9c21da88b HDB: Add getStandFrameDir()
36613d3196 HDB: Unstub aiPlayerInit()
55587c0751 HDB: Fix type of certain gfx arrays
a0ea424e08 HDB: Modify GfxCache to take tileGfx and picGfx
5bf7e9c23d HDB: Compilation fixes
ec5fea4e97 HDB: Split getGfx() into getTileGfx and getPicGfx
caff981b2f HDB: Add selectGfx()
8c62378090 HDB: Modify cacheEntGfx to use new gfx functions
8b91a75676 HDB: Unstub aiPlayerInit2()
77974e317c HDB: Fix warning() calls
2d7c0adabd HDB: Unstub aiPlayerDraw
3060427fe6 HDB: Modify C_MOVECAMERA debug output
00a8da026e HDB: Add animEntFrames()
be5b717c85 HDB: Add Anim Flags
55b5acb959 HDB: Add setter functions for BG/FG tile indices
244a51298f HDB: Add data for the Map Tile Animation Cycle
04ff0635f1 HDB: Add addBGTileAnimation and addFGTileAnimation
198e26e652 HDB: Add removeBG/FGTileAnimation()
13c614bd3a HDB: Unstub setBackground() and setForeground()
cad0e0bb98 HDB: Add cine clear FG, and set BG/FG functions
7dda9ea020 HDB: Process C_CLEAR_FG, C_SET_FG, C_SET_BG
223d024e30 HDB: Unstub cine functions for fore/background
fd8ad8e3da HDB: Fix signed/unsigned mismatch warnings
1cae287783 HDB: Modify getTileIndex to accept NULL input
3969a805ab HDB: Add AIEntLevel2 data
ffa56e7c4b HDB: Fix type of *draw
18763082bf HDB: Add stubbed AI::drawEnts()
edb6133e42 HDB: Add Map::drawEnts()
80b76d24f8 HDB: Add animating tile lists to Map::load
cb341ee6cc HDB: Add FPS and AnimDelay constants
94d443bfa8 HDB: Add animateTile()
e4edb7dc50 HDB: Add Foreground data
4d57cefb6c HDB: Unstub Gratings and Foregrounds check
76e4758b2b HDB: Unstub Animated Map Tiles
60b4c33a9c HDB: Add NULL check to BG/FG tile animation
4d22df8037 HDB: Add drawForegrounds() and drawGratings()
aec87e7058 HDB: Add _floats data
b913a3632d HDB: Add time-keeping functions
a56dca47f8 HDB: Unstub 'Draw Floating Entities'
1a8292fccb HDB: Unstub 'Increment Stun Timer'
b6520708a5 HDB: Draw Entities, Foregrounds and Gratings
76b589c901 HDB: Add checkFloating()
bbe7c82069 HDB: Add onEvenTile()
755bd46728 HDB: Add killPlayer()
bf98bcca01 HDB: Add removeFirstWaypoint()
c12d1a2cec HDB: Add stubbed animateEntity()
16d6c638e8 HDB: Unstub aiSergeantInit/2 and aiSergeantAction
1ad0764274 HDB: Use Masked Blitting instead of MaskedAlpha
8c024e7f57 HDB: Remove stubs from processCines: C_RESETCAMERA
b085dcfa97 HDB: Remove stub from processCines: C_USEENTITY
d5dca7ea7c HDB: Add variables for AutoAction tiles
db838a656e HDB: Add animGrabbing()
4965fecadc HDB: Add stubbed Action Functions
f80550e524 HDB: Add AutoAction struct and _autoActions array
204a9424cf HDB: Add list functions for _autoActions
dfa76fc545 HDB: Add _animTargets and related data
ab917b038a HDB: Add addAnimTarget() and animateTargets()
7c823019be HDB: Add _dummyPlayer as Virtual Player
dd6f335925 HDB: Remove _dummyPlayer stub from getPlayer()
00f125e7bd HDB: Unstub checkAutoList() from C_USEENTITY
5cba8ae09c HDB: Remove Player Gfx stub from lookAtEntityXY
154fc3c7f3 HDB: Add _actions list and related data
653960f58a HDB: Shift Action initialization to AI()
a39b9f373c HDB: Modify AI pointer arrays to be struct arrays
2cdf2a62de HDB: Add stubbed addWaypoint()
43f6a0a475 HDB: Add checkForTouchplate()
ab0402622e HDB: Add findEntity()
c3755f74ce HDB: Add addToActionList() and checkActionList()
070a1c45b2 HDB: Comment out C_USEENTITY
2b2d375027 HDB: Fix initialization warnings
d1a48b9d6f HDB: Fix CineCommand string and title values
996ae929fa HDB: Add checkAutoList calls to C_USENTITY
776b257e52 HDB: Add cacheTileSequence()
ef7eaa9257 HDB: Add NULL checking to getMapBG/FGTileFlags()
b2ee1c6802 HDB: Add checkOneTileExistInRange()
0b4a6fd1b0 HDB: Add initAnimInfo()
b351bec867 HDB: Call initAnimInfo() from hdb.cpp
168dd10981 HDB: Add entityName to _dummyPlayer
2e820d0e69 HDB: Add debug output for activateAction
6e9647eab5 HDB: Fix local variable warnings
a990792f9a HDB: Add the loadPic() helper
3ffbcec87e HDB: Add Window Class
28ab1f9549 HDB: Add and init the _window subsystem
21cbd050d4 HDB: Fix wrong code introduced during debugging
fcd8b6e00a HDB: Update module.mk
38e5b71668 HDB: Correct const-ness
a3b650be36 HDB: Added warning to catch ambigious code
86cc1df32d HDB: Fix crash when executing Lua with debug options
0cd1ffc34e HDB: Fix crash during initialisation
32b99eb8b8 HDB: Add struct DialogInfo and _dialogInfo
5ae9b45489 HDB: Add Font data
954d1c649c HDB: Add getter-setter for the cursor
e7ddd0b527 HDB: Add getter-setter for Kerning and Leading
94747f0f76 HDB: Add getter-setter for Text Edges
ae872f3569 HDB: Add getDimensions() to calculate pixel width
a427871168 HDB: Add loadFont()
6d28554d2a HDB: Add drawText()
fbc5dffc10 HDB: Init Cursor, Text Edges and load Game Font
a9314535c8 HDB: Remove 'Add Animating Info' stub
6336ce6f42 HDB: Add Dialog constants
ae32825243 HDB: Add openDialog()
66a7c617df HDB: Add setDialogDelay()`
da528445f9 HDB: Add cineDialog()
22d4f60b3a HDB: Process cineDialog()
a53b2c9550 HDB: Call animateTargets() from hdb.cpp
538efcad6b HDB: Add cineDialog() Lua function
0c8dad3a40 HDB: Add cinematicsActive()
535c56aa4d HDB: Add closeDialog()
d48404d087 HDB: Add checkDialogClose()
a1b1275764 HDB: Add and modify debug output
2f5367b0df HDB: Add drawBorder()
4b28b535bc HDB: Add drawDialog()
8cdd69ba41 HDB: Call drawDialog() from hdb.cpp
fd5d7ae477 HDB: Add moveEnts()
3522d6f334 HDB: Add debug output
11b19dd013 HDB: Call moveEnts()
9165641d69 HDB: Fix portability issue
8a66089796 JANITORIAL: Remove trailing spaces
a23fbd7b6b HDB: Adding tracing of entity drawing
d973d258dd HDB: Add debug output for font data
b7c5c2e815 HDB: Fix type and reading errors
7389d7d819 HDB: Add openDialog() call to hdb.cpp
87f8ed55b1 HDB: Fix character blitting
e625ce1ccd JANITORIAL: Whitespace fixes
8be8ef73df HDB: Add Infobar data
c0d9281b45 HDB: Add setInfobarDark()
0dcf1568ee HDB: Add setInfobarDark() Lua function
f3bfdf4295 HDB: Fix dialog border drawing
727c0b81ad HDB: More debug output for entity drawing
9671f336cf HDB: Fix drawing function calls
8419b98855 HDB: Add picture debugging code
7d4cc693b4 HDB: Add _cineBlitList and _cineFreeList
667641ed57 HDB: Add _cineBlitList functions
d41983e837 HDB: Add _cineFreeList functions
b3b5ef0b56 HDB: Add cineAbort() and cineCleanUp()
d5778951b5 HDB: Add cineMoveMaskedPic()
e896fa8470 HDB: Process cineMoveMaskedPic()
a2af042430 HDB: Add cineMoveMaskedPic() Lua function
2a04717617 HDB: Remove checkDialogsClose() stub
8e099fdc2d HDB: Remove stub for _cineBlitList drawing
043cd2e129 HDB: Remove addToActionList() stub
680b8ce846 HDB: Remove addToAutoActionList() stub
d3d0ceee41 HDB: Add cineStop()
e46e8b45d8 HDB: Process stopCine()
d7cc3ab225 HDB: Add cineStop() Lua function
812878661a HDB: Add cineAnimEntity()
2f54ef2f7f HDB: Process cineAnimEntity()
6eab766f99 HDB: Add cineAnimEntity() Lua function
e1b5fca018 HDB: Add cineSetAnimFrame()
9c0b5d939e HDB: Process cineSetAnimFrame()
5048f1b3ae HDB: Add cineSetAnimFrame() Lua function
91e74dca09 HDB: Fix boolean check
f937418f6d HDB: Add debug output
f8d7dd18d0 HDB: Fix setEntityGoal() direction
32e30366a4 HDB: Added more debug output and hid some noisy one
8d087a3c7f HDB: Added rest of the stubs for the rendering pipeline
f49b4d3221 HDB: Implemented AI::drawLevel2Ents()
a28eb3e60e HDB: Fix space formatting
4be327e394 HDB: Add findEntityIgnore() and findEntityType()
12a677d900 HDB: Add legalMove functions
70888532f8 HDB: Add checkPlayerCollision functions
ace7d27546 HDB: Add _arrowPaths data
1bfa1c1d0e HDB: Add addToPathList() and findArrowPath()
b9b1947894 HDB: Remove addToPathList stubs
fcdd7511d1 HDB: Add findPath()
bb674ec9c1 HDB: Add OmniBot functions
087f84b38b HDB: Add aiOmniBotMissile functions
63358b754e HDB: Add aiTurnBot functions
855fd3805c HDB: Fix space formatting
595b520f4a HDB: Add checkEntOnScreen() and checkXYOnScreen()
88bab8cc79 HDB: Add getter-setter for _mapExplosions
ca15646569 HDB: Add getter-setter function for _mapExplosions
10246121e0 HDB: Add getter-setter for _mapExpBarrels
4657593aa4 HDB: Add aiShockBot functions
c01eb1a61e HDB: Add RightBot functions
9be8ac9d35 HDB: Add dialogActive()
43e738ec17 HDB: Add _hereList data
a65936283d HDB: Add _hereList functions
69235618f2 HDB: Add _teleporters data
dc0ad525cd HDB: Add _teleporters related functions
72ee6a2bc5 HDB: Add Inventory getter-setter functions
248099ec76 HDB: Add PushBot functions
2a3ee7e2ef HDB: Add RailRider functions
f45904ca30 HDB: Add inventory drawing data
4344b2f8c8 HDB: Add getInvItem()
9ba96ae83e HDB: Add loadTile() and stringLength()
8f7e0479fc HDB: Add drawInventory() and related functions
37a393e9e1 HDB: Call drawInventory() from hdb.cpp
aa793bdcfd HDB: Added more debug output and hid some verbose stubs
8dbbb9b85c HDB: Added some code to stopping entity.
11166ea5d3 HDB: Added missing code to AI::stopEntity()
578b063a9d HDB: Add debug output to cineDialog
a070e60617 HDB: Fix Lua stack indices
cbf4888e2f HDB: Fix index for _charInfoBlocks
1c0da3526c HDB: Add statements for text render debugging
9ef57f67de HDB: Fix the type of _foreground and _background
03f84464cb HDB: Added test case for Dialog
79e33b113a HDB: Fix CineCommand struct, use const char * insted of preallocated arrays
7858f01170 HDB: Fix parameters in cineSetAnimFrame()
fbf1af2654 HDB: Unstub aiMaintBot functions
9f3fab3b4e HDB: Add hitPlayer()
d3c2c935a5 HDB: Add aiFourFirer functions
407c1913cc HDB: Replace booleans with macro function
f4ec024460 HDB: Add aiDeadEye functions
3343787666 HDB: Fix dialog text spacing
c0413509f1 HDB: Fix tile loading
406185408f JANITORIAL: Remove trailing whitespaces
efe0071fb4 HDB: Fix rendering surfaces without keycolor
8d4168ca58 HDB: Hid noisy stubs
3f01af23cf HDB: Added several Lua global values
e3808675d2 HDB: Add stubbed Input class
1b7034cd87 HDB: Add _input subsytem and init it
d553a37e39 HDB: Fix type of getMapBG/FGTileIndex
c946f42a92 HDB: Add remaining game Flags
4153d92b5a HDB: Add mpc.h from source files
4905233ef0 HDB: Add floatEntity()
b6bfa8c03e HDB: Add _dummyLaser
8aa509d9bf HDB: Remove the stopEntity stub from animateEntity
fbeb7f8c4e HDB: Add _triggerList data
368e80c75f HDB: Add lua_push functions and call()
0f313f3eda HDB: Add functions related to _triggerList
459921b046 HDB: Remove error message stub
00e6ce2680 HDB: Add invokeLuaFunction()
c0db320111 HDB: Add spawnBlocking()
86f7991eba HDB: Add _luaList data
0f4e637e2a HDB: Add _luaList functions
36dd16e1a9 HDB: Remove checkLuaList() stub
922e70b723 HDB: Remove 'checkTriggerList' stub
ef25f37258 HDB: Fix warning
72173c26d0 HDB: Fix warnings
3338849458 JANITORIAL: Add endline to the end of file
a98e246347 HDB: Add remaining luaGlobalStrings\Values
678de0f73f HDB: Add _callbacks data
dbfddba4cf HDB: Add stubbed aiBarrelExplosionEnd(int, int)
761c90e62a HDB: Add functions related to _callbacks
235040fb8a HDB: Modify constants for simpler access
0daae85340 HDB: Add and call useAutoDoorOpenClose()
dfa9a6bb3b HDB: Add FIXME for out-of-bounds access
091437533e HDB: Add debug output
576a2605da HDB: Track and assign new pointer after erasing
1acba7e5bb HDB: Update debug output
f8b436cab7 HDB: Fix gem counter position
a3e12b0708 HDB: Fix compiler-error thrown by constructor
4461c1b7ef HDB: Fix warnings
e18effcce4 HDB: Rewrite _animTargets as a struct array
3c44d05daa HDB: Fix initialization error
55c78f1f53 HDB: Fix formatting
9182fef47d HDB: Add stunEnemy()
8057837ba7 HDB: Add cycleFrames()
85a16cba27 HDB: Unstub aiPlayerAction()
f50ff7aabb HDB: Modify debug output
f74437e503 HDB: Unstub checkTeleportList()
763cc24c4c HDB: Fix warnings
003f8dc2a4 HDB: Move constants to draw-manager
48428a75b7 HDB: Add _textOutList data
178bb473c1 HDB: Add _textOutList functions
6d73298362 HDB: Call drawTextOut()
ba002d8616 HDB: Add cineTextOut() and cineCenterTextOut()
a406218c2e HDB: Process cineTextOut() and cineCenterTextOut()
9bd1d58b82 HDB: Add Lua cineTextOut() and cineCenterTextOut()
2d7ab33be2 HDB: Add _textOutList.push_back() call
4c5cb8bafe HDB: Add _gameState check
105abf5429 HDB: Add Pointer/Cursor data
40b23d122d HDB: Add Pointer functions
ea40074d84 HDB: Add getMouseX() and getMouseY()
1370cf8b9d HDB: Call DrawMan::drawPointer()
437b9a86a1 HDB: Add getter-setter for _gameState
14d83c9667 HDB: Unstub animGrabbing() call
6a6f0e99d8 HDB: Add tileDistance() and waypointsLeft()
fe914ffd41 HDB: Add setTargetXY()
0b87875a3a HDB: Unstub stylusDown()
037400ed1b HDB: Unstub stylusMove() and stylusUp()
f41e1999fb HDB: Add updateMouse() and call it in game loop
4a8ce49968 HDB: Remove _lastMouseX and _lastMouseY
6d75390e84 HDB: Add checkInvSelect()
5e0e12531b HDB: Update Mouse data for buttons
ff25a0f4dd HDB: Add updateMouseButtons and update updateMouse
5b327fb519 HDB: Fix bug when drawing gratings
b42109d368 HDB: Add _pauseFlag data
a607dd1bcd HDB: Add functions related to _pauseFlag
568ec34994 HDB: Add drawPause() and checkPause()
0ede3a249c HDB: Remove 'Check Pause Flag' stubs
ad2fa4185a HDB: Add pause checks to the Main loop
8a63a2169d HDB: Add updateKeys()
08771f2aeb HDB: Add getter-setter for _buttons
3d979e14ff HDB: Call updateKeys() from game loop
81ea30aa18 HDB: Add movePlayer() and playerUse()
806e9fedac HDB: Use case-insensitive string comparison
5b22ced438 HDB: Fix drawing Cine Pics. This affects drawing thorwn clock
6891f478a6 HDB: Add cineAbortable()
f0ab92faa1 HDB: Update setButtons()
1f920a201e HDB: Solve ambigious code
9182e0df17 HDB: Made debug output more compact
42ea7a97b0 HDB: Fire callbacks only when thier timeout is triggered
c702968984 HDB: Initialize _buttons
8c3bad6520 HDB: Fix copy-paste error
ea2e293173 HDB: Fix Header Guard and add Namespace
8cf8a96639 HDB: Add _deliveries data
b58b5b7ff5 HDB: Add _deliveries functions
a5c9e053ab HDB: Add stubbed openMessageBar function
56deb86049 HDB: Add _dlvsInfo data for the Deliveries Window
bbfab922cd HDB: Add Deliveries functions in window.h
8423774562 HDB: Call drawDeliveries()
7529d3e2b7 HDB: Fix crash when skipping cinematic
9bc1d5fb6e HDB: Fix directional key logic
709f575190 HDB: Fix getMapBGTileFlags()
ba6ca58d3b HDB: Fix legalMove() check
d848428f56 HDB: Unstub addToList stubs
2f67167c27 HDB: Add NPC functions
bebb2e3956 HDB: Add utility functions
a4eb195ab8 HDB: Remove warning
216ec886ac JANITORIAL: Fix code formatting
e5cf4308b9 JANITORIAL: Fix code formatting
224658a1ba HDB: Fix Maintenance bot path finding. Still it runs too fast
b697371154 HDB: Make animations follow the requested framerate
810dc15f97 HDB: Made main loop running 60fps
2a9c34f95b HDB: Add getEntityXY()
428af6c972 HDB: Add patches for deprecated Lua 4.0 calls
6b5fd8a95f HDB: Add lua functions for dialog and getEntityXY
c3be6f7f2b HDB: Add Inventory functions
f2150cd89a HDB: Add functions for Lua Entities
016e0baca8 HDB: Add entityFace()
c4dbb09675 HDB: Add Lua functions for Deliveries
e895a0929b HDB: Add Lua function for setEntDir()
a07cbc0dd1 HDB: Add Lua functions for Entities + entityFace()
a5ba855dd2 HDB: Add lua function for clearForeground()
50d297637f HDB: Add Lua function for animation()
e441680fbf HDB: Add Lua function for spawn()
1ee37266b1 HDB: Add Lua functions for Inventory
aadc58ca47 HDB: Add Lua function for killTrigger()
8421649142 HDB: Add Lua functions for textOut
2cd3bbe230 HDB: Add Lua function for setPointerState()
f9c560fd9a HDB: Fix warnings, const'ness
d93e0a2d61 HDB: Clip to screen when rendering text. This prevents crash when aborting the cinematics
988ac1f25b HDB: Add _dialogChoiceInfo
13102d05b0 HDB: Add _msgInfo
e3020ee4d5 HDB: Add DialogChoice and MessageBar functions
0aacd2d29a HDB: Add inventoryActive() function
8d74464065 HDB: Add Lua functions for message() and dialog()
ad0ce9a43f HDB: Call drawDialogChoice() and drawMessageBar()
b9fbfa1639 HDB: Unstub DialogChoice and MessageBar checks
cc1e3d5dee HDB: Fix compilation
45b90776e2 HDB: Hid noisy stubs
e31e9dbae1 HDB: Renamed draw-manager.* -> gfx.*
362cb060f3 HDB: Rename _drawMan -> _gfx
d55370ac82 HDB: Rename class DrawMan -> Gfx
2c520373d9 HDB: Rename map-loader.* -> map.*
2369415b30 HDB: Add Crate related functions
ea8e108cb6 HDB: Add Light Barrel related functions
3b35cb5aa7 HDB: Add Heavy Barrel related functions
77ebf4ae50 HDB: Add Exploding Barrel related functions
e76a738114 HDB: Unstub aiBarrelExplodeSpread()
9c7344ac30 HDB: Add SlugAttack related functions
44de693553 HDB: Add FrogStatue related functions
80c2d35ba6 HDB: Add envelope related functions
cb0f3bc776 HDB: Add Book related functions
d945f28c6a HDB: Add Clipboard related functions
240ab4e36f HDB: Add Note related functions
7fdef04af9 HDB: Add PDA related functions
dcce09471d HDB: Add Cell related functions
6247f1ebec HDB: Implement Window::closeAll()
6ffe021709 HDB: Reset _dialogInfo before each dialog.
41c1353edc HDB: More portable struct initializers
662f874c54 HDB: Fix tile animations
480b665e87 HDB: Use constant as framerate
d5e9324969 HDB: Initialise variable
2e171ad5fe HDB: Fix tile animation speed
7d08524b77 HDB: Shift Bots stubs to ai-bots.cpp
d88f4fb7c0 HDB: Add callbackDoorOpenClose() and use function
60958086c2 HDB: Add aiGemAttack functions
34f0992c4d HDB: Add aiChicken functions
a1fbe844b4 HDB: Add aiRoboStunner functions
7e586c9f21 HDB: Add aiClub functions
c0e2f9b479 HDB: Add aiSlugSlinger functions
5617ec541a HDB: Add Gem functions
b0b096402c HDB: Add functions for TeaCup, Burger and Cookie
c6f4bdc2c1 HDB: Add Keycard functions
a870b93421 HDB: Add Seed and Soda functions
dd53729b81 HDB: Add Dolly Tools, Splicer, Package and Router
70fb0e81cc HDB: Add functions for Magic Egg
7871ad6007 HDB: Add IceBlock, ItemChicken and CabKey
169c4d86f6 HDB: Add Transceiver functions
bbecaabf32 HDB: Add Monkeystone and GooCup functions
b8a98fdcfe HDB: Add Vortexian and AI_NONE functions
34b9457adc HDB: Delete functions missing from original
bebd51479e HDB: Add traceStraightPath()
b8b47c09fd HDB: Unstub addWaypoint()
5d874c540e HDB: Add and init Sound subsystem
4622fb3b80 HDB: Unstub playSound calls
ce06f4eb9e HDB: Fix compilation
734995512e HDB: Added more script patches
106a63aa81 HDB: Add LASTMAPNAME Lua variable
af43070e15 HDB: Implemented HDBGame::startMap()
34a3e1685b HDB: Added stub for Menu class
74eb242b5a HDB: Unstub HDBGame::restartMap()
c3c8299962 HDB: Completed rendering pipeline
4baa1e4f20 HDB: Add isClosedDoor() and isOpenDoor()
10802c22fb HDB: Add _bridges data
73b7b83098 HDB: Add addBridgeExtend() and animateBridges()
661ee3b104 HDB: Add useTarget()
e3ceb4dfbd HDB: Add Switch functions
c2c639cfc4 HDB: Add Cell Holder function
e1d69ed389 HDB: Add Touchplate functions
eacc59bca9 HDB: Add useDoorOpenCloseBot()
e97d425b8a HDB: Unstub printYouGotMsg call
347dd30f78 HDB: Implement loadLua()
3eab2731cd HDB: Implement loadMap()
1cd0a8d936 JANITORIAL: Fix formatting
ffe05e989b HDB: Add checkForTouchplate()
37b09c6e3d HDB: Implement boot params.
9369775b76 HDB: Fix compilation
5e343d6591 HDB: Add checkForTouchplate call
9da57f1eb7 HDB: Add startMap lua function
478c10a1fb HDB: Unstub aiVortexianAction
e319b120da HDB: Modify warning to debug output
f35b63bc13 HDB: Prevent crash when _skyClounds is empty.
fe9242f412 HDB: Implement safe version of removeEntity(). The previous one crashed
f832f66dd3 HDB: Fix removeEntity to not manipulate pointers
eb388f9a50 HDB: Remove invalid return statement
95c36ed358 HDB: Add Pushing code
a48ee7d111 HDB: Safer version of AI::moveEnts()
595187da81 HDB: Rewrote AI::killTrigger() to a safer variant
7e07602c25 HDB: Fix trigger launching
92a4ff67fe HDB: Implement cineSpawnEntity()
9b6e83451f HDB: Add check for unknown size
1b2437900c HDB: Do not declare AIEntity every frame
1e5e8ed4ec HDB: Unstub 'Cache graphics for Deliveries'
372cf8b734 HDB: Fix uninitized frame counters
85f37fd67a HDB: Hid noisy debug output
0a1ec9097c HDB: Finish cineCleanup()
375498e352 HDB: Fix cineAbort(), so it really removes the state machine program
71cff7f256 HDB: Fix AI::cineStart()
2d04954052 HDB: Safer loops
49cb33911e HDB: Add playSoundEX()
d70888269e HDB: Modify the return type of draw functions
ac04002411 HDB: Add Tile::free() and Picture::free()
c9c08476f1 HDB: Add Gfx data
d356756e6d HDB: Add Diverter functions
bcbe095ef8 HDB: Commet out non-compiling code
64cd74d1b2 HDB: Add aiDiverterAction()
c67fb14640 HDB: Add getGemGfx()
26c1c9440c HDB: Add Meerkat functions
7a6a169422 HDB: Add _fairystones data
292ada30e3 HDB: Add _fairystones functions
002f8edd48 HDB: Add GoodFairy functions
60eb04f833 HDB: Unstub addtoFairystones calls
0751cedb08 HDB: Remove '#if 0' conditionals
ad8f857595 HDB: Move Bots gfx into _gfx
5ed21d12df HDB: Move Bots gfx into _ai class
97d702f891 HDB: Add Gate Puddles
c3f409d0c9 HDB: Add BadFairy functions
de017b0ce9 HDB: Add PanicZone data and functions
8d4dea4bc3 HDB: Add GatePuddle functions
f7be3c5e28 HDB: Add missing initialization data
ff7de3179a HDB: Add icePuff functions
b8a2ed94c6 HDB: Add BuzzFly code
1b924b23b9 HDB: Add Dragon functions
03f1a13786 HDB: Simplify executeChunk() function
10df2d85dc HDB: Fix warning
5f8e3fab2c HDB: Fix warning
9a0e685f0e HDB: Fix warnings
6feed893de HDB: Fix warning
73be5db12e HDB: Attempt to implement hot patches
a29e3b9698 HDB: Proper place for the cheat patches. And wrap them into a define
20f7bf6df8 HDB: Add FatFrog functions
68431702c8 HDB: Add stopChannel()
ab06602332 HDB: Add clearDiverters()
22ca561f4a HDB: Add _laserRescan and _laserOnScreen
48546f3c8d HDB: Add laserScan()
a27faf35b4 HDB: Add Laser related stubs
7bf9cc945c HDB: Add Laser functions
0d2f2f2bf7 HDB: Fix enity lists, and warn on missing files
7caca5d2d0 HDB: Unstub the '#if 0' functions
0ca3f5bd7f HDB: Add Bots splitter-comments
74675ba2d5 HDB: Fix type warning
aed071e5a0 HDB: Add stubbed getMusicVolume()
267ddc8358 HDB: Add turnOnSnow()
0dff3cd8e6 HDB: Unstub Lua Snow functions
ebea69eceb HDB: Unstub lasers and more
a2c9c83b83 HDB: Unstub Window function calls
373106f896 HDB: Add cineStartMap()
f6a3eac497 HDB: Add cineStartMap() Lua function
9b48e15b8e HDB: Add cinePlayVoice() and cinePlaySound()
f89015a90d HDB: Add Lua functions for _sound
d285201ec8 HDB: Disable skipping manny quest for now
5941748209 HDB: Fixed AI::cineRemoveFromBlitList()
c63e7c838b HDB: Unstub stubs
7cb5f460c0 HDB: Add member variables to Menu
3fc69963f4 HDB: Add setInMapName() and related data
06c87e518c HDB: Add HDBGame save() and load()
8d57db2572 HDB: Add Map save() and loadSaveFile()
40879e47dd HDB: Fix Name Change
cdf8d2548f HDB: Remove unreferenced variable
6559b71819 HDB: Fix removeBGTileAnimation() and removeFGTileAnimation() implementations
c819a79c9b HDB: Add Window save() and loadSaveFile()
55a58747e2 HDB: Add Gfx save() and loadSaveFile()
2eb9bdfee8 HDB: Add stubbed Sound save() and loadSaveFile()
6f472b60a6 HDB: Fix Endian reading issues
8b806991b9 HDB: Add save and loadSave functions
2990f6cff5 HDB: Fix endian issues
0a6d4c042f HDB: Fix endian issues
d2df277403 HDB: Add saveSlot, loadSlot, saveGame and loadGame
ce6b62d896 HDB: Turn _gratinds[] and _foregrounds[] into structs from pointers
82fe644f54 HDB: Remove unnecessary functions
69303997ae HDB: Unstub double reads and writes
32465a119d HDB: Modify InvEnt to have AIEntity as member
b4db168f2a HDB: Add AI save() and loadSaveFile()
14f8e0574f GRAPHICS: Fix Managed Surface alpha blending
3851c2d9a6 GRAPHICS: Added source transparency parameter to ManagedSurface::transBlit
168ca5fc0d HDB: Used transparent alpha blitting
a7d78a1b00 HDB: Fix Sky handling
a8a43329bb HDB: Initialise variables
56f0e3f930 HDB: Removed useless warning
fffa7bd1a2 HDB: Unstub _ai->save() call
ebbee5cef4 HDB: Add FuncLookUp structs and functions
17eaafacfd HDB: Unstub code for saving and loading Gfx
910c1ed36d HDB: Unstub Load/Save _ents and _floats
d510e3efe5 HDB: Unstub save/load _animTargets[i].gfxList
961f3b46f0 HDB: Add structs and functions for Lua Globals
85a8209d97 HDB: Add save/load for the Lua Globals environment
2315a05ad3 HDB: Fix calling Lua save/load
6e60d6a287 HDB: Unstub saveGlobal, loadGlobal, purgeGlobals
b7b8b23d29 HDB: Add openFile, write, closeFile Lua functions
cbbe538e5d HDB: More Global script patches
e166f4e3ff HDB: And even more script patches
ec0bd5e667 HDB: Add global patch for io, os, sctrings
ac9f2d634b HDB: Add loadGame() and Sound::stopMusic()
963043f3b2 HDB: Shift Save/Load functions to saveload.cpp
d5a32a2b4e HDB: Add missing time code
00b53b48a9 HDB: Add stubbed functions
b503e2ba71 HDB: Add missing code in changeGameState()
9b43fbfa9f HDB: Save/Load _timePlayed
b1cbf1aeab HDB: Add subbed Menu functions
6e0e4411a1 HDB: Removed useless warning
d12d3ee647 HDB: Proper prototype for saveGameState()
c71426e2f8 HDB: Fix warnings
8403960c99 HDB: Added more code for loading save states from the command line
2b46fcf06d HDB: Properly process non-existent save loading
168921d7d7 HDB: Added debug output to save/load code
f544c83def HDB: Allocate memory on loading
458646981f HDB: Fix Window::loadSaveFile()
42edeb4114 HDB: Fix AI::loadSaveFile()
6fe1d65ca7 HDB: Added initial version for Lua dofile()
d0b5e0fbc7 HDB: Remove non-functioning code
38bdb36b23 HDB: Finish implementation of Lua dofile()
a8b4749c7e HDB: Add Input::assignKey(), LuaScript::isValid()
9d9a1b6c0f HDB: Add readConfig(), writeConfig() and Cheating
538ab04493 HDB: Added missing calls to loadGameState()
6c0684cbba HDB: Added missing calls to Map::Map::loadSaveFile()
c00223a6e9 HDB: Add stubbed songPlaying() and startMusic()
0ae4cb1ea7 HDB: Shift HDB::save() and HDB::loadSaveFile...
4c20c8be12 HDB: Add Sine and Cosine table
40765c4e9b HDB: Add Save struct and _saveHeader
ac4deacf50 HDB: Unstub fillGameSaveSlots()
29d1c96f0e HDB: Add startTitle() and drawTitle()
6f4e80b836 HDB: Add stubbed Sound functions
69e4668422 HDB: Add centerPrint()
9fcb307d1c HDB: Add isVoiceless()
5cb46f6246 HDB: Add Menu functions and other stubs
93155c6433 HDB: Fix Window::loadSaveFile()
e7016e52a9 HDB: Refarcot entity save/loading into separate methods
fe309b1456 HDB: Fix save/loading of inventory
a8877bce1b HDB: Add drawNebula(), drawRocketsAndSelections()
23239d54f6 HDB: Unstub drawToggle, drawSlider, drawWarpScreen
cf5863c794 HDB: Filter out more Lua globals from saving
d5a779168f HDB: Add Pause Button
a510482d64 HDB: Add stubs in Sound and Input
bb6c18496f HDB: Add _menuKey
611041701e HDB: Unstub processInput()
5b4602fdbe HDB: Set _menuKey
58512d2123 HDB: Add Bonus Star functions
f5b9d417b7 HDB: Set and Draw Bonus Stars
ee9de9157c HDB: Add Menu calls
b032068417 HDB: Add HDBGame::start() and remove AI::clearP...
eb7e3582ab HDB: Disable the command-line level-select
d8f454dfe1 HDB: Initialize Map member variables
bcaf795b59 HDB: Fix out-of-bounds access bug
8f83631a3b HDB: Add macros for RGB-565 conversions
abe99e332e HDB: Unstub updateFade()
a7e17c07f7 HDB: Remove redundant warnings
a869eb00a0 HDB: Restore bootparam and save/load from the command line funcitonality
1874674364 HDB: More debug for save/load code
1f7e179218 HDB: Unstub drawSnow()
f27674199b HDB: Clear the Persistent variables
6c5193c71c HDB: Init _mstoneGfx and replace strings
792333b6cc HDB: Show cursor in the main menu
b052946c61 HDB: Add mode-select to the level-select
0bd8e53f88 HDB: Unstub DirectX Flip
190b550caa HDB: Replace original color functions
c5bc56b331 HDB: Add Loading Screen
812a8c7c9d HDB: Remove redundant warning
24468bf630 HDB: Fix warnings
9903b335e1 HDB: Proper memory handling for map features
c0777f5a03 HDB: Add missing paint() call
0cd4f43862 HDB: Unstub updateVideo()
1feb91b2f8 HDB: Simplify bootparam processing
c5d1ea304b HDB: Unstubbing updateVideo()
a35cf6cb93 HDB: Added SetDebug/GetDebug, no relevant functionality
2be5c59d95 HDB: Complete checkPlayerTileCollision()
35ead09d75 HDB: Complete AI::drawLevel2Ents()
f83f965462 HDB: Complete AI::checkPlayerCollision()
614fc61254 HDB: Consistent memory management for map explosions
5fa5f6fb39 HDB: Fix _mapLoaded flag handling
62a6a36463 HDB: Complete Map::restartSystem()
0a291d028c HDB: Complete AI::restartSystem()
8c48bf972d HDB: Fix Gfx::updateFade()
74d0c5daed HDB: Fix Gfx::updateVideo()
ac50b10549 HDB: Fix getRandomNumber() usage in menu.cpp
8c19637727 HDB: Fix getRandomNumber() usage
ac9a62da03 HDB: Fix getRandomNumber() usage
f8769966f1 HDB: Fix getRandomNumber usage
79a4a37e8d HDB: Initialize Weapon Gfx
e1fbaaea2b HDB: Add cinematic functions for Pic
2f893eeadd HDB: Add cineRemoveEntity()
e0f49e8aee HDB: Add cineFunction()
ff5b6d830a HDB: Add _sound stubs
4216aa965c HDB: Unstub Sound Lua stubs
f4e2fbcbc7 HDB: Add missing Gfx variable and Weapon functions
fe09a9c09c HDB: Initialize Weapon variables
de7b30a23c HDB: Add queryInventoryTypeSlot()
cea99e3fcd HDB: Unstub Weapon code from save/load
44ae2202aa HDB: Fix Lua Index
a5da708868 HDB: Add Weapon Drawing and Equipping Code
0c5f2f0243 HDB: Add Player Attacking code
d07dcd210c HDB: Add code to ready Weapon
9dec31c458 HDB: Unstub drawWaypoints()
a745d45f38 HDB: Ignore the Controls Option
2c40e1ae36 HDB: Fix loading Lua scripts
73414fdc47 HDB: Add _debugLogo
469c2245b4 HDB: Add moveMap() and startMoveMap()
b36569d201 HDB: Add code to enable Debugging
c31217f1ee HDB: Add Debug checks
a3ba287c1e HDB: Add code for drawing Debug Mark
779f455292 HDB: Add temp variable to store Map name
723b86e1cf HDB: Add cheating debug statment and remove...
ed60dcd506 HDB: Fix 3D stars left
6aa054fcac HDB: Unstub the TRY AGAIN screen
eb9af0c7ee HDB: Fix getRandumNumber() usage in ai-bots.cpp
72d2f01b93 HDB: Unstub AI::init()
56bbb34a3b HDB: Add save/load for TryAgain data
a484fe4353 HDB: Unstub redundant warnings
f158aadfd1 HDB: Add loadIcon() for TYPE_ICON32 loading
fa7593d7d5 HDB: Fix Icon loading
26210cfce6 HDB: Add drawDebugInfo()
68b2e9adff HDB: Count FPS and print onto screen
4876064372 HDB: Unstub the Quit functionality
462d48a901 HDB: Unstub TODOs
6fdd336ae4 HDB: Move HDBGame::hasFeature() to detection.cpp for consistency
6789a868f0 HDB: Fix copy-paste error in AI::legalMove()
b5b2a113ff HDB: Fix bug from the original
944dbab7d6 HDB: Fix warning
ffe3103433 HDB: Fix warning
a98e2a8e6d JANITORIAL: Fix code formatting
a1645e2958 HDB: Fix warning
fe0082b4d6 HDB: Fix warnings
505bd8b927 HDB: Fix warning
55a650d5fe HDB: Fix data type
39bbc59cb5 HDB: Fix data types in AIEntity
bfa2d11a1d HDB: Fix warning
17e2c05417 HDB: Fix warning
ea2f09b256 COMMON: Restored functionaluty of Lua print
e0cb401bc2 HDB: Added more debug output to script compilation
6d83d2ea72 HDB: Added more stuff to cheat for MAP00
dda8c81375 HDB: Added (commented out) debug case for _use functions
49b0f7c6d2 HDB: Normalised usage of _systemInit for Lua
2bb172a586 HDB: Filter out more Lua globals from the save
345830222d HDB: Fix Lua execution at game restore
2909d9a9a0 HDB: Move save filename generation to genSaveFileName()
e1c616e06f HDB: Rename saves as in the original
74931e7205 HDB: Add destructor to AIEntity and AnimTarget
5cf1f6a2f9 HDB: Fix switches
9ab298748e HDB: Fix flag checking across the engien
e74bdbf410 HDB: Fix uninitalised reads
d80023c737 HDB: Fix delete mismatch
ac61b7ef9c HDB: Fix warning
14dbbdd852 HDB: Fix _fontSurfaces memory leak
be1fcc2fa8 HDB: Fix GfxCache memory leak
0c71ae2121 HDB: Fix uninitialised variables
d3ad2ed14a HDB: Fix memory leak in Player Graphics
ff2c6fe30a HDB: More var initialisation
d706fbf22e HDB: Fix memory leaks
f5aff6c72d HDB: Fix memset()
8825980e1f HDB: Remove redundant custom free() function
b90f0e143f HDB: Remove redundant FileMan function
7709b2828b HDB: Fix memory leaks with FileMan::findFiles()
adb43a79b7 HDB: Fix memory leaks in AI lists
e9e654d7db HDB: Convert _surface from struct to pointer
161f9e6707 HDB: NULL each tile after calling destructor
7b78aa5e9f HDB: Fix double free() and meaningless 'new' allocations
fa71ee9034 HDB: Fix memory leaks due to findFirstData()
5363b38fe5 HDB: Delete Player Graphics in destructor
ea77240d4e HDB: Fix memory leak due to removed animTargets
8d9004e432 HDB: Fix memory leaks when stream is returned NULL
fd91bb7f59 HDB: Fix more memory leaks
05cb55b888 HDB: Delete Cached gfx data in one place
a8d277be18 HDB: Fix delete command for _dir
ecefec2f77 HDB: Add _animTiles to fix memory leaks
d0248243d2 HDB: Refactor getPicGfx(), getTileGfx() and fix...
62a33b1399 HDB: Delete all _tTileLookupArray values at once
ae1f4efeb5 HDB: Fix memory leaks in Menu
bba1fa849b HDB: Fix loading
cea2285db1 HDB: Remove redundant frees
927770f34b HDB: Initialise class variables
8a80cc77e9 HDB: Add warnings
72dbb6074d HDB: Fix uninitialized read
9e1f792751 HDB: Differentiate Debug messages
1b6b2a96a0 HDB: Fix warnings
31ec40a91a HDB: Fix checkActionList()
9d45057630 HDB: Add Debug Output for Actions List
6d3856cd94 HDB: Add Patches for Map10
c10034df93 HDB: Fix warning
f02bc1da84 HDB: Add Lua Patch for Map11
ada43165a1 HDB: Animate Bridges
442835b555 HDB: Added script patch from MAP21.LUA
22a9c9ef5c HDB: Added line references to the script patches
c10fee7393 HDB: More Lua script patches to MAP30.LUA
cecf6e5fc8 HDB: Fix progress bar rendering
7b07d2f88c HDB: Hid some debug messages to deeper level
b96049a236 HDB: Fix game restarting
f9422e4347 HDB: Fix another incorrect allocation/deallocation.
edc68ef7b1 HDB: Added more constants instead of magic numbers
f778e08a1a HDB: Fix copy/paste error in map centering code.
c34824de58 HDB: Added support for CINE_OUTRO from the command line (level 31)
b2f52580f4 HDB: Added cheat code for MAP11 for testing the Lab
2988407936 HDB: Improved error messages during Lua execution
409a62352b HDB: Add one more patch to GLOBAL.LUA
d7c876d269 HDB: Sorted script patches
54c94a9b25 HDB: Added more script patches to MAP30.LUA
74e6168e0a HDB: Added script patch for MAP29.LUA
9370c0a4f3 HDB: Added script patches for MAP19.LUA
4c0181ac31 HDB: Remove leftover code
252c6e61c9 HDB: Fix player collision detection code
bd26cda952 HDB: Fix compilation for MSVC9
43438a632c HDB: Support loading from the launcher
0d989250ee HDB: Fix some CppCheck warnings in ai-bots
01bf7aa811 HDB: Fix some more CppCheck warnings, use static const in various functions
73c90d1a20 HDB: Clear MAP06 through level-select
1b9e2f36f1 HDB: Fix aiFatFrogTongueDraw()
933089dcba HDB: Patch misplaced function names
1fd53de72a HDB: Fix CppCheck warnings in ai-funcs
8a44ed4a97 HDB: Fix findTeleporterDest()
cfe228d7bb HDB: Fix some CppCheck warnings in ai-inventory and ai-lists
d4f927f338 HDB: Put both data and Lua saves into single file
7d4c665176 HDB: Fix LIGHTBARREL in Slime & moving floats
599e144453 HDB: Fix initialization warning
d61d93ebe1 HDB: Fix loading of Lua script from the save
312ebf6aaf HDB: Load thumbnail from the launcher
f94d153275 HDB: Fix secret stars level launching
b776651e45 HDB: More script patches to MAP30.LUA
04901e7ac9 HDB: Fix load menu items
bcf910470c HDB: Fix some CppCheck warnings in ai-player, ai-use, ai-waypoint and gfx
616045496c HDB: (Hopefully) fix a c&p error in hasFeature()
bf57f7befb HDB: Fix an out of bound issue in mapname
4b65e396c8 HDB: Reduce some variable scopes, some janitorial work
20a270a5ae HDB: Fix waypoints calculation code
0ce52ccc53 HDB: Implement removeSaveState()
f1bf353cd3 HDB: Reduce some more variable scopes
452612d02a HDB: Fix CppCheck warnings in window
8e102a7dc7 HDB: Add cheat to test MAP29
4a7c028e70 HDB: Add sound data to mpc.h
a9fbd1ae1e HDB: Add Sound names
4c012861bc HDB: Play a MP3 sound from hdb.cpp
c131e7c890 HDB: Fix compilation
f7713df735 HDB: Fix warnings
0c8e483d09 HDB: const'ness
b845e70102 HDB: Reduce header dependency
c3d0f49538 HDB: Reduce header dependency
17ef555e2d HDB: Reduce header dependency
01d114e5c1 HDB: Remove leftover file
e53367e225 HDB: Fix guard defines
9ea453bc4c HDB: Reduce header dependency
0c29eff799 HDB: Remove unused console.cpp
99fc798b2e HDB: Reduce header dependency
2844b48ac1 HDB: Reduce header dependency
a0817b0b5a HDB: Reduce header dependency
91da8c7aab HDB: Reduce header dependency
c63d207d63 HDB: Reduce header dependency
a0856c6c3a HDB: Reduce header dependency
810ac81b0f HDB: Reduce header dependency
951943ecec HDB: Reduce header dependency
e0b0d85f5b HDB: Reduce header dependency
a50e1469b7 HDB: Reduce header dependency
1a7fc846cf HDB: Add Sound Cache
2ba18da94d HDB: Stick Sound names in Lua
4a44f62b10 HDB: Add extension field to SoundCache
236318ce0c HDB: Update Sound Names in mpc.h
a09ac7b114 HDB: Add voice related data
123b65931e HDB: Add playVoice()
5ba58bf03c HDB: Simplify Voice struct
174b8c31cf HDB: Update Music filenames
becfce8bfc HDB: More cleanup in ai-bots
29c7a6cc4a HDB: More clean up in ai-bots
b7a89a5edd HDB: Clean up in ai-cinematic
e955dbb4a2 HDB: Clean up in ai-funcs
3aa373ab2b HDB: Fix misplaced Enum value
2bb60c69cd HDB: Add Music/Song data and functions
1edab20e02 HDB: Add additional debug output
85b922895a HDB: Fix Deliveries with no GFX
d3eacb7e0f HDB: Add playSound(), playSoundEx(), stopChannel()
5ba5a335a1 HDB: Unstub Sound related stubs
12f46b3f9d HDB: Remove redundant stubs
588d0235ae HDB: Comment out SND code until data is found
c6af142ce7 HDB: Fix warning
ac90e5541e HDB: Added more detection entries
da5f1fa265 HDB: Added demo-specific start code
7f7de57ba4 HDB: Modified the patching engine so it works for the demo
fc0dd1fb1a HDB: Added demo sound constants
421ae7165e HDB: Added heuristic to determing sound file type
74f3917db7 HDB: Made file manager case-insensitive.
2e3a36acba HDB: Simplify animateEntity by removing a useless call to getMapBGTileFlags()
cfa90aa7bf HDB: Added more demo Lua constants
0a6cd0a99a JANITORIAL: Beautify table formatting
f7bc31f9e6 HDB: Some cleanup in ai-init
5fe9b6f6e7 HDB: Minor fixes in Sound Effects code
6c21dfbbe6 HDB: Implemented demo differences for menu
444327deaf HDB: Remove redundant function call
67d45170ed HDB: More code differences for demo
d1b906a442 HDB: Implement rest of the demo differences
6e67fe35b9 HDB: Even more demo differences
78278af46a HDB: Check isDemo() first, otherwise it would crash
469fbe1c8a HDB: Add isPPC Flag
52f2af77f3 HDB: Fix Null-deleting code
3acb70c759 HDB: Wrap ReadStreams pointing to compressed...
b8bbc32a89 HDB: Add support for the PPC version
1184c542cd JANITORIAL: Fix whitespace errors
4539c04181 HDB: Fix warnings
bcb0171891 HDB: Fix WAV format checker and other minor fixes
13d7a0c934 HDB: Set DisposeAfterUse::NO in playStream()
c75e14cabb HDB: Remove redundant warning
102846becf COMMON: Added PocketPC platform
52f9e18d43 HDB: Use PocketPC platform enum
446afec1ca HDB: Reduce header dependency
517a261fbf HDB: Added Handango flag
d93c6ec724 HDB: Set Music and Voice to DisposeAfterUse::YES
c1d2468f07 HDB: Section off PPC-specific code
6e357d9d97 HDB: Minor PPC fixes
0fb3ad7ba0 HDB: Make Platform specific constants into variables
a9e65176a1 HDB: Add more Platform-specific Constants
f3d0bca83a HDB: Fix warning
a7828397af HDB: Made rendering pipeline to match original
7b7420144f HDB: De not create fade screen on every frame
02d855b066 HDB: Replaced font name with a constant
abaf1336a7 HDB: Hid noisy debug messages, removed one unneeded stub
a5ee5fbd18 HDB: Add Platform-specific constants for Menu
63f9cd97ad HDB: Fix PPC crash due to _menuBackoutGfx
b51881c446 HDB: Change song names for PPC
b2fded7dca HDB: Fix _screenDrawWidth and _screenDrawHeight
8062f98b5a HDB: Add Window Platform-specific Constants
e3ec3480ae HDB: Fix warning
345c017ff7 HDB: Section off WIN32 specific-code
89e4c9f5a9 HDB: Integrate PPC version of Window
878eefceb5 HDB: Integrate PPC version of Menu and Gfx
7ad5cf9d30 HDB: Add new PPC-specific code
c63d716180 HDB: Rewind played-out sounds
ee0445e557 HDB: Sync sound settings with config at the startup
9247adefec HDB: Fix isPPC() check
7916f2c86b HDB: Fix warnings
25eaaf38fb HDB: Fix inconsistency in platform-specific code
c4495e5449 HDB: Added commented out credits debugging patch
d4f1d41275 HDB: Fix fade rendering. No artifacts, yay!
08d486981c HDB: Check map hitting code
43ad1af61e HDB: Draw Pointer only for Windows version
16fd226902 HDB: Remove NULL deletes
1d1ace6ab5 HDB: Simplify setPixel()
9c2d639a35 HDB: Adapt loadFont, Picture::load, Tile::load for
cb8976b65a HDB: Add Handango GFX and Demo Title Screen
22251ec2a7 HDB: Introduce two new enums for the sound
161553db9b HDB: Reduce some more variable scopes, simplify a couple of checks in input.cpp
361f47ff54 HDB: Prevent Backwards Seeking in GZipReadStream
f11c3afea9 HDB: Fix file len usage in compressed MSD files
c95682dc50 HDB: Remove redundant TO_16_LE() calls
6581e48230 HDB: Add OGG Support for Linux
da005a6118 HDB: Portability fixes
1658fc8063 HDB: Do not use dereferencing for GZip stream
d548d1dfb8 HDB: Simplify findFirstData()
1f02749874 HDB: Simplify openMPC()
e514a6c8c1 HDB: Better error messages
4406d89743 HDB: Move heavy lifting out of HDBGame constructor
5a0305bb9a HDB: Fix warnings
b89f14360b HDB: Fix crash in gfx loading
1fd83bf7a2 HDB: Initialise skipped variables in PPC mode
41696e9efd HDB: Fix PPC screen dimensions
5570f784b6 HDB: Initialise more variables
1157a88cca HDB: Fix mismatched delete
c12a068bcc HDB: Better Lua tracing
fab015edd2 HDB: Fix script patch for MAP01
53534edc8f HDB: Fix PPC controls
fb95542a86 HDB: Fix drawDeliveries()
bbbeaec131 HDB: Save function pointers
24da0a245c HDB: Add PPC cursor
0536d53dbe HDB: Fix copy/paste error in script patch for MAP01
eecd232132 HDB: First attempt to fix PPC graphics
adc41ff141 HDB: Fix PPC screen dimensions once more
bccb817812 HDB: Rotate pictures on load
8198a5d99e HDB: Fix crash in start menu in PPC version
febdd3beee HDB: Fix crashes in PPC demo
e08a1ec37d HDB: Implement Handango differences
68765181e4 HDB: Add engine dependencies
d399dc6f9d HDB: Reduce the scope of some variables in window
e9970a20dd HDB: Implement PPC demo Lua differences for saving
680aeba0a4 HDB: Simplify conditional
ae17affac0 HDB: Fix centerPrint() Height
a69f6afe10 HDB: Convert FPS to Millis for double click check
83ceef1e97 HDB: Fix PPC _quitYes and _quitNo co-ordinates
8b1d05eefa HDB: Fix PPC No Deliveries screen
bbcab297f7 HDB: Reduce the scope of some more variables in gfx
f14edf90d4 HDB: Remove two unused variables
eaa972347f HDB: Increase number of slots to 99 and support saveload from the GMM
29eb9dc9d6 HDB: Remove an unused member of Song, get rid of the return value of several sound functions
a411d35b20 HDB: Add PPC version of updateFade()
a5f66ed1fe HDB: Fix warnings
e1f0506642 HDB: Fix drawDeliveries() when carrying 2...
f0eb59cdee HDB: Draw all stars/snow in PPC version.
c2a8a0c2c4 HDB: Fix PPC Double Click code
390152b0b8 HDB: Implement cheating as GUI option
d7b1e9d38e HDB: Implement quit screenshot differences for the PPC demos
45e49a6ba2 HDB: Support bootparams for demo
5f2be7e993 HDB: Remove unnecessary global references
0dbc63a31f HDB: Remove redundant global references
7e0af9a2cb HDB: Fix Try Again position
6fbadccf08 HDB: Fix voice playing when no message on screen
62a0fb8551 HDB: Remove unneeded include
23c7dc8ebd HDB: Implement differences in rendering pipeline for the PPC demo
2178770898 HDB: Change init functions to handle errors
6500e81aab HDB: Remove redundant STUBs
f934e0d094 HDB: Replace cursor in PPC version with the one from Win version
1e25bf5fbe HDB: Re-add updateFade() debug output
0ca9c2fbcc HDB: Remove unnecessary warnings
429bb7af4d HDB: Fix Sound caching to prevent Vorbis crash
af8df1bd56 JANITORIAL: Remove unnecessary whitespace
cf3c1f0997 HDB: Added optional length parameter for querying from FindFirstData
9907ebed0a HDB: Simplified sound loading code
d1ef6fc008 HDB: Cache sounds as data pointers. This fixes problem with distorted sounds
43f39b30de HDB: FUrther simplification of sound code
c3032f7742 HDB: Remove excess calls to stopVoices()
73b6724b92 HDB: Do not allocate sound handles dynamically
036ef5fdfd HDB: Mark autosave slots with 'Auto:' in the GUI
93f05fa32c HDB: Added debug info to entity loading
e5883e999b HDB: Fix teleporter on MAP29 in PPC version.
4d186571d5 HDB: Fix closed loops with laser beams
83d3af6009 HDB: Make the frame delay variable in order to have a more stable frame rate
36c2b15ab9 HDB: Fix out-of-bound access when on the edge of map
b29317c0b0 HDB: Janitorial - Fix some code formatting
32969d3d7e HDB: Fix monkeystone star triggers
abbe16bf01 HDB: Do not write config on every launch
373002d303 HDB: Added debug output for map loading
100ea9ff0e HDB: Fix warnings


Commit: cf7c1f35e632bf666a5745533f605d2fe431e6f1
    https://github.com/scummvm/scummvm/commit/cf7c1f35e632bf666a5745533f605d2fe431e6f1
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:16:50+02:00

Commit Message:
HDB: Remove 'Process Gettable Item' stub

Changed paths:
    engines/hdb/hdb.cpp


diff --git a/engines/hdb/hdb.cpp b/engines/hdb/hdb.cpp
index 3d769f9..c17c1dc 100644
--- a/engines/hdb/hdb.cpp
+++ b/engines/hdb/hdb.cpp
@@ -156,7 +156,23 @@ void HDBGame::useEntity(AIEntity *e) {
 	added = false;
 
 	if (_ai->getTableEnt(e->type)) {
-		warning("STUB: HDBGame::useEntity Process Gettable Entity");
+		memcpy(&temp, e, sizeof(AIEntity));
+
+		_ai->getItemSound(e->type);
+
+		added = _ai->addToInventory(e);
+		if (added) {
+			e = &temp;
+
+			if (temp.aiUse) {
+				temp.aiUse(&temp);
+			}
+
+			if (temp.luaFuncUse[0]) {
+				_lua->callFunction(temp.luaFuncUse, 0);
+			}
+		}
+
 	} else {
 		// These should be run over or run through
 		if (_ai->walkThroughEnt(e->type) || e->type == AI_NONE) {


Commit: 76d24266138d5b2b067abb0b756cdfc7b97bd923
    https://github.com/scummvm/scummvm/commit/76d24266138d5b2b067abb0b756cdfc7b97bd923
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:16:50+02:00

Commit Message:
HDB: Complete cineUse stub in lua-script.cpp

Changed paths:
    engines/hdb/lua-script.cpp


diff --git a/engines/hdb/lua-script.cpp b/engines/hdb/lua-script.cpp
index e8c31c4..66aa6dc 100644
--- a/engines/hdb/lua-script.cpp
+++ b/engines/hdb/lua-script.cpp
@@ -206,7 +206,12 @@ static int cinePlayVoice(lua_State *L) {
 }
 
 static int cineUseEntity(lua_State *L) {
-	warning("STUB: CINE USE ENTITY");
+	const char *string = lua_tostring(L, 1);
+
+	g_hdb->_lua->checkParameters("cineUseEntity", 1);
+
+	lua_pop(L, 1);
+	g_hdb->_ai->cineUse(string);
 	return 0;
 }
 


Commit: 6341309b606170b986fbbbdfacd7408cbf6d938e
    https://github.com/scummvm/scummvm/commit/6341309b606170b986fbbbdfacd7408cbf6d938e
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:16:50+02:00

Commit Message:
HDB: Add ai-inventory.o to module.mk

Changed paths:
    engines/hdb/module.mk


diff --git a/engines/hdb/module.mk b/engines/hdb/module.mk
index 2f8e0bd..6402b47 100644
--- a/engines/hdb/module.mk
+++ b/engines/hdb/module.mk
@@ -2,6 +2,7 @@ MODULE := engines/hdb
 
 MODULE_OBJS := \
 	ai-init.o \
+	ai-inventory.o \
 	ai-cinematic.o \
 	ai-funcs.o \
 	ai-player.o \


Commit: 79023f0f9e6ed8237cfc8061bc30dd47a5ce85fd
    https://github.com/scummvm/scummvm/commit/79023f0f9e6ed8237cfc8061bc30dd47a5ce85fd
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:16:50+02:00

Commit Message:
HDB: Pass correct variable into warning()

Changed paths:
    engines/hdb/ai-cinematic.cpp


diff --git a/engines/hdb/ai-cinematic.cpp b/engines/hdb/ai-cinematic.cpp
index 158897d..7159f9a 100644
--- a/engines/hdb/ai-cinematic.cpp
+++ b/engines/hdb/ai-cinematic.cpp
@@ -144,7 +144,7 @@ void AI::processCines() {
 				_cine[i]->e->y = (int)_cine[i]->y;
 				_cine[i]->e->level = (int)_cine[i]->x2;
 			} else {
-				warning("Can't locate '%s' in setEntity", _cine[i]->title);
+				warning("Can't locate '%s' in setEntity", _cine[i]->string);
 			}
 			complete = true;
 			break;


Commit: a9a2ee04796bc93b64acbf2a4db91d91fb6d6c51
    https://github.com/scummvm/scummvm/commit/a9a2ee04796bc93b64acbf2a4db91d91fb6d6c51
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:16:50+02:00

Commit Message:
HDB: Add getStringOffStack()

Changed paths:
    engines/hdb/lua-script.cpp
    engines/hdb/lua-script.h


diff --git a/engines/hdb/lua-script.cpp b/engines/hdb/lua-script.cpp
index 66aa6dc..5259c10 100644
--- a/engines/hdb/lua-script.cpp
+++ b/engines/hdb/lua-script.cpp
@@ -960,4 +960,14 @@ void LuaScript::checkParameters(const char *func, int params) {
 	}
 }
 
+const char *LuaScript::getStringOffStack() {
+	if (!_systemInit) {
+		return NULL;
+	}
+
+	const char *string = lua_tostring(_state, 1);
+	lua_remove(_state, 1);
+	return string;
+}
+
 }
diff --git a/engines/hdb/lua-script.h b/engines/hdb/lua-script.h
index 37b8df9..20cd94d 100644
--- a/engines/hdb/lua-script.h
+++ b/engines/hdb/lua-script.h
@@ -44,6 +44,8 @@ public:
 	bool executeFile(const Common::String &filename);
 	void checkParameters(const char *func, int params);
 
+	const char *getStringOffStack();
+
 private:
 	lua_State *_state;
 	int _pcallErrorhandlerRegistryIndex;
@@ -56,7 +58,6 @@ private:
 	bool executeChunk(Common::String &chunk, uint chunkSize, const Common::String &chunkName) const;
 	void stripComments(char *chunk);
 	void addPatches(Common::String &chunk, const char *scriptName);
-
 };
 
 }


Commit: 1c268c03bb5ece0e45afc3af1020842eb3b228c7
    https://github.com/scummvm/scummvm/commit/1c268c03bb5ece0e45afc3af1020842eb3b228c7
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:16:51+02:00

Commit Message:
HDB: Add initAllEnts()

Changed paths:
    engines/hdb/ai-funcs.cpp
    engines/hdb/ai.h


diff --git a/engines/hdb/ai-funcs.cpp b/engines/hdb/ai-funcs.cpp
index 3a425be..d0888d3 100644
--- a/engines/hdb/ai-funcs.cpp
+++ b/engines/hdb/ai-funcs.cpp
@@ -37,6 +37,21 @@ void AI::removeEntity(AIEntity *e) {
 	_ents->erase(&e);
 }
 
+// Initializes each entity after map is loaded
+void AI::initAllEnts() {
+	for (Common::Array<AIEntity *>::iterator it = _ents->begin(); it != _ents->end(); it++) {
+		(*it)->aiInit((*it));
+		if ((*it)->luaFuncInit[0]) {
+			if (g_hdb->_lua->callFunction((*it)->luaFuncInit, 2)) {
+				strcpy((*it)->entityName, g_hdb->_lua->getStringOffStack());
+				strcpy((*it)->printedName, g_hdb->_lua->getStringOffStack());
+			} else {
+				warning("'%s' doesn't exists", (*it)->luaFuncInit);
+			}
+		}
+	}
+}
+
 // Check to see if we can get this entity
 bool AI::getTableEnt(AIType type) {
 	switch (type) {
diff --git a/engines/hdb/ai.h b/engines/hdb/ai.h
index aaa8385..8dcb347 100644
--- a/engines/hdb/ai.h
+++ b/engines/hdb/ai.h
@@ -413,6 +413,7 @@ public:
 	// Entity Functions
 	AIEntity *locateEntity(const char *luaName);
 	void removeEntity(AIEntity *e);
+	void initAllEnts();
 	bool getTableEnt(AIType type);
 	bool walkThroughEnt(AIType type);
 	void getItemSound(AIType type);


Commit: ba78805c923ca8c88013bbb9f8fda5af967b5705
    https://github.com/scummvm/scummvm/commit/ba78805c923ca8c88013bbb9f8fda5af967b5705
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:16:51+02:00

Commit Message:
HDB: Call initAllEnts() after map is loaded

Changed paths:
    engines/hdb/map-loader.cpp


diff --git a/engines/hdb/map-loader.cpp b/engines/hdb/map-loader.cpp
index 459cb64..ed88d16 100644
--- a/engines/hdb/map-loader.cpp
+++ b/engines/hdb/map-loader.cpp
@@ -131,6 +131,8 @@ bool Map::load(Common::SeekableReadStream *stream) {
 		TODO: Add the animating tile lists
 	*/
 
+	g_hdb->_ai->initAllEnts();
+
 	_mapLoaded = true;
 
 	return true;


Commit: b449bd6fe286adb287faa3070a08e2a262fc3bad
    https://github.com/scummvm/scummvm/commit/b449bd6fe286adb287faa3070a08e2a262fc3bad
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:16:51+02:00

Commit Message:
HDB: Hid some annoying STUB warnings

Changed paths:
    engines/hdb/draw-manager.cpp
    engines/hdb/hdb.cpp
    engines/hdb/map-loader.cpp


diff --git a/engines/hdb/draw-manager.cpp b/engines/hdb/draw-manager.cpp
index 3202b3c..5783e61 100644
--- a/engines/hdb/draw-manager.cpp
+++ b/engines/hdb/draw-manager.cpp
@@ -102,7 +102,7 @@ void DrawMan::fillScreen(uint32 color) {
 
 void DrawMan::updateVideo() {
 	updateFade();
-	warning("STUB: DrawMan::updateVideo incomplete");
+	debug(9, "STUB: DrawMan::updateVideo incomplete");
 }
 
 void DrawMan::setFade(bool fadeIn, bool black, int steps) {
@@ -125,7 +125,7 @@ void DrawMan::setFade(bool fadeIn, bool black, int steps) {
 
 void DrawMan::updateFade() {
 	_fadeInfo.active = false;
-	warning("STUB: DrawMan::updateFade incomplete");
+	debug(9, "STUB: DrawMan::updateFade incomplete");
 }
 
 Tile *DrawMan::getTile(int index) {
diff --git a/engines/hdb/hdb.cpp b/engines/hdb/hdb.cpp
index c17c1dc..0942085 100644
--- a/engines/hdb/hdb.cpp
+++ b/engines/hdb/hdb.cpp
@@ -124,7 +124,7 @@ void HDBGame::changeGameState() {
 void HDBGame::paint() {
 	switch (_gameState) {
 	case GAME_TITLE:
-		warning("STUB: MENU::DrawTitle required");
+		debug(9, "STUB: MENU::DrawTitle required");
 		break;
 	case GAME_MENU:
 		warning("STUB: MENU::DrawMenu required");
diff --git a/engines/hdb/map-loader.cpp b/engines/hdb/map-loader.cpp
index ed88d16..e9f1f0b 100644
--- a/engines/hdb/map-loader.cpp
+++ b/engines/hdb/map-loader.cpp
@@ -198,12 +198,12 @@ void Map::draw() {
 						/*
 						TODO: Implement Gratings Check
 						*/
-						warning("STUB: Map::draw: Gratings Check not found");
+						debug(9, "STUB: Map::draw: Gratings Check not found");
 					} else if ((fTile->_flags & kFlagForeground)) {
 						/*
 						TODO: Implement Gratings Check
 						*/
-						warning("STUB: Map::draw: Gratings Check not found");
+						debug(9, "STUB: Map::draw: Foreground Check not found");
 					} else {
 						if (fTile->_flags & kFlagMasked) {
 							/*


Commit: 2dd40d79a2e0c14414a06190af3c64fc52f1f078
    https://github.com/scummvm/scummvm/commit/2dd40d79a2e0c14414a06190af3c64fc52f1f078
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:16:51+02:00

Commit Message:
HDB: Add stubs for caching graphics and LaserScan

Changed paths:
    engines/hdb/ai-funcs.cpp


diff --git a/engines/hdb/ai-funcs.cpp b/engines/hdb/ai-funcs.cpp
index d0888d3..acaae9e 100644
--- a/engines/hdb/ai-funcs.cpp
+++ b/engines/hdb/ai-funcs.cpp
@@ -50,6 +50,9 @@ void AI::initAllEnts() {
 			}
 		}
 	}
+
+	warning("STUB: initAllEnts: Cache graphics for Inventory and Deliveries");
+	warning("STUB: initAllEnts: LaserScan required");
 }
 
 // Check to see if we can get this entity


Commit: 15d964afecfaaacf2ae34b729ea4a3812fb70601
    https://github.com/scummvm/scummvm/commit/15d964afecfaaacf2ae34b729ea4a3812fb70601
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:16:51+02:00

Commit Message:
HDB: Add _actionMode and its getter-setters

Changed paths:
    engines/hdb/hdb.cpp
    engines/hdb/hdb.h


diff --git a/engines/hdb/hdb.cpp b/engines/hdb/hdb.cpp
index 0942085..018e1e5 100644
--- a/engines/hdb/hdb.cpp
+++ b/engines/hdb/hdb.cpp
@@ -85,6 +85,10 @@ bool HDBGame::init() {
 		error("LuaScript::init: Couldn't load the GLOBAL_LUA code.");
 	}
 
+	// REMOVE: Putting this here since Menu hasn't been implemented yet.
+	// Defaults the game into Action Mode
+	setActionMode(1);
+
 	_gameShutdown = false;
 	_systemInit = true;
 
diff --git a/engines/hdb/hdb.h b/engines/hdb/hdb.h
index 7416b3c..6b02786 100644
--- a/engines/hdb/hdb.h
+++ b/engines/hdb/hdb.h
@@ -119,6 +119,13 @@ public:
 
 	void useEntity(AIEntity *e);
 
+	int getActionMode() {
+		return _actionMode;
+	}
+	void setActionMode(int status) {
+		_actionMode = status;
+	}
+
 	bool _gameShutdown;
 	Graphics::PixelFormat _format;
 
@@ -129,6 +136,7 @@ private:
 
 	bool _systemInit;
 	GameState _gameState;
+	int _actionMode; // 0 or 1
 
 };
 


Commit: 71e735e101d0559dfb4caa0cd1dd7b3c3b3e95c5
    https://github.com/scummvm/scummvm/commit/71e735e101d0559dfb4caa0cd1dd7b3c3b3e95c5
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:16:51+02:00

Commit Message:
HDB: Add Entity Speed constants

Changed paths:
    engines/hdb/ai.h


diff --git a/engines/hdb/ai.h b/engines/hdb/ai.h
index 8dcb347..5d157c2 100644
--- a/engines/hdb/ai.h
+++ b/engines/hdb/ai.h
@@ -29,7 +29,10 @@ namespace HDB {
 
 enum {
 	kMaxInventory = 10,
-	kMaxDeliveries = 5
+	kMaxDeliveries = 5,
+	kPlayerMoveSpeed = 4,
+	kEnemyMoveSpeed = 2,
+	kPushMoveSpeed = (kPlayerMoveSpeed >> 1)
 };
 
 enum AIType {


Commit: 16740814d0c73bf8452c266526c67e01ab15dda6
    https://github.com/scummvm/scummvm/commit/16740814d0c73bf8452c266526c67e01ab15dda6
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:16:51+02:00

Commit Message:
HDB: Add spawn()

The usage of cacheEntGfx is currently stubbed

Changed paths:
    engines/hdb/ai-funcs.cpp
    engines/hdb/ai.h


diff --git a/engines/hdb/ai-funcs.cpp b/engines/hdb/ai-funcs.cpp
index acaae9e..f10638a 100644
--- a/engines/hdb/ai-funcs.cpp
+++ b/engines/hdb/ai-funcs.cpp
@@ -24,6 +24,57 @@
 
 namespace HDB {
 
+AIEntity *AI::spawn(AIType type, AIDir dir, int x, int y, char *funcInit, char *funcAction, char *funcUse, AIDir dir2, int level, int value1, int value2, int callInit) {
+	AIEntity *e = new AIEntity;
+
+	e->type = type;
+	e->dir = dir;
+
+	// Set Co-ordinates & Speed
+	e->x = x * kTileWidth;
+	e->tileX = x;
+	e->y = y * kTileHeight;
+	e->tileY = y;
+	e->moveSpeed = kPlayerMoveSpeed; // Default Speed
+	if (!g_hdb->getActionMode()) {
+		e->moveSpeed /= 2;
+	}
+
+	// Other variables
+	e->dir2 = dir2;
+	if (!level)
+		level = 1;
+	e->level = level;
+	e->value1 = value1;
+	e->value2 = value2;
+	e->animCycle = 2;	// Game frames to wait before animating graphic frames
+	e->animDelay = e->animCycle;
+	e->animFrame = 0;
+
+	if (funcInit) {
+		strcpy(e->luaFuncInit, funcInit);
+	}
+	if (funcAction) {
+		strcpy(e->luaFuncAction, funcAction);
+	}
+	if (funcUse) {
+		strcpy(e->luaFuncUse, funcUse);
+	}
+
+	if (e->luaFuncInit[0] == '*')
+		e->luaFuncInit[0] = 0;
+	if (e->luaFuncAction[0] == '*')
+		e->luaFuncAction[0] = 0;
+	if (e->luaFuncUse[0] == '*')
+		e->luaFuncUse[0] = 0;
+
+	_ents->push_back(e);
+
+	warning("STUB: AI::spawn: CacheEntGfx required");
+
+	return e;
+}
+
 AIEntity *AI::locateEntity(const char *luaName) {
 	for (Common::Array<AIEntity *>::iterator it = _ents->begin(); it != _ents->end(); it++) {
 		if (Common::matchString((*it)->entityName, luaName)) {
diff --git a/engines/hdb/ai.h b/engines/hdb/ai.h
index 5d157c2..cf21f65 100644
--- a/engines/hdb/ai.h
+++ b/engines/hdb/ai.h
@@ -414,6 +414,7 @@ public:
 	void restartSystem();
 
 	// Entity Functions
+	AIEntity *spawn(AIType type, AIDir dir, int x, int y, char *funcInit, char *funcAction, char *funcUse, AIDir dir2, int level, int value1, int value2, int callInit);
 	AIEntity *locateEntity(const char *luaName);
 	void removeEntity(AIEntity *e);
 	void initAllEnts();


Commit: 5e9dba2affadb300f370e3945f19375133a36a0e
    https://github.com/scummvm/scummvm/commit/5e9dba2affadb300f370e3945f19375133a36a0e
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:16:51+02:00

Commit Message:
HDB: Scan all icons and process them in Map::load

Changed paths:
    engines/hdb/map-loader.cpp


diff --git a/engines/hdb/map-loader.cpp b/engines/hdb/map-loader.cpp
index e9f1f0b..8ec381a 100644
--- a/engines/hdb/map-loader.cpp
+++ b/engines/hdb/map-loader.cpp
@@ -131,6 +131,390 @@ bool Map::load(Common::SeekableReadStream *stream) {
 		TODO: Add the animating tile lists
 	*/
 
+	struct {
+		AIType type;
+		AIDir dir;
+	} aiInfo[] = {
+		{ AI_GUY,			DIR_DOWN },
+		{ AI_GUY,			DIR_UP },
+		{ AI_GUY,			DIR_RIGHT },
+		{ AI_GUY,			DIR_LEFT },
+
+		{ ITEM_ENV_WHITE,	DIR_NONE },
+		{ ITEM_ENV_BLUE,	DIR_NONE },
+		{ ITEM_ENV_RED,		DIR_NONE },
+		{ ITEM_ENV_GREEN,	DIR_NONE },
+
+		{ AI_LASER,			DIR_RIGHT },
+		{ AI_LASER,			DIR_DOWN },
+		{ AI_LASER,			DIR_LEFT },
+		{ AI_LASER,			DIR_UP },
+
+		{ AI_DIVERTER,		DIR_DOWN },
+		{ AI_DIVERTER,		DIR_UP },
+		{ AI_DIVERTER,		DIR_RIGHT },
+		{ AI_DIVERTER,		DIR_LEFT },
+
+		{ AI_FOURFIRER,		DIR_RIGHT },
+		{ AI_FOURFIRER,		DIR_DOWN},
+		{ AI_FOURFIRER,		DIR_LEFT },
+		{ AI_FOURFIRER,		DIR_UP },
+
+		{ INFO_ARROW_TURN,	DIR_DOWN },
+		{ INFO_ARROW_TURN,	DIR_UP },
+		{ INFO_ARROW_TURN,	DIR_RIGHT },
+		{ INFO_ARROW_TURN,	DIR_LEFT },
+
+		{ INFO_ARROW_STOP,	DIR_DOWN },
+		{ INFO_ARROW_STOP,	DIR_UP },
+		{ INFO_ARROW_STOP,	DIR_RIGHT },
+		{ INFO_ARROW_STOP,	DIR_LEFT },
+
+		{ ITEM_CELL,		DIR_NONE },
+
+		{ AI_CRATE,			DIR_NONE },
+		{ AI_LIGHTBARREL,	DIR_NONE },
+		{ AI_HEAVYBARREL,	DIR_NONE },
+		{ AI_BOOMBARREL,	DIR_NONE },
+
+		{ ITEM_TRANSCEIVER, DIR_NONE },
+		{ ITEM_CLUB,		DIR_NONE },
+		{ ITEM_ROBOSTUNNER, DIR_NONE },
+		{ ITEM_SLUGSLINGER, DIR_NONE },
+
+		{ AI_SCIENTIST,		DIR_DOWN },
+		{ AI_SCIENTIST,		DIR_UP },
+		{ AI_SCIENTIST,		DIR_RIGHT },
+		{ AI_SCIENTIST,		DIR_LEFT },
+
+		{ AI_WORKER,		DIR_DOWN },
+		{ AI_WORKER,		DIR_UP },
+		{ AI_WORKER,		DIR_RIGHT },
+		{ AI_WORKER,		DIR_LEFT },
+
+		{ AI_SHOCKBOT,		DIR_DOWN },
+		{ AI_SHOCKBOT,		DIR_UP },
+		{ AI_SHOCKBOT,		DIR_RIGHT },
+		{ AI_SHOCKBOT,		DIR_LEFT },
+
+		{ AI_RIGHTBOT,		DIR_DOWN },
+		{ AI_RIGHTBOT,		DIR_UP },
+		{ AI_RIGHTBOT,		DIR_RIGHT },
+		{ AI_RIGHTBOT,		DIR_LEFT },
+
+		{ AI_PUSHBOT,		DIR_DOWN },
+		{ AI_PUSHBOT,		DIR_UP },
+		{ AI_PUSHBOT,		DIR_RIGHT },
+		{ AI_PUSHBOT,		DIR_LEFT },
+
+		{ AI_LISTENBOT,		DIR_DOWN },
+		{ AI_LISTENBOT,		DIR_UP },
+		{ AI_LISTENBOT,		DIR_RIGHT },
+		{ AI_LISTENBOT,		DIR_LEFT },
+
+		{ ITEM_MONKEYSTONE, DIR_NONE },
+
+		{ INFO_TELEPORTER1,	DIR_NONE },
+		{ INFO_TELEPORTER2,	DIR_NONE },
+		{ INFO_TELEPORTER3,	DIR_NONE },
+		{ INFO_TELEPORTER4,	DIR_NONE },
+		{ INFO_TELEPORTER5,	DIR_NONE },
+		{ INFO_TELEPORTER6,	DIR_NONE },
+		{ INFO_TELEPORTER7,	DIR_NONE },
+		{ INFO_TELEPORTER8,	DIR_NONE },
+		{ INFO_TELEPORTER9,	DIR_NONE },
+		{ INFO_TELEPORTER10,	DIR_NONE },
+		{ INFO_TELEPORTER11,	DIR_NONE },
+		{ INFO_TELEPORTER12,	DIR_NONE },
+		{ INFO_TELEPORTER13,	DIR_NONE },
+		{ INFO_TELEPORTER14,	DIR_NONE },
+		{ INFO_TELEPORTER15,	DIR_NONE },
+		{ INFO_TELEPORTER16,	DIR_NONE },
+		{ INFO_TELEPORTER17,	DIR_NONE },
+		{ INFO_TELEPORTER18,	DIR_NONE },
+		{ INFO_TELEPORTER19,	DIR_NONE },
+		{ INFO_TELEPORTER20,	DIR_NONE },
+
+		{ INFO_LEVELEXIT,	DIR_NONE },
+
+		{ INFO_ACTION1,		DIR_NONE },
+		{ INFO_ACTION2,		DIR_NONE },
+		{ INFO_ACTION3,		DIR_NONE },
+		{ INFO_ACTION4,		DIR_NONE },
+		{ INFO_ACTION5,		DIR_NONE },
+		{ INFO_ACTION6,		DIR_NONE },
+		{ INFO_ACTION7,		DIR_NONE },
+		{ INFO_ACTION8,		DIR_NONE },
+		{ INFO_ACTION9,		DIR_NONE },
+		{ INFO_ACTION10,	DIR_NONE },
+		{ INFO_ACTION11,	DIR_NONE },
+		{ INFO_ACTION12,	DIR_NONE },
+		{ INFO_ACTION13,	DIR_NONE },
+		{ INFO_ACTION14,	DIR_NONE },
+		{ INFO_ACTION15,	DIR_NONE },
+		{ INFO_ACTION16,	DIR_NONE },
+		{ INFO_ACTION17,	DIR_NONE },
+		{ INFO_ACTION18,	DIR_NONE },
+		{ INFO_ACTION19,	DIR_NONE },
+		{ INFO_ACTION20,	DIR_NONE },
+
+		{ AI_SPACEDUDE,		DIR_DOWN },
+		{ AI_SPACEDUDE,		DIR_UP },
+		{ AI_SPACEDUDE,		DIR_RIGHT },
+		{ AI_SPACEDUDE,		DIR_LEFT },
+
+		{ AI_SERGEANT,		DIR_DOWN },
+		{ AI_SERGEANT,		DIR_UP },
+		{ AI_SERGEANT,		DIR_RIGHT },
+		{ AI_SERGEANT,		DIR_LEFT },
+
+		{ AI_MAINTBOT,		DIR_DOWN },
+		{ AI_MAINTBOT,		DIR_UP },
+		{ AI_MAINTBOT,		DIR_RIGHT },
+		{ AI_MAINTBOT,		DIR_LEFT },
+
+		{ INFO_ACTION_AUTO,	DIR_NONE },
+
+		{ ITEM_GEM_WHITE,	DIR_NONE },
+		{ ITEM_GEM_BLUE,	DIR_NONE },
+		{ ITEM_GEM_RED,		DIR_NONE },
+		{ ITEM_GEM_GREEN,	DIR_NONE },
+
+		{ INFO_SET_MUSIC,	DIR_NONE },
+		{ INFO_LUA,			DIR_NONE },
+		{ INFO_HERE,		DIR_NONE },
+
+		{ AI_VORTEXIAN,		DIR_DOWN },
+
+		{ AI_CHICKEN,		DIR_DOWN },
+		{ AI_CHICKEN,		DIR_UP },
+		{ AI_CHICKEN,		DIR_RIGHT },
+		{ AI_CHICKEN,		DIR_LEFT },
+
+		{ ITEM_GOO_CUP,		DIR_NONE },
+		{ ITEM_TEACUP,		DIR_NONE },
+		{ ITEM_COOKIE,		DIR_NONE },
+		{ ITEM_BURGER,		DIR_NONE },
+		{ ITEM_PDA,			DIR_NONE },
+		{ ITEM_BOOK,		DIR_NONE },
+		{ ITEM_CLIPBOARD,	DIR_NONE },
+		{ ITEM_NOTE,		DIR_NONE },
+		{ ITEM_KEYCARD_WHITE,	DIR_NONE },
+		{ ITEM_KEYCARD_BLUE,	DIR_NONE },
+		{ ITEM_KEYCARD_RED,		DIR_NONE },
+		{ ITEM_KEYCARD_GREEN,	DIR_NONE },
+		{ ITEM_KEYCARD_PURPLE,	DIR_NONE },
+		{ ITEM_KEYCARD_BLACK,	DIR_NONE },
+		{ AI_MAGIC_EGG,		DIR_NONE },
+		{ AI_ICE_BLOCK,		DIR_NONE },
+		{ ITEM_CABKEY,		DIR_NONE },
+
+		{ AI_DEADWORKER,	DIR_NONE },
+		{ AI_OMNIBOT,		DIR_DOWN },
+		{ AI_OMNIBOT,		DIR_UP },
+		{ AI_OMNIBOT,		DIR_RIGHT },
+		{ AI_OMNIBOT,		DIR_LEFT },
+		{ AI_TURNBOT,		DIR_DOWN },
+		{ AI_TURNBOT,		DIR_UP },
+		{ AI_TURNBOT,		DIR_RIGHT },
+		{ AI_TURNBOT,		DIR_LEFT },
+		{ AI_DOLLY,			DIR_DOWN },
+		{ AI_DOLLY,			DIR_UP },
+		{ AI_DOLLY,			DIR_RIGHT },
+		{ AI_DOLLY,			DIR_LEFT },
+
+		{ INFO_TRIGGER,		DIR_NONE },
+
+		{ ITEM_DOLLYTOOL1,	DIR_NONE },
+		{ ITEM_DOLLYTOOL2,	DIR_NONE },
+		{ ITEM_DOLLYTOOL3,	DIR_NONE },
+		{ ITEM_DOLLYTOOL4,	DIR_NONE },
+
+		{ AI_RAILRIDER_ON,	DIR_UP },
+		{ AI_RAILRIDER_ON,	DIR_DOWN },
+		{ AI_RAILRIDER_ON,	DIR_LEFT },
+		{ AI_RAILRIDER_ON,	DIR_RIGHT },
+		{ AI_RAILRIDER,		DIR_UP },
+		{ AI_RAILRIDER,		DIR_DOWN },
+		{ AI_RAILRIDER,		DIR_LEFT },
+		{ AI_RAILRIDER,		DIR_RIGHT },
+
+		{ ITEM_SODA,		DIR_NONE },
+		{ INFO_ARROW_4WAY,	DIR_NONE },
+		{ AI_DEADEYE,		DIR_DOWN },
+		{ AI_DEADEYE,		DIR_UP },
+		{ AI_DEADEYE,		DIR_RIGHT },
+		{ AI_DEADEYE,		DIR_LEFT },
+		{ AI_MEERKAT,		DIR_NONE },
+		{ AI_FATFROG,		DIR_DOWN },
+		{ AI_FATFROG,		DIR_RIGHT },
+		{ AI_FATFROG,		DIR_LEFT },
+		{ AI_GOODFAIRY,		DIR_DOWN },
+		{ AI_GOODFAIRY,		DIR_UP },
+		{ AI_GOODFAIRY,		DIR_RIGHT },
+		{ AI_GOODFAIRY,		DIR_LEFT },
+		{ AI_BADFAIRY,		DIR_DOWN },
+		{ AI_BADFAIRY,		DIR_UP },
+		{ AI_BADFAIRY,		DIR_RIGHT },
+		{ AI_BADFAIRY,		DIR_LEFT },
+		{ AI_ACCOUNTANT,	DIR_DOWN },
+		{ AI_ACCOUNTANT,	DIR_UP },
+		{ AI_ACCOUNTANT,	DIR_RIGHT },
+		{ AI_ACCOUNTANT,	DIR_LEFT },
+		{ AI_ICEPUFF,		DIR_NONE },
+		{ AI_DRAGON,		DIR_NONE },
+		{ AI_BUZZFLY,		DIR_DOWN },
+		{ AI_BUZZFLY,		DIR_UP },
+		{ AI_BUZZFLY,		DIR_RIGHT },
+		{ AI_BUZZFLY,		DIR_LEFT },
+
+		{ AI_FROGSTATUE,	DIR_NONE },
+		{ ITEM_SLICER,		DIR_NONE },
+		{ INFO_FAIRY_SRC,	DIR_NONE },
+		{ INFO_FAIRY_SRC2,	DIR_NONE },
+		{ INFO_FAIRY_SRC3,	DIR_NONE },
+		{ INFO_FAIRY_SRC4,	DIR_NONE },
+		{ INFO_FAIRY_SRC5,	DIR_NONE },
+		{ INFO_FAIRY_DEST,	DIR_NONE },
+		{ INFO_FAIRY_DEST2,	DIR_NONE },
+		{ INFO_FAIRY_DEST3,	DIR_NONE },
+		{ INFO_FAIRY_DEST4,	DIR_NONE },
+		{ INFO_FAIRY_DEST5,	DIR_NONE },
+		{ INFO_QMARK,		DIR_NONE },
+		{ INFO_DEBUG,		DIR_NONE },
+		{ AI_NONE,			DIR_NONE },
+
+		{ AI_NONE,			DIR_NONE }
+	};
+
+	// Scan all icons and init all Entities
+	warning("STUB: Map::load: SetupProgressBar");
+	for (int i = 0; i < _iconNum;i++) {
+		// Don't spawn Action Mode Entities in Puzzle Mode
+		if (!g_hdb->getActionMode()) {
+			switch (aiInfo[_iconList[i].icon].type) {
+			case AI_DEADEYE:
+				if (_iconList[i].value1 == 1)	// For non-moving DeadEyes
+					break;
+			case AI_FOURFIRER:
+			case AI_LISTENBOT:
+			case ITEM_CLUB:
+			case ITEM_ROBOSTUNNER:
+			case ITEM_SLUGSLINGER:
+				continue;
+			}
+		}
+
+		// Handle special icons that aren't moving AI entities
+		switch (aiInfo[_iconList[i].icon].type) {
+		default:
+			g_hdb->_ai->spawn(
+				aiInfo[_iconList[i].icon].type,
+				aiInfo[_iconList[i].icon].dir,
+				_iconList[i].x,
+				_iconList[i].y,
+				_iconList[i].funcInit,
+				_iconList[i].funcAction,
+				_iconList[i].funcUse,
+				(AIDir)_iconList[i].dir,
+				_iconList[i].level,
+				_iconList[i].value1,
+				_iconList[i].value2,
+				0
+			);
+			break;
+		case INFO_ARROW_4WAY:
+			warning("STUB: Map::load: AddToPathList required");
+			break;
+		case INFO_ARROW_TURN:
+			warning("STUB: Map::load: AddToPathList required");
+			break;
+		case INFO_ARROW_STOP:
+			warning("STUB: Map::load: AddToPathList required");
+			break;
+
+		case INFO_ACTION1:
+		case INFO_ACTION2:
+		case INFO_ACTION3:
+		case INFO_ACTION4:
+		case INFO_ACTION5:
+		case INFO_ACTION6:
+		case INFO_ACTION7:
+		case INFO_ACTION8:
+		case INFO_ACTION9:
+		case INFO_ACTION10:
+		case INFO_ACTION11:
+		case INFO_ACTION12:
+		case INFO_ACTION13:
+		case INFO_ACTION14:
+		case INFO_ACTION15:
+		case INFO_ACTION16:
+		case INFO_ACTION17:
+		case INFO_ACTION18:
+		case INFO_ACTION19:
+		case INFO_ACTION20:
+			warning("STUB: Map::load: AddToActionList required");
+			break;
+		case INFO_ACTION_AUTO:
+			warning("STUB: Map::load: AddToAutoList required");
+			break;
+
+		case INFO_TELEPORTER1:
+		case INFO_TELEPORTER2:
+		case INFO_TELEPORTER3:
+		case INFO_TELEPORTER4:
+		case INFO_TELEPORTER5:
+		case INFO_TELEPORTER6:
+		case INFO_TELEPORTER7:
+		case INFO_TELEPORTER8:
+		case INFO_TELEPORTER9:
+		case INFO_TELEPORTER10:
+		case INFO_TELEPORTER11:
+		case INFO_TELEPORTER12:
+		case INFO_TELEPORTER13:
+		case INFO_TELEPORTER14:
+		case INFO_TELEPORTER15:
+		case INFO_TELEPORTER16:
+		case INFO_TELEPORTER17:
+		case INFO_TELEPORTER18:
+		case INFO_TELEPORTER19:
+		case INFO_TELEPORTER20:
+			warning("STUB: Map::load: AddToTeleporterList required");
+			break;
+
+		case INFO_SET_MUSIC:
+		case INFO_PROMOTE:
+		case INFO_DEMOTE:
+			break;
+
+		case INFO_LUA:
+			warning("STUB: Map::load: AddToLUAList required");
+			break;
+		case INFO_HERE:
+			warning("STUB: Map::load: AddToHereList required");
+			break;
+		case INFO_TRIGGER:
+			warning("STUB: Map::load: AddToTriggerList required");
+			break;
+
+		case INFO_FAIRY_SRC:
+		case INFO_FAIRY_SRC2:
+		case INFO_FAIRY_SRC3:
+		case INFO_FAIRY_SRC4:
+		case INFO_FAIRY_SRC5:
+			warning("STUB: Map::load: AddToFairystones(SRC) required");
+			break;
+
+		case INFO_FAIRY_DEST:
+		case INFO_FAIRY_DEST2:
+		case INFO_FAIRY_DEST3:
+		case INFO_FAIRY_DEST4:
+		case INFO_FAIRY_DEST5:
+			warning("STUB: Map::load: AddToFairystones(DEST) required");
+			break;
+		}
+	}
+
 	g_hdb->_ai->initAllEnts();
 
 	_mapLoaded = true;


Commit: 4a7980c8ccab6373597fb133a5a3773b89052e93
    https://github.com/scummvm/scummvm/commit/4a7980c8ccab6373597fb133a5a3773b89052e93
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:16:51+02:00

Commit Message:
HDB: Add GfxCache struct

Changed paths:
    engines/hdb/draw-manager.h


diff --git a/engines/hdb/draw-manager.h b/engines/hdb/draw-manager.h
index 343d8bc..2bf5386 100644
--- a/engines/hdb/draw-manager.h
+++ b/engines/hdb/draw-manager.h
@@ -48,6 +48,14 @@ struct TileLookup {
 	TileLookup() : filename(NULL), tData(NULL), skyIndex(0), animIndex(0) {}
 };
 
+struct GfxCache {
+	char name[32];
+	Tile *gfx;
+	uint32 size;
+	uint16 loaded;
+
+	GfxCache() : name(""), gfx(NULL), size(0), loaded(0) {}
+};
 
 class DrawMan {
 public:


Commit: 898d32e1dec832266265b66119fb802fb59989c3
    https://github.com/scummvm/scummvm/commit/898d32e1dec832266265b66119fb802fb59989c3
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:16:51+02:00

Commit Message:
HDB: Add _gfxCache to store cached graphics

Changed paths:
    engines/hdb/draw-manager.cpp
    engines/hdb/draw-manager.h


diff --git a/engines/hdb/draw-manager.cpp b/engines/hdb/draw-manager.cpp
index 5783e61..479e39c 100644
--- a/engines/hdb/draw-manager.cpp
+++ b/engines/hdb/draw-manager.cpp
@@ -26,11 +26,13 @@ namespace HDB {
 
 DrawMan::DrawMan() {
 	_tLookupArray = NULL;
+	_gfxCache = new Common::Array<GfxCache *>;
 	_globalSurface.create(kScreenWidth, kScreenHeight, g_hdb->_format);
 	_systemInit = false;
 }
 
 DrawMan::~DrawMan() {
+	delete _gfxCache;
 	_globalSurface.free();
 }
 
diff --git a/engines/hdb/draw-manager.h b/engines/hdb/draw-manager.h
index 2bf5386..101da99 100644
--- a/engines/hdb/draw-manager.h
+++ b/engines/hdb/draw-manager.h
@@ -92,6 +92,8 @@ private:
 	TileLookup *_tLookupArray;
 	uint16 _skyTiles[kMaxSkies];
 
+	Common::Array<GfxCache *> *_gfxCache;
+
 	int _currentSky;	// 0 if no Sky, 1+ for which Sky to use
 	struct {
 		bool active;


Commit: f6fe88bab927a3d5aa523ca8847fd68828c09722
    https://github.com/scummvm/scummvm/commit/f6fe88bab927a3d5aa523ca8847fd68828c09722
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:16:51+02:00

Commit Message:
HDB: Add getGfx to get and cache Gfx files

Changed paths:
    engines/hdb/draw-manager.cpp
    engines/hdb/draw-manager.h


diff --git a/engines/hdb/draw-manager.cpp b/engines/hdb/draw-manager.cpp
index 479e39c..b73b947 100644
--- a/engines/hdb/draw-manager.cpp
+++ b/engines/hdb/draw-manager.cpp
@@ -169,6 +169,33 @@ Picture *DrawMan::getPicture(const char *name) {
 	return picture;
 }
 
+Tile *DrawMan::getGfx(const char *name, uint32 size) {
+	// Try to find graphic
+	for (Common::Array<GfxCache *>::iterator it = _gfxCache->begin(); it != _gfxCache->end(); it++) {
+		if (Common::matchString((*it)->name, name)) {
+			if ((*it)->loaded == -1) {	// Marked for Deletetion?
+				(*it)->loaded = 1;		// Reactivate it
+				return (*it)->gfx;
+			}
+		}
+	}
+
+	GfxCache *gc = new GfxCache;
+	strcpy(gc->name, name);
+
+	Common::SeekableReadStream *stream = g_hdb->_fileMan->findFirstData(name, TYPE_TILE32);
+
+	Tile *gfxTile = new Tile;
+	gfxTile->load(stream);
+
+	gc->size = size;
+	gc->loaded = 1;
+
+	_gfxCache->push_back(gc);
+
+	return gc->gfx;
+}
+
 int DrawMan::isSky(int index) {
 	if (!index) {
 		return 0;
diff --git a/engines/hdb/draw-manager.h b/engines/hdb/draw-manager.h
index 101da99..c05c7e9 100644
--- a/engines/hdb/draw-manager.h
+++ b/engines/hdb/draw-manager.h
@@ -79,6 +79,8 @@ public:
 	int getTileIndex(const char *name);
 	Picture *getPicture(const char *name);
 
+	Tile *getGfx(const char *name, uint32 size);
+
 	int isSky(int skyIndex);
 	void setSky(int skyIndex);
 	void setup3DStars();


Commit: 96e37fdf473a7522a60ff08029028624df0764ce
    https://github.com/scummvm/scummvm/commit/96e37fdf473a7522a60ff08029028624df0764ce
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:16:51+02:00

Commit Message:
HDB: Add AnimFrame constants and extend AIEntity

Changed paths:
    engines/hdb/ai.h


diff --git a/engines/hdb/ai.h b/engines/hdb/ai.h
index cf21f65..c94f9ff 100644
--- a/engines/hdb/ai.h
+++ b/engines/hdb/ai.h
@@ -28,6 +28,8 @@
 namespace HDB {
 
 enum {
+	kMaxAnimFrames = 8,
+	kMaxDeathFrames = 12,
 	kMaxInventory = 10,
 	kMaxDeliveries = 5,
 	kPlayerMoveSpeed = 4,
@@ -369,7 +371,41 @@ struct AIEntity {
 	uint16		animDelay;								// changes every frame; based on anim_cycle at start
 	uint16		animCycle;								// delay between frame animations
 
-	// TODO: Add the frame arrays needed
+	union {
+		uint16 blinkFrames;
+		uint16 int1;
+	};
+	void *blinkGfx[kMaxAnimFrames];
+
+	union {
+		uint16 special1Frames;
+		uint16 int2;
+	};
+	void *special1Gfx[kMaxAnimFrames];
+
+	uint16		standdownFrames;
+	Tile		*standdownGfx[kMaxAnimFrames];
+
+	uint16		standupFrames;
+	Tile		*standupGfx[kMaxAnimFrames];
+
+	uint16		standleftFrames;
+	Tile		*standleftGfx[kMaxAnimFrames];
+
+	uint16		standrightFrames;
+	Tile		*standrightGfx[kMaxAnimFrames];
+
+	uint16		moveupFrames;
+	Tile		*moveupGfx[kMaxAnimFrames];
+
+	uint16		movedownFrames;
+	Tile		*movedownGfx[kMaxAnimFrames];
+
+	uint16		moveleftFrames;
+	Tile		*moveleftGfx[kMaxAnimFrames];
+
+	uint16		moverightFrames;
+	Tile		*moverightGfx[kMaxAnimFrames];
 };
 
 struct AIEntTypeInfo {


Commit: 65ca4062e382339dbda9594a8d4a546b57324662
    https://github.com/scummvm/scummvm/commit/65ca4062e382339dbda9594a8d4a546b57324662
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:16:51+02:00

Commit Message:
HDB: Add additional player frames

Changed paths:
    engines/hdb/ai.h


diff --git a/engines/hdb/ai.h b/engines/hdb/ai.h
index c94f9ff..d90dbac 100644
--- a/engines/hdb/ai.h
+++ b/engines/hdb/ai.h
@@ -550,6 +550,68 @@ private:
 	bool _playerEmerging;
 	bool _playerRunning;
 
+	uint16		pushupFrames;
+	Tile		*pushupGfx[kMaxAnimFrames];
+
+	uint16		pushdownFrames;
+	Tile		*pushdownGfx[kMaxAnimFrames];
+
+	uint16		pushleftFrames;
+	Tile		*pushleftGfx[kMaxAnimFrames];
+
+	uint16		pushrightFrames;
+	Tile		*pushrightGfx[kMaxAnimFrames];
+
+	Tile		*getGfx[5];			// only 1 frame in each direction (+1 for DIR_NONE at start)
+
+	uint16		dyingFrames;
+	Tile		*dyingGfx[kMaxDeathFrames];
+
+	Tile		*goodjobGfx;			// only 1 frame
+
+	uint16		horrible1Frames;
+	Tile		*horrible1Gfx[kMaxDeathFrames];
+	uint16		horrible2Frames;
+	Tile		*horrible2Gfx[kMaxDeathFrames];
+	uint16		horrible3Frames;
+	Tile		*horrible3Gfx[kMaxDeathFrames];
+	uint16		horrible4Frames;
+	Tile		*horrible4Gfx[kMaxDeathFrames];
+	uint16		plummetFrames;
+	Tile		*plummetGfx[kMaxDeathFrames];
+
+	uint16		clubUpFrames;
+	Tile		*clubUpGfx[kMaxAnimFrames];
+	uint16		clubDownFrames;
+	Tile		*clubDownGfx[kMaxAnimFrames];
+	uint16		clubLeftFrames;
+	Tile		*clubLeftGfx[kMaxAnimFrames];
+	uint16		clubRightFrames;
+	Tile		*clubRightGfx[kMaxAnimFrames];
+
+	uint16		stunUpFrames;
+	Tile		*stunUpGfx[kMaxAnimFrames];
+	uint16		stunDownFrames;
+	Tile		*stunDownGfx[kMaxAnimFrames];
+	uint16		stunLeftFrames;
+	Tile		*stunLeftGfx[kMaxAnimFrames];
+	uint16		stunRightFrames;
+	Tile		*stunRightGfx[kMaxAnimFrames];
+	Tile		*stun_lightningGfx[kMaxAnimFrames];
+	Tile		*stunnedGfx[kMaxAnimFrames];
+
+	uint16		slugUpFrames;
+	Tile		*slugUpGfx[kMaxAnimFrames];
+	uint16		slugDownFrames;
+	Tile		*slugDownGfx[kMaxAnimFrames];
+	uint16		slugLeftFrames;
+	Tile		*slugLeftGfx[kMaxAnimFrames];
+	uint16		slugRightFrames;
+	Tile		*slugRightGfx[kMaxAnimFrames];
+
+	uint16		slugAttackFrames;
+	Tile		*slugAttackGfx[kMaxAnimFrames];
+
 	// Player Resources and Deliveries
 
 	int _numGems;


Commit: deaa694591b0cb63c646f89bad8cbdb6f389c8ca
    https://github.com/scummvm/scummvm/commit/deaa694591b0cb63c646f89bad8cbdb6f389c8ca
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:16:51+02:00

Commit Message:
HDB: Add cacheEntGfx()

Changed paths:
    engines/hdb/ai-funcs.cpp
    engines/hdb/ai.h


diff --git a/engines/hdb/ai-funcs.cpp b/engines/hdb/ai-funcs.cpp
index f10638a..fd3e0ba 100644
--- a/engines/hdb/ai-funcs.cpp
+++ b/engines/hdb/ai-funcs.cpp
@@ -75,6 +75,353 @@ AIEntity *AI::spawn(AIType type, AIDir dir, int x, int y, char *funcInit, char *
 	return e;
 }
 
+bool AI::cacheEntGfx(AIEntity *e, bool init) {
+	int i = 0;
+	while (true) {
+		if (aiEntList[i].type == END_AI_TYPES) {
+			return false;
+		}
+
+		// Load Gfx for corresponding Entity
+		if (aiEntList[i].type == e->type) {
+			int j = 0;
+			AIStateDef *list = aiEntList[i].stateDef;
+
+			while (list[j].state != STATE_ENDSTATES) {
+
+				Common::Array<const char *> *gfxFiles = g_hdb->_fileMan->findFiles(list[j].name, TYPE_TILE32);
+				uint32 size;
+
+				for (Common::Array<const char *>::iterator it = gfxFiles->begin(); it != gfxFiles->end(); it++) {
+					size = g_hdb->_fileMan->getLength((*it), TYPE_TILE32);
+
+					Tile *gfx = g_hdb->_drawMan->getGfx((*it), size);
+					switch (list[j].state) {
+					case STATE_STANDDOWN:
+						e->standdownGfx[e->standdownFrames] = gfx;
+						e->standdownFrames++;
+						break;
+					case STATE_STANDUP:
+						e->standupGfx[e->standupFrames] = gfx;
+						e->standupFrames++;
+						break;
+					case STATE_STANDLEFT:
+						e->standleftGfx[e->standleftFrames] = gfx;
+						e->standleftFrames++;
+						break;
+					case STATE_STANDRIGHT:
+						e->standrightGfx[e->standrightFrames] = gfx;
+						e->standrightFrames++;
+						break;
+					case STATE_BLINK:
+						e->blinkGfx[e->blinkFrames] = gfx;
+						e->blinkFrames++;
+						break;
+					case STATE_MOVEDOWN:
+						e->movedownGfx[e->movedownFrames] = gfx;
+						e->movedownFrames++;
+						break;
+					case STATE_MOVEUP:
+						e->moveupGfx[e->moveupFrames] = gfx;
+						e->moveupFrames++;
+						break;
+					case STATE_MOVELEFT:
+						e->moveleftGfx[e->moveleftFrames] = gfx;
+						e->moveleftFrames++;
+						break;
+					case STATE_MOVERIGHT:
+						e->moverightGfx[e->moverightFrames] = gfx;
+						e->moverightFrames++;
+						break;
+
+					// Special Player Frames
+					case STATE_PUSHDOWN:
+						pushdownGfx[pushdownFrames] = gfx;
+						pushdownFrames++;
+						break;
+					case STATE_PUSHUP:
+						pushupGfx[pushupFrames] = gfx;
+						pushupFrames++;
+						break;
+					case STATE_PUSHLEFT:
+						pushleftGfx[pushleftFrames] = gfx;
+						pushleftFrames++;
+						break;
+					case STATE_PUSHRIGHT:
+						pushrightGfx[pushrightFrames] = gfx;
+						pushrightFrames++;
+						break;
+					case STATE_GRABUP:
+						getGfx[DIR_UP] = gfx; break;
+					case STATE_GRABDOWN:
+						getGfx[DIR_DOWN] = gfx; break;
+					case STATE_GRABLEFT:
+						getGfx[DIR_LEFT] = gfx; break;
+					case STATE_GRABRIGHT:
+						getGfx[DIR_RIGHT] = gfx; break;
+
+					case STATE_ATK_CLUB_UP:
+						clubUpGfx[clubUpFrames] = gfx;
+						clubUpFrames++;
+						break;
+					case STATE_ATK_CLUB_DOWN:
+						clubDownGfx[clubDownFrames] = gfx;
+						clubDownFrames++;
+						break;
+					case STATE_ATK_CLUB_LEFT:
+						clubLeftGfx[clubLeftFrames] = gfx;
+						clubLeftFrames++;
+						break;
+					case STATE_ATK_CLUB_RIGHT:
+						clubRightGfx[clubRightFrames] = gfx;
+						clubRightFrames++;
+						break;
+
+					case STATE_ATK_STUN_UP:
+						stunUpGfx[stunUpFrames] = gfx;
+						stunUpFrames++;
+						break;
+					case STATE_ATK_STUN_DOWN:
+						stunDownGfx[stunDownFrames] = gfx;
+						stunDownFrames++;
+						break;
+					case STATE_ATK_STUN_LEFT:
+						stunLeftGfx[stunLeftFrames] = gfx;
+						stunLeftFrames++;
+						break;
+					case STATE_ATK_STUN_RIGHT:
+						stunRightGfx[stunRightFrames] = gfx;
+						stunRightFrames++;
+						break;
+
+					case STATE_ATK_SLUG_UP:
+						slugUpGfx[slugUpFrames] = gfx;
+						slugUpFrames++;
+						break;
+					case STATE_ATK_SLUG_DOWN:
+						slugDownGfx[slugDownFrames] = gfx;
+						slugDownFrames++;
+						break;
+					case STATE_ATK_SLUG_LEFT:
+						slugLeftGfx[slugLeftFrames] = gfx;
+						slugLeftFrames++;
+						break;
+					case STATE_ATK_SLUG_RIGHT:
+						slugRightGfx[slugRightFrames] = gfx;
+						slugRightFrames++;
+						break;
+
+					// Maintenance Bot
+					case STATE_USEUP:
+						e->standupGfx[4] = gfx;
+						break;
+					case STATE_USEDOWN:
+						e->standdownGfx[4] = gfx;
+						break;
+					case STATE_USELEFT:
+						e->standleftGfx[4] = gfx;
+						break;
+					case STATE_USERIGHT:
+						e->standrightGfx[4] = gfx;
+						break;
+
+					// Death & Dying for Player
+					case STATE_DYING:
+						dyingGfx[dyingFrames] = gfx;
+						dyingFrames++;
+						break;
+					case STATE_GOODJOB:
+						goodjobGfx = gfx;
+						break;
+
+					case STATE_HORRIBLE1:
+						horrible1Gfx[horrible1Frames] = gfx;
+						horrible1Frames++;
+						break;
+					case STATE_HORRIBLE2:
+						horrible2Gfx[horrible2Frames] = gfx;
+						horrible2Frames++;
+						break;
+					case STATE_HORRIBLE3:
+						horrible3Gfx[horrible3Frames] = gfx;
+						horrible3Frames++;
+						break;
+					case STATE_HORRIBLE4:
+						horrible4Gfx[horrible4Frames] = gfx;
+						horrible4Frames++;
+						break;
+					case STATE_PLUMMET:
+						plummetGfx[plummetFrames] = gfx;
+						plummetFrames++;
+						break;
+
+					// floating frames - overwrite "standup" info
+					case STATE_FLOATING:
+						e->blinkGfx[e->blinkFrames] = gfx;
+						e->blinkFrames++;
+						break;
+
+					// melted frames - go in the special area (lightbarrels)
+					// shocking frames - go in the special1 area (shockbots)
+					// exploding frames, same
+					case STATE_MELTED:
+					case STATE_SHOCKING:
+					case STATE_EXPLODING:
+						e->special1Gfx[e->special1Frames] = gfx;
+						e->special1Frames++;
+						break;
+
+					// ICEPUFF spawning states
+					case STATE_ICEP_PEEK:
+						e->blinkGfx[e->blinkFrames] = gfx;
+						e->blinkFrames++;
+						break;
+					case STATE_ICEP_APPEAR:
+						e->standupGfx[e->standupFrames] = gfx;
+						e->standupFrames++;
+						break;
+					case STATE_ICEP_THROWDOWN:
+						e->standdownGfx[e->standdownFrames] = gfx;
+						e->standdownFrames++;
+						break;
+					case STATE_ICEP_THROWRIGHT:
+						e->standrightGfx[e->standrightFrames] = gfx;
+						e->standrightFrames++;
+						break;
+					case STATE_ICEP_THROWLEFT:
+						e->standleftGfx[e->standleftFrames] = gfx;
+						e->standleftFrames++;
+						break;
+					case STATE_ICEP_DISAPPEAR:
+						e->special1Gfx[e->special1Frames] = gfx;
+						e->special1Frames++;
+						break;
+
+					// FATFROG spawning states
+					case STATE_LICKDOWN:
+						e->movedownGfx[e->movedownFrames] = gfx;
+						e->movedownFrames++;
+						break;
+					case STATE_LICKLEFT:
+						e->moveleftGfx[e->moveleftFrames] = gfx;
+						e->moveleftFrames++;
+						break;
+					case STATE_LICKRIGHT:
+						e->moverightGfx[e->moverightFrames] = gfx;
+						e->moverightFrames++;
+						break;
+
+					// MEERKAT spawning states
+					case STATE_MEER_MOVE:
+						e->standdownGfx[e->standdownFrames] = gfx;
+						e->standdownFrames++;
+						break;
+					case STATE_MEER_APPEAR:
+						e->standleftGfx[e->standleftFrames] = gfx;
+						e->standleftFrames++;
+						break;
+					case STATE_MEER_BITE:
+						e->standrightGfx[e->standrightFrames] = gfx;
+						e->standrightFrames++;
+						break;
+					case STATE_MEER_DISAPPEAR:
+						e->standupGfx[e->standupFrames] = gfx;
+						e->standupFrames++;
+						break;
+					case STATE_MEER_LOOK:
+						e->movedownGfx[e->movedownFrames] = gfx;
+						e->movedownFrames++;
+						break;
+
+					// DIVERTER spawning states
+					case STATE_DIVERTER_BL:
+						e->standdownGfx[e->standdownFrames] = gfx;
+						e->standdownFrames++;
+						break;
+					case STATE_DIVERTER_BR:
+						e->standupGfx[e->standupFrames] = gfx;
+						e->standupFrames++;
+						break;
+					case STATE_DIVERTER_TL:
+						e->standleftGfx[e->standleftFrames] = gfx;
+						e->standleftFrames++;
+						break;
+					case STATE_DIVERTER_TR:
+						e->standrightGfx[e->standrightFrames] = gfx;
+						e->standrightFrames++;
+						break;
+					// DOLLY states
+					// angry[4] = standright[4]
+					// kissright[4]/kissleft[4] = standleft[8]
+					// panic[4]/laugh[4] = standdown[8]
+					// dollyuseright[5] = special1[5]
+					case STATE_ANGRY:
+						e->standrightGfx[e->standrightFrames] = gfx;
+						e->standrightFrames++;
+						break;
+					case STATE_KISSRIGHT:
+						e->standleftGfx[e->standleftFrames] = gfx;
+						e->standleftFrames++;
+						break;
+					case STATE_KISSLEFT:
+						e->standleftGfx[4 + e->int1] = gfx;
+						e->int1++;
+						break;
+					case STATE_PANIC:
+						e->standdownGfx[e->standdownFrames] = gfx;
+						e->standdownFrames++;
+						break;
+					case STATE_LAUGH:
+						e->standdownGfx[4 + e->value1] = gfx;
+						e->value1++;
+						break;
+					case STATE_DOLLYUSERIGHT:
+						e->special1Gfx[e->special1Frames] = gfx;
+						e->special1Frames++;
+						break;
+
+					// SARGE yelling
+					case STATE_YELL:
+						e->special1Gfx[e->special1Frames] = gfx;
+						e->special1Frames++;
+						break;
+					}
+				}
+				j++;
+			}
+
+			e->aiInit = aiEntList[i].initFunc;
+			e->aiInit2 = aiEntList[i].initFunc2;
+			if (init) {
+				e->aiInit(e);
+				if (e->aiInit2) {
+					e->aiInit2(e);
+				}
+				if (e->luaFuncInit[0]) {
+					g_hdb->_lua->callFunction(e->luaFuncInit, 2);
+
+					const char *str1 = g_hdb->_lua->getStringOffStack();
+					const char *str2 = g_hdb->_lua->getStringOffStack();
+					if (str1) {
+						strcpy(e->entityName, str1);
+					}
+					if (str2) {
+						strcpy(e->printedName, str2);
+					}
+				}
+			} else {
+				if (e->aiInit2) {
+					e->aiInit2(e);
+				}
+			}
+
+			break; // Entity Initiated
+		}
+		i++;
+	}
+	return true;
+}
+
 AIEntity *AI::locateEntity(const char *luaName) {
 	for (Common::Array<AIEntity *>::iterator it = _ents->begin(); it != _ents->end(); it++) {
 		if (Common::matchString((*it)->entityName, luaName)) {
diff --git a/engines/hdb/ai.h b/engines/hdb/ai.h
index d90dbac..1c6de5f 100644
--- a/engines/hdb/ai.h
+++ b/engines/hdb/ai.h
@@ -451,6 +451,7 @@ public:
 
 	// Entity Functions
 	AIEntity *spawn(AIType type, AIDir dir, int x, int y, char *funcInit, char *funcAction, char *funcUse, AIDir dir2, int level, int value1, int value2, int callInit);
+	bool cacheEntGfx(AIEntity *e, bool init);
 	AIEntity *locateEntity(const char *luaName);
 	void removeEntity(AIEntity *e);
 	void initAllEnts();


Commit: 266bcfb97add23f46be7e2a125190f9e3598f7bc
    https://github.com/scummvm/scummvm/commit/266bcfb97add23f46be7e2a125190f9e3598f7bc
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:16:51+02:00

Commit Message:
HDB: Remove Cache Gfx stub from spawn

Changed paths:
    engines/hdb/ai-funcs.cpp


diff --git a/engines/hdb/ai-funcs.cpp b/engines/hdb/ai-funcs.cpp
index fd3e0ba..453d7cc 100644
--- a/engines/hdb/ai-funcs.cpp
+++ b/engines/hdb/ai-funcs.cpp
@@ -68,9 +68,15 @@ AIEntity *AI::spawn(AIType type, AIDir dir, int x, int y, char *funcInit, char *
 	if (e->luaFuncUse[0] == '*')
 		e->luaFuncUse[0] = 0;
 
-	_ents->push_back(e);
+	e->standdownFrames = e->standupFrames = e->standleftFrames = e->standrightFrames = 0;
+	e->movedownFrames = e->moveupFrames = e->moveleftFrames = e->moverightFrames = 0;
+	e->blinkFrames = 0;
 
-	warning("STUB: AI::spawn: CacheEntGfx required");
+	if (!cacheEntGfx(e, (bool)callInit)) {
+		return NULL;
+	} else {
+		_ents->push_back(e);
+	}
 
 	return e;
 }


Commit: 8810def2b257601d61013bb255d87521910c47e5
    https://github.com/scummvm/scummvm/commit/8810def2b257601d61013bb255d87521910c47e5
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:16:51+02:00

Commit Message:
HDB: Add debug output to C_SETENTITY

Changed paths:
    engines/hdb/ai-cinematic.cpp


diff --git a/engines/hdb/ai-cinematic.cpp b/engines/hdb/ai-cinematic.cpp
index 7159f9a..bc89afe 100644
--- a/engines/hdb/ai-cinematic.cpp
+++ b/engines/hdb/ai-cinematic.cpp
@@ -143,6 +143,7 @@ void AI::processCines() {
 				_cine[i]->e->tileY = (int)_cine[i]->y / kTileHeight;
 				_cine[i]->e->y = (int)_cine[i]->y;
 				_cine[i]->e->level = (int)_cine[i]->x2;
+				debug(2, "Found '%s' in setEntity", _cine[i]->string);
 			} else {
 				warning("Can't locate '%s' in setEntity", _cine[i]->string);
 			}


Commit: 641c2a91796a4fbfecc80652b3dbfb0a597f02eb
    https://github.com/scummvm/scummvm/commit/641c2a91796a4fbfecc80652b3dbfb0a597f02eb
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:16:51+02:00

Commit Message:
HDB: Added Lua print stack utility function

Changed paths:
    engines/hdb/lua-script.cpp
    engines/hdb/lua-script.h


diff --git a/engines/hdb/lua-script.cpp b/engines/hdb/lua-script.cpp
index 5259c10..08d5f77 100644
--- a/engines/hdb/lua-script.cpp
+++ b/engines/hdb/lua-script.cpp
@@ -960,6 +960,13 @@ void LuaScript::checkParameters(const char *func, int params) {
 	}
 }
 
+void lua_printstack(lua_State *L) {
+	int n = lua_gettop(L);
+	for (int i = 1; i <= n; i++)  {
+		debug(1, "STACK %d %s %s", i, lua_tostring(L, i), luaL_typename(L, i));
+	}
+}
+
 const char *LuaScript::getStringOffStack() {
 	if (!_systemInit) {
 		return NULL;
diff --git a/engines/hdb/lua-script.h b/engines/hdb/lua-script.h
index 20cd94d..32830b3 100644
--- a/engines/hdb/lua-script.h
+++ b/engines/hdb/lua-script.h
@@ -60,6 +60,8 @@ private:
 	void addPatches(Common::String &chunk, const char *scriptName);
 };
 
+void lua_printstack(lua_State *L);
+
 }
 
 #endif // !HDB_LUA_SCRIPT_H


Commit: e7c72d05808bc8276797e6b580592ab8c2ae00c9
    https://github.com/scummvm/scummvm/commit/e7c72d05808bc8276797e6b580592ab8c2ae00c9
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:16:51+02:00

Commit Message:
HDB: Fixed nu,ber of parameters when calling Lua functions

Changed paths:
    engines/hdb/lua-script.cpp


diff --git a/engines/hdb/lua-script.cpp b/engines/hdb/lua-script.cpp
index 08d5f77..fc10a9d 100644
--- a/engines/hdb/lua-script.cpp
+++ b/engines/hdb/lua-script.cpp
@@ -811,14 +811,13 @@ bool LuaScript::initScript(Common::SeekableReadStream *stream, const char *scrip
 }
 
 bool LuaScript::callFunction(const char *name, int returns) {
-
 	if (!_systemInit) {
 		return false;
 	}
 
 	lua_getglobal(_state, name);
 
-	if (lua_pcall(_state, 0, 0, -2)) {
+	if (lua_pcall(_state, 0, returns, -2)) {
 		error("An error occured while executing \"%s\": %s.", name, lua_tostring(_state, -1));
 		lua_pop(_state, -1);
 


Commit: d6852227e8bf0b028883929718174ecc9d04e9a0
    https://github.com/scummvm/scummvm/commit/d6852227e8bf0b028883929718174ecc9d04e9a0
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:16:51+02:00

Commit Message:
HDB: Add Waypoint data

Addition includes constants, structs and member
variables

Changed paths:
    engines/hdb/ai-init.cpp
    engines/hdb/ai.h


diff --git a/engines/hdb/ai-init.cpp b/engines/hdb/ai-init.cpp
index b7f7a48..812b510 100644
--- a/engines/hdb/ai-init.cpp
+++ b/engines/hdb/ai-init.cpp
@@ -704,5 +704,9 @@ void AI::restartSystem() {
 
 	// Clear Cinematic System
 	_cineActive = _cameraLock = _playerLock = _cineAborted = false;
+
+	// Clear waypoints
+	memset(&_waypoints[0], 0, sizeof(_waypoints));
+	_numWaypoints = 0;
 }
 } // End of Namespace
diff --git a/engines/hdb/ai.h b/engines/hdb/ai.h
index 1c6de5f..9d0a428 100644
--- a/engines/hdb/ai.h
+++ b/engines/hdb/ai.h
@@ -32,6 +32,7 @@ enum {
 	kMaxDeathFrames = 12,
 	kMaxInventory = 10,
 	kMaxDeliveries = 5,
+	kMaxWaypoints = 10,
 	kPlayerMoveSpeed = 4,
 	kEnemyMoveSpeed = 2,
 	kPushMoveSpeed = (kPlayerMoveSpeed >> 1)
@@ -423,6 +424,10 @@ struct InvEnt {
 	AIEntity ent;
 };
 
+struct Waypoint {
+	int x, y, level;
+};
+
 struct CineCommand {
 	CineType cmdType;
 	double x, y;
@@ -622,6 +627,10 @@ private:
 	InvEnt _inventory[kMaxInventory];
 	int _numInventory;
 
+	Waypoint _waypoints[kMaxWaypoints];
+	int _numWaypoints;
+	Tile *_waypointGfx[4]; // Animating waypoint gfx
+
 	// Cinematics Variables
 	bool _cineAbortable;
 	bool _cineAborted;


Commit: b0f714cb25c343fecb00656c2f0df028368126c5
    https://github.com/scummvm/scummvm/commit/b0f714cb25c343fecb00656c2f0df028368126c5
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:16:51+02:00

Commit Message:
HDB: Add clearWaypoints()

Changed paths:
  A engines/hdb/ai-waypoint.cpp
    engines/hdb/ai.h
    engines/hdb/module.mk


diff --git a/engines/hdb/ai-waypoint.cpp b/engines/hdb/ai-waypoint.cpp
new file mode 100644
index 0000000..ec31bd1
--- /dev/null
+++ b/engines/hdb/ai-waypoint.cpp
@@ -0,0 +1,32 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "hdb/hdb.h"
+
+namespace HDB {
+
+void AI::clearWaypoints() {
+	memset(&_waypoints[0], 0, sizeof(_waypoints));
+	_numWaypoints = 0;
+}
+
+} // End of Namespace
diff --git a/engines/hdb/ai.h b/engines/hdb/ai.h
index 9d0a428..344c4b4 100644
--- a/engines/hdb/ai.h
+++ b/engines/hdb/ai.h
@@ -537,6 +537,7 @@ public:
 
 	// Waypoint & Movement Functions
 	void lookAtXY(int x, int y);
+	void clearWaypoints();
 
 	// Inventory Functions
 	bool addToInventory(AIEntity *e);
diff --git a/engines/hdb/module.mk b/engines/hdb/module.mk
index 6402b47..137ff04 100644
--- a/engines/hdb/module.mk
+++ b/engines/hdb/module.mk
@@ -6,6 +6,7 @@ MODULE_OBJS := \
 	ai-cinematic.o \
 	ai-funcs.o \
 	ai-player.o \
+	ai-waypoint.o \
 	console.o \
 	draw-manager.o \
 	detection.o \


Commit: e473c1d48931a87f7b45db3b7908affea4529d33
    https://github.com/scummvm/scummvm/commit/e473c1d48931a87f7b45db3b7908affea4529d33
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:16:51+02:00

Commit Message:
HDB: Add stopEntity()

Changed paths:
    engines/hdb/ai-funcs.cpp
    engines/hdb/ai.h


diff --git a/engines/hdb/ai-funcs.cpp b/engines/hdb/ai-funcs.cpp
index 453d7cc..8df88cf 100644
--- a/engines/hdb/ai-funcs.cpp
+++ b/engines/hdb/ai-funcs.cpp
@@ -428,6 +428,64 @@ bool AI::cacheEntGfx(AIEntity *e, bool init) {
 	return true;
 }
 
+// Stops the movement of an entity
+void AI::stopEntity(AIEntity *e) {
+	if (e == _player) {
+		clearWaypoints();
+		// Reset Player speed
+		e->moveSpeed = kPlayerMoveSpeed;
+	}
+
+	// Reset animation
+	e->animFrame = 0;
+
+	// Align with tile boundaries
+	e->x = e->tileX * kTileWidth;
+	e->y = e->tileY * kTileHeight;
+	e->goalX = e->tileX;
+	e->goalY = e->tileY;
+	e->drawXOff = e->drawYOff = 0;
+
+	// Don't change the state of Diverters or Floating entities
+	switch (e->state) {
+	case STATE_FLOATLEFT:
+	case STATE_FLOATRIGHT:
+	case STATE_FLOATUP:
+	case STATE_FLOATDOWN:
+		e->state = STATE_FLOATING;
+		return;
+	}
+
+	if (e->type != AI_DIVERTER) {
+		switch (e->dir) {
+		case DIR_UP:
+			if (e->standupFrames)
+				e->state = STATE_STANDUP;
+			else
+				e->state = STATE_NONE;
+			break;
+		case DIR_DOWN:
+			if (e->standdownFrames)
+				e->state = STATE_STANDDOWN;
+			else
+				e->state = STATE_NONE;
+			break;
+		case DIR_LEFT:
+			if (e->standleftFrames)
+				e->state = STATE_STANDLEFT;
+			else
+				e->state = STATE_NONE;
+			break;
+		case DIR_RIGHT:
+			if (e->standrightFrames)
+				e->state = STATE_STANDRIGHT;
+			else
+				e->state = STATE_NONE;
+			break;
+		}
+	}
+}
+
 AIEntity *AI::locateEntity(const char *luaName) {
 	for (Common::Array<AIEntity *>::iterator it = _ents->begin(); it != _ents->end(); it++) {
 		if (Common::matchString((*it)->entityName, luaName)) {
diff --git a/engines/hdb/ai.h b/engines/hdb/ai.h
index 344c4b4..1eaa41c 100644
--- a/engines/hdb/ai.h
+++ b/engines/hdb/ai.h
@@ -356,7 +356,7 @@ struct AIEntity {
 	AIDir		dir2;									// this is from TED
 
 	uint16		x, y;
-	uint16		drawXOff, drawYOoff;					// might need a drawing offset
+	uint16		drawXOff, drawYOff;					// might need a drawing offset
 	uint16		onScreen;								// FLAG: is this entity onscreen?
 	uint16		moveSpeed;								// movement speed of this entity
 	uint16		xVel, yVel;								// movement values
@@ -457,6 +457,7 @@ public:
 	// Entity Functions
 	AIEntity *spawn(AIType type, AIDir dir, int x, int y, char *funcInit, char *funcAction, char *funcUse, AIDir dir2, int level, int value1, int value2, int callInit);
 	bool cacheEntGfx(AIEntity *e, bool init);
+	void stopEntity(AIEntity *e);
 	AIEntity *locateEntity(const char *luaName);
 	void removeEntity(AIEntity *e);
 	void initAllEnts();


Commit: e39f5c361f790c90a7d57d894a4e04568858000f
    https://github.com/scummvm/scummvm/commit/e39f5c361f790c90a7d57d894a4e04568858000f
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:16:52+02:00

Commit Message:
HDB: Add cineLockPlayer() and cineUnlockPlayer()

Changed paths:
    engines/hdb/ai-cinematic.cpp
    engines/hdb/ai.h


diff --git a/engines/hdb/ai-cinematic.cpp b/engines/hdb/ai-cinematic.cpp
index bc89afe..44fe3a3 100644
--- a/engines/hdb/ai-cinematic.cpp
+++ b/engines/hdb/ai-cinematic.cpp
@@ -200,6 +200,18 @@ void AI::cineStart(bool abortable, const char *abortFunc) {
 	_cameraLock = false;
 }
 
+void AI::cineLockPlayer() {
+	CineCommand *cmd = new CineCommand;
+	cmd->cmdType = C_LOCKPLAYER;
+	_cine.push_back(cmd);
+}
+
+void AI::cineUnlockPlayer() {
+	CineCommand *cmd = new CineCommand;
+	cmd->cmdType = C_UNLOCKPLAYER;
+	_cine.push_back(cmd);
+}
+
 void AI::cineSetCamera(int x, int y) {
 	CineCommand *cmd = new CineCommand;
 	cmd->x = x * kTileWidth;
diff --git a/engines/hdb/ai.h b/engines/hdb/ai.h
index 1eaa41c..378318f 100644
--- a/engines/hdb/ai.h
+++ b/engines/hdb/ai.h
@@ -526,6 +526,8 @@ public:
 	// Cinematic Functions
 	void processCines();
 	void cineStart(bool abortable, const char *abortFunc);
+	void cineLockPlayer();
+	void cineUnlockPlayer();
 	void cineSetCamera(int x, int y);
 	void cineResetCamera();
 	void cineMoveCamera(int x, int y, int speed);


Commit: 2868423cd30fa2be11e7254e82e1e37b937afa77
    https://github.com/scummvm/scummvm/commit/2868423cd30fa2be11e7254e82e1e37b937afa77
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:16:52+02:00

Commit Message:
HDB: Process cineLockPlayer() + cineUnlockPlayer()

Changed paths:
    engines/hdb/ai-cinematic.cpp


diff --git a/engines/hdb/ai-cinematic.cpp b/engines/hdb/ai-cinematic.cpp
index 44fe3a3..0f21d4f 100644
--- a/engines/hdb/ai-cinematic.cpp
+++ b/engines/hdb/ai-cinematic.cpp
@@ -83,6 +83,18 @@ void AI::processCines() {
 				g_system->getMillis(), _cine[i]->start, _cine[i]->delay);
 
 		switch (_cine[i]->cmdType) {
+		case C_LOCKPLAYER:
+			_playerLock = true;
+			complete = true;
+			if (_player) {
+				stopEntity(_player);
+			}
+			clearWaypoints();
+			break;
+		case C_UNLOCKPLAYER:
+			_playerLock = false;
+			complete = true;
+			break;
 		case C_SETCAMERA:
 			_cameraX = _cine[i]->x;
 			_cameraY = _cine[i]->y;


Commit: b2d1bbf5f50e0d8834a49df90856224b4545af24
    https://github.com/scummvm/scummvm/commit/b2d1bbf5f50e0d8834a49df90856224b4545af24
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:16:52+02:00

Commit Message:
HDB: Remove cineLockPlayer + cineUnlockPlayer stub

Changed paths:
    engines/hdb/lua-script.cpp


diff --git a/engines/hdb/lua-script.cpp b/engines/hdb/lua-script.cpp
index fc10a9d..f240bcb 100644
--- a/engines/hdb/lua-script.cpp
+++ b/engines/hdb/lua-script.cpp
@@ -140,12 +140,12 @@ static int cineStartMap(lua_State *L) {
 }
 
 static int cineLockPlayer(lua_State *L) {
-	warning("STUB: CINE LOCK PLAYER");
+	g_hdb->_ai->cineLockPlayer();
 	return 0;
 }
 
 static int cineUnlockPlayer(lua_State *L) {
-	warning("STUB: CINE UNLOCK PLAYER");
+	g_hdb->_ai->cineUnlockPlayer();
 	return 0;
 }
 


Commit: 054a9a55301b49a657c714c155ccaea29f896d41
    https://github.com/scummvm/scummvm/commit/054a9a55301b49a657c714c155ccaea29f896d41
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:16:52+02:00

Commit Message:
HDB: Add setEntityGoal()

Changed paths:
    engines/hdb/ai-funcs.cpp
    engines/hdb/ai.h


diff --git a/engines/hdb/ai-funcs.cpp b/engines/hdb/ai-funcs.cpp
index 8df88cf..6ccc982 100644
--- a/engines/hdb/ai-funcs.cpp
+++ b/engines/hdb/ai-funcs.cpp
@@ -499,6 +499,44 @@ void AI::removeEntity(AIEntity *e) {
 	_ents->erase(&e);
 }
 
+void AI::setEntityGoal(AIEntity *e, int x, int y) {
+	int xv, yv;
+
+	e->xVel = e->yVel = 0;
+
+	xv = x - e->tileX;
+	if (xv < 0) {
+		e->xVel = -e->moveSpeed;
+		e->state = STATE_MOVELEFT;
+		e->dir = DIR_LEFT;
+	} else if (xv > 0) {
+		e->xVel = e->moveSpeed;
+		e->state = STATE_MOVERIGHT;
+		e->dir = DIR_RIGHT;
+	}
+
+	yv = y - e->tileY;
+	if (yv < 0) {
+		e->yVel = -e->moveSpeed;
+		e->state = STATE_MOVELEFT;
+		e->dir = DIR_LEFT;
+	} else if (yv > 0) {
+		e->yVel = e->moveSpeed;
+		e->state = STATE_MOVERIGHT;
+		e->dir = DIR_RIGHT;
+	}
+
+	if (e->type == AI_GUY && _playerRunning) {
+		e->xVel = e->xVel << 1;
+		e->yVel = e->yVel << 1;
+	}
+
+	e->goalX = x;
+	e->goalY = y;
+	e->animFrame = 0;
+	e->drawXOff = e->drawYOff = 0;
+}
+
 // Initializes each entity after map is loaded
 void AI::initAllEnts() {
 	for (Common::Array<AIEntity *>::iterator it = _ents->begin(); it != _ents->end(); it++) {
diff --git a/engines/hdb/ai.h b/engines/hdb/ai.h
index 378318f..d6af20d 100644
--- a/engines/hdb/ai.h
+++ b/engines/hdb/ai.h
@@ -359,7 +359,7 @@ struct AIEntity {
 	uint16		drawXOff, drawYOff;					// might need a drawing offset
 	uint16		onScreen;								// FLAG: is this entity onscreen?
 	uint16		moveSpeed;								// movement speed of this entity
-	uint16		xVel, yVel;								// movement values
+	int16		xVel, yVel;								// movement values
 	uint16		tileX, tileY;
 	uint16		goalX, goalY;							// where we're trying to go - TILE COORDS
 	uint16		touchpX, touchpY, touchpTile, touchpWait;		// ACTION index a touchplate is using, which you're on
@@ -460,6 +460,7 @@ public:
 	void stopEntity(AIEntity *e);
 	AIEntity *locateEntity(const char *luaName);
 	void removeEntity(AIEntity *e);
+	void setEntityGoal(AIEntity *e, int x, int y);
 	void initAllEnts();
 	bool getTableEnt(AIType type);
 	bool walkThroughEnt(AIType type);


Commit: 3a8a79f2cc22c77b1c4e5779a174587300427355
    https://github.com/scummvm/scummvm/commit/3a8a79f2cc22c77b1c4e5779a174587300427355
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:16:52+02:00

Commit Message:
HDB: Add cineMoveEntity()

Changed paths:
    engines/hdb/ai-cinematic.cpp
    engines/hdb/ai.h


diff --git a/engines/hdb/ai-cinematic.cpp b/engines/hdb/ai-cinematic.cpp
index 0f21d4f..cab0d0f 100644
--- a/engines/hdb/ai-cinematic.cpp
+++ b/engines/hdb/ai-cinematic.cpp
@@ -273,6 +273,18 @@ void AI::cineSetEntity(const char *entName, int x, int y, int level) {
 	_cine.push_back(cmd);
 }
 
+void AI::cineMoveEntity(const char *entName, int x, int y, int level, int speed) {
+	CineCommand *cmd = new CineCommand;
+	cmd->x = x;
+	cmd->y = y;
+	cmd->x2 = level;
+	cmd->start = 0;
+	cmd->speed = speed;
+	cmd->title = entName;
+	cmd->cmdType = C_MOVEENTITY;
+	_cine.push_back(cmd);
+}
+
 void AI::cineUse(const char *entName) {
 	CineCommand *cmd = new CineCommand;
 	cmd->string = entName;
diff --git a/engines/hdb/ai.h b/engines/hdb/ai.h
index d6af20d..8c620ad 100644
--- a/engines/hdb/ai.h
+++ b/engines/hdb/ai.h
@@ -535,6 +535,7 @@ public:
 	void cineWait(int seconds);
 	void cineWaitUntilDone();
 	void cineSetEntity(const char *entName, int x, int y, int level);
+	void cineMoveEntity(const char *entName, int x, int y, int level, int speed);
 	void cineUse(const char *entName);
 	void cineFadeIn(bool isBlack, int steps);
 	void cineFadeOut(bool isBlack, int steps);


Commit: 89ceed279876b4fd39272c504055c4729e24549e
    https://github.com/scummvm/scummvm/commit/89ceed279876b4fd39272c504055c4729e24549e
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:16:52+02:00

Commit Message:
HDB: Process cineMoveEntity()

Changed paths:
    engines/hdb/ai-cinematic.cpp


diff --git a/engines/hdb/ai-cinematic.cpp b/engines/hdb/ai-cinematic.cpp
index cab0d0f..6d0c2b3 100644
--- a/engines/hdb/ai-cinematic.cpp
+++ b/engines/hdb/ai-cinematic.cpp
@@ -161,6 +161,24 @@ void AI::processCines() {
 			}
 			complete = true;
 			break;
+		case C_MOVEENTITY:
+			if (!_cine[i]->start) {
+				AIEntity *e = locateEntity(_cine[i]->title);
+				if (e) {
+					_cine[i]->e = e;
+					_cine[i]->e->moveSpeed = _cine[i]->speed;
+					_cine[i]->e->level = (int)_cine[i]->x2;
+					setEntityGoal(_cine[i]->e, (int)_cine[i]->x, (int)_cine[i]->y);
+					_cine[i]->start = 1;
+				} else {
+					warning("Can't locate '%s' in moveEntity", _cine[i]->title);
+				}
+			} else {
+				if (!_cine[i]->e->goalX) {
+					complete = true;
+				}
+			}
+
 		case C_USEENTITY:
 			_cine[i]->e = locateEntity(_cine[i]->string);
 			warning("STUB: PROCESSCINES: USEENTITY: HDBGame::useEntity required;");


Commit: 0aee0d4ebc879c7576bbc00eb20c42dd2e8777ee
    https://github.com/scummvm/scummvm/commit/0aee0d4ebc879c7576bbc00eb20c42dd2e8777ee
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:16:52+02:00

Commit Message:
HDB: Remove cineMoveEntity stub

Changed paths:
    engines/hdb/ai-cinematic.cpp
    engines/hdb/ai.h
    engines/hdb/lua-script.cpp


diff --git a/engines/hdb/ai-cinematic.cpp b/engines/hdb/ai-cinematic.cpp
index 6d0c2b3..cb4f1a8 100644
--- a/engines/hdb/ai-cinematic.cpp
+++ b/engines/hdb/ai-cinematic.cpp
@@ -178,7 +178,7 @@ void AI::processCines() {
 					complete = true;
 				}
 			}
-
+			break;
 		case C_USEENTITY:
 			_cine[i]->e = locateEntity(_cine[i]->string);
 			warning("STUB: PROCESSCINES: USEENTITY: HDBGame::useEntity required;");
diff --git a/engines/hdb/ai.h b/engines/hdb/ai.h
index 8c620ad..65f6b9f 100644
--- a/engines/hdb/ai.h
+++ b/engines/hdb/ai.h
@@ -436,7 +436,7 @@ struct CineCommand {
 	int start, end;
 	uint32	delay;
 	int	speed;
-	char *title;
+	const char *title;
 	const char *string;
 	char *id;
 	AIEntity *e;
diff --git a/engines/hdb/lua-script.cpp b/engines/hdb/lua-script.cpp
index f240bcb..ba37b41 100644
--- a/engines/hdb/lua-script.cpp
+++ b/engines/hdb/lua-script.cpp
@@ -234,7 +234,16 @@ static int cineRemoveEntity(lua_State *L) {
 }
 
 static int cineMoveEntity(lua_State *L) {
-	warning("STUB: CINE MOVE ENTITY");
+	const char *entName = lua_tostring(L, 1);
+	double x = lua_tonumber(L, 2);
+	double y = lua_tonumber(L, 3);
+	double level = lua_tonumber(L, 4);
+	double speed = lua_tonumber(L, 5);
+
+	g_hdb->_lua->checkParameters("cineMoveEntity", 5);
+
+	lua_pop(L, 5);
+	g_hdb->_ai->cineMoveEntity(entName, (int)x, (int)y, (int)level, (int)speed);
 	return 0;
 }
 


Commit: 157bd54fc3a11e82179e46611471fe12ecd9ee5a
    https://github.com/scummvm/scummvm/commit/157bd54fc3a11e82179e46611471fe12ecd9ee5a
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:16:52+02:00

Commit Message:
HDB: Add cineEntityFace()

Changed paths:
    engines/hdb/ai-cinematic.cpp
    engines/hdb/ai.h


diff --git a/engines/hdb/ai-cinematic.cpp b/engines/hdb/ai-cinematic.cpp
index cb4f1a8..45274b4 100644
--- a/engines/hdb/ai-cinematic.cpp
+++ b/engines/hdb/ai-cinematic.cpp
@@ -303,6 +303,14 @@ void AI::cineMoveEntity(const char *entName, int x, int y, int level, int speed)
 	_cine.push_back(cmd);
 }
 
+void AI::cineEntityFace(const char *luaName, double dir) {
+	CineCommand *cmd = new CineCommand;
+	cmd->title = luaName;
+	cmd->x = dir;
+	cmd->cmdType = C_ENTITYFACE;
+	_cine.push_back(cmd);
+}
+
 void AI::cineUse(const char *entName) {
 	CineCommand *cmd = new CineCommand;
 	cmd->string = entName;
diff --git a/engines/hdb/ai.h b/engines/hdb/ai.h
index 65f6b9f..cb24cac 100644
--- a/engines/hdb/ai.h
+++ b/engines/hdb/ai.h
@@ -536,6 +536,7 @@ public:
 	void cineWaitUntilDone();
 	void cineSetEntity(const char *entName, int x, int y, int level);
 	void cineMoveEntity(const char *entName, int x, int y, int level, int speed);
+	void cineEntityFace(const char *luaName, double dir);
 	void cineUse(const char *entName);
 	void cineFadeIn(bool isBlack, int steps);
 	void cineFadeOut(bool isBlack, int steps);


Commit: dfdcbd8b4f397ebc2209d301b0f9ae5c9ee6e320
    https://github.com/scummvm/scummvm/commit/dfdcbd8b4f397ebc2209d301b0f9ae5c9ee6e320
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:16:52+02:00

Commit Message:
HDB: Process cineEntityFace()

Changed paths:
    engines/hdb/ai-cinematic.cpp


diff --git a/engines/hdb/ai-cinematic.cpp b/engines/hdb/ai-cinematic.cpp
index 45274b4..0fa6bc8 100644
--- a/engines/hdb/ai-cinematic.cpp
+++ b/engines/hdb/ai-cinematic.cpp
@@ -179,6 +179,33 @@ void AI::processCines() {
 				}
 			}
 			break;
+		case C_ENTITYFACE:
+		{
+			AIEntity *e = locateEntity(_cine[i]->title);
+
+			if (e) {
+				int d = (int)_cine[i]->x;
+				e->dir = (AIDir)d;
+				switch (e->dir) {
+				case DIR_UP:
+					e->state = STATE_STANDUP;
+					break;
+				case DIR_DOWN:
+					e->state = STATE_STANDDOWN;
+					break;
+				case DIR_LEFT:
+					e->state = STATE_STANDLEFT;
+					break;
+				case DIR_RIGHT:
+					e->state = STATE_STANDRIGHT;
+					break;
+				}
+			} else {
+				warning("Can't find %s to ENTITYFACE", _cine[i]->title);
+			}
+			complete = true;
+			break;
+		}
 		case C_USEENTITY:
 			_cine[i]->e = locateEntity(_cine[i]->string);
 			warning("STUB: PROCESSCINES: USEENTITY: HDBGame::useEntity required;");


Commit: 28e8f3d789cb0cf14650ec014cbdc9ea2b8e0172
    https://github.com/scummvm/scummvm/commit/28e8f3d789cb0cf14650ec014cbdc9ea2b8e0172
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:16:52+02:00

Commit Message:
HDB: Remove cineEntityFace stub

Changed paths:
    engines/hdb/lua-script.cpp


diff --git a/engines/hdb/lua-script.cpp b/engines/hdb/lua-script.cpp
index ba37b41..c7a2947 100644
--- a/engines/hdb/lua-script.cpp
+++ b/engines/hdb/lua-script.cpp
@@ -308,7 +308,13 @@ static int cineFunction(lua_State *L) {
 }
 
 static int cineEntityFace(lua_State *L) {
-	warning("STUB: CINE ENTITY FACE");
+	const char *luaName = lua_tostring(L, 1);
+	double dir = lua_tonumber(L, 2);
+
+	g_hdb->_lua->checkParameters("CineEntityFace", 2);
+
+	lua_pop(L, 2);
+	g_hdb->_ai->cineEntityFace(luaName, dir);
 	return 0;
 }
 


Commit: 3fc0cb74b123bb6b854534fdc48a0ae4d9440710
    https://github.com/scummvm/scummvm/commit/3fc0cb74b123bb6b854534fdc48a0ae4d9440710
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:16:52+02:00

Commit Message:
HDB: Remove 'Cache Graphics for Inventory' stub

Changed paths:
    engines/hdb/ai-funcs.cpp
    engines/hdb/ai-init.cpp


diff --git a/engines/hdb/ai-funcs.cpp b/engines/hdb/ai-funcs.cpp
index 6ccc982..b07399f 100644
--- a/engines/hdb/ai-funcs.cpp
+++ b/engines/hdb/ai-funcs.cpp
@@ -551,7 +551,41 @@ void AI::initAllEnts() {
 		}
 	}
 
-	warning("STUB: initAllEnts: Cache graphics for Inventory and Deliveries");
+	for (int i = 0; i < _numInventory; i++) {
+		AIEntity *temp = &_inventory[i].ent;
+
+		// Clear out all ptrs in entity before writing
+		for (int j = 0; i < kMaxAnimFrames; i++) {
+			temp->blinkGfx[j] = NULL;
+			temp->movedownGfx[j] = NULL;
+			temp->moveupGfx[j] = NULL;
+			temp->moveleftGfx[j] = NULL;
+			temp->moverightGfx[j] = NULL;
+			temp->standdownGfx[j] = NULL;
+			temp->standupGfx[j] = NULL;
+			temp->standleftGfx[j] = NULL;
+			temp->standrightGfx[j] = NULL;
+			temp->special1Gfx[j] = NULL;
+		}
+
+		temp->blinkFrames = 0;
+		temp->movedownFrames = 0;
+		temp->moveupFrames = 0;
+		temp->moveleftFrames = 0;
+		temp->moverightFrames = 0;
+		temp->standdownFrames = 0;
+		temp->standupFrames = 0;
+		temp->standleftFrames = 0;
+		temp->standrightFrames = 0;
+
+		temp->draw = NULL;
+		temp->aiDraw = NULL;
+		temp->aiAction = temp->aiInit = temp->aiUse = NULL;
+
+		cacheEntGfx(temp, false);
+	}
+
+	warning("STUB: initAllEnts: Cache graphics for Deliveries");
 	warning("STUB: initAllEnts: LaserScan required");
 }
 
diff --git a/engines/hdb/ai-init.cpp b/engines/hdb/ai-init.cpp
index 812b510..fcb371a 100644
--- a/engines/hdb/ai-init.cpp
+++ b/engines/hdb/ai-init.cpp
@@ -669,7 +669,7 @@ AIEntTypeInfo aiEntList[] = {
 AI::AI() {
 	_ents = new Common::Array<AIEntity *>;
 	// REMOVE: Remove for final. Used here due to lack of a MENU
-	_numGems = _numGooCups = _numMonkeystones = 0;
+	_numGems = _numGooCups = _numMonkeystones = _numInventory = 0;
 }
 
 AI::~AI() {


Commit: 11685a6ba140d9f695daa476a215917884b1ea51
    https://github.com/scummvm/scummvm/commit/11685a6ba140d9f695daa476a215917884b1ea51
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:16:52+02:00

Commit Message:
HDB: Add animLuaEntity()

Changed paths:
    engines/hdb/ai-funcs.cpp
    engines/hdb/ai.h


diff --git a/engines/hdb/ai-funcs.cpp b/engines/hdb/ai-funcs.cpp
index b07399f..b6cafe1 100644
--- a/engines/hdb/ai-funcs.cpp
+++ b/engines/hdb/ai-funcs.cpp
@@ -589,6 +589,16 @@ void AI::initAllEnts() {
 	warning("STUB: initAllEnts: LaserScan required");
 }
 
+void AI::animLuaEntity(const char *initName, AIState st) {
+	for (Common::Array<AIEntity *>::iterator it = _ents->begin(); it != _ents->end(); it++) {
+		if (Common::matchString((*it)->entityName, initName)) {
+			(*it)->state = st;
+			(*it)->animFrame = 0;
+			(*it)->animDelay = (*it)->animCycle;
+		}
+	}
+}
+
 // Check to see if we can get this entity
 bool AI::getTableEnt(AIType type) {
 	switch (type) {
diff --git a/engines/hdb/ai.h b/engines/hdb/ai.h
index cb24cac..1719799 100644
--- a/engines/hdb/ai.h
+++ b/engines/hdb/ai.h
@@ -462,6 +462,9 @@ public:
 	void removeEntity(AIEntity *e);
 	void setEntityGoal(AIEntity *e, int x, int y);
 	void initAllEnts();
+
+	void animLuaEntity(const char *initName, AIState st);
+
 	bool getTableEnt(AIType type);
 	bool walkThroughEnt(AIType type);
 	void getItemSound(AIType type);


Commit: 511ec64e0c1c729689e7392e32e77720957c273d
    https://github.com/scummvm/scummvm/commit/511ec64e0c1c729689e7392e32e77720957c273d
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:16:52+02:00

Commit Message:
HDB: Remove animEntity stub

Changed paths:
    engines/hdb/lua-script.cpp


diff --git a/engines/hdb/lua-script.cpp b/engines/hdb/lua-script.cpp
index c7a2947..e73e8fa 100644
--- a/engines/hdb/lua-script.cpp
+++ b/engines/hdb/lua-script.cpp
@@ -385,7 +385,14 @@ static int removeEntity(lua_State *L) {
 }
 
 static int animEntity(lua_State *L) {
-	warning("STUB: ANIM ENTITY");
+	const char *entName = lua_tostring(L, 1);
+	double state = lua_tonumber(L, 2);
+
+	g_hdb->_lua->checkParameters("animEntity", 2);
+
+	lua_pop(L, 2);
+	int s = (int)state;
+	g_hdb->_ai->animLuaEntity(entName, (AIState)s);
 	return 0;
 }
 


Commit: f81314580885e717d0dc82a082296e09d66f4fa1
    https://github.com/scummvm/scummvm/commit/f81314580885e717d0dc82a082296e09d66f4fa1
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:16:52+02:00

Commit Message:
HDB: Clear Waypoint data in AI::init()

Changed paths:
    engines/hdb/ai-init.cpp


diff --git a/engines/hdb/ai-init.cpp b/engines/hdb/ai-init.cpp
index fcb371a..1230ed0 100644
--- a/engines/hdb/ai-init.cpp
+++ b/engines/hdb/ai-init.cpp
@@ -679,6 +679,17 @@ AI::~AI() {
 bool AI::init() {
 	warning("STUB: AI::init incomplete");
 
+	// Clear Waypoint list and load Waypoint graphics
+	_numWaypoints = 0;
+	_waypointGfx[0] = new Tile;
+	_waypointGfx[0]->load(g_hdb->_fileMan->findFirstData("icon_waypoint_select1", TYPE_TILE32));
+	_waypointGfx[1] = new Tile;
+	_waypointGfx[1]->load(g_hdb->_fileMan->findFirstData("icon_waypoint_select2", TYPE_TILE32));
+	_waypointGfx[2] = new Tile;
+	_waypointGfx[2]->load(g_hdb->_fileMan->findFirstData("icon_waypoint_select3", TYPE_TILE32));
+	_waypointGfx[3] = new Tile;
+	_waypointGfx[3]->load(g_hdb->_fileMan->findFirstData("icon_waypoint_select4", TYPE_TILE32));
+
 	_playerRunning = false;
 
 	restartSystem();


Commit: b0cd169cb9aab153f5c9fe24dad4e099d5734d76
    https://github.com/scummvm/scummvm/commit/b0cd169cb9aab153f5c9fe24dad4e099d5734d76
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:16:52+02:00

Commit Message:
HDB: Clear Player Graphics in restartSystem()

Changed paths:
    engines/hdb/ai-init.cpp
    engines/hdb/ai.h


diff --git a/engines/hdb/ai-init.cpp b/engines/hdb/ai-init.cpp
index 1230ed0..82f0331 100644
--- a/engines/hdb/ai-init.cpp
+++ b/engines/hdb/ai-init.cpp
@@ -710,6 +710,39 @@ void AI::restartSystem() {
 	_playerOnIce = false;
 	_playerEmerging = false;
 
+	// Clean up Player Graphics Storage
+	memset(_horrible1Gfx, NULL, kMaxDeathFrames * sizeof(Tile *));
+	memset(_horrible2Gfx, NULL, kMaxDeathFrames * sizeof(Tile *));
+	memset(_horrible3Gfx, NULL, kMaxDeathFrames * sizeof(Tile *));
+	memset(_horrible4Gfx, NULL, kMaxDeathFrames * sizeof(Tile *));
+	memset(_plummetGfx, NULL, kMaxDeathFrames * sizeof(Tile *));
+	memset(_dyingGfx, NULL, kMaxDeathFrames * sizeof(Tile *));
+
+	memset(_pushdownGfx, NULL, kMaxAnimFrames * sizeof(Tile *));
+	memset(_pushupGfx, NULL, kMaxAnimFrames * sizeof(Tile *));
+	memset(_pushleftGfx, NULL, kMaxAnimFrames * sizeof(Tile *));
+	memset(_pushrightGfx, NULL, kMaxAnimFrames * sizeof(Tile *));
+	memset(_stunDownGfx, NULL, kMaxAnimFrames * sizeof(Tile *));
+	memset(_stunUpGfx, NULL, kMaxAnimFrames * sizeof(Tile *));
+	memset(_stunLeftGfx, NULL, kMaxAnimFrames * sizeof(Tile *));
+	memset(_stunRightGfx, NULL, kMaxAnimFrames * sizeof(Tile *));
+	memset(_slugDownGfx, NULL, kMaxAnimFrames * sizeof(Tile *));
+	memset(_slugUpGfx, NULL, kMaxAnimFrames * sizeof(Tile *));
+	memset(_slugLeftGfx, NULL, kMaxAnimFrames * sizeof(Tile *));
+	memset(_slugRightGfx, NULL, kMaxAnimFrames * sizeof(Tile *));
+
+	if (_clubDownFrames) {
+		_clubDownFrames = 3;
+		_clubUpFrames = 3;
+		_clubLeftFrames = 3;
+		_clubRightFrames = 3;
+	}
+
+	memset(_clubDownGfx, NULL, kMaxAnimFrames * sizeof(Tile *));
+	memset(_clubUpGfx, NULL, kMaxAnimFrames * sizeof(Tile *));
+	memset(_clubLeftGfx, NULL, kMaxAnimFrames * sizeof(Tile *));
+	memset(_clubRightGfx, NULL, kMaxAnimFrames * sizeof(Tile *));
+
 	// Clear the Entity List
 	_ents->clear();
 
diff --git a/engines/hdb/ai.h b/engines/hdb/ai.h
index 1719799..5e140f7 100644
--- a/engines/hdb/ai.h
+++ b/engines/hdb/ai.h
@@ -566,67 +566,67 @@ private:
 	bool _playerEmerging;
 	bool _playerRunning;
 
-	uint16		pushupFrames;
-	Tile		*pushupGfx[kMaxAnimFrames];
-
-	uint16		pushdownFrames;
-	Tile		*pushdownGfx[kMaxAnimFrames];
-
-	uint16		pushleftFrames;
-	Tile		*pushleftGfx[kMaxAnimFrames];
-
-	uint16		pushrightFrames;
-	Tile		*pushrightGfx[kMaxAnimFrames];
-
-	Tile		*getGfx[5];			// only 1 frame in each direction (+1 for DIR_NONE at start)
-
-	uint16		dyingFrames;
-	Tile		*dyingGfx[kMaxDeathFrames];
-
-	Tile		*goodjobGfx;			// only 1 frame
-
-	uint16		horrible1Frames;
-	Tile		*horrible1Gfx[kMaxDeathFrames];
-	uint16		horrible2Frames;
-	Tile		*horrible2Gfx[kMaxDeathFrames];
-	uint16		horrible3Frames;
-	Tile		*horrible3Gfx[kMaxDeathFrames];
-	uint16		horrible4Frames;
-	Tile		*horrible4Gfx[kMaxDeathFrames];
-	uint16		plummetFrames;
-	Tile		*plummetGfx[kMaxDeathFrames];
-
-	uint16		clubUpFrames;
-	Tile		*clubUpGfx[kMaxAnimFrames];
-	uint16		clubDownFrames;
-	Tile		*clubDownGfx[kMaxAnimFrames];
-	uint16		clubLeftFrames;
-	Tile		*clubLeftGfx[kMaxAnimFrames];
-	uint16		clubRightFrames;
-	Tile		*clubRightGfx[kMaxAnimFrames];
-
-	uint16		stunUpFrames;
-	Tile		*stunUpGfx[kMaxAnimFrames];
-	uint16		stunDownFrames;
-	Tile		*stunDownGfx[kMaxAnimFrames];
-	uint16		stunLeftFrames;
-	Tile		*stunLeftGfx[kMaxAnimFrames];
-	uint16		stunRightFrames;
-	Tile		*stunRightGfx[kMaxAnimFrames];
-	Tile		*stun_lightningGfx[kMaxAnimFrames];
-	Tile		*stunnedGfx[kMaxAnimFrames];
-
-	uint16		slugUpFrames;
-	Tile		*slugUpGfx[kMaxAnimFrames];
-	uint16		slugDownFrames;
-	Tile		*slugDownGfx[kMaxAnimFrames];
-	uint16		slugLeftFrames;
-	Tile		*slugLeftGfx[kMaxAnimFrames];
-	uint16		slugRightFrames;
-	Tile		*slugRightGfx[kMaxAnimFrames];
-
-	uint16		slugAttackFrames;
-	Tile		*slugAttackGfx[kMaxAnimFrames];
+	uint16		_pushupFrames;
+	Tile		*_pushupGfx[kMaxAnimFrames];
+
+	uint16		_pushdownFrames;
+	Tile		*_pushdownGfx[kMaxAnimFrames];
+
+	uint16		_pushleftFrames;
+	Tile		*_pushleftGfx[kMaxAnimFrames];
+
+	uint16		_pushrightFrames;
+	Tile		*_pushrightGfx[kMaxAnimFrames];
+
+	Tile		*_getGfx[5];			// only 1 frame in each direction (+1 for DIR_NONE at start)
+
+	uint16		_dyingFrames;
+	Tile		*_dyingGfx[kMaxDeathFrames];
+
+	Tile		*_goodjobGfx;			// only 1 frame
+
+	uint16		_horrible1Frames;
+	Tile		*_horrible1Gfx[kMaxDeathFrames];
+	uint16		_horrible2Frames;
+	Tile		*_horrible2Gfx[kMaxDeathFrames];
+	uint16		_horrible3Frames;
+	Tile		*_horrible3Gfx[kMaxDeathFrames];
+	uint16		_horrible4Frames;
+	Tile		*_horrible4Gfx[kMaxDeathFrames];
+	uint16		_plummetFrames;
+	Tile		*_plummetGfx[kMaxDeathFrames];
+
+	uint16		_clubUpFrames;
+	Tile		*_clubUpGfx[kMaxAnimFrames];
+	uint16		_clubDownFrames;
+	Tile		*_clubDownGfx[kMaxAnimFrames];
+	uint16		_clubLeftFrames;
+	Tile		*_clubLeftGfx[kMaxAnimFrames];
+	uint16		_clubRightFrames;
+	Tile		*_clubRightGfx[kMaxAnimFrames];
+
+	uint16		_stunUpFrames;
+	Tile		*_stunUpGfx[kMaxAnimFrames];
+	uint16		_stunDownFrames;
+	Tile		*_stunDownGfx[kMaxAnimFrames];
+	uint16		_stunLeftFrames;
+	Tile		*_stunLeftGfx[kMaxAnimFrames];
+	uint16		_stunRightFrames;
+	Tile		*_stunRightGfx[kMaxAnimFrames];
+	Tile		*_stun_lightningGfx[kMaxAnimFrames];
+	Tile		*_stunnedGfx[kMaxAnimFrames];
+
+	uint16		_slugUpFrames;
+	Tile		*_slugUpGfx[kMaxAnimFrames];
+	uint16		_slugDownFrames;
+	Tile		*_slugDownGfx[kMaxAnimFrames];
+	uint16		_slugLeftFrames;
+	Tile		*_slugLeftGfx[kMaxAnimFrames];
+	uint16		_slugRightFrames;
+	Tile		*_slugRightGfx[kMaxAnimFrames];
+
+	uint16		_slugAttackFrames;
+	Tile		*_slugAttackGfx[kMaxAnimFrames];
 
 	// Player Resources and Deliveries
 


Commit: 6c8dce6c17a967c2b5a9ae4f39380a670a454848
    https://github.com/scummvm/scummvm/commit/6c8dce6c17a967c2b5a9ae4f39380a670a454848
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:16:52+02:00

Commit Message:
HDB: Fix member variables names

Changed paths:
    engines/hdb/ai-funcs.cpp


diff --git a/engines/hdb/ai-funcs.cpp b/engines/hdb/ai-funcs.cpp
index b6cafe1..e8cabee 100644
--- a/engines/hdb/ai-funcs.cpp
+++ b/engines/hdb/ai-funcs.cpp
@@ -142,79 +142,79 @@ bool AI::cacheEntGfx(AIEntity *e, bool init) {
 
 					// Special Player Frames
 					case STATE_PUSHDOWN:
-						pushdownGfx[pushdownFrames] = gfx;
-						pushdownFrames++;
+						_pushdownGfx[_pushdownFrames] = gfx;
+						_pushdownFrames++;
 						break;
 					case STATE_PUSHUP:
-						pushupGfx[pushupFrames] = gfx;
-						pushupFrames++;
+						_pushupGfx[_pushupFrames] = gfx;
+						_pushupFrames++;
 						break;
 					case STATE_PUSHLEFT:
-						pushleftGfx[pushleftFrames] = gfx;
-						pushleftFrames++;
+						_pushleftGfx[_pushleftFrames] = gfx;
+						_pushleftFrames++;
 						break;
 					case STATE_PUSHRIGHT:
-						pushrightGfx[pushrightFrames] = gfx;
-						pushrightFrames++;
+						_pushrightGfx[_pushrightFrames] = gfx;
+						_pushrightFrames++;
 						break;
 					case STATE_GRABUP:
-						getGfx[DIR_UP] = gfx; break;
+						_getGfx[DIR_UP] = gfx; break;
 					case STATE_GRABDOWN:
-						getGfx[DIR_DOWN] = gfx; break;
+						_getGfx[DIR_DOWN] = gfx; break;
 					case STATE_GRABLEFT:
-						getGfx[DIR_LEFT] = gfx; break;
+						_getGfx[DIR_LEFT] = gfx; break;
 					case STATE_GRABRIGHT:
-						getGfx[DIR_RIGHT] = gfx; break;
+						_getGfx[DIR_RIGHT] = gfx; break;
 
 					case STATE_ATK_CLUB_UP:
-						clubUpGfx[clubUpFrames] = gfx;
-						clubUpFrames++;
+						_clubUpGfx[_clubUpFrames] = gfx;
+						_clubUpFrames++;
 						break;
 					case STATE_ATK_CLUB_DOWN:
-						clubDownGfx[clubDownFrames] = gfx;
-						clubDownFrames++;
+						_clubDownGfx[_clubDownFrames] = gfx;
+						_clubDownFrames++;
 						break;
 					case STATE_ATK_CLUB_LEFT:
-						clubLeftGfx[clubLeftFrames] = gfx;
-						clubLeftFrames++;
+						_clubLeftGfx[_clubLeftFrames] = gfx;
+						_clubLeftFrames++;
 						break;
 					case STATE_ATK_CLUB_RIGHT:
-						clubRightGfx[clubRightFrames] = gfx;
-						clubRightFrames++;
+						_clubRightGfx[_clubRightFrames] = gfx;
+						_clubRightFrames++;
 						break;
 
 					case STATE_ATK_STUN_UP:
-						stunUpGfx[stunUpFrames] = gfx;
-						stunUpFrames++;
+						_stunUpGfx[_stunUpFrames] = gfx;
+						_stunUpFrames++;
 						break;
 					case STATE_ATK_STUN_DOWN:
-						stunDownGfx[stunDownFrames] = gfx;
-						stunDownFrames++;
+						_stunDownGfx[_stunDownFrames] = gfx;
+						_stunDownFrames++;
 						break;
 					case STATE_ATK_STUN_LEFT:
-						stunLeftGfx[stunLeftFrames] = gfx;
-						stunLeftFrames++;
+						_stunLeftGfx[_stunLeftFrames] = gfx;
+						_stunLeftFrames++;
 						break;
 					case STATE_ATK_STUN_RIGHT:
-						stunRightGfx[stunRightFrames] = gfx;
-						stunRightFrames++;
+						_stunRightGfx[_stunRightFrames] = gfx;
+						_stunRightFrames++;
 						break;
 
 					case STATE_ATK_SLUG_UP:
-						slugUpGfx[slugUpFrames] = gfx;
-						slugUpFrames++;
+						_slugUpGfx[_slugUpFrames] = gfx;
+						_slugUpFrames++;
 						break;
 					case STATE_ATK_SLUG_DOWN:
-						slugDownGfx[slugDownFrames] = gfx;
-						slugDownFrames++;
+						_slugDownGfx[_slugDownFrames] = gfx;
+						_slugDownFrames++;
 						break;
 					case STATE_ATK_SLUG_LEFT:
-						slugLeftGfx[slugLeftFrames] = gfx;
-						slugLeftFrames++;
+						_slugLeftGfx[_slugLeftFrames] = gfx;
+						_slugLeftFrames++;
 						break;
 					case STATE_ATK_SLUG_RIGHT:
-						slugRightGfx[slugRightFrames] = gfx;
-						slugRightFrames++;
+						_slugRightGfx[_slugRightFrames] = gfx;
+						_slugRightFrames++;
 						break;
 
 					// Maintenance Bot
@@ -233,32 +233,32 @@ bool AI::cacheEntGfx(AIEntity *e, bool init) {
 
 					// Death & Dying for Player
 					case STATE_DYING:
-						dyingGfx[dyingFrames] = gfx;
-						dyingFrames++;
+						_dyingGfx[_dyingFrames] = gfx;
+						_dyingFrames++;
 						break;
 					case STATE_GOODJOB:
-						goodjobGfx = gfx;
+						_goodjobGfx = gfx;
 						break;
 
 					case STATE_HORRIBLE1:
-						horrible1Gfx[horrible1Frames] = gfx;
-						horrible1Frames++;
+						_horrible1Gfx[_horrible1Frames] = gfx;
+						_horrible1Frames++;
 						break;
 					case STATE_HORRIBLE2:
-						horrible2Gfx[horrible2Frames] = gfx;
-						horrible2Frames++;
+						_horrible2Gfx[_horrible2Frames] = gfx;
+						_horrible2Frames++;
 						break;
 					case STATE_HORRIBLE3:
-						horrible3Gfx[horrible3Frames] = gfx;
-						horrible3Frames++;
+						_horrible3Gfx[_horrible3Frames] = gfx;
+						_horrible3Frames++;
 						break;
 					case STATE_HORRIBLE4:
-						horrible4Gfx[horrible4Frames] = gfx;
-						horrible4Frames++;
+						_horrible4Gfx[_horrible4Frames] = gfx;
+						_horrible4Frames++;
 						break;
 					case STATE_PLUMMET:
-						plummetGfx[plummetFrames] = gfx;
-						plummetFrames++;
+						_plummetGfx[_plummetFrames] = gfx;
+						_plummetFrames++;
 						break;
 
 					// floating frames - overwrite "standup" info


Commit: 630c6b44f8911a3444e4098091ae2907fa78eede
    https://github.com/scummvm/scummvm/commit/630c6b44f8911a3444e4098091ae2907fa78eede
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:16:52+02:00

Commit Message:
HDB: Clean up Lua stack after script execution

Changed paths:
    engines/hdb/lua-script.cpp


diff --git a/engines/hdb/lua-script.cpp b/engines/hdb/lua-script.cpp
index e73e8fa..75f8a41 100644
--- a/engines/hdb/lua-script.cpp
+++ b/engines/hdb/lua-script.cpp
@@ -829,6 +829,9 @@ bool LuaScript::initScript(Common::SeekableReadStream *stream, const char *scrip
 		return false;
 	}
 
+	// Remove the error handler function from the stack
+	lua_pop(_state, 1);
+
 	return true;
 }
 
@@ -942,6 +945,9 @@ bool LuaScript::executeChunk(Common::String &chunk, uint chunkSize, const Common
 		return false;
 	}
 
+	// Remove the error handler function from the stack
+	lua_pop(_state, 1);
+
 	return true;
 }
 


Commit: 629ba37616763b18cdc1c5ece8821ccb68486648
    https://github.com/scummvm/scummvm/commit/629ba37616763b18cdc1c5ece8821ccb68486648
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:16:52+02:00

Commit Message:
HDB: Add debug output to findFirstData()

Changed paths:
    engines/hdb/file-manager.cpp


diff --git a/engines/hdb/file-manager.cpp b/engines/hdb/file-manager.cpp
index b8b77f2..622d2c0 100644
--- a/engines/hdb/file-manager.cpp
+++ b/engines/hdb/file-manager.cpp
@@ -96,6 +96,8 @@ Common::SeekableReadStream *FileMan::findFirstData(const char *string, DataType
 	Common::String fileString;
 	MPCEntry *file = NULL;
 
+	debug(2, "Looking for Data: '%s'", string);
+
 	// Find MPC Entry
 	for (MPCIterator it = _dir.begin(); it != _dir.end(); it++) {
 		fileString = (*it)->filename;
@@ -103,11 +105,14 @@ Common::SeekableReadStream *FileMan::findFirstData(const char *string, DataType
 			if ((*it)->type == type) {
 				file = *it;
 				break;
+			} else {
+				debug(2, "Found Data but type mismatch: '%s', target: %d, found: %d", string, type, (*it)->type);
 			}
 		}
 	}
 
 	if (file == NULL) {
+		debug(2, "Couldn't find Data: '%s'", string);
 		return NULL;
 	}
 


Commit: 6e340391532b7a617bae790ba5ae896230d89725
    https://github.com/scummvm/scummvm/commit/6e340391532b7a617bae790ba5ae896230d89725
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:16:52+02:00

Commit Message:
HDB: Fix waypointGfx DataType

Changed paths:
    engines/hdb/ai-init.cpp


diff --git a/engines/hdb/ai-init.cpp b/engines/hdb/ai-init.cpp
index 82f0331..183f028 100644
--- a/engines/hdb/ai-init.cpp
+++ b/engines/hdb/ai-init.cpp
@@ -682,13 +682,13 @@ bool AI::init() {
 	// Clear Waypoint list and load Waypoint graphics
 	_numWaypoints = 0;
 	_waypointGfx[0] = new Tile;
-	_waypointGfx[0]->load(g_hdb->_fileMan->findFirstData("icon_waypoint_select1", TYPE_TILE32));
+	_waypointGfx[0]->load(g_hdb->_fileMan->findFirstData("icon_waypoint_select1", TYPE_ICON32));
 	_waypointGfx[1] = new Tile;
-	_waypointGfx[1]->load(g_hdb->_fileMan->findFirstData("icon_waypoint_select2", TYPE_TILE32));
+	_waypointGfx[1]->load(g_hdb->_fileMan->findFirstData("icon_waypoint_select2", TYPE_ICON32));
 	_waypointGfx[2] = new Tile;
-	_waypointGfx[2]->load(g_hdb->_fileMan->findFirstData("icon_waypoint_select3", TYPE_TILE32));
+	_waypointGfx[2]->load(g_hdb->_fileMan->findFirstData("icon_waypoint_select3", TYPE_ICON32));
 	_waypointGfx[3] = new Tile;
-	_waypointGfx[3]->load(g_hdb->_fileMan->findFirstData("icon_waypoint_select4", TYPE_TILE32));
+	_waypointGfx[3]->load(g_hdb->_fileMan->findFirstData("icon_waypoint_select4", TYPE_ICON32));
 
 	_playerRunning = false;
 


Commit: ae876db69cc16ea961e5624ff4e3161b24e0fdc9
    https://github.com/scummvm/scummvm/commit/ae876db69cc16ea961e5624ff4e3161b24e0fdc9
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:16:52+02:00

Commit Message:
HDB: Fix special1Gfx data type

Changed paths:
    engines/hdb/ai.h


diff --git a/engines/hdb/ai.h b/engines/hdb/ai.h
index 5e140f7..8604fa3 100644
--- a/engines/hdb/ai.h
+++ b/engines/hdb/ai.h
@@ -382,7 +382,7 @@ struct AIEntity {
 		uint16 special1Frames;
 		uint16 int2;
 	};
-	void *special1Gfx[kMaxAnimFrames];
+	Tile *special1Gfx[kMaxAnimFrames];
 
 	uint16		standdownFrames;
 	Tile		*standdownGfx[kMaxAnimFrames];


Commit: 1b25f846a17494e9e74c9a21657ed9652ce68990
    https://github.com/scummvm/scummvm/commit/1b25f846a17494e9e74c9a21657ed9652ce68990
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:16:52+02:00

Commit Message:
HDB: Fix switch-case warnings

Changed paths:
    engines/hdb/ai-cinematic.cpp
    engines/hdb/ai-funcs.cpp
    engines/hdb/ai-inventory.cpp
    engines/hdb/map-loader.cpp


diff --git a/engines/hdb/ai-cinematic.cpp b/engines/hdb/ai-cinematic.cpp
index 0fa6bc8..b30d137 100644
--- a/engines/hdb/ai-cinematic.cpp
+++ b/engines/hdb/ai-cinematic.cpp
@@ -199,6 +199,8 @@ void AI::processCines() {
 				case DIR_RIGHT:
 					e->state = STATE_STANDRIGHT;
 					break;
+				default:
+					warning("AI-CINEMATIC: processCines: Unknown Dir");
 				}
 			} else {
 				warning("Can't find %s to ENTITYFACE", _cine[i]->title);
diff --git a/engines/hdb/ai-funcs.cpp b/engines/hdb/ai-funcs.cpp
index e8cabee..732e4fd 100644
--- a/engines/hdb/ai-funcs.cpp
+++ b/engines/hdb/ai-funcs.cpp
@@ -391,6 +391,8 @@ bool AI::cacheEntGfx(AIEntity *e, bool init) {
 						e->special1Gfx[e->special1Frames] = gfx;
 						e->special1Frames++;
 						break;
+					default:
+						warning("AI-FUNCS: cacheEntGfx: Unknown State");
 					}
 				}
 				j++;
@@ -454,6 +456,8 @@ void AI::stopEntity(AIEntity *e) {
 	case STATE_FLOATDOWN:
 		e->state = STATE_FLOATING;
 		return;
+	default:
+		warning("AI-FUNCS: stopEntity: Unknown State");
 	}
 
 	if (e->type != AI_DIVERTER) {
@@ -482,6 +486,8 @@ void AI::stopEntity(AIEntity *e) {
 			else
 				e->state = STATE_NONE;
 			break;
+		default:
+			warning("AI-FUNCS: stopEntity: Unknown Dir");
 		}
 	}
 }
@@ -719,6 +725,8 @@ void AI::lookAtXY(int x, int y) {
 		_player->state = STATE_STANDRIGHT;
 		warning("STUB: Set _player->draw to Player standright_gfx");
 		break;
+	default:
+		warning("AI-FUNCS: lookAtXY: Unknown Dir");
 	}
 }
 } // End of Namespace
diff --git a/engines/hdb/ai-inventory.cpp b/engines/hdb/ai-inventory.cpp
index 5fcccf2..d050b3c 100644
--- a/engines/hdb/ai-inventory.cpp
+++ b/engines/hdb/ai-inventory.cpp
@@ -51,6 +51,9 @@ bool AI::addToInventory(AIEntity *e) {
 		_numMonkeystones++;
 		removeEntity(e);
 		return true;
+	default:
+		warning("AI-INVENTORY: addToInventory: Unknown Type");
+		return false;
 	}
 
 	if (_numInventory >= kMaxInventory) {
@@ -67,6 +70,8 @@ bool AI::addToInventory(AIEntity *e) {
 	case ITEM_ROBOSTUNNER:
 	case ITEM_SLUGSLINGER:
 		warning("STUB: addToInventory: Ready weapon");
+	default:
+		warning("AI-INVENTORY: addToInventory: Unknown Type");
 	}
 
 	warning("STUB: addToInventory: Print a 'You Got' message");
diff --git a/engines/hdb/map-loader.cpp b/engines/hdb/map-loader.cpp
index 8ec381a..d1f9597 100644
--- a/engines/hdb/map-loader.cpp
+++ b/engines/hdb/map-loader.cpp
@@ -402,6 +402,8 @@ bool Map::load(Common::SeekableReadStream *stream) {
 			case ITEM_ROBOSTUNNER:
 			case ITEM_SLUGSLINGER:
 				continue;
+			default:
+				warning("MAP-LOADER: load: Unknown Type");
 			}
 		}
 


Commit: dcc30b45ac2865228a0797d80885958463310029
    https://github.com/scummvm/scummvm/commit/dcc30b45ac2865228a0797d80885958463310029
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:16:52+02:00

Commit Message:
HDB: Fix type of loaded

Changed paths:
    engines/hdb/draw-manager.h


diff --git a/engines/hdb/draw-manager.h b/engines/hdb/draw-manager.h
index c05c7e9..57ef1ad 100644
--- a/engines/hdb/draw-manager.h
+++ b/engines/hdb/draw-manager.h
@@ -52,7 +52,7 @@ struct GfxCache {
 	char name[32];
 	Tile *gfx;
 	uint32 size;
-	uint16 loaded;
+	int16 loaded;
 
 	GfxCache() : name(""), gfx(NULL), size(0), loaded(0) {}
 };


Commit: f1344e261d111904acfad0d41c66bfb344c5c6f2
    https://github.com/scummvm/scummvm/commit/f1344e261d111904acfad0d41c66bfb344c5c6f2
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:16:52+02:00

Commit Message:
HDB: Add constructors to all structs

Changed paths:
    engines/hdb/ai-funcs.cpp
    engines/hdb/ai.h
    engines/hdb/map-loader.h


diff --git a/engines/hdb/ai-funcs.cpp b/engines/hdb/ai-funcs.cpp
index 732e4fd..cd13505 100644
--- a/engines/hdb/ai-funcs.cpp
+++ b/engines/hdb/ai-funcs.cpp
@@ -558,7 +558,7 @@ void AI::initAllEnts() {
 	}
 
 	for (int i = 0; i < _numInventory; i++) {
-		AIEntity *temp = &_inventory[i].ent;
+		AIEntity *temp = _inventory[i].ent;
 
 		// Clear out all ptrs in entity before writing
 		for (int j = 0; i < kMaxAnimFrames; i++) {
diff --git a/engines/hdb/ai.h b/engines/hdb/ai.h
index 8604fa3..c919729 100644
--- a/engines/hdb/ai.h
+++ b/engines/hdb/ai.h
@@ -332,7 +332,14 @@ enum CineType {
 
 struct AIStateDef {
 	AIState state;
-	const char name[64];
+	char name[64];
+
+	AIStateDef() : state(STATE_NONE), name("") {}
+	AIStateDef(AIState state, const char *inputName) : state(state) {
+		for (int i = 0;i < 64;i++) {
+			name[i] = inputName[i];
+		}
+	}
 };
 
 struct AIEntity {
@@ -376,7 +383,7 @@ struct AIEntity {
 		uint16 blinkFrames;
 		uint16 int1;
 	};
-	void *blinkGfx[kMaxAnimFrames];
+	Tile *blinkGfx[kMaxAnimFrames];
 
 	union {
 		uint16 special1Frames;
@@ -407,6 +414,88 @@ struct AIEntity {
 
 	uint16		moverightFrames;
 	Tile		*moverightGfx[kMaxAnimFrames];
+
+	AIEntity() : luaFuncInit(""), luaFuncAction(""), luaFuncUse(""), entityName(""), printedName("") {
+		type = AI_NONE;
+		state = STATE_NONE;
+		dir = DIR_NONE;
+
+		draw = NULL;
+
+		aiInit = aiInit2 = NULL;
+		aiAction = NULL;
+		aiUse = NULL;
+		aiDraw = NULL;
+
+		level = 0;
+		value1 = value2 = 0;
+		dir2 = DIR_NONE;
+
+		x = y = 0;
+		drawXOff = drawYOff = 0;
+		onScreen = 0;
+		moveSpeed = 0;
+		xVel = yVel = 0;
+		tileX = tileY = 0;
+		goalX = goalY = 0;
+		touchpX = touchpY = touchpTile = touchpWait = 0;
+		stunnedWait = 0;
+		sequence = 0;
+
+		animCycle = 0;
+		animDelay = 0;
+		animFrame = 0;
+
+		blinkFrames = 0;
+		for (int i = 0; i < kMaxAnimFrames; i++) {
+			blinkGfx[i] = new Tile;
+		}
+
+		special1Frames = 0;
+		for (int i = 0; i < kMaxAnimFrames; i++) {
+			special1Gfx[i] = new Tile;
+		}
+
+		standdownFrames = 0;
+		for (int i = 0; i < kMaxAnimFrames; i++) {
+			standdownGfx[i] = new Tile;
+		}
+
+		standupFrames = 0;
+		for (int i = 0; i < kMaxAnimFrames; i++) {
+			standupGfx[i] = new Tile;
+		}
+
+		standleftFrames = 0;
+		for (int i = 0; i < kMaxAnimFrames; i++) {
+			standleftGfx[i] = new Tile;
+		}
+
+		standrightFrames = 0;
+		for (int i = 0; i < kMaxAnimFrames; i++) {
+			standrightGfx[i] = new Tile;
+		}
+
+		movedownFrames = 0;
+		for (int i = 0; i < kMaxAnimFrames; i++) {
+			movedownGfx[i] = new Tile;
+		}
+
+		moveupFrames = 0;
+		for (int i = 0; i < kMaxAnimFrames; i++) {
+			moveupGfx[i] = new Tile;
+		}
+
+		moveleftFrames = 0;
+		for (int i = 0; i < kMaxAnimFrames; i++) {
+			moveleftGfx[i] = new Tile;
+		}
+
+		moverightFrames = 0;
+		for (int i = 0; i < kMaxAnimFrames; i++) {
+			moverightGfx[i] = new Tile;
+		}
+	}
 };
 
 struct AIEntTypeInfo {
@@ -415,17 +504,25 @@ struct AIEntTypeInfo {
 	AIStateDef *stateDef;
 	void (*initFunc)(AIEntity *e);
 	void (*initFunc2)(AIEntity *e);
+
+	AIEntTypeInfo() : type(AI_NONE), luaName(NULL), stateDef(NULL), initFunc(NULL), initFunc2(NULL) {}
+	AIEntTypeInfo(AIType type, const char *luaName, AIStateDef *stateDef, void(*initFunc)(AIEntity *e), void(*initFunc2)(AIEntity *e)) : type(type), luaName(luaName), stateDef(stateDef), initFunc(initFunc), initFunc2(initFunc2) {}
+
 };
 
 extern AIEntTypeInfo aiEntList[];
 
 struct InvEnt {
 	uint16 keep;
-	AIEntity ent;
+	AIEntity *ent;
+
+	InvEnt() : keep(0), ent(NULL) {}
 };
 
 struct Waypoint {
 	int x, y, level;
+
+	Waypoint() : x(0), y(0), level(0) {}
 };
 
 struct CineCommand {
diff --git a/engines/hdb/map-loader.h b/engines/hdb/map-loader.h
index 9a18837..12c481f 100644
--- a/engines/hdb/map-loader.h
+++ b/engines/hdb/map-loader.h
@@ -43,12 +43,16 @@ struct MSMIcon {
 	uint16	dir;					// direction entity is facing
 	uint16	level;					// which floor level entity is on
 	uint16	value1, value2;
+
+	MSMIcon(): icon(0), x(0), y(0), funcInit(""), funcAction(""), funcUse(""), dir(0), level(0), value1(0), value2(0) {}
 };
 
 struct SeeThroughTile {
 	uint16 x;
 	uint16 y;
 	uint16 tile;
+
+	SeeThroughTile() : x(0), y(0), tile(0) {}
 };
 
 class Map {


Commit: 46918c917eb4936b303ab497738dd801258a1d6d
    https://github.com/scummvm/scummvm/commit/46918c917eb4936b303ab497738dd801258a1d6d
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:16:52+02:00

Commit Message:
HDB: Compilation fixes

Changed paths:
    engines/hdb/ai.h


diff --git a/engines/hdb/ai.h b/engines/hdb/ai.h
index c919729..63eefc7 100644
--- a/engines/hdb/ai.h
+++ b/engines/hdb/ai.h
@@ -332,14 +332,7 @@ enum CineType {
 
 struct AIStateDef {
 	AIState state;
-	char name[64];
-
-	AIStateDef() : state(STATE_NONE), name("") {}
-	AIStateDef(AIState state, const char *inputName) : state(state) {
-		for (int i = 0;i < 64;i++) {
-			name[i] = inputName[i];
-		}
-	}
+	const char name[64];
 };
 
 struct AIEntity {
@@ -504,10 +497,6 @@ struct AIEntTypeInfo {
 	AIStateDef *stateDef;
 	void (*initFunc)(AIEntity *e);
 	void (*initFunc2)(AIEntity *e);
-
-	AIEntTypeInfo() : type(AI_NONE), luaName(NULL), stateDef(NULL), initFunc(NULL), initFunc2(NULL) {}
-	AIEntTypeInfo(AIType type, const char *luaName, AIStateDef *stateDef, void(*initFunc)(AIEntity *e), void(*initFunc2)(AIEntity *e)) : type(type), luaName(luaName), stateDef(stateDef), initFunc(initFunc), initFunc2(initFunc2) {}
-
 };
 
 extern AIEntTypeInfo aiEntList[];


Commit: 949f27872a3efec74f19f8b8508d4b81ffdf1048
    https://github.com/scummvm/scummvm/commit/949f27872a3efec74f19f8b8508d4b81ffdf1048
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:16:52+02:00

Commit Message:
HDB: Add constructors to Tile and Picture

Changed paths:
    engines/hdb/draw-manager.cpp
    engines/hdb/draw-manager.h


diff --git a/engines/hdb/draw-manager.cpp b/engines/hdb/draw-manager.cpp
index b73b947..37d41c2 100644
--- a/engines/hdb/draw-manager.cpp
+++ b/engines/hdb/draw-manager.cpp
@@ -298,6 +298,10 @@ void DrawMan::drawSky() {
 	}
 }
 
+Picture::Picture() : _width(0), _height(0), _name("") {
+	_surface.create(_width, _height, g_hdb->_format);
+}
+
 Picture::~Picture() {
 	_surface.free();
 }
@@ -348,6 +352,10 @@ void Picture::drawMasked(int x, int y) {
 	}
 }
 
+Tile::Tile() : _flags(0), _name("") {
+	_surface.create(32, 32, g_hdb->_format);
+}
+
 Tile::~Tile() {
 	_surface.free();
 }
diff --git a/engines/hdb/draw-manager.h b/engines/hdb/draw-manager.h
index 57ef1ad..1474ae7 100644
--- a/engines/hdb/draw-manager.h
+++ b/engines/hdb/draw-manager.h
@@ -130,6 +130,7 @@ private:
 class Picture {
 public:
 
+	Picture();
 	~Picture();
 
 	Graphics::Surface load(Common::SeekableReadStream *stream);
@@ -148,6 +149,7 @@ private:
 class Tile {
 public:
 
+	Tile();
 	~Tile();
 
 	Graphics::Surface load(Common::SeekableReadStream *stream);


Commit: 15c2a946d197e99fb9eb036e23ecb7253c69cab9
    https://github.com/scummvm/scummvm/commit/15c2a946d197e99fb9eb036e23ecb7253c69cab9
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:16:52+02:00

Commit Message:
HDB: Modify _inventory to an array of InvEnt*

Changed paths:
    engines/hdb/ai-funcs.cpp
    engines/hdb/ai-inventory.cpp
    engines/hdb/ai.h


diff --git a/engines/hdb/ai-funcs.cpp b/engines/hdb/ai-funcs.cpp
index cd13505..8e2db69 100644
--- a/engines/hdb/ai-funcs.cpp
+++ b/engines/hdb/ai-funcs.cpp
@@ -558,7 +558,7 @@ void AI::initAllEnts() {
 	}
 
 	for (int i = 0; i < _numInventory; i++) {
-		AIEntity *temp = _inventory[i].ent;
+		AIEntity *temp = _inventory[i]->ent;
 
 		// Clear out all ptrs in entity before writing
 		for (int j = 0; i < kMaxAnimFrames; i++) {
diff --git a/engines/hdb/ai-inventory.cpp b/engines/hdb/ai-inventory.cpp
index d050b3c..ea23dd2 100644
--- a/engines/hdb/ai-inventory.cpp
+++ b/engines/hdb/ai-inventory.cpp
@@ -61,7 +61,7 @@ bool AI::addToInventory(AIEntity *e) {
 		return false;
 	}
 
-	memcpy(&_inventory[_numInventory].ent, e, sizeof(AIEntity));
+	_inventory[_numInventory]->ent = e;
 	_numInventory++;
 
 	// If weapon, ready it
diff --git a/engines/hdb/ai.h b/engines/hdb/ai.h
index 63eefc7..89491b6 100644
--- a/engines/hdb/ai.h
+++ b/engines/hdb/ai.h
@@ -720,7 +720,7 @@ private:
 	int _numGooCups;
 	int _numMonkeystones;
 
-	InvEnt _inventory[kMaxInventory];
+	InvEnt *_inventory[kMaxInventory];
 	int _numInventory;
 
 	Waypoint _waypoints[kMaxWaypoints];


Commit: 5c2cfac2094a6161bb94c06b57efc0ae72a9eb7e
    https://github.com/scummvm/scummvm/commit/5c2cfac2094a6161bb94c06b57efc0ae72a9eb7e
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:16:52+02:00

Commit Message:
HDB: Add clearInventory()

Changed paths:
    engines/hdb/ai-inventory.cpp
    engines/hdb/ai.h


diff --git a/engines/hdb/ai-inventory.cpp b/engines/hdb/ai-inventory.cpp
index ea23dd2..dd4e6ae 100644
--- a/engines/hdb/ai-inventory.cpp
+++ b/engines/hdb/ai-inventory.cpp
@@ -79,4 +79,21 @@ bool AI::addToInventory(AIEntity *e) {
 	return true;
 }
 
+// Clear out the Player inventory except Gems,
+// Monkeystones and Goo Cups unless its marked
+void AI::clearInventory() {
+	int keepslot = 0;
+	for (int i = 0; i < _numInventory; i++) {
+		if (!_inventory[i]->keep) {
+			_inventory[i] = NULL;
+		} else {
+			if (i != keepslot) {
+				_inventory[keepslot] = _inventory[i];
+				_inventory[i] = NULL;
+			}
+			keepslot++;
+		}
+	}
+	_numInventory = keepslot;
+}
 } // End of Namespace
diff --git a/engines/hdb/ai.h b/engines/hdb/ai.h
index 89491b6..8e6a7ab 100644
--- a/engines/hdb/ai.h
+++ b/engines/hdb/ai.h
@@ -636,6 +636,7 @@ public:
 
 	// Inventory Functions
 	bool addToInventory(AIEntity *e);
+	void clearInventory();
 
 	// Cinematic Variables
 	Common::Array<CineCommand *> _cine;


Commit: f9c21da88bbf265e38ef54d22d86f3d24fd48062
    https://github.com/scummvm/scummvm/commit/f9c21da88bbf265e38ef54d22d86f3d24fd48062
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:16:52+02:00

Commit Message:
HDB: Add getStandFrameDir()

Changed paths:
    engines/hdb/ai-waypoint.cpp
    engines/hdb/ai.h


diff --git a/engines/hdb/ai-waypoint.cpp b/engines/hdb/ai-waypoint.cpp
index ec31bd1..88a0c44 100644
--- a/engines/hdb/ai-waypoint.cpp
+++ b/engines/hdb/ai-waypoint.cpp
@@ -29,4 +29,37 @@ void AI::clearWaypoints() {
 	_numWaypoints = 0;
 }
 
+void *AI::getStandFrameDir(AIEntity *e) {
+	switch (e->dir) {
+	case DIR_DOWN:
+		if (e->standdownFrames)
+			return e->standdownGfx[0];
+		else if (e->movedownFrames)
+			return e->movedownGfx[0];
+		break;
+	case DIR_UP:
+		if (e->standupFrames)
+			return e->standupGfx[0];
+		else if (e->moveupFrames)
+			return e->moveupGfx[0];
+		break;
+	case DIR_LEFT:
+		if (e->standleftFrames)
+			return e->standleftGfx[0];
+		else if (e->moveleftFrames)
+			return e->moveleftGfx[0];
+		break;
+	case DIR_RIGHT:
+		if (e->standrightFrames)
+			return e->standrightGfx[0];
+		else if (e->moverightFrames)
+			return e->moverightGfx[0];
+		break;
+	case DIR_NONE:
+		warning("AI-WAYPOINT: getStandFrameDir: DIR_NONE found");
+		break;
+	}
+	return e->standdownGfx[0];
+}
+
 } // End of Namespace
diff --git a/engines/hdb/ai.h b/engines/hdb/ai.h
index 8e6a7ab..e3d846f 100644
--- a/engines/hdb/ai.h
+++ b/engines/hdb/ai.h
@@ -633,6 +633,7 @@ public:
 	// Waypoint & Movement Functions
 	void lookAtXY(int x, int y);
 	void clearWaypoints();
+	void *getStandFrameDir(AIEntity *e);
 
 	// Inventory Functions
 	bool addToInventory(AIEntity *e);


Commit: 36613d3196a365766c03a1a998d5a9b7e70bfb27
    https://github.com/scummvm/scummvm/commit/36613d3196a365766c03a1a998d5a9b7e70bfb27
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:16:52+02:00

Commit Message:
HDB: Unstub aiPlayerInit()

Changed paths:
    engines/hdb/ai-player.cpp


diff --git a/engines/hdb/ai-player.cpp b/engines/hdb/ai-player.cpp
index 8d42d27..7cf10f5 100644
--- a/engines/hdb/ai-player.cpp
+++ b/engines/hdb/ai-player.cpp
@@ -25,7 +25,31 @@
 namespace HDB {
 
 void aiPlayerInit(AIEntity *e) {
-	warning("STUB: AI: aiPlayerInit required");
+	g_hdb->_ai->clearInventory();
+	e->aiAction = aiPlayerAction;
+	e->draw = g_hdb->_ai->getStandFrameDir(e);
+
+	switch (e->dir) {
+	case DIR_UP:
+		e->state = STATE_STANDUP;
+		break;
+	case DIR_DOWN:
+		e->state = STATE_STANDDOWN;
+		break;
+	case DIR_LEFT:
+		e->state = STATE_STANDLEFT;
+		break;
+	case DIR_RIGHT:
+		e->state = STATE_STANDRIGHT;
+		break;
+	case DIR_NONE:
+		warning("AI-PLAYER: aiPlayerInit: DIR_NONE found");
+		break;
+	}
+
+	e->moveSpeed = kPlayerMoveSpeed;
+	strcpy(e->entityName, "player");
+	g_hdb->_ai->assignPlayer(e);
 }
 
 void aiPlayerInit2(AIEntity *e) {


Commit: 55587c0751ee9166aedf61154ad62f2e35caea2d
    https://github.com/scummvm/scummvm/commit/55587c0751ee9166aedf61154ad62f2e35caea2d
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:16:53+02:00

Commit Message:
HDB: Fix type of certain gfx arrays

Changed paths:
    engines/hdb/ai.h


diff --git a/engines/hdb/ai.h b/engines/hdb/ai.h
index e3d846f..cef6eaf 100644
--- a/engines/hdb/ai.h
+++ b/engines/hdb/ai.h
@@ -639,14 +639,6 @@ public:
 	bool addToInventory(AIEntity *e);
 	void clearInventory();
 
-	// Cinematic Variables
-	Common::Array<CineCommand *> _cine;
-
-private:
-
-	Common::Array<AIEntity *> *_ents;
-	AIEntity *_player;
-
 	// Player Variables
 	bool _playerDead;
 	bool _playerInvisible;	// While on RailRider for example
@@ -685,13 +677,13 @@ private:
 	Tile		*_plummetGfx[kMaxDeathFrames];
 
 	uint16		_clubUpFrames;
-	Tile		*_clubUpGfx[kMaxAnimFrames];
+	Picture		*_clubUpGfx[kMaxAnimFrames];
 	uint16		_clubDownFrames;
-	Tile		*_clubDownGfx[kMaxAnimFrames];
+	Picture		*_clubDownGfx[kMaxAnimFrames];
 	uint16		_clubLeftFrames;
-	Tile		*_clubLeftGfx[kMaxAnimFrames];
+	Picture		*_clubLeftGfx[kMaxAnimFrames];
 	uint16		_clubRightFrames;
-	Tile		*_clubRightGfx[kMaxAnimFrames];
+	Picture		*_clubRightGfx[kMaxAnimFrames];
 
 	uint16		_stunUpFrames;
 	Tile		*_stunUpGfx[kMaxAnimFrames];
@@ -701,7 +693,7 @@ private:
 	Tile		*_stunLeftGfx[kMaxAnimFrames];
 	uint16		_stunRightFrames;
 	Tile		*_stunRightGfx[kMaxAnimFrames];
-	Tile		*_stun_lightningGfx[kMaxAnimFrames];
+	Tile		*_stunLightningGfx[kMaxAnimFrames];
 	Tile		*_stunnedGfx[kMaxAnimFrames];
 
 	uint16		_slugUpFrames;
@@ -714,7 +706,7 @@ private:
 	Tile		*_slugRightGfx[kMaxAnimFrames];
 
 	uint16		_slugAttackFrames;
-	Tile		*_slugAttackGfx[kMaxAnimFrames];
+	Picture		*_slugAttackGfx[kMaxAnimFrames];
 
 	// Player Resources and Deliveries
 
@@ -729,6 +721,14 @@ private:
 	int _numWaypoints;
 	Tile *_waypointGfx[4]; // Animating waypoint gfx
 
+	// Cinematic Variables
+	Common::Array<CineCommand *> _cine;
+
+private:
+
+	Common::Array<AIEntity *> *_ents;
+	AIEntity *_player;
+
 	// Cinematics Variables
 	bool _cineAbortable;
 	bool _cineAborted;


Commit: a0ea424e08dc40604213b201ed6b4a67828377f2
    https://github.com/scummvm/scummvm/commit/a0ea424e08dc40604213b201ed6b4a67828377f2
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:16:53+02:00

Commit Message:
HDB: Modify GfxCache to take tileGfx and picGfx

Changed paths:
    engines/hdb/draw-manager.h


diff --git a/engines/hdb/draw-manager.h b/engines/hdb/draw-manager.h
index 1474ae7..a0601f7 100644
--- a/engines/hdb/draw-manager.h
+++ b/engines/hdb/draw-manager.h
@@ -50,11 +50,14 @@ struct TileLookup {
 
 struct GfxCache {
 	char name[32];
-	Tile *gfx;
+	union {
+		Tile *tileGfx;
+		Picture *picGfx;
+	};
 	uint32 size;
 	int16 loaded;
 
-	GfxCache() : name(""), gfx(NULL), size(0), loaded(0) {}
+	GfxCache() : name(""), tileGfx(NULL), picGfx(NULL), size(0), loaded(0) {}
 };
 
 class DrawMan {


Commit: 5bf7e9c23d4347f598f7fffb29c01273a1a36e1e
    https://github.com/scummvm/scummvm/commit/5bf7e9c23d4347f598f7fffb29c01273a1a36e1e
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:16:53+02:00

Commit Message:
HDB: Compilation fixes

Changed paths:
    engines/hdb/draw-manager.h


diff --git a/engines/hdb/draw-manager.h b/engines/hdb/draw-manager.h
index a0601f7..012ef80 100644
--- a/engines/hdb/draw-manager.h
+++ b/engines/hdb/draw-manager.h
@@ -57,7 +57,7 @@ struct GfxCache {
 	uint32 size;
 	int16 loaded;
 
-	GfxCache() : name(""), tileGfx(NULL), picGfx(NULL), size(0), loaded(0) {}
+	GfxCache() : name(""), tileGfx(NULL), size(0), loaded(0) {}
 };
 
 class DrawMan {


Commit: ec5fea4e97345ebbf456940b0b5e42df6f9e6491
    https://github.com/scummvm/scummvm/commit/ec5fea4e97345ebbf456940b0b5e42df6f9e6491
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:16:53+02:00

Commit Message:
HDB: Split getGfx() into getTileGfx and getPicGfx

Changed paths:
    engines/hdb/draw-manager.cpp
    engines/hdb/draw-manager.h


diff --git a/engines/hdb/draw-manager.cpp b/engines/hdb/draw-manager.cpp
index 37d41c2..c716e6d 100644
--- a/engines/hdb/draw-manager.cpp
+++ b/engines/hdb/draw-manager.cpp
@@ -169,13 +169,13 @@ Picture *DrawMan::getPicture(const char *name) {
 	return picture;
 }
 
-Tile *DrawMan::getGfx(const char *name, uint32 size) {
+Tile *DrawMan::getTileGfx(const char *name, uint32 size) {
 	// Try to find graphic
 	for (Common::Array<GfxCache *>::iterator it = _gfxCache->begin(); it != _gfxCache->end(); it++) {
 		if (Common::matchString((*it)->name, name)) {
 			if ((*it)->loaded == -1) {	// Marked for Deletetion?
 				(*it)->loaded = 1;		// Reactivate it
-				return (*it)->gfx;
+				return (*it)->tileGfx;
 			}
 		}
 	}
@@ -188,12 +188,41 @@ Tile *DrawMan::getGfx(const char *name, uint32 size) {
 	Tile *gfxTile = new Tile;
 	gfxTile->load(stream);
 
+	gc->tileGfx = gfxTile;
 	gc->size = size;
 	gc->loaded = 1;
 
 	_gfxCache->push_back(gc);
 
-	return gc->gfx;
+	return gc->tileGfx;
+}
+
+Picture *DrawMan::getPicGfx(const char *name, uint32 size) {
+	// Try to find graphic
+	for (Common::Array<GfxCache *>::iterator it = _gfxCache->begin(); it != _gfxCache->end(); it++) {
+		if (Common::matchString((*it)->name, name)) {
+			if ((*it)->loaded == -1) {	// Marked for Deletetion?
+				(*it)->loaded = 1;		// Reactivate it
+				return (*it)->picGfx;
+			}
+		}
+	}
+
+	GfxCache *gc = new GfxCache;
+	strcpy(gc->name, name);
+
+	Common::SeekableReadStream *stream = g_hdb->_fileMan->findFirstData(name, TYPE_TILE32);
+
+	Picture *gfxPic = new Picture;
+	gfxPic->load(stream);
+
+	gc->picGfx = gfxPic;
+	gc->size = size;
+	gc->loaded = 1;
+
+	_gfxCache->push_back(gc);
+
+	return gc->picGfx;
 }
 
 int DrawMan::isSky(int index) {
diff --git a/engines/hdb/draw-manager.h b/engines/hdb/draw-manager.h
index 012ef80..934a37a 100644
--- a/engines/hdb/draw-manager.h
+++ b/engines/hdb/draw-manager.h
@@ -82,7 +82,8 @@ public:
 	int getTileIndex(const char *name);
 	Picture *getPicture(const char *name);
 
-	Tile *getGfx(const char *name, uint32 size);
+	Tile *getTileGfx(const char *name, uint32 size);
+	Picture *getPicGfx(const char *name, uint32 size);
 
 	int isSky(int skyIndex);
 	void setSky(int skyIndex);


Commit: caff981b2f763d869dad54cafb81a90521c71223
    https://github.com/scummvm/scummvm/commit/caff981b2f763d869dad54cafb81a90521c71223
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:16:53+02:00

Commit Message:
HDB: Add selectGfx()

Changed paths:
    engines/hdb/draw-manager.cpp
    engines/hdb/draw-manager.h


diff --git a/engines/hdb/draw-manager.cpp b/engines/hdb/draw-manager.cpp
index c716e6d..b59b86f 100644
--- a/engines/hdb/draw-manager.cpp
+++ b/engines/hdb/draw-manager.cpp
@@ -169,6 +169,53 @@ Picture *DrawMan::getPicture(const char *name) {
 	return picture;
 }
 
+// Returns: true->Tile, false->Pic
+bool DrawMan::selectGfxType(const char *name) {
+	// Check for Pic types
+	if (Common::matchString(name, "clubup1"))
+		return false;
+	if (Common::matchString(name, "clubup2"))
+		return false;
+	if (Common::matchString(name, "clubup3"))
+		return false;
+	if (Common::matchString(name, "clubup4"))
+		return false;
+	if (Common::matchString(name, "clubdown1"))
+		return false;
+	if (Common::matchString(name, "clubdown2"))
+		return false;
+	if (Common::matchString(name, "clubdown3"))
+		return false;
+	if (Common::matchString(name, "clubdown4"))
+		return false;
+	if (Common::matchString(name, "clubleft1"))
+		return false;
+	if (Common::matchString(name, "clubleft2"))
+		return false;
+	if (Common::matchString(name, "clubleft3"))
+		return false;
+	if (Common::matchString(name, "clubleft4"))
+		return false;
+	if (Common::matchString(name, "clubright1"))
+		return false;
+	if (Common::matchString(name, "clubright2"))
+		return false;
+	if (Common::matchString(name, "clubright3"))
+		return false;
+	if (Common::matchString(name, "clubright4"))
+		return false;
+	if (Common::matchString(name, "slug_shot1"))
+		return false;
+	if (Common::matchString(name, "slug_shot2"))
+		return false;
+	if (Common::matchString(name, "slug_shot3"))
+		return false;
+	if (Common::matchString(name, "slug_shot4"))
+		return false;
+
+	return true;
+}
+
 Tile *DrawMan::getTileGfx(const char *name, uint32 size) {
 	// Try to find graphic
 	for (Common::Array<GfxCache *>::iterator it = _gfxCache->begin(); it != _gfxCache->end(); it++) {
diff --git a/engines/hdb/draw-manager.h b/engines/hdb/draw-manager.h
index 934a37a..69d44ae 100644
--- a/engines/hdb/draw-manager.h
+++ b/engines/hdb/draw-manager.h
@@ -82,6 +82,8 @@ public:
 	int getTileIndex(const char *name);
 	Picture *getPicture(const char *name);
 
+	// Returns: true->Tile, false->Pic
+	bool selectGfxType(const char *name);
 	Tile *getTileGfx(const char *name, uint32 size);
 	Picture *getPicGfx(const char *name, uint32 size);
 


Commit: 8c6237809053ab1cad11c9f701a3fd6a075c0a94
    https://github.com/scummvm/scummvm/commit/8c6237809053ab1cad11c9f701a3fd6a075c0a94
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:16:53+02:00

Commit Message:
HDB: Modify cacheEntGfx to use new gfx functions

Changed paths:
    engines/hdb/ai-funcs.cpp


diff --git a/engines/hdb/ai-funcs.cpp b/engines/hdb/ai-funcs.cpp
index 8e2db69..4d90e88 100644
--- a/engines/hdb/ai-funcs.cpp
+++ b/engines/hdb/ai-funcs.cpp
@@ -101,298 +101,309 @@ bool AI::cacheEntGfx(AIEntity *e, bool init) {
 				for (Common::Array<const char *>::iterator it = gfxFiles->begin(); it != gfxFiles->end(); it++) {
 					size = g_hdb->_fileMan->getLength((*it), TYPE_TILE32);
 
-					Tile *gfx = g_hdb->_drawMan->getGfx((*it), size);
-					switch (list[j].state) {
-					case STATE_STANDDOWN:
-						e->standdownGfx[e->standdownFrames] = gfx;
-						e->standdownFrames++;
-						break;
-					case STATE_STANDUP:
-						e->standupGfx[e->standupFrames] = gfx;
-						e->standupFrames++;
-						break;
-					case STATE_STANDLEFT:
-						e->standleftGfx[e->standleftFrames] = gfx;
-						e->standleftFrames++;
-						break;
-					case STATE_STANDRIGHT:
-						e->standrightGfx[e->standrightFrames] = gfx;
-						e->standrightFrames++;
-						break;
-					case STATE_BLINK:
-						e->blinkGfx[e->blinkFrames] = gfx;
-						e->blinkFrames++;
-						break;
-					case STATE_MOVEDOWN:
-						e->movedownGfx[e->movedownFrames] = gfx;
-						e->movedownFrames++;
-						break;
-					case STATE_MOVEUP:
-						e->moveupGfx[e->moveupFrames] = gfx;
-						e->moveupFrames++;
-						break;
-					case STATE_MOVELEFT:
-						e->moveleftGfx[e->moveleftFrames] = gfx;
-						e->moveleftFrames++;
-						break;
-					case STATE_MOVERIGHT:
-						e->moverightGfx[e->moverightFrames] = gfx;
-						e->moverightFrames++;
-						break;
-
-					// Special Player Frames
-					case STATE_PUSHDOWN:
-						_pushdownGfx[_pushdownFrames] = gfx;
-						_pushdownFrames++;
-						break;
-					case STATE_PUSHUP:
-						_pushupGfx[_pushupFrames] = gfx;
-						_pushupFrames++;
-						break;
-					case STATE_PUSHLEFT:
-						_pushleftGfx[_pushleftFrames] = gfx;
-						_pushleftFrames++;
-						break;
-					case STATE_PUSHRIGHT:
-						_pushrightGfx[_pushrightFrames] = gfx;
-						_pushrightFrames++;
-						break;
-					case STATE_GRABUP:
-						_getGfx[DIR_UP] = gfx; break;
-					case STATE_GRABDOWN:
-						_getGfx[DIR_DOWN] = gfx; break;
-					case STATE_GRABLEFT:
-						_getGfx[DIR_LEFT] = gfx; break;
-					case STATE_GRABRIGHT:
-						_getGfx[DIR_RIGHT] = gfx; break;
-
-					case STATE_ATK_CLUB_UP:
-						_clubUpGfx[_clubUpFrames] = gfx;
-						_clubUpFrames++;
-						break;
-					case STATE_ATK_CLUB_DOWN:
-						_clubDownGfx[_clubDownFrames] = gfx;
-						_clubDownFrames++;
-						break;
-					case STATE_ATK_CLUB_LEFT:
-						_clubLeftGfx[_clubLeftFrames] = gfx;
-						_clubLeftFrames++;
-						break;
-					case STATE_ATK_CLUB_RIGHT:
-						_clubRightGfx[_clubRightFrames] = gfx;
-						_clubRightFrames++;
-						break;
-
-					case STATE_ATK_STUN_UP:
-						_stunUpGfx[_stunUpFrames] = gfx;
-						_stunUpFrames++;
-						break;
-					case STATE_ATK_STUN_DOWN:
-						_stunDownGfx[_stunDownFrames] = gfx;
-						_stunDownFrames++;
-						break;
-					case STATE_ATK_STUN_LEFT:
-						_stunLeftGfx[_stunLeftFrames] = gfx;
-						_stunLeftFrames++;
-						break;
-					case STATE_ATK_STUN_RIGHT:
-						_stunRightGfx[_stunRightFrames] = gfx;
-						_stunRightFrames++;
-						break;
-
-					case STATE_ATK_SLUG_UP:
-						_slugUpGfx[_slugUpFrames] = gfx;
-						_slugUpFrames++;
-						break;
-					case STATE_ATK_SLUG_DOWN:
-						_slugDownGfx[_slugDownFrames] = gfx;
-						_slugDownFrames++;
-						break;
-					case STATE_ATK_SLUG_LEFT:
-						_slugLeftGfx[_slugLeftFrames] = gfx;
-						_slugLeftFrames++;
-						break;
-					case STATE_ATK_SLUG_RIGHT:
-						_slugRightGfx[_slugRightFrames] = gfx;
-						_slugRightFrames++;
-						break;
-
-					// Maintenance Bot
-					case STATE_USEUP:
-						e->standupGfx[4] = gfx;
-						break;
-					case STATE_USEDOWN:
-						e->standdownGfx[4] = gfx;
-						break;
-					case STATE_USELEFT:
-						e->standleftGfx[4] = gfx;
-						break;
-					case STATE_USERIGHT:
-						e->standrightGfx[4] = gfx;
-						break;
-
-					// Death & Dying for Player
-					case STATE_DYING:
-						_dyingGfx[_dyingFrames] = gfx;
-						_dyingFrames++;
-						break;
-					case STATE_GOODJOB:
-						_goodjobGfx = gfx;
-						break;
-
-					case STATE_HORRIBLE1:
-						_horrible1Gfx[_horrible1Frames] = gfx;
-						_horrible1Frames++;
-						break;
-					case STATE_HORRIBLE2:
-						_horrible2Gfx[_horrible2Frames] = gfx;
-						_horrible2Frames++;
-						break;
-					case STATE_HORRIBLE3:
-						_horrible3Gfx[_horrible3Frames] = gfx;
-						_horrible3Frames++;
-						break;
-					case STATE_HORRIBLE4:
-						_horrible4Gfx[_horrible4Frames] = gfx;
-						_horrible4Frames++;
-						break;
-					case STATE_PLUMMET:
-						_plummetGfx[_plummetFrames] = gfx;
-						_plummetFrames++;
-						break;
-
-					// floating frames - overwrite "standup" info
-					case STATE_FLOATING:
-						e->blinkGfx[e->blinkFrames] = gfx;
-						e->blinkFrames++;
-						break;
-
-					// melted frames - go in the special area (lightbarrels)
-					// shocking frames - go in the special1 area (shockbots)
-					// exploding frames, same
-					case STATE_MELTED:
-					case STATE_SHOCKING:
-					case STATE_EXPLODING:
-						e->special1Gfx[e->special1Frames] = gfx;
-						e->special1Frames++;
-						break;
-
-					// ICEPUFF spawning states
-					case STATE_ICEP_PEEK:
-						e->blinkGfx[e->blinkFrames] = gfx;
-						e->blinkFrames++;
-						break;
-					case STATE_ICEP_APPEAR:
-						e->standupGfx[e->standupFrames] = gfx;
-						e->standupFrames++;
-						break;
-					case STATE_ICEP_THROWDOWN:
-						e->standdownGfx[e->standdownFrames] = gfx;
-						e->standdownFrames++;
-						break;
-					case STATE_ICEP_THROWRIGHT:
-						e->standrightGfx[e->standrightFrames] = gfx;
-						e->standrightFrames++;
-						break;
-					case STATE_ICEP_THROWLEFT:
-						e->standleftGfx[e->standleftFrames] = gfx;
-						e->standleftFrames++;
-						break;
-					case STATE_ICEP_DISAPPEAR:
-						e->special1Gfx[e->special1Frames] = gfx;
-						e->special1Frames++;
-						break;
-
-					// FATFROG spawning states
-					case STATE_LICKDOWN:
-						e->movedownGfx[e->movedownFrames] = gfx;
-						e->movedownFrames++;
-						break;
-					case STATE_LICKLEFT:
-						e->moveleftGfx[e->moveleftFrames] = gfx;
-						e->moveleftFrames++;
-						break;
-					case STATE_LICKRIGHT:
-						e->moverightGfx[e->moverightFrames] = gfx;
-						e->moverightFrames++;
-						break;
-
-					// MEERKAT spawning states
-					case STATE_MEER_MOVE:
-						e->standdownGfx[e->standdownFrames] = gfx;
-						e->standdownFrames++;
-						break;
-					case STATE_MEER_APPEAR:
-						e->standleftGfx[e->standleftFrames] = gfx;
-						e->standleftFrames++;
-						break;
-					case STATE_MEER_BITE:
-						e->standrightGfx[e->standrightFrames] = gfx;
-						e->standrightFrames++;
-						break;
-					case STATE_MEER_DISAPPEAR:
-						e->standupGfx[e->standupFrames] = gfx;
-						e->standupFrames++;
-						break;
-					case STATE_MEER_LOOK:
-						e->movedownGfx[e->movedownFrames] = gfx;
-						e->movedownFrames++;
-						break;
-
-					// DIVERTER spawning states
-					case STATE_DIVERTER_BL:
-						e->standdownGfx[e->standdownFrames] = gfx;
-						e->standdownFrames++;
-						break;
-					case STATE_DIVERTER_BR:
-						e->standupGfx[e->standupFrames] = gfx;
-						e->standupFrames++;
-						break;
-					case STATE_DIVERTER_TL:
-						e->standleftGfx[e->standleftFrames] = gfx;
-						e->standleftFrames++;
-						break;
-					case STATE_DIVERTER_TR:
-						e->standrightGfx[e->standrightFrames] = gfx;
-						e->standrightFrames++;
-						break;
-					// DOLLY states
-					// angry[4] = standright[4]
-					// kissright[4]/kissleft[4] = standleft[8]
-					// panic[4]/laugh[4] = standdown[8]
-					// dollyuseright[5] = special1[5]
-					case STATE_ANGRY:
-						e->standrightGfx[e->standrightFrames] = gfx;
-						e->standrightFrames++;
-						break;
-					case STATE_KISSRIGHT:
-						e->standleftGfx[e->standleftFrames] = gfx;
-						e->standleftFrames++;
-						break;
-					case STATE_KISSLEFT:
-						e->standleftGfx[4 + e->int1] = gfx;
-						e->int1++;
-						break;
-					case STATE_PANIC:
-						e->standdownGfx[e->standdownFrames] = gfx;
-						e->standdownFrames++;
-						break;
-					case STATE_LAUGH:
-						e->standdownGfx[4 + e->value1] = gfx;
-						e->value1++;
-						break;
-					case STATE_DOLLYUSERIGHT:
-						e->special1Gfx[e->special1Frames] = gfx;
-						e->special1Frames++;
-						break;
-
-					// SARGE yelling
-					case STATE_YELL:
-						e->special1Gfx[e->special1Frames] = gfx;
-						e->special1Frames++;
-						break;
-					default:
-						warning("AI-FUNCS: cacheEntGfx: Unknown State");
+					if (g_hdb->_drawMan->selectGfxType((*it))) {
+						Tile *gfx = g_hdb->_drawMan->getTileGfx((*it), size);
+
+						switch (list[j].state) {
+						case STATE_STANDDOWN:
+							e->standdownGfx[e->standdownFrames] = gfx;
+							e->standdownFrames++;
+							break;
+						case STATE_STANDUP:
+							e->standupGfx[e->standupFrames] = gfx;
+							e->standupFrames++;
+							break;
+						case STATE_STANDLEFT:
+							e->standleftGfx[e->standleftFrames] = gfx;
+							e->standleftFrames++;
+							break;
+						case STATE_STANDRIGHT:
+							e->standrightGfx[e->standrightFrames] = gfx;
+							e->standrightFrames++;
+							break;
+						case STATE_BLINK:
+							e->blinkGfx[e->blinkFrames] = gfx;
+							e->blinkFrames++;
+							break;
+						case STATE_MOVEDOWN:
+							e->movedownGfx[e->movedownFrames] = gfx;
+							e->movedownFrames++;
+							break;
+						case STATE_MOVEUP:
+							e->moveupGfx[e->moveupFrames] = gfx;
+							e->moveupFrames++;
+							break;
+						case STATE_MOVELEFT:
+							e->moveleftGfx[e->moveleftFrames] = gfx;
+							e->moveleftFrames++;
+							break;
+						case STATE_MOVERIGHT:
+							e->moverightGfx[e->moverightFrames] = gfx;
+							e->moverightFrames++;
+							break;
+
+							// Special Player Frames
+						case STATE_PUSHDOWN:
+							_pushdownGfx[_pushdownFrames] = gfx;
+							_pushdownFrames++;
+							break;
+						case STATE_PUSHUP:
+							_pushupGfx[_pushupFrames] = gfx;
+							_pushupFrames++;
+							break;
+						case STATE_PUSHLEFT:
+							_pushleftGfx[_pushleftFrames] = gfx;
+							_pushleftFrames++;
+							break;
+						case STATE_PUSHRIGHT:
+							_pushrightGfx[_pushrightFrames] = gfx;
+							_pushrightFrames++;
+							break;
+						case STATE_GRABUP:
+							_getGfx[DIR_UP] = gfx; break;
+						case STATE_GRABDOWN:
+							_getGfx[DIR_DOWN] = gfx; break;
+						case STATE_GRABLEFT:
+							_getGfx[DIR_LEFT] = gfx; break;
+						case STATE_GRABRIGHT:
+							_getGfx[DIR_RIGHT] = gfx; break;
+
+						case STATE_ATK_STUN_UP:
+							_stunUpGfx[_stunUpFrames] = gfx;
+							_stunUpFrames++;
+							break;
+						case STATE_ATK_STUN_DOWN:
+							_stunDownGfx[_stunDownFrames] = gfx;
+							_stunDownFrames++;
+							break;
+						case STATE_ATK_STUN_LEFT:
+							_stunLeftGfx[_stunLeftFrames] = gfx;
+							_stunLeftFrames++;
+							break;
+						case STATE_ATK_STUN_RIGHT:
+							_stunRightGfx[_stunRightFrames] = gfx;
+							_stunRightFrames++;
+							break;
+
+						case STATE_ATK_SLUG_UP:
+							_slugUpGfx[_slugUpFrames] = gfx;
+							_slugUpFrames++;
+							break;
+						case STATE_ATK_SLUG_DOWN:
+							_slugDownGfx[_slugDownFrames] = gfx;
+							_slugDownFrames++;
+							break;
+						case STATE_ATK_SLUG_LEFT:
+							_slugLeftGfx[_slugLeftFrames] = gfx;
+							_slugLeftFrames++;
+							break;
+						case STATE_ATK_SLUG_RIGHT:
+							_slugRightGfx[_slugRightFrames] = gfx;
+							_slugRightFrames++;
+							break;
+
+							// Maintenance Bot
+						case STATE_USEUP:
+							e->standupGfx[4] = gfx;
+							break;
+						case STATE_USEDOWN:
+							e->standdownGfx[4] = gfx;
+							break;
+						case STATE_USELEFT:
+							e->standleftGfx[4] = gfx;
+							break;
+						case STATE_USERIGHT:
+							e->standrightGfx[4] = gfx;
+							break;
+
+							// Death & Dying for Player
+						case STATE_DYING:
+							_dyingGfx[_dyingFrames] = gfx;
+							_dyingFrames++;
+							break;
+						case STATE_GOODJOB:
+							_goodjobGfx = gfx;
+							break;
+
+						case STATE_HORRIBLE1:
+							_horrible1Gfx[_horrible1Frames] = gfx;
+							_horrible1Frames++;
+							break;
+						case STATE_HORRIBLE2:
+							_horrible2Gfx[_horrible2Frames] = gfx;
+							_horrible2Frames++;
+							break;
+						case STATE_HORRIBLE3:
+							_horrible3Gfx[_horrible3Frames] = gfx;
+							_horrible3Frames++;
+							break;
+						case STATE_HORRIBLE4:
+							_horrible4Gfx[_horrible4Frames] = gfx;
+							_horrible4Frames++;
+							break;
+						case STATE_PLUMMET:
+							_plummetGfx[_plummetFrames] = gfx;
+							_plummetFrames++;
+							break;
+
+							// floating frames - overwrite "standup" info
+						case STATE_FLOATING:
+							e->blinkGfx[e->blinkFrames] = gfx;
+							e->blinkFrames++;
+							break;
+
+							// melted frames - go in the special area (lightbarrels)
+							// shocking frames - go in the special1 area (shockbots)
+							// exploding frames, same
+						case STATE_MELTED:
+						case STATE_SHOCKING:
+						case STATE_EXPLODING:
+							e->special1Gfx[e->special1Frames] = gfx;
+							e->special1Frames++;
+							break;
+
+							// ICEPUFF spawning states
+						case STATE_ICEP_PEEK:
+							e->blinkGfx[e->blinkFrames] = gfx;
+							e->blinkFrames++;
+							break;
+						case STATE_ICEP_APPEAR:
+							e->standupGfx[e->standupFrames] = gfx;
+							e->standupFrames++;
+							break;
+						case STATE_ICEP_THROWDOWN:
+							e->standdownGfx[e->standdownFrames] = gfx;
+							e->standdownFrames++;
+							break;
+						case STATE_ICEP_THROWRIGHT:
+							e->standrightGfx[e->standrightFrames] = gfx;
+							e->standrightFrames++;
+							break;
+						case STATE_ICEP_THROWLEFT:
+							e->standleftGfx[e->standleftFrames] = gfx;
+							e->standleftFrames++;
+							break;
+						case STATE_ICEP_DISAPPEAR:
+							e->special1Gfx[e->special1Frames] = gfx;
+							e->special1Frames++;
+							break;
+
+							// FATFROG spawning states
+						case STATE_LICKDOWN:
+							e->movedownGfx[e->movedownFrames] = gfx;
+							e->movedownFrames++;
+							break;
+						case STATE_LICKLEFT:
+							e->moveleftGfx[e->moveleftFrames] = gfx;
+							e->moveleftFrames++;
+							break;
+						case STATE_LICKRIGHT:
+							e->moverightGfx[e->moverightFrames] = gfx;
+							e->moverightFrames++;
+							break;
+
+							// MEERKAT spawning states
+						case STATE_MEER_MOVE:
+							e->standdownGfx[e->standdownFrames] = gfx;
+							e->standdownFrames++;
+							break;
+						case STATE_MEER_APPEAR:
+							e->standleftGfx[e->standleftFrames] = gfx;
+							e->standleftFrames++;
+							break;
+						case STATE_MEER_BITE:
+							e->standrightGfx[e->standrightFrames] = gfx;
+							e->standrightFrames++;
+							break;
+						case STATE_MEER_DISAPPEAR:
+							e->standupGfx[e->standupFrames] = gfx;
+							e->standupFrames++;
+							break;
+						case STATE_MEER_LOOK:
+							e->movedownGfx[e->movedownFrames] = gfx;
+							e->movedownFrames++;
+							break;
+
+							// DIVERTER spawning states
+						case STATE_DIVERTER_BL:
+							e->standdownGfx[e->standdownFrames] = gfx;
+							e->standdownFrames++;
+							break;
+						case STATE_DIVERTER_BR:
+							e->standupGfx[e->standupFrames] = gfx;
+							e->standupFrames++;
+							break;
+						case STATE_DIVERTER_TL:
+							e->standleftGfx[e->standleftFrames] = gfx;
+							e->standleftFrames++;
+							break;
+						case STATE_DIVERTER_TR:
+							e->standrightGfx[e->standrightFrames] = gfx;
+							e->standrightFrames++;
+							break;
+							// DOLLY states
+							// angry[4] = standright[4]
+							// kissright[4]/kissleft[4] = standleft[8]
+							// panic[4]/laugh[4] = standdown[8]
+							// dollyuseright[5] = special1[5]
+						case STATE_ANGRY:
+							e->standrightGfx[e->standrightFrames] = gfx;
+							e->standrightFrames++;
+							break;
+						case STATE_KISSRIGHT:
+							e->standleftGfx[e->standleftFrames] = gfx;
+							e->standleftFrames++;
+							break;
+						case STATE_KISSLEFT:
+							e->standleftGfx[4 + e->int1] = gfx;
+							e->int1++;
+							break;
+						case STATE_PANIC:
+							e->standdownGfx[e->standdownFrames] = gfx;
+							e->standdownFrames++;
+							break;
+						case STATE_LAUGH:
+							e->standdownGfx[4 + e->value1] = gfx;
+							e->value1++;
+							break;
+						case STATE_DOLLYUSERIGHT:
+							e->special1Gfx[e->special1Frames] = gfx;
+							e->special1Frames++;
+							break;
+
+							// SARGE yelling
+						case STATE_YELL:
+							e->special1Gfx[e->special1Frames] = gfx;
+							e->special1Frames++;
+							break;
+						default:
+							warning("AI-FUNCS: cacheEntGfx: Unknown State");
+							break;
+						}
+					} else {
+						Picture *gfx = g_hdb->_drawMan->getPicGfx((*it), size);
+
+						switch (list[j].state) {
+						case STATE_ATK_CLUB_UP:
+							_clubUpGfx[_clubUpFrames] = gfx;
+							_clubUpFrames++;
+							break;
+						case STATE_ATK_CLUB_DOWN:
+							_clubDownGfx[_clubDownFrames] = gfx;
+							_clubDownFrames++;
+							break;
+						case STATE_ATK_CLUB_LEFT:
+							_clubLeftGfx[_clubLeftFrames] = gfx;
+							_clubLeftFrames++;
+							break;
+						case STATE_ATK_CLUB_RIGHT:
+							_clubRightGfx[_clubRightFrames] = gfx;
+							_clubRightFrames++;
+							break;
+						default:
+							warning("AI-FUNCS: cacheEntGfx: Unknown State");
+							break;
+						}
 					}
 				}
 				j++;


Commit: 8b91a75676ddd72286474ca7fc4fe28e44af6861
    https://github.com/scummvm/scummvm/commit/8b91a75676ddd72286474ca7fc4fe28e44af6861
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:16:53+02:00

Commit Message:
HDB: Unstub aiPlayerInit2()

Changed paths:
    engines/hdb/ai-player.cpp


diff --git a/engines/hdb/ai-player.cpp b/engines/hdb/ai-player.cpp
index 7cf10f5..9f21476 100644
--- a/engines/hdb/ai-player.cpp
+++ b/engines/hdb/ai-player.cpp
@@ -53,7 +53,78 @@ void aiPlayerInit(AIEntity *e) {
 }
 
 void aiPlayerInit2(AIEntity *e) {
-	warning("STUB: AI: aiPlayerInit2 required");
+	if (!g_hdb->_ai->_clubUpGfx[0]) {
+		warning("STUB: weapon_sel_gfx uninitialized");
+		g_hdb->_ai->_clubUpGfx[0] = new Picture;
+		g_hdb->_ai->_clubUpGfx[0]->load(g_hdb->_fileMan->findFirstData("clubup1", TYPE_PIC));
+		g_hdb->_ai->_clubUpGfx[1] = new Picture;
+		g_hdb->_ai->_clubUpGfx[1]->load(g_hdb->_fileMan->findFirstData("clubup2", TYPE_PIC));
+		g_hdb->_ai->_clubUpGfx[2] = new Picture;
+		g_hdb->_ai->_clubUpGfx[2]->load(g_hdb->_fileMan->findFirstData("clubup3", TYPE_PIC));
+		g_hdb->_ai->_clubUpGfx[3] = new Picture;
+		g_hdb->_ai->_clubUpGfx[3]->load(g_hdb->_fileMan->findFirstData("clubup3", TYPE_PIC));
+
+		g_hdb->_ai->_clubDownGfx[0] = new Picture;
+		g_hdb->_ai->_clubDownGfx[0]->load(g_hdb->_fileMan->findFirstData("clubdown1", TYPE_PIC));
+		g_hdb->_ai->_clubDownGfx[1] = new Picture;
+		g_hdb->_ai->_clubDownGfx[1]->load(g_hdb->_fileMan->findFirstData("clubdown2", TYPE_PIC));
+		g_hdb->_ai->_clubDownGfx[2] = new Picture;
+		g_hdb->_ai->_clubDownGfx[2]->load(g_hdb->_fileMan->findFirstData("clubdown3", TYPE_PIC));
+		g_hdb->_ai->_clubDownGfx[3] = new Picture;
+		g_hdb->_ai->_clubDownGfx[3]->load(g_hdb->_fileMan->findFirstData("clubdown3", TYPE_PIC));
+
+		g_hdb->_ai->_clubLeftGfx[0] = new Picture;
+		g_hdb->_ai->_clubLeftGfx[0]->load(g_hdb->_fileMan->findFirstData("clubleft1", TYPE_PIC));
+		g_hdb->_ai->_clubLeftGfx[1] = new Picture;
+		g_hdb->_ai->_clubLeftGfx[1]->load(g_hdb->_fileMan->findFirstData("clubleft2", TYPE_PIC));
+		g_hdb->_ai->_clubLeftGfx[2] = new Picture;
+		g_hdb->_ai->_clubLeftGfx[2]->load(g_hdb->_fileMan->findFirstData("clubleft3", TYPE_PIC));
+		g_hdb->_ai->_clubLeftGfx[3] = new Picture;
+		g_hdb->_ai->_clubLeftGfx[3]->load(g_hdb->_fileMan->findFirstData("clubleft3", TYPE_PIC));
+
+		g_hdb->_ai->_clubRightGfx[0] = new Picture;
+		g_hdb->_ai->_clubRightGfx[0]->load(g_hdb->_fileMan->findFirstData("clubright1", TYPE_PIC));
+		g_hdb->_ai->_clubRightGfx[1] = new Picture;
+		g_hdb->_ai->_clubRightGfx[1]->load(g_hdb->_fileMan->findFirstData("clubright2", TYPE_PIC));
+		g_hdb->_ai->_clubRightGfx[2] = new Picture;
+		g_hdb->_ai->_clubRightGfx[2]->load(g_hdb->_fileMan->findFirstData("clubright3", TYPE_PIC));
+		g_hdb->_ai->_clubRightGfx[3] = new Picture;
+		g_hdb->_ai->_clubRightGfx[3]->load(g_hdb->_fileMan->findFirstData("clubright3", TYPE_PIC));
+
+		g_hdb->_ai->_clubUpFrames = 4;
+		g_hdb->_ai->_clubDownFrames = 4;
+		g_hdb->_ai->_clubLeftFrames = 4;
+		g_hdb->_ai->_clubRightFrames = 4;
+
+		g_hdb->_ai->_slugAttackGfx[0] = new Picture;
+		g_hdb->_ai->_slugAttackGfx[0]->load(g_hdb->_fileMan->findFirstData("slug_shot1", TYPE_PIC));
+		g_hdb->_ai->_slugAttackGfx[1] = new Picture;
+		g_hdb->_ai->_slugAttackGfx[1]->load(g_hdb->_fileMan->findFirstData("slug_shot2", TYPE_PIC));
+		g_hdb->_ai->_slugAttackGfx[2] = new Picture;
+		g_hdb->_ai->_slugAttackGfx[2]->load(g_hdb->_fileMan->findFirstData("slug_shot3", TYPE_PIC));
+		g_hdb->_ai->_slugAttackGfx[3] = new Picture;
+		g_hdb->_ai->_slugAttackGfx[3]->load(g_hdb->_fileMan->findFirstData("slug_shot4", TYPE_PIC));
+
+		int32 size = g_hdb->_fileMan->getLength("shock_spark_sit01", TYPE_TILE32);
+		g_hdb->_ai->_stunLightningGfx[0] = g_hdb->_drawMan->getTileGfx("shock_spark_sit01", size);
+		size = g_hdb->_fileMan->getLength("shock_spark_sit02", TYPE_TILE32);
+		g_hdb->_ai->_stunLightningGfx[1] = g_hdb->_drawMan->getTileGfx("shock_spark_sit02", size);
+		size = g_hdb->_fileMan->getLength("shock_spark_sit03", TYPE_TILE32);
+		g_hdb->_ai->_stunLightningGfx[2] = g_hdb->_drawMan->getTileGfx("shock_spark_sit03", size);
+		size = g_hdb->_fileMan->getLength("shock_spark_sit04", TYPE_TILE32);
+		g_hdb->_ai->_stunLightningGfx[3] = g_hdb->_drawMan->getTileGfx("shock_spark_sit04", size);
+
+		size = g_hdb->_fileMan->getLength("starstun_sit01", TYPE_TILE32);
+		g_hdb->_ai->_stunnedGfx[0] = g_hdb->_drawMan->getTileGfx("starstun_sit01", size);
+		size = g_hdb->_fileMan->getLength("starstun_sit02", TYPE_TILE32);
+		g_hdb->_ai->_stunnedGfx[1] = g_hdb->_drawMan->getTileGfx("starstun_sit02", size);
+		size = g_hdb->_fileMan->getLength("starstun_sit03", TYPE_TILE32);
+		g_hdb->_ai->_stunnedGfx[2] = g_hdb->_drawMan->getTileGfx("starstun_sit03", size);
+		size = g_hdb->_fileMan->getLength("starstun_sit04", TYPE_TILE32);
+		g_hdb->_ai->_stunnedGfx[3] = g_hdb->_drawMan->getTileGfx("starstun_sit04", size);
+	}
+
+	e->draw = g_hdb->_ai->getStandFrameDir(e);
 }
 
 void aiPlayerAction(AIEntity *e) {


Commit: 77974e317c468150e90e1d90bb9a21aec9f91ab1
    https://github.com/scummvm/scummvm/commit/77974e317c468150e90e1d90bb9a21aec9f91ab1
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:16:53+02:00

Commit Message:
HDB: Fix warning() calls

Changed paths:
    engines/hdb/ai-cinematic.cpp
    engines/hdb/ai-funcs.cpp
    engines/hdb/ai-inventory.cpp
    engines/hdb/map-loader.cpp


diff --git a/engines/hdb/ai-cinematic.cpp b/engines/hdb/ai-cinematic.cpp
index b30d137..100d335 100644
--- a/engines/hdb/ai-cinematic.cpp
+++ b/engines/hdb/ai-cinematic.cpp
@@ -200,7 +200,7 @@ void AI::processCines() {
 					e->state = STATE_STANDRIGHT;
 					break;
 				default:
-					warning("AI-CINEMATIC: processCines: Unknown Dir");
+					warning("AI-CINEMATIC: processCines: DIR_NONE");
 				}
 			} else {
 				warning("Can't find %s to ENTITYFACE", _cine[i]->title);
diff --git a/engines/hdb/ai-funcs.cpp b/engines/hdb/ai-funcs.cpp
index 4d90e88..6f519c4 100644
--- a/engines/hdb/ai-funcs.cpp
+++ b/engines/hdb/ai-funcs.cpp
@@ -377,7 +377,7 @@ bool AI::cacheEntGfx(AIEntity *e, bool init) {
 							e->special1Frames++;
 							break;
 						default:
-							warning("AI-FUNCS: cacheEntGfx: Unknown State");
+							warning("AI-FUNCS: cacheEntGfx: Unintended State");
 							break;
 						}
 					} else {
@@ -401,7 +401,7 @@ bool AI::cacheEntGfx(AIEntity *e, bool init) {
 							_clubRightFrames++;
 							break;
 						default:
-							warning("AI-FUNCS: cacheEntGfx: Unknown State");
+							warning("AI-FUNCS: cacheEntGfx: Unintended State");
 							break;
 						}
 					}
@@ -468,7 +468,7 @@ void AI::stopEntity(AIEntity *e) {
 		e->state = STATE_FLOATING;
 		return;
 	default:
-		warning("AI-FUNCS: stopEntity: Unknown State");
+		warning("AI-FUNCS: stopEntity: Unintended State");
 	}
 
 	if (e->type != AI_DIVERTER) {
@@ -498,7 +498,7 @@ void AI::stopEntity(AIEntity *e) {
 				e->state = STATE_NONE;
 			break;
 		default:
-			warning("AI-FUNCS: stopEntity: Unknown Dir");
+			warning("AI-FUNCS: stopEntity: DIR_NONE");
 		}
 	}
 }
@@ -737,7 +737,7 @@ void AI::lookAtXY(int x, int y) {
 		warning("STUB: Set _player->draw to Player standright_gfx");
 		break;
 	default:
-		warning("AI-FUNCS: lookAtXY: Unknown Dir");
+		warning("AI-FUNCS: lookAtXY: DIR_NONE");
 	}
 }
 } // End of Namespace
diff --git a/engines/hdb/ai-inventory.cpp b/engines/hdb/ai-inventory.cpp
index dd4e6ae..7505aef 100644
--- a/engines/hdb/ai-inventory.cpp
+++ b/engines/hdb/ai-inventory.cpp
@@ -52,7 +52,7 @@ bool AI::addToInventory(AIEntity *e) {
 		removeEntity(e);
 		return true;
 	default:
-		warning("AI-INVENTORY: addToInventory: Unknown Type");
+		warning("AI-INVENTORY: addToInventory: Unintended Type");
 		return false;
 	}
 
@@ -71,7 +71,7 @@ bool AI::addToInventory(AIEntity *e) {
 	case ITEM_SLUGSLINGER:
 		warning("STUB: addToInventory: Ready weapon");
 	default:
-		warning("AI-INVENTORY: addToInventory: Unknown Type");
+		warning("AI-INVENTORY: addToInventory: Unintended Type");
 	}
 
 	warning("STUB: addToInventory: Print a 'You Got' message");
diff --git a/engines/hdb/map-loader.cpp b/engines/hdb/map-loader.cpp
index d1f9597..0d105d8 100644
--- a/engines/hdb/map-loader.cpp
+++ b/engines/hdb/map-loader.cpp
@@ -403,7 +403,7 @@ bool Map::load(Common::SeekableReadStream *stream) {
 			case ITEM_SLUGSLINGER:
 				continue;
 			default:
-				warning("MAP-LOADER: load: Unknown Type");
+				warning("MAP-LOADER: load: Unintended Type");
 			}
 		}
 


Commit: 2d7c0adabd8823f5c224157a74eaecdabdd022cb
    https://github.com/scummvm/scummvm/commit/2d7c0adabd8823f5c224157a74eaecdabdd022cb
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:16:53+02:00

Commit Message:
HDB: Unstub aiPlayerDraw

Changed paths:
    engines/hdb/ai-player.cpp


diff --git a/engines/hdb/ai-player.cpp b/engines/hdb/ai-player.cpp
index 9f21476..ff49b56 100644
--- a/engines/hdb/ai-player.cpp
+++ b/engines/hdb/ai-player.cpp
@@ -132,7 +132,50 @@ void aiPlayerAction(AIEntity *e) {
 }
 
 void aiPlayerDraw(AIEntity *e, int mx, int my) {
-	warning("STUB: AI: aiPlayerDraw required");
+	switch (e->state) {
+	case STATE_ATK_CLUB_UP:
+		g_hdb->_ai->_clubUpGfx[e->animFrame]->drawMasked(e->x + e->drawXOff - mx, e->y + e->drawYOff - my);
+		break;
+	case STATE_ATK_CLUB_DOWN:
+		g_hdb->_ai->_clubDownGfx[e->animFrame]->drawMasked(e->x + e->drawXOff - mx, e->y + e->drawYOff - my);
+		break;
+	case STATE_ATK_CLUB_LEFT:
+		g_hdb->_ai->_clubLeftGfx[e->animFrame]->drawMasked(e->x + e->drawXOff - mx, e->y + e->drawYOff - my);
+		break;
+	case STATE_ATK_CLUB_RIGHT:
+		g_hdb->_ai->_clubRightGfx[e->animFrame]->drawMasked(e->x + e->drawXOff - mx, e->y + e->drawYOff - my);
+		break;
+	default:
+		warning("AI-PLAYER: aiPlayerDraw: Unintended State");
+		break;
+	}
+
+	if (e->sequence) {
+		static int frame = 0;
+		switch (e->dir) {
+		case DIR_UP:
+			g_hdb->_ai->_stunLightningGfx[frame]->drawMasked(e->x - mx, e->y - 32 - my);
+			g_hdb->_ai->_stunLightningGfx[frame]->drawMasked(e->x - mx, e->y - 64 - my);
+			break;
+		case DIR_DOWN:
+			g_hdb->_ai->_stunLightningGfx[frame]->drawMasked(e->x - mx, e->y + 32 - my);
+			g_hdb->_ai->_stunLightningGfx[frame]->drawMasked(e->x - mx, e->y + 64 - my);
+			break;
+		case DIR_LEFT:
+			g_hdb->_ai->_stunLightningGfx[frame]->drawMasked(e->x - 32 - mx, e->y - my);
+			g_hdb->_ai->_stunLightningGfx[frame]->drawMasked(e->x - 64 - mx, e->y - my);
+			break;
+		case DIR_RIGHT:
+			g_hdb->_ai->_stunLightningGfx[frame]->drawMasked(e->x + 32 - mx, e->y - my);
+			g_hdb->_ai->_stunLightningGfx[frame]->drawMasked(e->x + 64 - mx, e->y - my);
+			break;
+		case DIR_NONE:
+			warning("AI-PLAYER: aiPlayerDraw: DIR_NONE found");
+			break;
+		}
+
+		frame = (frame + 1) & 3;
+	}
 }
 
 void aiGemAttackInit(AIEntity *e) {


Commit: 3060427fe6967ebf8f3b8ebdc42db9bd15284bfb
    https://github.com/scummvm/scummvm/commit/3060427fe6967ebf8f3b8ebdc42db9bd15284bfb
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:16:53+02:00

Commit Message:
HDB: Modify C_MOVECAMERA debug output

Changed paths:
    engines/hdb/ai-cinematic.cpp


diff --git a/engines/hdb/ai-cinematic.cpp b/engines/hdb/ai-cinematic.cpp
index 100d335..ee67737 100644
--- a/engines/hdb/ai-cinematic.cpp
+++ b/engines/hdb/ai-cinematic.cpp
@@ -291,7 +291,7 @@ void AI::cineMoveCamera(int x, int y, int speed) {
 	cmd->x = x * kTileWidth;
 	cmd->y = y * kTileHeight;
 	cmd->speed = speed;
-	debug("Setting up C_MOVECAMERA: x: %f, y: %f", cmd->x, cmd->y);
+	debug(2, "Setting up C_MOVECAMERA: x: %f, y: %f", cmd->x, cmd->y);
 	cmd->cmdType = C_MOVECAMERA;
 	_cine.push_back(cmd);
 }


Commit: 00a8da026e62b739520fb0f3ee907f28a8f8f41e
    https://github.com/scummvm/scummvm/commit/00a8da026e62b739520fb0f3ee907f28a8f8f41e
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:16:53+02:00

Commit Message:
HDB: Add animEntFrames()

Changed paths:
    engines/hdb/ai-funcs.cpp
    engines/hdb/ai.h


diff --git a/engines/hdb/ai-funcs.cpp b/engines/hdb/ai-funcs.cpp
index 6f519c4..0da3867 100644
--- a/engines/hdb/ai-funcs.cpp
+++ b/engines/hdb/ai-funcs.cpp
@@ -606,6 +606,311 @@ void AI::initAllEnts() {
 	warning("STUB: initAllEnts: LaserScan required");
 }
 
+void AI::animEntFrames(AIEntity *e) {
+	int max = 1;
+	// Set current graphic to draw
+	switch (e->state) {
+	case STATE_STANDDOWN:
+		e->draw = e->standdownGfx[0];
+		max = 1;
+		break;
+	case STATE_STANDUP:
+		e->draw = e->standupGfx[0];
+		max = 1;
+		break;
+	case STATE_STANDLEFT:
+		e->draw = e->standleftGfx[0];
+		max = 1;
+		break;
+	case STATE_STANDRIGHT:
+		e->draw = e->standrightGfx[0];
+		max = 1;
+		break;
+	case STATE_BLINK:
+		e->draw = e->blinkGfx[e->animFrame];
+		max = e->blinkFrames;
+		break;
+	case STATE_MOVEUP:
+		e->draw = e->moveupGfx[e->animFrame];
+		max = e->moveupFrames;
+		break;
+	case STATE_MOVEDOWN:
+		e->draw = e->movedownGfx[e->animFrame];
+		max = e->movedownFrames;
+		break;
+	case STATE_MOVELEFT:
+		e->draw = e->moveleftGfx[e->animFrame];
+		max = e->moveleftFrames;
+		break;
+	case STATE_MOVERIGHT:
+		e->draw = e->moverightGfx[e->animFrame];
+		max = e->moverightFrames;
+		break;
+	case STATE_PUSHDOWN:
+		e->draw = _pushdownGfx[e->animFrame];
+		max = _pushdownFrames;
+		break;
+	case STATE_PUSHUP:
+		e->draw = _pushupGfx[e->animFrame];
+		max = _pushupFrames;
+		break;
+	case STATE_PUSHLEFT:
+		e->draw = _pushleftGfx[e->animFrame];
+		max = _pushleftFrames;
+		break;
+	case STATE_PUSHRIGHT:
+		e->draw = _pushrightGfx[e->animFrame];
+		max = _pushrightFrames;
+		break;
+
+	case STATE_GRABUP:
+		e->draw = _getGfx[DIR_UP];
+		max = 1;
+		break;
+	case STATE_GRABDOWN:
+		e->draw = _getGfx[DIR_DOWN];
+		max = 1;
+		break;
+	case STATE_GRABLEFT:
+		e->draw = _getGfx[DIR_LEFT];
+		max = 1;
+		break;
+	case STATE_GRABRIGHT:
+		e->draw = _getGfx[DIR_RIGHT];
+		max = 1;
+		break;
+
+	case STATE_HORRIBLE1:
+		e->draw = _horrible1Gfx[e->animFrame];
+		max = _horrible1Frames;
+		if (e->animFrame == max - 1)
+			e->state = STATE_DEAD;
+		break;
+	case STATE_HORRIBLE2:
+	{
+		static int		click = 0;
+		e->draw = _horrible2Gfx[e->animFrame];
+		max = _horrible2Frames;
+		click++;
+		if (click == 16) {
+			warning("STUB: Play SND_SHOCKBOT_SHOCK");
+			click = 0;
+		}
+	}
+	break;
+	case STATE_HORRIBLE3:
+	{
+		static int		click = 0;
+		e->draw = _horrible3Gfx[e->animFrame];
+		max = _horrible3Frames;
+		click++;
+		if (click == 32) {
+			warning("STUB: Play SND_GUY_GRABBED");
+			click = 0;
+		}
+	}
+	break;
+	case STATE_HORRIBLE4:
+		e->draw = _horrible4Gfx[e->animFrame];
+		max = _horrible4Frames;
+		if (e->animFrame == max - 1)
+			e->state = STATE_DEAD;
+		break;
+
+	case STATE_PLUMMET:
+		e->draw = _plummetGfx[e->animFrame];
+		max = _plummetFrames;
+		if (e->animFrame == max - 1) {
+			e->state = STATE_NONE;
+			setPlayerInvisible(true);
+		}
+		break;
+
+		//
+		// maintenance bot uses stuff
+		//
+	case STATE_USEDOWN:
+		e->draw = e->standdownGfx[4];
+		return;
+	case STATE_USEUP:
+		e->draw = e->standupGfx[4];
+		return;
+	case STATE_USELEFT:
+		e->draw = e->standleftGfx[4];
+		return;
+	case STATE_USERIGHT:
+		e->draw = e->standrightGfx[4];
+		return;
+
+		//
+		// death!
+		//
+	case STATE_DYING:
+		e->draw = _dyingGfx[e->animFrame];
+		max = _dyingFrames;
+		if (e->animFrame == max - 1)
+			e->state = STATE_DEAD;
+		break;
+
+	case STATE_DEAD:
+		e->draw = _dyingGfx[_dyingFrames - 1];
+		max = _dyingFrames;
+		break;
+
+	case STATE_GOODJOB:
+		e->draw = _goodjobGfx;
+		max = 1;
+		break;
+
+		//
+		// floating stuff uses the "standup" frames for animating the float
+		//
+	case STATE_FLOATING:
+	case STATE_FLOATDOWN:
+	case STATE_FLOATUP:
+	case STATE_FLOATLEFT:
+	case STATE_FLOATRIGHT:
+		e->draw = e->blinkGfx[e->animFrame];
+		max = e->blinkFrames;
+		break;
+	case STATE_MELTED:
+	case STATE_EXPLODING:
+		e->draw = e->special1Gfx[e->animFrame];
+		max = e->special1Frames;
+		if (e->type == AI_BOOMBARREL) {			// while exploding, call this function
+			aiBarrelExplodeSpread(e);
+			if (e->animFrame == max - 1) {
+				removeEntity(e);
+				return;
+			}
+		}
+		break;
+
+		//
+		// ICEPUFF states
+		//
+	case STATE_ICEP_PEEK:
+		e->draw = e->blinkGfx[e->animFrame];
+		max = e->blinkFrames;
+		break;
+	case STATE_ICEP_APPEAR:
+		e->draw = e->standupGfx[e->animFrame];
+		max = e->standupFrames;
+		break;
+	case STATE_ICEP_THROWDOWN:
+		e->draw = e->standdownGfx[e->animFrame];
+		max = e->standdownFrames;
+		break;
+	case STATE_ICEP_THROWRIGHT:
+		e->draw = e->standrightGfx[e->animFrame];
+		max = e->standrightFrames;
+		break;
+	case STATE_ICEP_THROWLEFT:
+		e->draw = e->standleftGfx[e->animFrame];
+		max = e->standleftFrames;
+		break;
+	case STATE_ICEP_DISAPPEAR:
+		e->draw = e->special1Gfx[e->animFrame];
+		max = e->special1Frames;
+		break;
+
+		//
+		// MEERKAT states
+		//
+	case STATE_MEER_MOVE:
+		e->draw = e->standdownGfx[e->animFrame];
+		max = e->standdownFrames;
+		break;
+	case STATE_MEER_APPEAR:
+		e->draw = e->standleftGfx[e->animFrame];
+		max = e->standleftFrames;
+		break;
+	case STATE_MEER_BITE:
+		e->draw = e->standrightGfx[e->animFrame];
+		max = e->standrightFrames;
+		break;
+	case STATE_MEER_DISAPPEAR:
+		e->draw = e->standupGfx[e->animFrame];
+		max = e->standupFrames;
+		break;
+	case STATE_MEER_LOOK:
+		e->draw = e->movedownGfx[e->animFrame];
+		max = e->movedownFrames;
+		break;
+
+		//
+		// DIVERTER spawning states
+		//
+	case STATE_DIVERTER_BL:
+		e->draw = e->standdownGfx[e->animFrame];
+		max = e->standdownFrames;
+		break;
+	case STATE_DIVERTER_BR:
+		e->draw = e->standupGfx[e->animFrame];
+		max = e->standupFrames;
+		break;
+	case STATE_DIVERTER_TL:
+		e->draw = e->standleftGfx[e->animFrame];
+		max = e->standleftFrames;
+		break;
+	case STATE_DIVERTER_TR:
+		e->draw = e->standrightGfx[e->animFrame];
+		max = e->standrightFrames;
+		break;
+
+		//
+		// DOLLY states
+		// angry[4] = standright[4]
+		// kissright[4]/kissleft[4] = standleft[8]
+		// panic[4]/laugh[4] = standdown[8]
+		// dollyuseright[5] = special1[5]
+		//
+	case STATE_ANGRY:
+		e->draw = e->standrightGfx[e->animFrame];
+		max = 2;
+		break;
+	case STATE_KISSRIGHT:
+		e->draw = e->standleftGfx[e->animFrame];
+		max = 4;
+		break;
+	case STATE_KISSLEFT:
+		e->draw = e->standleftGfx[e->animFrame + 4];
+		max = 4;
+		break;
+	case STATE_PANIC:
+		e->draw = e->standdownGfx[e->animFrame];
+		max = 2;
+		break;
+	case STATE_LAUGH:
+		e->draw = e->standdownGfx[e->animFrame + 4];
+		max = 2;
+		break;
+	case STATE_DOLLYUSERIGHT:
+		e->draw = e->special1Gfx[e->animFrame];
+		max = e->special1Frames;
+		break;
+
+		// SARGE yelling
+	case STATE_YELL:
+		e->draw = e->special1Gfx[e->animFrame];
+		max = e->special1Frames;
+		break;
+	default:
+		warning("AI-FUNCS: animEntFrames: Unintended State");
+		break;
+	}
+
+	// Cycle animation frames
+	if (e->animDelay-- > 0)
+		return;
+	e->animDelay = e->animCycle;
+
+	e->animFrame++;
+	if (e->animFrame == max) {
+		e->animFrame = 0;
+	}
+}
+
 void AI::animLuaEntity(const char *initName, AIState st) {
 	for (Common::Array<AIEntity *>::iterator it = _ents->begin(); it != _ents->end(); it++) {
 		if (Common::matchString((*it)->entityName, initName)) {
diff --git a/engines/hdb/ai.h b/engines/hdb/ai.h
index cef6eaf..bbc8d78 100644
--- a/engines/hdb/ai.h
+++ b/engines/hdb/ai.h
@@ -549,6 +549,7 @@ public:
 	void setEntityGoal(AIEntity *e, int x, int y);
 	void initAllEnts();
 
+	void animEntFrames(AIEntity *e);
 	void animLuaEntity(const char *initName, AIState st);
 
 	bool getTableEnt(AIType type);


Commit: be5b717c85933eeb34ceb708424ba580e2bd17c8
    https://github.com/scummvm/scummvm/commit/be5b717c85933eeb34ceb708424ba580e2bd17c8
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:16:53+02:00

Commit Message:
HDB: Add Anim Flags

Changed paths:
    engines/hdb/hdb.h


diff --git a/engines/hdb/hdb.h b/engines/hdb/hdb.h
index 6b02786..76b13f1 100644
--- a/engines/hdb/hdb.h
+++ b/engines/hdb/hdb.h
@@ -69,11 +69,14 @@ enum GameState {
 };
 
 enum Flag {
-	kFlagInvisible = 0x20,
+	kFlagInvisible	= 0x20,
 	kFlagForeground = 0x80,
-	kFlagStairTop = 0x400000,
-	kFlagGrating = 0x4000000,
-	kFlagMasked = 0x2000000
+	kFlagStairTop	= 0x400000,
+	kFlagAnimSlow	= 0x800000,
+	kFlagAnimMedium = 0x1000000,
+	kFlagAnimFast	= 0x1800000,
+	kFlagGrating	= 0x4000000,
+	kFlagMasked		= 0x2000000
 };
 
 enum {


Commit: 55b5acb959f42d737f75d96d361f38cbedb8e017
    https://github.com/scummvm/scummvm/commit/55b5acb959f42d737f75d96d361f38cbedb8e017
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:16:53+02:00

Commit Message:
HDB: Add setter functions for BG/FG tile indices

Changed paths:
    engines/hdb/map-loader.cpp
    engines/hdb/map-loader.h


diff --git a/engines/hdb/map-loader.cpp b/engines/hdb/map-loader.cpp
index 0d105d8..f5e2fde 100644
--- a/engines/hdb/map-loader.cpp
+++ b/engines/hdb/map-loader.cpp
@@ -642,6 +642,20 @@ uint16 Map::getMapFGTileIndex(int x, int y) {
 	return _foreground[y * _width + x];
 }
 
+void Map::setMapBGTileIndex(int x, int y, int index) {
+	if (x < 0 || x >= _width || y < 0 || y >= _height) {
+		return;
+	}
+	_background[y * _width + x] = index;
+}
+
+void Map::setMapFGTileIndex(int x, int y, int index) {
+	if (x < 0 || x >= _width || y < 0 || y >= _height) {
+		return;
+	}
+	_foreground[y * _width + x] = index;
+}
+
 void Map::getMapXY(int *x, int *y) {
 	*x = _mapX;
 	*y = _mapY;
diff --git a/engines/hdb/map-loader.h b/engines/hdb/map-loader.h
index 12c481f..0e2f3d0 100644
--- a/engines/hdb/map-loader.h
+++ b/engines/hdb/map-loader.h
@@ -67,6 +67,9 @@ public:
 	uint32 getMapFGTileFlags(int x, int y);
 	uint16 getMapBGTileIndex(int x, int y);
 	uint16 getMapFGTileIndex(int x, int y);
+	void setMapBGTileIndex(int x, int y, int index);
+	void setMapFGTileIndex(int x, int y, int index);
+
 	void getMapXY(int *x, int *y);
 	void setMapXY(int x, int y);
 	void centerMapXY(int x, int y);


Commit: 244a51298f0edb6065964e5fef9d826d50574489
    https://github.com/scummvm/scummvm/commit/244a51298f0edb6065964e5fef9d826d50574489
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:16:53+02:00

Commit Message:
HDB: Add data for the Map Tile Animation Cycle

Changed paths:
    engines/hdb/map-loader.h


diff --git a/engines/hdb/map-loader.h b/engines/hdb/map-loader.h
index 0e2f3d0..dd13535 100644
--- a/engines/hdb/map-loader.h
+++ b/engines/hdb/map-loader.h
@@ -78,6 +78,14 @@ public:
 	int _mapTileX, _mapTileY; // Tile Coordinates of Map
 	int _mapTileXOff, _mapTileYOff; // Tile Coordinates Offset (0-31)
 
+	int _animCycle;	// Tile Animation Counter
+	Common::Array<uint32> _listBGAnimSlow;
+	Common::Array<uint32> _listBGAnimMedium;
+	Common::Array<uint32> _listBGAnimFast;
+	Common::Array<uint32> _listFGAnimSlow;
+	Common::Array<uint32> _listFGAnimMedium;
+	Common::Array<uint32> _listFGAnimFast;
+
 private:
 	char _name[32];
 	uint16 _width;


Commit: 04ff0635f13c9234b80311329ec26543842077ca
    https://github.com/scummvm/scummvm/commit/04ff0635f13c9234b80311329ec26543842077ca
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:16:53+02:00

Commit Message:
HDB: Add addBGTileAnimation and addFGTileAnimation

Changed paths:
    engines/hdb/map-loader.cpp
    engines/hdb/map-loader.h


diff --git a/engines/hdb/map-loader.cpp b/engines/hdb/map-loader.cpp
index f5e2fde..431ef6c 100644
--- a/engines/hdb/map-loader.cpp
+++ b/engines/hdb/map-loader.cpp
@@ -656,6 +656,38 @@ void Map::setMapFGTileIndex(int x, int y, int index) {
 	_foreground[y * _width + x] = index;
 }
 
+void Map::addBGTileAnimation(int x, int y) {
+
+	int i = y * _width + x;
+
+	uint32 flags = g_hdb->_drawMan->getTile(_background[i])->_flags;
+
+	// BACKGROUND
+	if (flags & kFlagAnimFast) {
+		_listBGAnimFast.push_back(i);
+	} else if (flags & kFlagAnimSlow) {
+		_listBGAnimSlow.push_back(i);
+	} else if (flags & kFlagAnimMedium) {
+		_listBGAnimMedium.push_back(i);
+	}
+}
+
+void Map::addFGTileAnimation(int x, int y) {
+
+	int i = y * _width + x;
+
+	uint32 flags = g_hdb->_drawMan->getTile(_foreground[i])->_flags;
+
+	// FOREGROUND
+	if (flags & kFlagAnimFast) {
+		_listFGAnimFast.push_back(i);
+	} else if (flags & kFlagAnimSlow) {
+		_listFGAnimSlow.push_back(i);
+	} else if (flags & kFlagAnimMedium) {
+		_listFGAnimMedium.push_back(i);
+	}
+}
+
 void Map::getMapXY(int *x, int *y) {
 	*x = _mapX;
 	*y = _mapY;
diff --git a/engines/hdb/map-loader.h b/engines/hdb/map-loader.h
index dd13535..158b5f9 100644
--- a/engines/hdb/map-loader.h
+++ b/engines/hdb/map-loader.h
@@ -69,6 +69,8 @@ public:
 	uint16 getMapFGTileIndex(int x, int y);
 	void setMapBGTileIndex(int x, int y, int index);
 	void setMapFGTileIndex(int x, int y, int index);
+	void addBGTileAnimation(int x, int y);
+	void addFGTileAnimation(int x, int y);
 
 	void getMapXY(int *x, int *y);
 	void setMapXY(int x, int y);


Commit: 198e26e652200b462ac1be7bb3f2f2250c2c2dbd
    https://github.com/scummvm/scummvm/commit/198e26e652200b462ac1be7bb3f2f2250c2c2dbd
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:16:53+02:00

Commit Message:
HDB: Add removeBG/FGTileAnimation()

Changed paths:
    engines/hdb/map-loader.cpp
    engines/hdb/map-loader.h


diff --git a/engines/hdb/map-loader.cpp b/engines/hdb/map-loader.cpp
index 431ef6c..c17a6f0 100644
--- a/engines/hdb/map-loader.cpp
+++ b/engines/hdb/map-loader.cpp
@@ -688,6 +688,58 @@ void Map::addFGTileAnimation(int x, int y) {
 	}
 }
 
+void Map::removeBGTileAnimation(int x, int y) {
+	int i = y * _width + x;
+
+	uint32 flags = g_hdb->_drawMan->getTile(_background[i])->_flags;
+
+	if (flags & kFlagAnimFast) {
+		for(Common::Array<uint32>::iterator it = _listBGAnimFast.begin(); it!=_listBGAnimFast.end(); it++)
+			if (i == (*it)) {
+				_listBGAnimFast.erase(it);
+				break;
+			}
+	} else if (flags & kFlagAnimSlow) {
+		for (Common::Array<uint32>::iterator it = _listBGAnimSlow.begin(); it != _listBGAnimSlow.end(); it++)
+			if (i == (*it)) {
+				_listBGAnimSlow.erase(it);
+				break;
+			}
+	} else if (flags & kFlagAnimMedium) {
+		for (Common::Array<uint32>::iterator it = _listBGAnimMedium.begin(); it != _listBGAnimMedium.end(); it++)
+			if (i == (*it)) {
+				_listBGAnimMedium.erase(it);
+				break;
+			}
+	}
+}
+
+void Map::removeFGTileAnimation(int x, int y) {
+	int i = y * _width + x;
+
+	uint32 flags = g_hdb->_drawMan->getTile(_foreground[i])->_flags;
+
+	if (flags & kFlagAnimFast) {
+		for(Common::Array<uint32>::iterator it = _listFGAnimFast.begin(); it!=_listFGAnimFast.end(); it++)
+			if (i == (*it)) {
+				_listFGAnimFast.erase(it);
+				break;
+			}
+	} else if (flags & kFlagAnimSlow) {
+		for (Common::Array<uint32>::iterator it = _listFGAnimSlow.begin(); it != _listFGAnimSlow.end(); it++)
+			if (i == (*it)) {
+				_listFGAnimSlow.erase(it);
+				break;
+			}
+	} else if (flags & kFlagAnimMedium) {
+		for (Common::Array<uint32>::iterator it = _listFGAnimMedium.begin(); it != _listFGAnimMedium.end(); it++)
+			if (i == (*it)) {
+				_listFGAnimMedium.erase(it);
+				break;
+			}
+	}
+}
+
 void Map::getMapXY(int *x, int *y) {
 	*x = _mapX;
 	*y = _mapY;
diff --git a/engines/hdb/map-loader.h b/engines/hdb/map-loader.h
index 158b5f9..9451b53 100644
--- a/engines/hdb/map-loader.h
+++ b/engines/hdb/map-loader.h
@@ -71,6 +71,8 @@ public:
 	void setMapFGTileIndex(int x, int y, int index);
 	void addBGTileAnimation(int x, int y);
 	void addFGTileAnimation(int x, int y);
+	void removeBGTileAnimation(int x, int y);
+	void removeFGTileAnimation(int x, int y);
 
 	void getMapXY(int *x, int *y);
 	void setMapXY(int x, int y);


Commit: 13c614bd3a14fed4ba7b3344a347c018468f3c5e
    https://github.com/scummvm/scummvm/commit/13c614bd3a14fed4ba7b3344a347c018468f3c5e
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:16:53+02:00

Commit Message:
HDB: Unstub setBackground() and setForeground()

Changed paths:
    engines/hdb/lua-script.cpp


diff --git a/engines/hdb/lua-script.cpp b/engines/hdb/lua-script.cpp
index 75f8a41..db66c23 100644
--- a/engines/hdb/lua-script.cpp
+++ b/engines/hdb/lua-script.cpp
@@ -417,12 +417,32 @@ static int clearForeground(lua_State *L) {
 }
 
 static int setForeground(lua_State *L) {
-	warning("STUB: SET FOREGROUND");
+	double x = lua_tonumber(L, 1);
+	double y = lua_tonumber(L, 2);
+	const char *tileName = lua_tostring(L, 3);
+
+	g_hdb->_lua->checkParameters("setForeground", 3);
+
+	lua_pop(L, 3);
+	int index = g_hdb->_drawMan->getTileIndex(tileName);
+	g_hdb->_drawMan->getTile(index);
+	g_hdb->_map->setMapFGTileIndex((int)x, (int)y, index);
+	g_hdb->_map->addFGTileAnimation((int)x, (int)y);
 	return 0;
 }
 
 static int setBackground(lua_State *L) {
-	warning("STUB: CLEAR BACKGROUND");
+	double x = lua_tonumber(L, 1);
+	double y = lua_tonumber(L, 2);
+	const char *tileName = lua_tostring(L, 3);
+
+	g_hdb->_lua->checkParameters("setBackground", 3);
+
+	lua_pop(L, 3);
+	int index = g_hdb->_drawMan->getTileIndex(tileName);
+	g_hdb->_drawMan->getTile(index);
+	g_hdb->_map->setMapBGTileIndex((int)x, (int)y, index);
+	g_hdb->_map->addBGTileAnimation((int)x, (int)y);
 	return 0;
 }
 


Commit: cad0e0bb9886f97c671368cf48df9735c1a7cbbc
    https://github.com/scummvm/scummvm/commit/cad0e0bb9886f97c671368cf48df9735c1a7cbbc
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:16:53+02:00

Commit Message:
HDB: Add cine clear FG, and set BG/FG functions

Changed paths:
    engines/hdb/ai-cinematic.cpp
    engines/hdb/ai.h


diff --git a/engines/hdb/ai-cinematic.cpp b/engines/hdb/ai-cinematic.cpp
index ee67737..d279050 100644
--- a/engines/hdb/ai-cinematic.cpp
+++ b/engines/hdb/ai-cinematic.cpp
@@ -365,4 +365,30 @@ void AI::cineFadeOut(bool isBlack, int steps) {
 	_cine.push_back(cmd);
 }
 
+void AI::cineClearForeground(int x, int y) {
+	CineCommand *cmd = new CineCommand;
+	cmd->x = x;
+	cmd->y = y;
+	cmd->cmdType = C_CLEAR_FG;
+	_cine.push_back(cmd);
+}
+
+void AI::cineSetBackground(int x, int y, int index) {
+	CineCommand *cmd = new CineCommand;
+	cmd->x = x;
+	cmd->y = y;
+	cmd->start = index;
+	cmd->cmdType = C_SET_BG;
+	_cine.push_back(cmd);
+}
+
+void AI::cineSetForeground(int x, int y, int index) {
+	CineCommand *cmd = new CineCommand;
+	cmd->x = x;
+	cmd->y = y;
+	cmd->start = index;
+	cmd->cmdType = C_SET_FG;
+	_cine.push_back(cmd);
+}
+
 } // End of Namespace
diff --git a/engines/hdb/ai.h b/engines/hdb/ai.h
index bbc8d78..dc0b37f 100644
--- a/engines/hdb/ai.h
+++ b/engines/hdb/ai.h
@@ -630,6 +630,9 @@ public:
 	void cineUse(const char *entName);
 	void cineFadeIn(bool isBlack, int steps);
 	void cineFadeOut(bool isBlack, int steps);
+	void cineClearForeground(int x, int y);
+	void cineSetBackground(int x, int y, int index);
+	void cineSetForeground(int x, int y, int index);
 
 	// Waypoint & Movement Functions
 	void lookAtXY(int x, int y);


Commit: 7dda9ea0204d6152015fa0ff4dd009d3d555a117
    https://github.com/scummvm/scummvm/commit/7dda9ea0204d6152015fa0ff4dd009d3d555a117
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:16:53+02:00

Commit Message:
HDB: Process C_CLEAR_FG, C_SET_FG, C_SET_BG

Changed paths:
    engines/hdb/ai-cinematic.cpp


diff --git a/engines/hdb/ai-cinematic.cpp b/engines/hdb/ai-cinematic.cpp
index d279050..c868e6b 100644
--- a/engines/hdb/ai-cinematic.cpp
+++ b/engines/hdb/ai-cinematic.cpp
@@ -231,6 +231,21 @@ void AI::processCines() {
 				complete = true;
 			}
 			break;
+		case C_CLEAR_FG:
+			g_hdb->_map->setMapFGTileIndex((int)_cine[i]->x, (int)_cine[i]->y, -1);
+			g_hdb->_map->removeFGTileAnimation((int)_cine[i]->x, (int)_cine[i]->y);
+			complete = true;
+			break;
+		case C_SET_BG:
+			g_hdb->_map->setMapBGTileIndex((int)_cine[i]->x, (int)_cine[i]->y, (int)_cine[i]->start);
+			g_hdb->_map->addBGTileAnimation((int)_cine[i]->x, (int)_cine[i]->y);
+			complete = true;
+			break;
+		case C_SET_FG:
+			g_hdb->_map->setMapFGTileIndex((int)_cine[i]->x, (int)_cine[i]->y, (int)_cine[i]->start);
+			g_hdb->_map->addFGTileAnimation((int)_cine[i]->x, (int)_cine[i]->y);
+			complete = true;
+			break;
 		default:
 			warning("STUB: AI::PROCESSCINES incomplete for %d", _cine[i]->cmdType);
 			break;


Commit: 223d024e307c7df461678c133f92b86cea3be8e5
    https://github.com/scummvm/scummvm/commit/223d024e307c7df461678c133f92b86cea3be8e5
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:16:53+02:00

Commit Message:
HDB: Unstub cine functions for fore/background

Changed paths:
    engines/hdb/lua-script.cpp


diff --git a/engines/hdb/lua-script.cpp b/engines/hdb/lua-script.cpp
index db66c23..9691763 100644
--- a/engines/hdb/lua-script.cpp
+++ b/engines/hdb/lua-script.cpp
@@ -288,17 +288,41 @@ static int cineSpawnEntity(lua_State *L) {
 }
 
 static int cineClearForeground(lua_State *L) {
-	warning("STUB: CINE CLEAR FOREGROUND");
+	double x = lua_tonumber(L, 1);
+	double y = lua_tonumber(L, 1);
+
+	g_hdb->_lua->checkParameters("cineClearForeground", 2);
+
+	lua_pop(L, 2);
+	g_hdb->_ai->cineClearForeground((int)x, (int)y);
 	return 0;
 }
 
 static int cineSetForeground(lua_State *L) {
-	warning("STUB: CINE SET FOREGROUND");
+	double x = lua_tonumber(L, 1);
+	double y = lua_tonumber(L, 1);
+	const char *tileName = lua_tostring(L, 3);
+
+	g_hdb->_lua->checkParameters("cineSetForeground", 3);
+
+	lua_pop(L, 3);
+	int index = g_hdb->_drawMan->getTileIndex(tileName);
+	g_hdb->_drawMan->getTile(index);
+	g_hdb->_ai->cineSetForeground((int)x, (int)y, index);
 	return 0;
 }
 
 static int cineSetBackground(lua_State *L) {
-	warning("STUB: CINE SET BACKGROUND");
+	double x = lua_tonumber(L, 1);
+	double y = lua_tonumber(L, 1);
+	const char *tileName = lua_tostring(L, 3);
+
+	g_hdb->_lua->checkParameters("cineSetBackground", 3);
+
+	lua_pop(L, 3);
+	int index = g_hdb->_drawMan->getTileIndex(tileName);
+	g_hdb->_drawMan->getTile(index);
+	g_hdb->_ai->cineSetBackground((int)x, (int)y, index);
 	return 0;
 }
 


Commit: fd8ad8e3da8e14d3e52504f2041e55f38cdc0985
    https://github.com/scummvm/scummvm/commit/fd8ad8e3da8e14d3e52504f2041e55f38cdc0985
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:16:53+02:00

Commit Message:
HDB: Fix signed/unsigned mismatch warnings

Changed paths:
    engines/hdb/map-loader.cpp


diff --git a/engines/hdb/map-loader.cpp b/engines/hdb/map-loader.cpp
index c17a6f0..3b2fbe3 100644
--- a/engines/hdb/map-loader.cpp
+++ b/engines/hdb/map-loader.cpp
@@ -695,19 +695,19 @@ void Map::removeBGTileAnimation(int x, int y) {
 
 	if (flags & kFlagAnimFast) {
 		for(Common::Array<uint32>::iterator it = _listBGAnimFast.begin(); it!=_listBGAnimFast.end(); it++)
-			if (i == (*it)) {
+			if ((uint)i == (*it)) {
 				_listBGAnimFast.erase(it);
 				break;
 			}
 	} else if (flags & kFlagAnimSlow) {
 		for (Common::Array<uint32>::iterator it = _listBGAnimSlow.begin(); it != _listBGAnimSlow.end(); it++)
-			if (i == (*it)) {
+			if ((uint)i == (*it)) {
 				_listBGAnimSlow.erase(it);
 				break;
 			}
 	} else if (flags & kFlagAnimMedium) {
 		for (Common::Array<uint32>::iterator it = _listBGAnimMedium.begin(); it != _listBGAnimMedium.end(); it++)
-			if (i == (*it)) {
+			if ((uint)i == (*it)) {
 				_listBGAnimMedium.erase(it);
 				break;
 			}
@@ -721,19 +721,19 @@ void Map::removeFGTileAnimation(int x, int y) {
 
 	if (flags & kFlagAnimFast) {
 		for(Common::Array<uint32>::iterator it = _listFGAnimFast.begin(); it!=_listFGAnimFast.end(); it++)
-			if (i == (*it)) {
+			if ((uint)i == (*it)) {
 				_listFGAnimFast.erase(it);
 				break;
 			}
 	} else if (flags & kFlagAnimSlow) {
 		for (Common::Array<uint32>::iterator it = _listFGAnimSlow.begin(); it != _listFGAnimSlow.end(); it++)
-			if (i == (*it)) {
+			if ((uint)i == (*it)) {
 				_listFGAnimSlow.erase(it);
 				break;
 			}
 	} else if (flags & kFlagAnimMedium) {
 		for (Common::Array<uint32>::iterator it = _listFGAnimMedium.begin(); it != _listFGAnimMedium.end(); it++)
-			if (i == (*it)) {
+			if ((uint)i == (*it)) {
 				_listFGAnimMedium.erase(it);
 				break;
 			}


Commit: 1cae287783814cbfa4b11b4f1fecdd3b7b566c39
    https://github.com/scummvm/scummvm/commit/1cae287783814cbfa4b11b4f1fecdd3b7b566c39
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:16:53+02:00

Commit Message:
HDB: Modify getTileIndex to accept NULL input

Changed paths:
    engines/hdb/draw-manager.cpp


diff --git a/engines/hdb/draw-manager.cpp b/engines/hdb/draw-manager.cpp
index b59b86f..afc6b43 100644
--- a/engines/hdb/draw-manager.cpp
+++ b/engines/hdb/draw-manager.cpp
@@ -154,6 +154,9 @@ Tile *DrawMan::getTile(int index) {
 }
 
 int DrawMan::getTileIndex(const char *name) {
+	if (!name) {
+		return -1;
+	}
 	for (int i = 0; i < _numTiles; i++) {
 		if (Common::matchString(_tLookupArray[i].filename, name)) {
 			return i;


Commit: 3969a805abd803bb52b3589aa20f79654a8ea3e1
    https://github.com/scummvm/scummvm/commit/3969a805abd803bb52b3589aa20f79654a8ea3e1
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:16:53+02:00

Commit Message:
HDB: Add AIEntLevel2 data

Addition includes constants, structs and a
pointer array

Changed paths:
    engines/hdb/ai.h


diff --git a/engines/hdb/ai.h b/engines/hdb/ai.h
index dc0b37f..6994a81 100644
--- a/engines/hdb/ai.h
+++ b/engines/hdb/ai.h
@@ -30,6 +30,7 @@ namespace HDB {
 enum {
 	kMaxAnimFrames = 8,
 	kMaxDeathFrames = 12,
+	kMaxLevel2Ents = 60,
 	kMaxInventory = 10,
 	kMaxDeliveries = 5,
 	kMaxWaypoints = 10,
@@ -508,6 +509,17 @@ struct InvEnt {
 	InvEnt() : keep(0), ent(NULL) {}
 };
 
+struct AIEntLevel2 {
+	uint16 x;
+	uint16 y;
+	Tile *draw;
+	AIEntity *e;
+	void(*aiDraw)(AIEntity *e, int x, int y);
+	uint32 stunnedWait;
+
+	AIEntLevel2() : x(0), y(0), draw(NULL), e(NULL), aiDraw(NULL), stunnedWait(0) {}
+};
+
 struct Waypoint {
 	int x, y, level;
 
@@ -718,6 +730,9 @@ public:
 	int _numGooCups;
 	int _numMonkeystones;
 
+	AIEntLevel2 *_entsLevel2[kMaxLevel2Ents];
+	int _numLevel2Ents;
+
 	InvEnt *_inventory[kMaxInventory];
 	int _numInventory;
 


Commit: ffa56e7c4b98fc72f40ac45bb2ec77b4f3194a59
    https://github.com/scummvm/scummvm/commit/ffa56e7c4b98fc72f40ac45bb2ec77b4f3194a59
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:16:53+02:00

Commit Message:
HDB: Fix type of *draw

Changed paths:
    engines/hdb/ai-waypoint.cpp
    engines/hdb/ai.h


diff --git a/engines/hdb/ai-waypoint.cpp b/engines/hdb/ai-waypoint.cpp
index 88a0c44..3887b97 100644
--- a/engines/hdb/ai-waypoint.cpp
+++ b/engines/hdb/ai-waypoint.cpp
@@ -29,7 +29,7 @@ void AI::clearWaypoints() {
 	_numWaypoints = 0;
 }
 
-void *AI::getStandFrameDir(AIEntity *e) {
+Tile *AI::getStandFrameDir(AIEntity *e) {
 	switch (e->dir) {
 	case DIR_DOWN:
 		if (e->standdownFrames)
diff --git a/engines/hdb/ai.h b/engines/hdb/ai.h
index 6994a81..ad5e43c 100644
--- a/engines/hdb/ai.h
+++ b/engines/hdb/ai.h
@@ -341,7 +341,7 @@ struct AIEntity {
 	AIState state;
 	AIDir dir;
 
-	void *draw;											// Current frame to draw
+	Tile *draw;											// Current frame to draw
 
 	void (*aiInit)(AIEntity *e);						// func ptr to init routine
 	void (*aiInit2)(AIEntity *e);						// func ptr to init2 routine - graphic init only (this for LoadGame functionality)
@@ -649,7 +649,7 @@ public:
 	// Waypoint & Movement Functions
 	void lookAtXY(int x, int y);
 	void clearWaypoints();
-	void *getStandFrameDir(AIEntity *e);
+	Tile *getStandFrameDir(AIEntity *e);
 
 	// Inventory Functions
 	bool addToInventory(AIEntity *e);


Commit: 18763082bffe9e8702211e662bf246af2948dd0c
    https://github.com/scummvm/scummvm/commit/18763082bffe9e8702211e662bf246af2948dd0c
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:16:53+02:00

Commit Message:
HDB: Add stubbed AI::drawEnts()

Changed paths:
    engines/hdb/ai-funcs.cpp
    engines/hdb/ai.h


diff --git a/engines/hdb/ai-funcs.cpp b/engines/hdb/ai-funcs.cpp
index 0da3867..5105aa7 100644
--- a/engines/hdb/ai-funcs.cpp
+++ b/engines/hdb/ai-funcs.cpp
@@ -921,6 +921,85 @@ void AI::animLuaEntity(const char *initName, AIState st) {
 	}
 }
 
+void AI::drawEnts(int x, int y, int w, int h) {
+
+	static int stunAnim = 0;
+
+	// Draw Floating Entities
+	warning("STUB: AI::drawEnts: Draw Floating Entities");
+
+	// Draw all other Ents
+	_numLevel2Ents = 0;
+
+	for (Common::Array<AIEntity *>::iterator it = _ents->begin(); it != _ents->end(); it++) {
+		AIEntity *e = (*it);
+		if (e->type == AI_LASER || e->type == AI_DIVERTER) {
+			if (e->aiDraw) {
+				if (e->level == 2 && _numLevel2Ents < kMaxLevel2Ents) {
+					_entsLevel2[_numLevel2Ents]->aiDraw = e->aiDraw;
+					_entsLevel2[_numLevel2Ents]->x = x;
+					_entsLevel2[_numLevel2Ents]->y = y;
+					_entsLevel2[_numLevel2Ents]->e = e;
+					_entsLevel2[_numLevel2Ents]->stunnedWait = 0;
+					_numLevel2Ents++;
+				} else {
+					e->aiDraw(e, x, y);
+				}
+			}
+		}
+
+		if ((e->x > x - kTileWidth) && (e->x < x + w) && (e->y > y - kTileHeight) && (e->y < y + h)) {
+			// If extra drawing func is present, call it
+			if (e->aiDraw && e->type != AI_LASER && e->type != AI_DIVERTER) {
+				if (e->level == 2 && _numLevel2Ents < kMaxLevel2Ents) {
+					_entsLevel2[_numLevel2Ents]->aiDraw = e->aiDraw;
+					_entsLevel2[_numLevel2Ents]->draw = e->draw;
+					_entsLevel2[_numLevel2Ents]->x = x;
+					_entsLevel2[_numLevel2Ents]->y = y;
+					_entsLevel2[_numLevel2Ents]->e = e;
+					_entsLevel2[_numLevel2Ents]->stunnedWait = 0;
+					_numLevel2Ents++;
+				} else
+					e->aiDraw(e, x, y);
+			}
+
+			switch (e->type) {
+			case AI_VORTEXIAN:
+				warning("STUB: AI::drawEnts: Tile Alpha Blitting required");
+				break;
+			case AI_GUY: // Draw Player Last
+				break;
+			default:
+				if (e->level == 2 && _numLevel2Ents < kMaxLevel2Ents) {
+					_entsLevel2[_numLevel2Ents]->aiDraw = NULL;
+					_entsLevel2[_numLevel2Ents]->draw = e->draw;
+					_entsLevel2[_numLevel2Ents]->x = e->x - x + e->drawXOff;
+					_entsLevel2[_numLevel2Ents]->y = e->y - y + e->drawYOff;
+					_entsLevel2[_numLevel2Ents]->e = NULL;
+					_entsLevel2[_numLevel2Ents]->stunnedWait = e->stunnedWait;
+					_numLevel2Ents++;
+				} else {
+					if (e->draw)
+						e->draw->drawMasked(e->x - x + e->drawXOff, e->y - y + e->drawYOff);
+
+					if (e->stunnedWait)
+						g_hdb->_ai->_stunnedGfx[stunAnim]->drawMasked(e->x - x, e->y - y);
+				}
+				break;
+			}
+			e->onScreen = 1;
+		} else
+			e->onScreen = 0;
+	}
+
+	warning("STUB: AI::drawEnts: Increment Stun Timer");
+
+	// Draw player last
+	if (_player && _player->level < 2 && !_playerInvisible && _player->draw) {
+		_player->draw->drawMasked(_player->x - x + _player->drawXOff, _player->y - y + _player->drawYOff);
+	}
+}
+
 // Check to see if we can get this entity
 bool AI::getTableEnt(AIType type) {
 	switch (type) {
diff --git a/engines/hdb/ai.h b/engines/hdb/ai.h
index ad5e43c..6ab3a8b 100644
--- a/engines/hdb/ai.h
+++ b/engines/hdb/ai.h
@@ -563,6 +563,7 @@ public:
 
 	void animEntFrames(AIEntity *e);
 	void animLuaEntity(const char *initName, AIState st);
+	void drawEnts(int x, int y, int w, int h);
 
 	bool getTableEnt(AIType type);
 	bool walkThroughEnt(AIType type);


Commit: edb6133e42f2d701e16ad4bf1c2b9a144827ad5a
    https://github.com/scummvm/scummvm/commit/edb6133e42f2d701e16ad4bf1c2b9a144827ad5a
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:16:53+02:00

Commit Message:
HDB: Add Map::drawEnts()

Changed paths:
    engines/hdb/map-loader.cpp
    engines/hdb/map-loader.h


diff --git a/engines/hdb/map-loader.cpp b/engines/hdb/map-loader.cpp
index 3b2fbe3..dff7f0a 100644
--- a/engines/hdb/map-loader.cpp
+++ b/engines/hdb/map-loader.cpp
@@ -81,7 +81,6 @@ bool Map::load(Common::SeekableReadStream *stream) {
 		Common::hexdump((const byte *)_background, 512);
 	}
 
-
 	// Reading Foreground
 	_foreground = new uint16[_width * _height];
 	stream->seek(_foregroundOffset);
@@ -614,6 +613,10 @@ void Map::draw() {
 	*/
 }
 
+void Map::drawEnts() {
+	g_hdb->_ai->drawEnts(_mapX, _mapY, kScreenXTiles * kTileWidth, kScreenYTiles * kTileHeight);
+}
+
 uint32 Map::getMapBGTileFlags(int x, int y) {
 	if (x < 0 || x >= _width || y < 0 || y >= _height) {
 		return 0;
diff --git a/engines/hdb/map-loader.h b/engines/hdb/map-loader.h
index 9451b53..9a44cd0 100644
--- a/engines/hdb/map-loader.h
+++ b/engines/hdb/map-loader.h
@@ -62,6 +62,7 @@ public:
 	int loadTiles();
 	bool load(Common::SeekableReadStream *stream);
 	void draw();
+	void drawEnts();
 
 	uint32 getMapBGTileFlags(int x, int y);
 	uint32 getMapFGTileFlags(int x, int y);


Commit: 80b76d24f8d26eb3463a9719f83d357efbd6a258
    https://github.com/scummvm/scummvm/commit/80b76d24f8d26eb3463a9719f83d357efbd6a258
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:16:53+02:00

Commit Message:
HDB: Add animating tile lists to Map::load

Changed paths:
    engines/hdb/map-loader.cpp


diff --git a/engines/hdb/map-loader.cpp b/engines/hdb/map-loader.cpp
index dff7f0a..b04becc 100644
--- a/engines/hdb/map-loader.cpp
+++ b/engines/hdb/map-loader.cpp
@@ -126,9 +126,11 @@ bool Map::load(Common::SeekableReadStream *stream) {
 	g_hdb->_drawMan->setSky(sky);
 	_mapX = _mapY = 0;
 
-	/*
-		TODO: Add the animating tile lists
-	*/
+	// Setup animating Tile lists
+	for (int i = 0; i < _width*_height;i++) {
+		addBGTileAnimation(i % _width, i / _width);
+		addFGTileAnimation(i % _width, i / _width);
+	}
 
 	struct {
 		AIType type;


Commit: cb341ee6cc9ef0d6a3e28584b13e1ab8797dd840
    https://github.com/scummvm/scummvm/commit/cb341ee6cc9ef0d6a3e28584b13e1ab8797dd840
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:16:53+02:00

Commit Message:
HDB: Add FPS and AnimDelay constants

Changed paths:
    engines/hdb/hdb.h


diff --git a/engines/hdb/hdb.h b/engines/hdb/hdb.h
index 76b13f1..ede41ba 100644
--- a/engines/hdb/hdb.h
+++ b/engines/hdb/hdb.h
@@ -81,7 +81,12 @@ enum Flag {
 
 enum {
 	kScreenWidth = 640,
-	kScreenHeight = 480
+	kScreenHeight = 480,
+	kGameFPS = 60,
+	kAnimFrameDelay = kGameFPS / 30,
+	kAnimSlowFrames = kAnimFrameDelay * 10,
+	kAnimMediumFrames = kAnimFrameDelay * 6,
+	kAnimFastFrames = kAnimFrameDelay * 2
 };
 
 class HDBGame : public Engine {


Commit: 94d443bfa8bb14b8b2ea8a10bd8a5c085268be76
    https://github.com/scummvm/scummvm/commit/94d443bfa8bb14b8b2ea8a10bd8a5c085268be76
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:16:54+02:00

Commit Message:
HDB: Add animateTile()

Changed paths:
    engines/hdb/draw-manager.cpp
    engines/hdb/draw-manager.h


diff --git a/engines/hdb/draw-manager.cpp b/engines/hdb/draw-manager.cpp
index afc6b43..97a4cca 100644
--- a/engines/hdb/draw-manager.cpp
+++ b/engines/hdb/draw-manager.cpp
@@ -377,6 +377,10 @@ void DrawMan::drawSky() {
 	}
 }
 
+int DrawMan::animateTile(int tileIndex) {
+	return _tLookupArray[tileIndex].animIndex;
+}
+
 Picture::Picture() : _width(0), _height(0), _name("") {
 	_surface.create(_width, _height, g_hdb->_format);
 }
diff --git a/engines/hdb/draw-manager.h b/engines/hdb/draw-manager.h
index 69d44ae..3f97d1b 100644
--- a/engines/hdb/draw-manager.h
+++ b/engines/hdb/draw-manager.h
@@ -95,6 +95,8 @@ public:
 	void draw3DStarsLeft();
 	void drawSky();
 
+	int animateTile(int tileIndex);
+
 private:
 	int _numTiles;
 	TileLookup *_tLookupArray;


Commit: e4edb7dc507e579484d1ad5abdb9edf59e2379fc
    https://github.com/scummvm/scummvm/commit/e4edb7dc507e579484d1ad5abdb9edf59e2379fc
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:16:54+02:00

Commit Message:
HDB: Add Foreground data

Addition includes constants, struct and member
variables

Changed paths:
    engines/hdb/map-loader.cpp
    engines/hdb/map-loader.h


diff --git a/engines/hdb/map-loader.cpp b/engines/hdb/map-loader.cpp
index b04becc..b54953ef 100644
--- a/engines/hdb/map-loader.cpp
+++ b/engines/hdb/map-loader.cpp
@@ -26,6 +26,24 @@ namespace HDB {
 
 Map::Map() {
 	_mapLoaded = false;
+
+	for (int i = 0; i < kMaxGratings;i++) {
+		_gratings[i] = new Foreground;
+	}
+
+	for (int i = 0; i < kMaxForegrounds;i++) {
+		_foregrounds[i] = new Foreground;
+	}
+}
+
+Map::~Map() {
+	for (int i = 0; i < kMaxGratings;i++) {
+		delete _gratings[i];
+	}
+
+	for (int i = 0; i < kMaxForegrounds;i++) {
+		delete _foregrounds[i];
+	}
 }
 
 int Map::loadTiles() {
diff --git a/engines/hdb/map-loader.h b/engines/hdb/map-loader.h
index 9a44cd0..8ee0760 100644
--- a/engines/hdb/map-loader.h
+++ b/engines/hdb/map-loader.h
@@ -29,7 +29,9 @@ namespace HDB {
 
 enum {
 	kScreenXTiles = 17,
-	kScreenYTiles = 16
+	kScreenYTiles = 16,
+	kMaxGratings = 250,
+	kMaxForegrounds = 250
 };
 
 struct MSMIcon {
@@ -47,6 +49,14 @@ struct MSMIcon {
 	MSMIcon(): icon(0), x(0), y(0), funcInit(""), funcAction(""), funcUse(""), dir(0), level(0), value1(0), value2(0) {}
 };
 
+struct Foreground {
+	uint16 x;
+	uint16 y;
+	uint16 tile;
+
+	Foreground() : x(0), y(0), tile(0) {}
+};
+
 struct SeeThroughTile {
 	uint16 x;
 	uint16 y;
@@ -58,6 +68,7 @@ struct SeeThroughTile {
 class Map {
 public:
 	Map();
+	~Map();
 
 	int loadTiles();
 	bool load(Common::SeekableReadStream *stream);
@@ -83,6 +94,9 @@ public:
 	int _mapTileX, _mapTileY; // Tile Coordinates of Map
 	int _mapTileXOff, _mapTileYOff; // Tile Coordinates Offset (0-31)
 
+	Foreground *_gratings[kMaxGratings], *_foregrounds[kMaxForegrounds];
+	int _numGratings, _numForegrounds;
+
 	int _animCycle;	// Tile Animation Counter
 	Common::Array<uint32> _listBGAnimSlow;
 	Common::Array<uint32> _listBGAnimMedium;


Commit: 4d57cefb6c0dec864434750f0931ddc6752a30d0
    https://github.com/scummvm/scummvm/commit/4d57cefb6c0dec864434750f0931ddc6752a30d0
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:16:54+02:00

Commit Message:
HDB: Unstub Gratings and Foregrounds check

Changed paths:
    engines/hdb/map-loader.cpp


diff --git a/engines/hdb/map-loader.cpp b/engines/hdb/map-loader.cpp
index b54953ef..837597e 100644
--- a/engines/hdb/map-loader.cpp
+++ b/engines/hdb/map-loader.cpp
@@ -578,6 +578,8 @@ void Map::draw() {
 		return;
 	}
 
+	_numForegrounds = _numGratings = 0;
+
 	for (int j = 0; j < maxTileY; j++) {
 		screenX = _mapTileXOff;
 		for (int i = 0; i < maxTileX; i++) {
@@ -599,21 +601,22 @@ void Map::draw() {
 				Tile *fTile = g_hdb->_drawMan->getTile(tileIndex);
 				if (fTile && !(fTile->_flags & kFlagInvisible)) {
 
-					if ((fTile->_flags & kFlagGrating)) {
-						/*
-						TODO: Implement Gratings Check
-						*/
-						debug(9, "STUB: Map::draw: Gratings Check not found");
+					if ((fTile->_flags & kFlagGrating) && (_numGratings < kMaxGratings)) {
+						// Check for Gratings Flag
+						_gratings[_numGratings]->x = screenX;
+						_gratings[_numGratings]->y = screenY;
+						_gratings[_numGratings]->tile = tileIndex;
+						if (_numGratings < kMaxGratings)
+							_numGratings++;
 					} else if ((fTile->_flags & kFlagForeground)) {
-						/*
-						TODO: Implement Gratings Check
-						*/
-						debug(9, "STUB: Map::draw: Foreground Check not found");
+						// Check for Foregrounds Flag
+						_foregrounds[_numForegrounds]->x = screenX;
+						_foregrounds[_numForegrounds]->y = screenY;
+						_foregrounds[_numForegrounds]->tile = tileIndex;
+						if (_numForegrounds < kMaxForegrounds)
+							_numForegrounds++;
 					} else {
 						if (fTile->_flags & kFlagMasked) {
-							/*
-								TODO: Implement MaskedMapTile drawing
-							*/
 							fTile->drawMasked(screenX, screenY);
 						} else {
 							fTile->draw(screenX, screenY);


Commit: 76e4758b2b1551a7354f72f416f6a23ab49eb754
    https://github.com/scummvm/scummvm/commit/76e4758b2b1551a7354f72f416f6a23ab49eb754
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:16:54+02:00

Commit Message:
HDB: Unstub Animated Map Tiles

Changed paths:
    engines/hdb/map-loader.cpp


diff --git a/engines/hdb/map-loader.cpp b/engines/hdb/map-loader.cpp
index 837597e..249c52a 100644
--- a/engines/hdb/map-loader.cpp
+++ b/engines/hdb/map-loader.cpp
@@ -631,9 +631,40 @@ void Map::draw() {
 		screenY += kTileWidth;
 	}
 
-	/*
-		TODO: Implement animated Map Tiles
-	*/
+	// Animate FAST Map Tiles
+	if (!(_animCycle % kAnimFastFrames)) {
+		for (Common::Array<uint32>::iterator it = _listBGAnimFast.begin(); it != _listBGAnimFast.end(); it++) {
+			_background[(*it)] = g_hdb->_drawMan->animateTile(_background[(*it)]);
+		}
+
+		for (Common::Array<uint32>::iterator it = _listFGAnimFast.begin(); it != _listFGAnimFast.end(); it++) {
+			_foreground[(*it)] = g_hdb->_drawMan->animateTile(_foreground[(*it)]);
+		}
+	}
+
+	// Animate MEDIUM Map Tiles
+	if (!(_animCycle % kAnimFastFrames)) {
+		for (Common::Array<uint32>::iterator it = _listBGAnimMedium.begin(); it != _listBGAnimMedium.end(); it++) {
+			_background[(*it)] = g_hdb->_drawMan->animateTile(_background[(*it)]);
+		}
+
+		for (Common::Array<uint32>::iterator it = _listFGAnimMedium.begin(); it != _listFGAnimMedium.end(); it++) {
+			_foreground[(*it)] = g_hdb->_drawMan->animateTile(_foreground[(*it)]);
+		}
+	}
+
+	// Animate SLOW Map Tiles
+	if (!(_animCycle % kAnimFastFrames)) {
+		for (Common::Array<uint32>::iterator it = _listBGAnimSlow.begin(); it != _listBGAnimSlow.end(); it++) {
+			_background[(*it)] = g_hdb->_drawMan->animateTile(_background[(*it)]);
+		}
+
+		for (Common::Array<uint32>::iterator it = _listFGAnimSlow.begin(); it != _listFGAnimSlow.end(); it++) {
+			_foreground[(*it)] = g_hdb->_drawMan->animateTile(_foreground[(*it)]);
+		}
+	}
+
+	_animCycle++;
 }
 
 void Map::drawEnts() {


Commit: 60b4c33a9c5643322f093b62e2df8985705bbbb6
    https://github.com/scummvm/scummvm/commit/60b4c33a9c5643322f093b62e2df8985705bbbb6
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:16:54+02:00

Commit Message:
HDB: Add NULL check to BG/FG tile animation

Changed paths:
    engines/hdb/map-loader.cpp


diff --git a/engines/hdb/map-loader.cpp b/engines/hdb/map-loader.cpp
index 249c52a..dfbd1a8 100644
--- a/engines/hdb/map-loader.cpp
+++ b/engines/hdb/map-loader.cpp
@@ -717,7 +717,10 @@ void Map::addBGTileAnimation(int x, int y) {
 
 	int i = y * _width + x;
 
-	uint32 flags = g_hdb->_drawMan->getTile(_background[i])->_flags;
+	Tile *tile = g_hdb->_drawMan->getTile(_background[i]);
+	if (!tile)
+		return;
+	uint32 flags = tile->_flags;
 
 	// BACKGROUND
 	if (flags & kFlagAnimFast) {
@@ -733,7 +736,10 @@ void Map::addFGTileAnimation(int x, int y) {
 
 	int i = y * _width + x;
 
-	uint32 flags = g_hdb->_drawMan->getTile(_foreground[i])->_flags;
+	Tile *tile = g_hdb->_drawMan->getTile(_foreground[i]);
+	if (!tile)
+		return;
+	uint32 flags = tile->_flags;
 
 	// FOREGROUND
 	if (flags & kFlagAnimFast) {
@@ -748,7 +754,10 @@ void Map::addFGTileAnimation(int x, int y) {
 void Map::removeBGTileAnimation(int x, int y) {
 	int i = y * _width + x;
 
-	uint32 flags = g_hdb->_drawMan->getTile(_background[i])->_flags;
+	Tile *tile = g_hdb->_drawMan->getTile(_background[i]);
+	if (!tile)
+		return;
+	uint32 flags = tile->_flags;
 
 	if (flags & kFlagAnimFast) {
 		for(Common::Array<uint32>::iterator it = _listBGAnimFast.begin(); it!=_listBGAnimFast.end(); it++)
@@ -774,7 +783,10 @@ void Map::removeBGTileAnimation(int x, int y) {
 void Map::removeFGTileAnimation(int x, int y) {
 	int i = y * _width + x;
 
-	uint32 flags = g_hdb->_drawMan->getTile(_foreground[i])->_flags;
+	Tile *tile = g_hdb->_drawMan->getTile(_foreground[i]);
+	if (!tile)
+		return;
+	uint32 flags = tile->_flags;
 
 	if (flags & kFlagAnimFast) {
 		for(Common::Array<uint32>::iterator it = _listFGAnimFast.begin(); it!=_listFGAnimFast.end(); it++)


Commit: 4d22df8037f6e7da6c3df5ca342b631b67fe40d9
    https://github.com/scummvm/scummvm/commit/4d22df8037f6e7da6c3df5ca342b631b67fe40d9
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:16:54+02:00

Commit Message:
HDB: Add drawForegrounds() and drawGratings()

Changed paths:
    engines/hdb/map-loader.cpp
    engines/hdb/map-loader.h


diff --git a/engines/hdb/map-loader.cpp b/engines/hdb/map-loader.cpp
index dfbd1a8..0e18a71e 100644
--- a/engines/hdb/map-loader.cpp
+++ b/engines/hdb/map-loader.cpp
@@ -671,6 +671,22 @@ void Map::drawEnts() {
 	g_hdb->_ai->drawEnts(_mapX, _mapY, kScreenXTiles * kTileWidth, kScreenYTiles * kTileHeight);
 }
 
+void Map::drawGratings() {
+	for (int i = 0; i < kMaxGratings;i++) {
+		g_hdb->_drawMan->getTile(_gratings[i]->tile)->drawMasked(_gratings[i]->x, _gratings[i]->y);
+	}
+
+	debug(1, "Gratings Count: %d", _numGratings);
+}
+
+void Map::drawForegrounds() {
+	for (int i = 0; i < kMaxForegrounds;i++) {
+		g_hdb->_drawMan->getTile(_foregrounds[i]->tile)->drawMasked(_foregrounds[i]->x, _foregrounds[i]->y);
+	}
+
+	debug(1, "Foregrounds Count: %d", _numForegrounds);
+}
+
 uint32 Map::getMapBGTileFlags(int x, int y) {
 	if (x < 0 || x >= _width || y < 0 || y >= _height) {
 		return 0;
diff --git a/engines/hdb/map-loader.h b/engines/hdb/map-loader.h
index 8ee0760..da8b7d6 100644
--- a/engines/hdb/map-loader.h
+++ b/engines/hdb/map-loader.h
@@ -74,6 +74,8 @@ public:
 	bool load(Common::SeekableReadStream *stream);
 	void draw();
 	void drawEnts();
+	void drawGratings();
+	void drawForegrounds();
 
 	uint32 getMapBGTileFlags(int x, int y);
 	uint32 getMapFGTileFlags(int x, int y);


Commit: aec87e7058c788e7d37d1e639056d616b1ff56e2
    https://github.com/scummvm/scummvm/commit/aec87e7058c788e7d37d1e639056d616b1ff56e2
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:16:54+02:00

Commit Message:
HDB: Add _floats data

Addition includes struct and member variables

Changed paths:
    engines/hdb/ai-init.cpp
    engines/hdb/ai.h


diff --git a/engines/hdb/ai-init.cpp b/engines/hdb/ai-init.cpp
index 183f028..e03f456 100644
--- a/engines/hdb/ai-init.cpp
+++ b/engines/hdb/ai-init.cpp
@@ -668,12 +668,22 @@ AIEntTypeInfo aiEntList[] = {
 
 AI::AI() {
 	_ents = new Common::Array<AIEntity *>;
+	_floats = new Common::Array<AIEntity *>;
+
+	for (int i = 0; i < kMaxLevel2Ents;i++) {
+		_entsLevel2[i] = new AIEntLevel2;
+	}
+
 	// REMOVE: Remove for final. Used here due to lack of a MENU
 	_numGems = _numGooCups = _numMonkeystones = _numInventory = 0;
 }
 
 AI::~AI() {
 	delete _ents;
+	delete _floats;
+	for (int i = 0; i < kMaxLevel2Ents;i++) {
+		delete _entsLevel2[i];
+	}
 }
 
 bool AI::init() {
diff --git a/engines/hdb/ai.h b/engines/hdb/ai.h
index 6ab3a8b..c29f1c8 100644
--- a/engines/hdb/ai.h
+++ b/engines/hdb/ai.h
@@ -747,6 +747,7 @@ public:
 private:
 
 	Common::Array<AIEntity *> *_ents;
+	Common::Array<AIEntity *> *_floats;
 	AIEntity *_player;
 
 	// Cinematics Variables


Commit: b913a3632d80dfed276c325de8cae622f35873ff
    https://github.com/scummvm/scummvm/commit/b913a3632d80dfed276c325de8cae622f35873ff
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:16:54+02:00

Commit Message:
HDB: Add time-keeping functions

Changed paths:
    engines/hdb/hdb.cpp
    engines/hdb/hdb.h


diff --git a/engines/hdb/hdb.cpp b/engines/hdb/hdb.cpp
index 018e1e5..bea2c7e 100644
--- a/engines/hdb/hdb.cpp
+++ b/engines/hdb/hdb.cpp
@@ -288,6 +288,11 @@ Common::Error HDBGame::run() {
 		_drawMan->drawSky();
 		_map->draw();
 		_ai->processCines();
+
+		// Update Timer that's NOT used for in-game Timing
+		_prevTimeSlice = _timeSlice;
+		_timeSlice = g_system->getMillis();
+
 		paint();
 
 		g_system->updateScreen();
diff --git a/engines/hdb/hdb.h b/engines/hdb/hdb.h
index ede41ba..b748101 100644
--- a/engines/hdb/hdb.h
+++ b/engines/hdb/hdb.h
@@ -134,10 +134,31 @@ public:
 		_actionMode = status;
 	}
 
+	void resetTimer() {
+		_timePlayed = _timeSeconds = 0;
+	}
+
+	uint16 getTime() {
+		return _timePlayed / 1000;
+	}
+
+	uint16 getTimeSlice() {
+		return _timeSlice;
+	}
+
+	uint16 getTimeSliceDelta() {
+		return _timeSlice - _prevTimeSlice;
+	}
+
 	bool _gameShutdown;
 	Graphics::PixelFormat _format;
 
 private:
+
+	uint32 _timePlayed;
+	uint32 _timeSlice, _prevTimeSlice;
+	uint32 _timeSeconds;
+
 	Console *_console;
 
 	// Game Variables


Commit: a56dca47f85cc12b60ed3a3702fd5ac44a337b4e
    https://github.com/scummvm/scummvm/commit/a56dca47f85cc12b60ed3a3702fd5ac44a337b4e
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:16:54+02:00

Commit Message:
HDB: Unstub 'Draw Floating Entities'

Changed paths:
    engines/hdb/ai-funcs.cpp


diff --git a/engines/hdb/ai-funcs.cpp b/engines/hdb/ai-funcs.cpp
index 5105aa7..32bd8a6 100644
--- a/engines/hdb/ai-funcs.cpp
+++ b/engines/hdb/ai-funcs.cpp
@@ -926,7 +926,18 @@ void AI::drawEnts(int x, int y, int w, int h) {
 	static int stunAnim = 0;
 
 	// Draw Floating Entities
-	warning("STUB: AI::drawEnts: Draw Floating Entities");
+	for (Common::Array<AIEntity *>::iterator it = _floats->begin(); it != _floats->end(); it++) {
+		AIEntity *e = (*it);
+		if (e->aiDraw) {
+			e->aiDraw(e, x, y);
+		}
+
+		if ((e->x > x - kTileWidth) && (e->x < x + w) && (e->y > y - kTileHeight) && (e->y < y + h)) {
+			e->draw->drawMasked(e->x - x + e->drawXOff, e->y - y + e->drawYOff);
+			e->onScreen = 1;
+		} else
+			e->onScreen = 0;
+	}
 
 	// Draw all other Ents
 	_numLevel2Ents = 0;


Commit: 1a8292fccbd82583c124ce060a990993e8c5f0bb
    https://github.com/scummvm/scummvm/commit/1a8292fccbd82583c124ce060a990993e8c5f0bb
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:16:54+02:00

Commit Message:
HDB: Unstub 'Increment Stun Timer'

Changed paths:
    engines/hdb/ai-funcs.cpp


diff --git a/engines/hdb/ai-funcs.cpp b/engines/hdb/ai-funcs.cpp
index 32bd8a6..9bbcf9d 100644
--- a/engines/hdb/ai-funcs.cpp
+++ b/engines/hdb/ai-funcs.cpp
@@ -924,6 +924,7 @@ void AI::animLuaEntity(const char *initName, AIState st) {
 void AI::drawEnts(int x, int y, int w, int h) {
 
 	static int stunAnim = 0;
+	static uint32 stunTimer = g_hdb->getTimeSlice();
 
 	// Draw Floating Entities
 	for (Common::Array<AIEntity *>::iterator it = _floats->begin(); it != _floats->end(); it++) {
@@ -1003,7 +1004,10 @@ void AI::drawEnts(int x, int y, int w, int h) {
 			e->onScreen = 0;
 	}
 
-	warning("STUB: AI::drawEnts: Increment Stun Timer");
+	if (stunTimer < g_hdb->getTimeSlice()) {
+		stunAnim = (stunAnim + 1) & 3;
+		stunTimer = g_hdb->getTimeSlice();
+	}
 
 	// Draw player last
 	if (_player && _player->level < 2 && !_playerInvisible && _player->draw) {


Commit: b6520708a5d1303fecf8b12ab7e21c15d6be0265
    https://github.com/scummvm/scummvm/commit/b6520708a5d1303fecf8b12ab7e21c15d6be0265
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:16:54+02:00

Commit Message:
HDB: Draw Entities, Foregrounds and Gratings

Changed paths:
    engines/hdb/hdb.cpp


diff --git a/engines/hdb/hdb.cpp b/engines/hdb/hdb.cpp
index bea2c7e..66bffa7 100644
--- a/engines/hdb/hdb.cpp
+++ b/engines/hdb/hdb.cpp
@@ -288,6 +288,9 @@ Common::Error HDBGame::run() {
 		_drawMan->drawSky();
 		_map->draw();
 		_ai->processCines();
+		_map->drawEnts();
+		_map->drawGratings();
+		_map->drawForegrounds();
 
 		// Update Timer that's NOT used for in-game Timing
 		_prevTimeSlice = _timeSlice;


Commit: 76b589c9018b4a19cb636d404285594dbe3b3698
    https://github.com/scummvm/scummvm/commit/76b589c9018b4a19cb636d404285594dbe3b3698
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:16:54+02:00

Commit Message:
HDB: Add checkFloating()

Changed paths:
    engines/hdb/ai-funcs.cpp
    engines/hdb/ai.h


diff --git a/engines/hdb/ai-funcs.cpp b/engines/hdb/ai-funcs.cpp
index 9bbcf9d..1c25198 100644
--- a/engines/hdb/ai-funcs.cpp
+++ b/engines/hdb/ai-funcs.cpp
@@ -1015,6 +1015,14 @@ void AI::drawEnts(int x, int y, int w, int h) {
 	}
 }
 
+bool AI::checkFloating(int x, int y) {
+	for (Common::Array<AIEntity *>::iterator it = _floats->begin(); it != _floats->end(); it++) {
+		if ((*it)->tileX == x && (*it)->tileY == y)
+			return true;
+	}
+	return false;
+}
+
 // Check to see if we can get this entity
 bool AI::getTableEnt(AIType type) {
 	switch (type) {
diff --git a/engines/hdb/ai.h b/engines/hdb/ai.h
index c29f1c8..b6b9b4a 100644
--- a/engines/hdb/ai.h
+++ b/engines/hdb/ai.h
@@ -565,6 +565,8 @@ public:
 	void animLuaEntity(const char *initName, AIState st);
 	void drawEnts(int x, int y, int w, int h);
 
+	bool checkFloating(int x, int y);
+
 	bool getTableEnt(AIType type);
 	bool walkThroughEnt(AIType type);
 	void getItemSound(AIType type);


Commit: bbe7c8206903ddaa84ca3ee3308c45d2d226f81c
    https://github.com/scummvm/scummvm/commit/bbe7c8206903ddaa84ca3ee3308c45d2d226f81c
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:16:54+02:00

Commit Message:
HDB: Add onEvenTile()

Changed paths:
    engines/hdb/ai.h


diff --git a/engines/hdb/ai.h b/engines/hdb/ai.h
index b6b9b4a..3c60936 100644
--- a/engines/hdb/ai.h
+++ b/engines/hdb/ai.h
@@ -543,6 +543,8 @@ struct CineCommand {
 				start(0), end(0), delay(0), speed(0), title(NULL), string(NULL), id(NULL), e(NULL) {}
 };
 
+#define onEvenTile(x, y)	( !(x & 31) && !(y & 31) )
+
 class AI {
 public:
 	AI();


Commit: 755bd46728a2829fe4a5a010f15909ff894607c5
    https://github.com/scummvm/scummvm/commit/755bd46728a2829fe4a5a010f15909ff894607c5
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:16:54+02:00

Commit Message:
HDB: Add killPlayer()

Changed paths:
    engines/hdb/ai-funcs.cpp
    engines/hdb/ai.h


diff --git a/engines/hdb/ai-funcs.cpp b/engines/hdb/ai-funcs.cpp
index 1c25198..50f030f 100644
--- a/engines/hdb/ai-funcs.cpp
+++ b/engines/hdb/ai-funcs.cpp
@@ -606,6 +606,53 @@ void AI::initAllEnts() {
 	warning("STUB: initAllEnts: LaserScan required");
 }
 
+void AI::killPlayer(Death method) {
+
+	int x = _player->x, y = _player->y;
+
+	stopEntity(_player);
+	_player->x = x;
+	_player->y = y;
+	_playerInvisible = false;
+	_playerDead = true;
+
+	warning("STUB: killPlayer: Close Dialogs");
+
+	switch (method) {
+	case DEATH_NORMAL:
+		_player->state = STATE_DYING;
+		warning("STUB: killPlayer: Play SND_GUY_DYING");
+		break;
+	case DEATH_FRIED:
+		_player->state = STATE_HORRIBLE1;
+		warning("STUB: killPlayer: Play SND_GUY_FRIED");
+		break;
+	case DEATH_SHOCKED:
+		_player->state = STATE_HORRIBLE2;
+		warning("STUB: killPlayer: Play SND_GUY_DYING");
+		warning("STUB: killPlayer: Play SND_SHOCKBOT_SHOCK");
+		break;
+	case DEATH_GRABBED:
+		_player->state = STATE_HORRIBLE3;
+		warning("STUB: killPlayer: Play SND_GUY_GRABBED");
+		break;
+	case DEATH_DROWNED:
+		_player->state = STATE_HORRIBLE4;
+		warning("STUB: killPlayer: Play SND_GUY_DROWN");
+		break;
+	case DEATH_PANICZONE:
+		_player->state = STATE_DYING;
+		warning("STUB: killPlayer: Play SND_PANIC_DEATH");
+		break;
+	case DEATH_PLUMMET:
+		_player->state = STATE_PLUMMET;
+		warning("STUB: killPlayer: Play SND_GUY_PLUMMET");
+		break;
+	}
+
+	warning("STUB: killPlayer: Stop Music");
+}
+
 void AI::animEntFrames(AIEntity *e) {
 	int max = 1;
 	// Set current graphic to draw
diff --git a/engines/hdb/ai.h b/engines/hdb/ai.h
index 3c60936..a9b1b86 100644
--- a/engines/hdb/ai.h
+++ b/engines/hdb/ai.h
@@ -203,6 +203,16 @@ enum AIDir {
 	DIR_RIGHT
 };
 
+enum Death {
+	DEATH_NORMAL,
+	DEATH_FRIED,
+	DEATH_DROWNED,
+	DEATH_GRABBED,
+	DEATH_SHOCKED,
+	DEATH_PANICZONE,
+	DEATH_PLUMMET
+};
+
 enum AIState {
 	STATE_NONE,
 	STATE_STANDDOWN,
@@ -562,6 +572,7 @@ public:
 	void removeEntity(AIEntity *e);
 	void setEntityGoal(AIEntity *e, int x, int y);
 	void initAllEnts();
+	void killPlayer(Death method);
 
 	void animEntFrames(AIEntity *e);
 	void animLuaEntity(const char *initName, AIState st);


Commit: bf98bcca010613957ac0630e3ff715a738d7a819
    https://github.com/scummvm/scummvm/commit/bf98bcca010613957ac0630e3ff715a738d7a819
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:16:54+02:00

Commit Message:
HDB: Add removeFirstWaypoint()

Changed paths:
    engines/hdb/ai-waypoint.cpp
    engines/hdb/ai.h


diff --git a/engines/hdb/ai-waypoint.cpp b/engines/hdb/ai-waypoint.cpp
index 3887b97..ee053ed 100644
--- a/engines/hdb/ai-waypoint.cpp
+++ b/engines/hdb/ai-waypoint.cpp
@@ -24,6 +24,21 @@
 
 namespace HDB {
 
+void AI::removeFirstWaypoint() {
+	if (!_numWaypoints)
+		return;
+
+	int i;
+	for (i = 0;i < _numWaypoints;i++) {
+		_waypoints[i] = _waypoints[i + 1];
+	}
+
+	_waypoints[i].x = 0;
+	_waypoints[i].y = 0;
+	_waypoints[i].level = 0;
+	_numWaypoints--;
+}
+
 void AI::clearWaypoints() {
 	memset(&_waypoints[0], 0, sizeof(_waypoints));
 	_numWaypoints = 0;
diff --git a/engines/hdb/ai.h b/engines/hdb/ai.h
index a9b1b86..67db4bb 100644
--- a/engines/hdb/ai.h
+++ b/engines/hdb/ai.h
@@ -664,6 +664,7 @@ public:
 
 	// Waypoint & Movement Functions
 	void lookAtXY(int x, int y);
+	void removeFirstWaypoint();
 	void clearWaypoints();
 	Tile *getStandFrameDir(AIEntity *e);
 


Commit: c12d1a2cec905df6c1c0496ff11760e27d556924
    https://github.com/scummvm/scummvm/commit/c12d1a2cec905df6c1c0496ff11760e27d556924
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:16:54+02:00

Commit Message:
HDB: Add stubbed animateEntity()

Changed paths:
    engines/hdb/ai-funcs.cpp
    engines/hdb/ai.h
    engines/hdb/hdb.h


diff --git a/engines/hdb/ai-funcs.cpp b/engines/hdb/ai-funcs.cpp
index 50f030f..a9d56c8 100644
--- a/engines/hdb/ai-funcs.cpp
+++ b/engines/hdb/ai-funcs.cpp
@@ -653,6 +653,127 @@ void AI::killPlayer(Death method) {
 	warning("STUB: killPlayer: Stop Music");
 }
 
+/*
+	Note from original:
+	Moves the entity along toward its goal, sets current frame to draw
+	depending on its current state.  Special checking is done for the
+	player in here to move him along his waypoints.
+*/
+void AI::animateEntity(AIEntity *e) {
+
+	int bgTileFlags, bgTileIndex;
+	int fgTileFlags, fgTileIndex;
+
+	// Move entity if player is not dead
+	if (!_playerDead) {
+		e->x += e->xVel;
+		e->y += e->yVel;
+		e->tileX = e->x / kTileWidth;
+		e->tileY = e->y / kTileHeight;
+	}
+
+	// For non-players, check for trigger being hit
+	if (onEvenTile(e->x, e->y)) {
+		warning("STUB: animateEntity: Check for Triggers being hit");
+	}
+
+	// If player, then scroll the screen with the player
+	if (e == _player && !_playerDead) {
+		if (!_cameraLock)
+			g_hdb->_map->centerMapXY(e->x + 16, e->y + 16);
+
+		// Check if player walked into teleporter
+		warning("STUB: animateEntity: Check Teleporter List");
+
+		// Check for bad tiles (DEATH)
+		int cx = (e->x + 16) / kTileWidth;
+		int cy = (e->y + 16) / kTileHeight;
+		bgTileFlags = g_hdb->_map->getMapBGTileFlags(cx, cy);
+		fgTileFlags = g_hdb->_map->getMapFGTileFlags(cx, cy);
+		if ((bgTileFlags & kFlagPlayerDie) && !(checkFloating(cx, cy)) && !(fgTileFlags & kFlagGrating)) {
+			if (bgTileFlags & kFlagEnergyFloor)
+				killPlayer(DEATH_SHOCKED);
+			else if ((bgTileFlags & kFlagPlasmaFloor) || (bgTileFlags & kFlagRadFloor))
+				killPlayer(DEATH_FRIED);
+			else
+				killPlayer(DEATH_NORMAL);
+			return;
+		}
+
+		// Check if player wants to stop
+		// If yes, sets last waypoint right in front of player
+		int xOff = 0, yOff = 0;
+		if (_numWaypoints > 1) {
+
+			switch (e->dir) {
+			case DIR_UP:
+				xOff = 0;
+				yOff = -1;
+				break;
+			case DIR_DOWN:
+				xOff = 0;
+				yOff = 1;
+				break;
+			case DIR_LEFT:
+				xOff = -1;
+				yOff = 0;
+				break;
+			case DIR_RIGHT:
+				xOff = 1;
+				yOff = 0;
+				break;
+			case DIR_NONE:
+				warning("AI-FUNCS: animateEntity: DIR_NONE found");
+				break;
+			}
+			if ((e->tileX+xOff == _waypoints[_numWaypoints-1].x && e->tileY + yOff == _waypoints[_numWaypoints - 1].y) && e->level == _waypoints[_numWaypoints - 1].level) {
+				memset(&_waypoints[0], 0, sizeof(_waypoints));
+				_numWaypoints = 1;
+				_waypoints[0].x = e->tileX + xOff;
+				_waypoints[0].y = e->tileY + yOff;
+				_waypoints[0].level = e->level;
+				e->goalX = e->tileX + xOff;
+				e->goalY = e->tileY + yOff;
+			}
+		}
+	}
+
+	// Check for moving up/down stair levels
+	bgTileIndex = g_hdb->_map->getMapBGTileIndex(e->tileX, e->tileY);
+	bgTileFlags = g_hdb->_map->getMapBGTileFlags(e->tileX, e->tileY);
+	fgTileFlags = g_hdb->_map->getMapFGTileFlags(e->tileX, e->tileY);
+	if (bgTileFlags & kFlagStairTop)
+		e->level = 2;
+	else if (bgTileFlags & kFlagStairBot)
+		e->level = 1;
+
+	// Reached goal?
+	// Cinematic require less accuracy for NPCs
+	int result;
+	if (_cineActive && e != _player)
+		result = (abs(e->x - (e->goalX * kTileWidth)) <= abs(e->xVel)) && (abs(e->y - (e->goalY * kTileHeight)) <= abs(e->yVel));
+	else
+		result = (e->x == e->goalX * kTileWidth) && (e->y == e->goalY * kTileHeight);
+
+	if (result) {
+		// If player, this is a waypoint goal.
+		// Drop one waypoint from list
+		if (e == _player) {
+			removeFirstWaypoint();
+			_playerEmerging = false;
+		}
+
+		// If entity not player, stop it here
+		// If entity is player and no waypoints are left, stop it here
+		if (e != _player || (!_numWaypoints && e == _player)) {
+			warning("STUB: animateEntity: Stop entity");
+		} else if (onEvenTile(e->x, e->y))
+			setEntityGoal(e, _waypoints[0].x, _waypoints[0].y);
+	}
+
+	animEntFrames(e);
+}
+
 void AI::animEntFrames(AIEntity *e) {
 	int max = 1;
 	// Set current graphic to draw
diff --git a/engines/hdb/ai.h b/engines/hdb/ai.h
index 67db4bb..5c9dee1 100644
--- a/engines/hdb/ai.h
+++ b/engines/hdb/ai.h
@@ -574,6 +574,7 @@ public:
 	void initAllEnts();
 	void killPlayer(Death method);
 
+	void animateEntity(AIEntity *e);
 	void animEntFrames(AIEntity *e);
 	void animLuaEntity(const char *initName, AIState st);
 	void drawEnts(int x, int y, int w, int h);
diff --git a/engines/hdb/hdb.h b/engines/hdb/hdb.h
index b748101..0a3e0a4 100644
--- a/engines/hdb/hdb.h
+++ b/engines/hdb/hdb.h
@@ -69,14 +69,19 @@ enum GameState {
 };
 
 enum Flag {
-	kFlagInvisible	= 0x20,
-	kFlagForeground = 0x80,
-	kFlagStairTop	= 0x400000,
-	kFlagAnimSlow	= 0x800000,
-	kFlagAnimMedium = 0x1000000,
-	kFlagAnimFast	= 0x1800000,
-	kFlagGrating	= 0x4000000,
-	kFlagMasked		= 0x2000000
+	kFlagPlayerDie		= 0x8,
+	kFlagInvisible		= 0x20,
+	kFlagForeground		= 0x80,
+	kFlagEnergyFloor	= 0x40000,
+	kFlagPlasmaFloor	= 0x6000D,
+	kFlagRadFloor		= 0x6800D,
+	kFlagStairBot		= 0x200000,
+	kFlagStairTop		= 0x400000,
+	kFlagAnimSlow		= 0x800000,
+	kFlagAnimMedium		= 0x1000000,
+	kFlagAnimFast		= 0x1800000,
+	kFlagGrating		= 0x4000000,
+	kFlagMasked			= 0x2000000
 };
 
 enum {


Commit: 16d6c638e820178e2a0bc78aa3d87a4615cc7603
    https://github.com/scummvm/scummvm/commit/16d6c638e820178e2a0bc78aa3d87a4615cc7603
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:16:54+02:00

Commit Message:
HDB: Unstub aiSergeantInit/2 and aiSergeantAction

Changed paths:
    engines/hdb/ai-player.cpp


diff --git a/engines/hdb/ai-player.cpp b/engines/hdb/ai-player.cpp
index ff49b56..4cace98 100644
--- a/engines/hdb/ai-player.cpp
+++ b/engines/hdb/ai-player.cpp
@@ -215,15 +215,21 @@ void aiDollyInit2(AIEntity *e) {
 }
 
 void aiSergeantInit(AIEntity *e) {
-	warning("STUB: AI: aiSergeantInit required");
+	e->moveSpeed = kPlayerMoveSpeed >> 1;
+	if (e->value1)
+		e->aiAction = aiSergeantAction;
 }
 
 void aiSergeantInit2(AIEntity *e) {
-	warning("STUB: AI: aiSergeantInit2 required");
+	e->draw = g_hdb->_ai->getStandFrameDir(e);
 }
 
 void aiSergeantAction(AIEntity *e) {
-	warning("STUB: AI: aiSergeantAction required");
+	if (e->goalX) {
+		warning("AI-PLAYER: aiSergeantAction: Play SND_FOOTSTEPS sounds");
+		g_hdb->_ai->animateEntity(e);
+	} else
+		g_hdb->_ai->animEntFrames(e);
 }
 
 void aiSpacedudeInit(AIEntity *e) {


Commit: 1ad07642747a66a71e1aac7a595cbd15a986b7b7
    https://github.com/scummvm/scummvm/commit/1ad07642747a66a71e1aac7a595cbd15a986b7b7
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:16:54+02:00

Commit Message:
HDB: Use Masked Blitting instead of MaskedAlpha

This is a temporary fix until MaskedAlphaBlitting
is implemented.

Changed paths:
    engines/hdb/ai-funcs.cpp


diff --git a/engines/hdb/ai-funcs.cpp b/engines/hdb/ai-funcs.cpp
index a9d56c8..992fbf6 100644
--- a/engines/hdb/ai-funcs.cpp
+++ b/engines/hdb/ai-funcs.cpp
@@ -1145,7 +1145,9 @@ void AI::drawEnts(int x, int y, int w, int h) {
 
 			switch (e->type) {
 			case AI_VORTEXIAN:
-				warning("STUB: AI::drawEnts: Tile Alpha Blitting required");
+				if (e->draw)
+					e->draw->drawMasked(e->x - x + e->drawXOff, e->y - y + e->drawYOff);
+				debug(1, "STUB: AI::drawEnts: Replace Masked Blitting with Alpha Masked Blitting");
 				break;
 			case AI_GUY: // Draw Player Last
 				break;


Commit: 8c024e7f57347a78f2478d59ab6f881b1e1a51b2
    https://github.com/scummvm/scummvm/commit/8c024e7f57347a78f2478d59ab6f881b1e1a51b2
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:16:54+02:00

Commit Message:
HDB: Remove stubs from processCines: C_RESETCAMERA

Changed paths:
    engines/hdb/ai-cinematic.cpp


diff --git a/engines/hdb/ai-cinematic.cpp b/engines/hdb/ai-cinematic.cpp
index c868e6b..2baac7a 100644
--- a/engines/hdb/ai-cinematic.cpp
+++ b/engines/hdb/ai-cinematic.cpp
@@ -105,8 +105,8 @@ void AI::processCines() {
 		case C_RESETCAMERA:
 			int px, py;
 			_cameraLock = false;
-			warning("STUB: AI::GetPlayerXY required");
-			warning("STUB: MAP::CenterMapXY required");
+			g_hdb->_ai->getPlayerXY(&px, &py);
+			g_hdb->_map->centerMapXY(px + 16, py + 16);
 			complete = true;
 			break;
 		case C_MOVECAMERA:


Commit: b085dcfa974ddcb1cdad211b088428dfc9cb625d
    https://github.com/scummvm/scummvm/commit/b085dcfa974ddcb1cdad211b088428dfc9cb625d
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:16:54+02:00

Commit Message:
HDB: Remove stub from processCines: C_USEENTITY

Changed paths:
    engines/hdb/ai-cinematic.cpp


diff --git a/engines/hdb/ai-cinematic.cpp b/engines/hdb/ai-cinematic.cpp
index 2baac7a..8706981 100644
--- a/engines/hdb/ai-cinematic.cpp
+++ b/engines/hdb/ai-cinematic.cpp
@@ -209,8 +209,11 @@ void AI::processCines() {
 			break;
 		}
 		case C_USEENTITY:
-			_cine[i]->e = locateEntity(_cine[i]->string);
-			warning("STUB: PROCESSCINES: USEENTITY: HDBGame::useEntity required;");
+			for (Common::Array<AIEntity *>::iterator it = _ents->begin(); it != _ents->end(); it++) {
+				if (Common::matchString((*it)->entityName, _cine[i]->string)) {
+					g_hdb->useEntity((*it));
+				}
+			}
 			warning("STUB: PROCESSCINES: USEENTITY: CheckActionList required;");
 			warning("STUB: PROCESSCINES: USEENTITY: CheckAutoList required;");
 			complete = true;


Commit: d5dca7ea7c3ab63060b1ecefc9dc31b1ada8004d
    https://github.com/scummvm/scummvm/commit/d5dca7ea7c3ab63060b1ecefc9dc31b1ada8004d
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:16:54+02:00

Commit Message:
HDB: Add variables for AutoAction tiles

Changed paths:
    engines/hdb/ai-init.cpp
    engines/hdb/ai.h


diff --git a/engines/hdb/ai-init.cpp b/engines/hdb/ai-init.cpp
index e03f456..76c7944 100644
--- a/engines/hdb/ai-init.cpp
+++ b/engines/hdb/ai-init.cpp
@@ -700,6 +700,73 @@ bool AI::init() {
 	_waypointGfx[3] = new Tile;
 	_waypointGfx[3]->load(g_hdb->_fileMan->findFirstData("icon_waypoint_select4", TYPE_ICON32));
 
+	// Setup Vars to reference SPECIAL Map Tiles
+	_useSwitchOff	= g_hdb->_drawMan->getTileIndex("anim_t32_switch_off01");
+	_useSwitchOn	= g_hdb->_drawMan->getTileIndex("t32_switch_on");
+	_useSwitch2Off	= g_hdb->_drawMan->getTileIndex("anim_t32_1switch_off01");
+	_useSwitch2On	= g_hdb->_drawMan->getTileIndex("t32_1switch_on");
+//	_useHandswitchOn	= g_hdb->_drawMan->getTileIndex("t32_ship_handswitch_on");
+//	_useHandswitchOff	= g_hdb->_drawMan->getTileIndex("anim_t32_ship_handswitch_off1");
+	_useHolderEmpty	= g_hdb->_drawMan->getTileIndex("anim_t32_holder_empty1");
+	_useHolderFull	= g_hdb->_drawMan->getTileIndex("t32_holder_full");
+	_useMailsorter	= g_hdb->_drawMan->getTileIndex("anim_t32_mailsort1");
+	_useAskcomp		= g_hdb->_drawMan->getTileIndex("anim_t32_askcomp1");
+
+	_targetDoorN	= g_hdb->_drawMan->getTileIndex("t32_door_n_1");
+	_targetDoorP	= g_hdb->_drawMan->getTileIndex("t32_door_p_1");
+	_targetDoorS	= g_hdb->_drawMan->getTileIndex("t32_door_s_1");
+	_targetDoorNv	= g_hdb->_drawMan->getTileIndex("t32_door_nv_1");
+	_targetDoorPv	= g_hdb->_drawMan->getTileIndex("t32_door_pv_1");
+	_targetDoorSv	= g_hdb->_drawMan->getTileIndex("t32_door_sv_1");
+
+	_targetDoor2N	= g_hdb->_drawMan->getTileIndex("t32_door2_n_1");
+	_targetDoor2P	= g_hdb->_drawMan->getTileIndex("t32_door2_p_1");
+	_targetDoor2S	= g_hdb->_drawMan->getTileIndex("t32_door2_s_1");
+	_targetDoor2Nv	= g_hdb->_drawMan->getTileIndex("t32_door2_nv_1");
+	_targetDoor2Pv	= g_hdb->_drawMan->getTileIndex("t32_door2_pv_1");
+	_targetDoor2Sv	= g_hdb->_drawMan->getTileIndex("t32_door2_sv_1");
+
+	_target2DoorN	= g_hdb->_drawMan->getTileIndex("t32_e2_door_n_1");
+	_target2DoorP	= g_hdb->_drawMan->getTileIndex("t32_e2_door_p_1");
+	_target2DoorS	= g_hdb->_drawMan->getTileIndex("t32_e2_door_s_1");
+	_target2DoorNv	= g_hdb->_drawMan->getTileIndex("t32_e2_door_nv_1");
+	_target2DoorPv	= g_hdb->_drawMan->getTileIndex("t32_e2_door_pv_1");
+	_target2DoorSv	= g_hdb->_drawMan->getTileIndex("t32_e2_door_sv_1");
+
+	_target3DoorN	= g_hdb->_drawMan->getTileIndex("t32_e3_door_n_1");
+	_target3DoorP	= g_hdb->_drawMan->getTileIndex("t32_e3_door_p_1");
+	_target3DoorS	= g_hdb->_drawMan->getTileIndex("t32_e3_door_s_1");
+	_target3DoorNv	= g_hdb->_drawMan->getTileIndex("t32_e3_door_nv_1");
+	_target3DoorPv	= g_hdb->_drawMan->getTileIndex("t32_e3_door_pv_1");
+	_target3DoorSv	= g_hdb->_drawMan->getTileIndex("t32_e3_door_sv_1");
+
+	_targetBridgeU	= g_hdb->_drawMan->getTileIndex("t32_bridgeup1");
+	_targetBridgeD	= g_hdb->_drawMan->getTileIndex("t32_bridgedown1");
+	_targetBridgeL	= g_hdb->_drawMan->getTileIndex("t32_bridgeleft1");
+	_targetBridgeR	= g_hdb->_drawMan->getTileIndex("t32_bridgeright1");
+	_targetBridgeMidLR	= g_hdb->_drawMan->getTileIndex("t32_mgrate_mid");
+	_targetBridgeMidUD	= g_hdb->_drawMan->getTileIndex("t32_mgrate_tbmid");
+	_touchplateOn	= g_hdb->_drawMan->getTileIndex("t32_touchplateon");
+	_touchplateOff	= g_hdb->_drawMan->getTileIndex("t32_touchplateoff");
+	_blockpole		= g_hdb->_drawMan->getTileIndex("t32_blockpole_1");
+	_useTeleporter	= g_hdb->_drawMan->getTileIndex("anim_t32_teleporter1");
+
+	_useSwitchOff	= g_hdb->_drawMan->getTileIndex("t32_temple_touchplate_on");
+	_useSwitchOff	= g_hdb->_drawMan->getTileIndex("t32_temple_touchplate_off");
+
+	_kcHolderWhiteOff	= g_hdb->_drawMan->getTileIndex("anim_t32_kcholder_white_off1");
+	_kcHolderWhiteOn	= g_hdb->_drawMan->getTileIndex("t32_kcholder_white_on");
+	_kcHolderBlueOff	= g_hdb->_drawMan->getTileIndex("anim_t32_kcholder_blue_off1");
+	_kcHolderBlueOn		= g_hdb->_drawMan->getTileIndex("t32_kcholder_blue_on");
+	_kcHolderRedOff		= g_hdb->_drawMan->getTileIndex("anim_t32_kcholder_red_off1");
+	_kcHolderRedOn		= g_hdb->_drawMan->getTileIndex("t32_kcholder_red_on");
+	_kcHolderGreenOff	= g_hdb->_drawMan->getTileIndex("anim_t32_kcholder_green_off1");
+	_kcHolderGreenOn	= g_hdb->_drawMan->getTileIndex("t32_kcholder_green_on");
+	_kcHolderPurpleOff	= g_hdb->_drawMan->getTileIndex("anim_t32_kcholder_purple_off1");
+	_kcHolderPurpleOn	= g_hdb->_drawMan->getTileIndex("t32_kcholder_purple_on");
+	_kcHolderBlackOff	= g_hdb->_drawMan->getTileIndex("anim_t32_kcholder_black_off1");
+	_kcHolderBlackOn	= g_hdb->_drawMan->getTileIndex("t32_kcholder_black_on");
+
 	_playerRunning = false;
 
 	restartSystem();
diff --git a/engines/hdb/ai.h b/engines/hdb/ai.h
index 5c9dee1..6e6247b 100644
--- a/engines/hdb/ai.h
+++ b/engines/hdb/ai.h
@@ -748,6 +748,76 @@ public:
 	int _numGooCups;
 	int _numMonkeystones;
 
+	// Special Tiles that are usable
+	// These variables hold the tile-indices set
+	// in ai-init.cpp
+
+	int			_useSwitchOff;			// the door opening switch
+	int			_useSwitchOn;			// state, when opened
+	int			_useHolderEmpty;		// cell holding switch
+	int			_useHolderFull;		// state, when full
+	int			_useSwitch2Off;		// another switch
+	int			_useSwitch2On;			// state, when opened
+	int			_useMailsorter;			// mailsorter entity
+	int			_useAskcomp;			// askcomp entitiy
+	int			_useTeleporter;			// teleporter entity
+	int			_useHandswitchOn;		// 2-sided handswitch
+	int			_useHandswitchOff;		// 2-sided handswitch
+
+	int			_targetDoorN;			// horz SILVER door
+	int			_targetDoorP;			// horz BLUE door
+	int			_targetDoorS;			// horz RED door
+	int			_targetDoorNv;			// vert SILVER door
+	int			_targetDoorPv;			// vert BLUE door
+	int			_targetDoorSv;			// vert RED door
+
+	int			_targetDoor2N;			// horz SILVER door
+	int			_targetDoor2P;			// horz BLUE door
+	int			_targetDoor2S;			// horz RED door
+	int			_targetDoor2Nv;			// vert SILVER door
+	int			_targetDoor2Pv;			// vert BLUE door
+	int			_targetDoor2Sv;			// vert RED door
+
+	int			_target2DoorN;			// horz SILVER door
+	int			_target2DoorP;			// horz BLUE door
+	int			_target2DoorS;			// horz RED door
+	int			_target2DoorNv;			// vert SILVER door
+	int			_target2DoorPv;			// vert BLUE door
+	int			_target2DoorSv;			// vert RED door
+
+	int			_target3DoorN;			// horz SILVER door
+	int			_target3DoorP;			// horz BLUE door
+	int			_target3DoorS;			// horz RED door
+	int			_target3DoorNv;			// vert SILVER door
+	int			_target3DoorPv;			// vert BLUE door
+	int			_target3DoorSv;			// vert RED door
+
+	int			_targetBridgeU;		// bridge extending UP
+	int			_targetBridgeD;		// bridge extending DOWN
+	int			_targetBridgeL;		// bridge extending LEFT
+	int			_targetBridgeR;		// bridge extending RIGHT
+
+	int			_targetBridgeMidLR;	// bridge grating plank LEFT/RIGHT
+	int			_targetBridgeMidUD;	// bridge grating plank UP/DOWN
+	int			_touchplateOn;			// touchplate ON
+	int			_touchplateOff;
+	int			_templeTouchpOn;		// touchplate ON
+	int			_templeTouchpOff;
+	int			_blockpole;				// blockpole
+
+	int			_kcHolderWhiteOff;	// keycard holders
+	int			_kcHolderWhiteOn;
+	int			_kcHolderBlueOff;
+	int			_kcHolderBlueOn;
+	int			_kcHolderRedOff;
+	int			_kcHolderRedOn;
+	int			_kcHolderGreenOff;
+	int			_kcHolderGreenOn;
+	int			_kcHolderPurpleOff;
+	int			_kcHolderPurpleOn;
+	int			_kcHolderBlackOff;
+	int			_kcHolderBlackOn;
+
 	AIEntLevel2 *_entsLevel2[kMaxLevel2Ents];
 	int _numLevel2Ents;
 


Commit: db838a656eb85755659ff93769269b66490652f7
    https://github.com/scummvm/scummvm/commit/db838a656eb85755659ff93769269b66490652f7
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:16:54+02:00

Commit Message:
HDB: Add animGrabbing()

Changed paths:
    engines/hdb/ai-funcs.cpp
    engines/hdb/ai.h


diff --git a/engines/hdb/ai-funcs.cpp b/engines/hdb/ai-funcs.cpp
index 992fbf6..ea02353 100644
--- a/engines/hdb/ai-funcs.cpp
+++ b/engines/hdb/ai-funcs.cpp
@@ -1185,6 +1185,41 @@ void AI::drawEnts(int x, int y, int w, int h) {
 	}
 }
 
+void AI::animGrabbing() {
+	if (_player->state == STATE_GRABUP ||
+		_player->state == STATE_GRABDOWN ||
+		_player->state == STATE_GRABLEFT ||
+		_player->state == STATE_GRABRIGHT)
+		return;
+
+	AIState s;
+
+	switch (_player->dir) {
+	case DIR_UP:
+		s = STATE_GRABUP;
+		_player->draw = _getGfx[DIR_UP];
+		break;
+	case DIR_DOWN:
+		s = STATE_GRABDOWN;
+		_player->draw = _getGfx[DIR_DOWN];
+		break;
+	case DIR_LEFT:
+		s = STATE_GRABLEFT;
+		_player->draw = _getGfx[DIR_LEFT];
+		break;
+	case DIR_RIGHT:
+		s = STATE_GRABRIGHT;
+		_player->draw = _getGfx[DIR_RIGHT];
+		break;
+	default:
+		warning("AI-FUNCS: animGrabbing: DIR_NONE found");
+		break;
+	}
+
+	_player->state = s;
+	_player->animFrame = 5;
+}
+
 bool AI::checkFloating(int x, int y) {
 	for (Common::Array<AIEntity *>::iterator it = _floats->begin(); it != _floats->end(); it++) {
 		if ((*it)->tileX == x && (*it)->tileY == y)
diff --git a/engines/hdb/ai.h b/engines/hdb/ai.h
index 6e6247b..8206a2c 100644
--- a/engines/hdb/ai.h
+++ b/engines/hdb/ai.h
@@ -578,6 +578,7 @@ public:
 	void animEntFrames(AIEntity *e);
 	void animLuaEntity(const char *initName, AIState st);
 	void drawEnts(int x, int y, int w, int h);
+	void animGrabbing();
 
 	bool checkFloating(int x, int y);
 


Commit: 4965fecadc612b5e55a3fb2e6b6690764dd86d16
    https://github.com/scummvm/scummvm/commit/4965fecadc612b5e55a3fb2e6b6690764dd86d16
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:16:54+02:00

Commit Message:
HDB: Add stubbed Action Functions

Changed paths:
  A engines/hdb/ai-use.cpp
    engines/hdb/ai.h


diff --git a/engines/hdb/ai-use.cpp b/engines/hdb/ai-use.cpp
new file mode 100644
index 0000000..fa78aed
--- /dev/null
+++ b/engines/hdb/ai-use.cpp
@@ -0,0 +1,86 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be AI::useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "hdb/hdb.h"
+
+namespace HDB {
+
+// Black Door Switch
+bool AI::useSwitch(AIEntity *e, int x, int y, int targetX, int targetY, int onTile) {
+	warning("STUB: Define useSwitch");
+	return false;
+}
+
+bool AI::useSwitchOn(AIEntity *e, int x, int y, int targetX, int targetY, int offTile) {
+	warning("STUB: Define useSwitchOn");
+	return false;
+}
+
+bool AI::useSwitch2(AIEntity *e, int x, int y, int targetX, int targetY) {
+	warning("STUB: Define useSwitch2");
+	return false;
+}
+
+// Colored Keycard Switch
+bool AI::useLockedSwitch(AIEntity *e, int x, int y, int targetX, int targetY, int onTile, AIType item, char *keyerror) {
+	warning("STUB: Define useLockedSwitch");
+	return false;
+}
+
+bool AI::useLockedSwitchOn(AIEntity *e, int x, int y, int targetX, int targetY, int offTile, AIType item) {
+	warning("STUB: Define useLockedSwitchOn");
+	return false;
+}
+
+// Purple Cell Holder Switch
+bool AI::useCellHolder(AIEntity *e, int x, int y, int targetX, int targetY) {
+	warning("STUB: Define useCellHolder");
+	return false;
+}
+
+// Touchplate
+bool AI::useTouchplate(AIEntity *e, int x, int y, int targetX, int targetY, int type) {
+	warning("STUB: Define useTouchplate");
+	return false;
+}
+bool AI::useTouchplateOn(AIEntity *e, int x, int y, int targetX, int targetY, int type) {
+	warning("STUB: Define useTouchplateOn");
+	return false;
+}
+
+// Normal Door
+bool AI::useDoorOpenClose(AIEntity *e, int x, int y) {
+	warning("STUB: Define useDoorOpenClose");
+	return false;
+}
+bool AI::useAutoDoorOpenClose(AIEntity *e, int x, int y) {
+	warning("STUB: Define useAutoDoorOpenClose");
+	return false;
+}
+
+// Any Type Door
+bool AI::useDoorOpenCloseBot(AIEntity *e, int x, int y) {
+	warning("STUB: Define useDoorOpenCloseBot");
+	return false;
+}
+
+} // End of Namespace
\ No newline at end of file
diff --git a/engines/hdb/ai.h b/engines/hdb/ai.h
index 8206a2c..b6a7094 100644
--- a/engines/hdb/ai.h
+++ b/engines/hdb/ai.h
@@ -834,6 +834,31 @@ public:
 
 private:
 
+	// Action Functions
+
+	// Black Door Switch
+	bool useSwitch(AIEntity *e, int x, int y, int targetX, int targetY, int onTile);
+	bool useSwitchOn(AIEntity *e, int x, int y, int targetX, int targetY, int offTile);
+	bool useSwitch2(AIEntity *e, int x, int y, int targetX, int targetY);
+
+	// Colored Keycard Switch
+	bool useLockedSwitch(AIEntity *e, int x, int y, int targetX, int targetY, int onTile, AIType item, char *keyerror);
+	bool useLockedSwitchOn(AIEntity *e, int x, int y, int targetX, int targetY, int offTile, AIType item);
+
+	// Purple Cell Holder Switch
+	bool useCellHolder(AIEntity *e, int x, int y, int targetX, int targetY);
+
+	// Touchplate
+	bool useTouchplate(AIEntity *e, int x, int y, int targetX, int targetY, int type);
+	bool useTouchplateOn(AIEntity *e, int x, int y, int targetX, int targetY, int type);
+
+	// Normal Door
+	bool useDoorOpenClose(AIEntity *e, int x, int y);
+	bool useAutoDoorOpenClose(AIEntity *e, int x, int y);
+
+	// Any Type Door
+	bool useDoorOpenCloseBot(AIEntity *e, int x, int y);
+
 	Common::Array<AIEntity *> *_ents;
 	Common::Array<AIEntity *> *_floats;
 	AIEntity *_player;


Commit: f80550e5246d4cef4e7b36cf4f52977219c972f8
    https://github.com/scummvm/scummvm/commit/f80550e5246d4cef4e7b36cf4f52977219c972f8
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:16:54+02:00

Commit Message:
HDB: Add AutoAction struct and _autoActions array

Changed paths:
    engines/hdb/ai-init.cpp
    engines/hdb/ai.h


diff --git a/engines/hdb/ai-init.cpp b/engines/hdb/ai-init.cpp
index 76c7944..65240d1 100644
--- a/engines/hdb/ai-init.cpp
+++ b/engines/hdb/ai-init.cpp
@@ -820,6 +820,9 @@ void AI::restartSystem() {
 	memset(_clubLeftGfx, NULL, kMaxAnimFrames * sizeof(Tile *));
 	memset(_clubRightGfx, NULL, kMaxAnimFrames * sizeof(Tile *));
 
+	// Clear the Auto-Action list
+	memset(_autoActions, 0, sizeof(_autoActions));
+
 	// Clear the Entity List
 	_ents->clear();
 
diff --git a/engines/hdb/ai.h b/engines/hdb/ai.h
index b6a7094..9327bae 100644
--- a/engines/hdb/ai.h
+++ b/engines/hdb/ai.h
@@ -34,6 +34,7 @@ enum {
 	kMaxInventory = 10,
 	kMaxDeliveries = 5,
 	kMaxWaypoints = 10,
+	kMaxAutoActions = 30,
 	kPlayerMoveSpeed = 4,
 	kEnemyMoveSpeed = 2,
 	kPushMoveSpeed = (kPlayerMoveSpeed >> 1)
@@ -536,6 +537,16 @@ struct Waypoint {
 	Waypoint() : x(0), y(0), level(0) {}
 };
 
+struct AutoAction {
+	uint16 x, y;
+	bool activated;
+	char luaFuncInit[32];
+	char luaFuncUse[32];
+	char entityName[32];
+
+	AutoAction() : x(0), y(0), activated(false), luaFuncInit(""), luaFuncUse(""), entityName("") {}
+};
+
 struct CineCommand {
 	CineType cmdType;
 	double x, y;
@@ -829,6 +840,8 @@ public:
 	int _numWaypoints;
 	Tile *_waypointGfx[4]; // Animating waypoint gfx
 
+	AutoAction *_autoActions[kMaxAutoActions];
+
 	// Cinematic Variables
 	Common::Array<CineCommand *> _cine;
 


Commit: 204a9424cffcc34393a80df55b2238a423466d17
    https://github.com/scummvm/scummvm/commit/204a9424cffcc34393a80df55b2238a423466d17
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:16:54+02:00

Commit Message:
HDB: Add list functions for _autoActions

Changed paths:
  A engines/hdb/ai-lists.cpp
    engines/hdb/ai.h


diff --git a/engines/hdb/ai-lists.cpp b/engines/hdb/ai-lists.cpp
new file mode 100644
index 0000000..2d772a8
--- /dev/null
+++ b/engines/hdb/ai-lists.cpp
@@ -0,0 +1,222 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can Redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "hdb/hdb.h"
+
+namespace HDB {
+
+void AI::addToAutoList(int x, int y, const char *luaFuncInit, const char *luaFuncUse) {
+
+	const char *get;
+
+	for (int i = 0;i < kMaxAutoActions;i++) {
+		if (!_autoActions[i]) {
+			_autoActions[i] = new AutoAction;
+			_autoActions[i]->x = x;
+			_autoActions[i]->y = y;
+			_autoActions[i]->activated = false;
+			if (luaFuncInit[0] != '*')
+				strcpy(&_autoActions[i]->luaFuncInit[0], luaFuncInit);
+			if (luaFuncUse[0] != '*')
+				strcpy(&_autoActions[i]->luaFuncUse[0], luaFuncUse);
+
+			if (_autoActions[i]->luaFuncInit[0]) {
+				g_hdb->_lua->callFunction(_autoActions[i]->luaFuncInit, 2);
+				get = g_hdb->_lua->getStringOffStack();
+				if (!get)
+					return;
+				strcpy(&_autoActions[i]->entityName[0], get);
+				get = g_hdb->_lua->getStringOffStack();
+				if (!get)
+					return;
+				strcpy(&_autoActions[i]->entityName[0], get);
+			}
+			return;
+		}
+	}
+}
+
+void AI::autoDeactivate(int x, int y) {
+	for (int i = 0; i < kMaxAutoActions;i++) {
+		if (_autoActions[i]->x == x && _autoActions[i]->y == y) {
+			_autoActions[i]->activated = false;
+			return;
+		}
+	}
+}
+
+bool AI::activateAction(AIEntity *e, int x, int y, int targetX, int targetY) {
+	bool success = false;
+	int tileIndex = g_hdb->_map->getMapFGTileIndex(x, y);
+
+	// If FG tile invisivle or grating, ignore if
+	int fgFlags = g_hdb->_map->getMapFGTileFlags(x, y);
+	if (fgFlags & (kFlagInvisible | kFlagGrating))
+		tileIndex = -1;
+
+	if (tileIndex < 0)
+		tileIndex = g_hdb->_map->getMapBGTileIndex(x, y);
+
+	// Check which tile is going to activate
+	if ( tileIndex == _useSwitchOff || tileIndex == _useSwitchOff + 1 )
+		success = useSwitch( e, x, y, targetX, targetY, _useSwitchOn );
+	else
+	if ( tileIndex == _useSwitchOn )
+		success = useSwitchOn( e, x, y, targetX, targetY, _useSwitchOff );
+	else
+	//-------------------------------------------------------------------
+	if ( tileIndex == _useHandswitchOff || tileIndex == _useHandswitchOff + 1 )
+		success = useSwitch( e, x, y, targetX, targetY, _useHandswitchOn );
+	else
+	if ( tileIndex == _useHandswitchOn )
+		success = useSwitchOn( e, x, y, targetX, targetY, _useHandswitchOff );
+	else
+	//-------------------------------------------------------------------
+	if ( tileIndex == _kcHolderWhiteOff || tileIndex == _kcHolderWhiteOff + 1 )
+		success = useLockedSwitch( e, x, y, targetX, targetY, _kcHolderWhiteOn, ITEM_KEYCARD_WHITE, "I need a White Keycard." );
+	else
+	if ( tileIndex == _kcHolderWhiteOn )
+		success = useLockedSwitchOn( e, x, y, targetX, targetY, _kcHolderWhiteOff, ITEM_KEYCARD_WHITE );
+	else
+	if ( tileIndex == _kcHolderBlueOff || tileIndex == _kcHolderBlueOff + 1 )
+		success = useLockedSwitch( e, x, y, targetX, targetY, _kcHolderBlueOn, ITEM_KEYCARD_BLUE, "I need a Blue Keycard." );
+	else
+	if ( tileIndex == _kcHolderBlueOn )
+		success = useLockedSwitchOn( e, x, y, targetX, targetY, _kcHolderBlueOff, ITEM_KEYCARD_BLUE );
+	else
+	if ( tileIndex == _kcHolderRedOff || tileIndex == _kcHolderRedOff + 1 )
+		success = useLockedSwitch( e, x, y, targetX, targetY, _kcHolderRedOn, ITEM_KEYCARD_RED, "I need a Red Keycard." );
+	else
+	if ( tileIndex == _kcHolderRedOn )
+		success = useLockedSwitchOn( e, x, y, targetX, targetY, _kcHolderRedOff, ITEM_KEYCARD_RED );
+	else
+	if ( tileIndex == _kcHolderGreenOff || tileIndex == _kcHolderGreenOff + 1 )
+		success = useLockedSwitch( e, x, y, targetX, targetY, _kcHolderGreenOn, ITEM_KEYCARD_GREEN, "I need a Green Keycard." );
+	else
+	if ( tileIndex == _kcHolderGreenOn )
+		success = useLockedSwitchOn( e, x, y, targetX, targetY, _kcHolderGreenOff, ITEM_KEYCARD_GREEN );
+	else
+	if ( tileIndex == _kcHolderPurpleOff || tileIndex == _kcHolderPurpleOff + 1 )
+		success = useLockedSwitch( e, x, y, targetX, targetY, _kcHolderPurpleOn, ITEM_KEYCARD_PURPLE, "I need a Purple Keycard." );
+	else
+	if ( tileIndex == _kcHolderPurpleOn )
+		success = useLockedSwitchOn( e, x, y, targetX, targetY, _kcHolderPurpleOff, ITEM_KEYCARD_PURPLE );
+	else
+	if ( tileIndex == _kcHolderBlackOff || tileIndex == _kcHolderBlackOff + 1 )
+		success = useLockedSwitch( e, x, y, targetX, targetY, _kcHolderBlackOn, ITEM_KEYCARD_BLACK, "I need a Black Keycard." );
+	else
+	if ( tileIndex == _kcHolderBlackOn )
+		success = useLockedSwitchOn( e, x, y, targetX, targetY, _kcHolderBlackOff, ITEM_KEYCARD_BLACK );
+	else
+	//-------------------------------------------------------------------
+	if ( tileIndex == _useSwitch2Off || tileIndex == _useSwitch2Off + 1 )
+		success = useSwitch2( e, x, y, targetX, targetY );
+	else
+	if ( tileIndex == _useHolderEmpty || tileIndex == _useHolderEmpty + 1 )
+		success = useCellHolder( e, x, y, targetX, targetY );
+	else
+	//-------------------------------------------------------------------
+	if ( tileIndex == _targetDoorN || tileIndex == _targetDoorN + 3 )
+		success = useAutoDoorOpenClose( e, x, y );
+	else
+	if ( tileIndex == _targetDoorP || tileIndex == _targetDoorP + 3 )
+		success = useDoorOpenCloseBot( e, x, y );
+	else
+	if ( tileIndex == _targetDoorS || tileIndex == _targetDoorS + 3 )
+		success = useDoorOpenCloseBot( e, x, y );
+	else
+	if ( tileIndex == _targetDoorNv || tileIndex == _targetDoorNv + 3 )
+		success = useAutoDoorOpenClose( e, x, y );
+	else
+	if ( tileIndex == _targetDoorPv || tileIndex == _targetDoorPv + 3 )
+		success = useDoorOpenCloseBot( e, x, y );
+	else
+	if ( tileIndex == _targetDoorSv || tileIndex == _targetDoorSv + 3 )
+		success = useDoorOpenCloseBot( e, x, y );
+	else
+	//-------------------------------------------------------------------
+	if ( tileIndex == _targetDoorN || tileIndex == _targetDoor2N + 3 )
+		success = useAutoDoorOpenClose( e, x, y );
+	else
+	if ( tileIndex == _targetDoorP || tileIndex == _targetDoor2P + 3 )
+		success = useDoorOpenCloseBot( e, x, y );
+	else
+	if ( tileIndex == _targetDoorS || tileIndex == _targetDoor2S + 3 )
+		success = useDoorOpenCloseBot( e, x, y );
+	else
+	if ( tileIndex == _targetDoorNv || tileIndex == _targetDoor2Nv + 3 )
+		success = useAutoDoorOpenClose( e, x, y );
+	else
+	if ( tileIndex == _targetDoorPv || tileIndex == _targetDoor2Pv + 3 )
+		success = useDoorOpenCloseBot( e, x, y );
+	else
+	if ( tileIndex == _targetDoorSv || tileIndex == _targetDoor2Sv + 3 )
+		success = useDoorOpenCloseBot( e, x, y );
+	else
+	//-------------------------------------------------------------------
+	if ( tileIndex == _touchplateOff )
+		success = useTouchplate( e, x, y, targetX, targetY, _touchplateOn );
+	else
+	if ( tileIndex == _touchplateOn )
+		success = useTouchplateOn( e, x, y, targetX, targetY, _touchplateOff );
+	else
+	if ( tileIndex == _templeTouchpOff )
+		success = useTouchplate( e, x, y, targetX, targetY, _templeTouchpOn );
+	else
+	if ( tileIndex == _templeTouchpOn )
+		success = useTouchplateOn( e, x, y, targetX, targetY, _templeTouchpOff );
+
+		return success;
+}
+
+bool AI::checkAutoList(AIEntity *e, int x, int y) {
+	for (int i = 0;i < kMaxAutoActions;i++) {
+		if (_autoActions[i]->x == x && _autoActions[i]->y == y && !_autoActions[i]->activated) {
+			bool success = activateAction(e, x, y, 0, 0);
+			_autoActions[i]->activated = true;
+
+			if (success && _autoActions[i]->luaFuncUse[0])
+				g_hdb->_lua->callFunction(_autoActions[i]->luaFuncUse, 0);
+
+			if (e == _player) {
+				lookAtXY(x, y);
+				animGrabbing();
+			}
+
+			return true;
+		}
+	}
+	return false;
+}
+
+bool AI::autoActive(int x, int y) {
+	for (int i = 0;i < kMaxAutoActions;i++) {
+		if (_autoActions[i]->x == x && _autoActions[i]->y == y) {
+			if (!_autoActions[i]->activated)
+				return false;
+			return true;
+		}
+	}
+	return false;
+}
+
+} // End of Namespace
diff --git a/engines/hdb/ai.h b/engines/hdb/ai.h
index 9327bae..7fcb6ab 100644
--- a/engines/hdb/ai.h
+++ b/engines/hdb/ai.h
@@ -591,6 +591,13 @@ public:
 	void drawEnts(int x, int y, int w, int h);
 	void animGrabbing();
 
+	// List functions
+	void addToAutoList(int x, int y, const char *luaFuncInt, const char *luaFuncUse);
+	void autoDeactivate(int x, int y);
+	bool activateAction(AIEntity *e, int x, int y, int targetX, int targetY);
+	bool checkAutoList(AIEntity *e, int x, int y);
+	bool autoActive(int x, int y);
+
 	bool checkFloating(int x, int y);
 
 	bool getTableEnt(AIType type);


Commit: dfa76fc545286fe806c4eb7d14864385a6d5785f
    https://github.com/scummvm/scummvm/commit/dfa76fc545286fe806c4eb7d14864385a6d5785f
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:16:54+02:00

Commit Message:
HDB: Add _animTargets and related data

Changed paths:
    engines/hdb/ai-init.cpp
    engines/hdb/ai.h


diff --git a/engines/hdb/ai-init.cpp b/engines/hdb/ai-init.cpp
index 65240d1..22cf729 100644
--- a/engines/hdb/ai-init.cpp
+++ b/engines/hdb/ai-init.cpp
@@ -669,6 +669,7 @@ AIEntTypeInfo aiEntList[] = {
 AI::AI() {
 	_ents = new Common::Array<AIEntity *>;
 	_floats = new Common::Array<AIEntity *>;
+	_animTargets = new Common::Array<AnimTarget *>;
 
 	for (int i = 0; i < kMaxLevel2Ents;i++) {
 		_entsLevel2[i] = new AIEntLevel2;
@@ -681,6 +682,7 @@ AI::AI() {
 AI::~AI() {
 	delete _ents;
 	delete _floats;
+	delete _animTargets;
 	for (int i = 0; i < kMaxLevel2Ents;i++) {
 		delete _entsLevel2[i];
 	}
diff --git a/engines/hdb/ai.h b/engines/hdb/ai.h
index 7fcb6ab..754dfdf 100644
--- a/engines/hdb/ai.h
+++ b/engines/hdb/ai.h
@@ -29,6 +29,7 @@ namespace HDB {
 
 enum {
 	kMaxAnimFrames = 8,
+	kMaxAnimTFrames = 16,
 	kMaxDeathFrames = 12,
 	kMaxLevel2Ents = 60,
 	kMaxInventory = 10,
@@ -304,6 +305,12 @@ enum AIState {
 	STATE_ENDSTATES
 };
 
+enum AnimSpeed {
+	ANIM_SLOW,
+	ANIM_NORMAL,
+	ANIM_FAST
+};
+
 enum CineType {
 	C_NO_COMMAND,
 	C_STOPCINE,
@@ -513,13 +520,6 @@ struct AIEntTypeInfo {
 
 extern AIEntTypeInfo aiEntList[];
 
-struct InvEnt {
-	uint16 keep;
-	AIEntity *ent;
-
-	InvEnt() : keep(0), ent(NULL) {}
-};
-
 struct AIEntLevel2 {
 	uint16 x;
 	uint16 y;
@@ -531,6 +531,30 @@ struct AIEntLevel2 {
 	AIEntLevel2() : x(0), y(0), draw(NULL), e(NULL), aiDraw(NULL), stunnedWait(0) {}
 };
 
+struct AnimTarget {
+	uint16 x, y;
+	uint16 start, end;
+	int16 vel;
+	uint16 animCycle;
+	uint16 animFrame;
+	bool killAuto; // Keep it alive if its an Auto?
+	bool inMap;
+	Tile *gfxList[kMaxAnimTFrames];
+
+	AnimTarget() : x(0), y(0), start(0), end(0), vel(0), animCycle(0), animFrame(0), killAuto(false), inMap(false) {
+		for (int i = 0; i < kMaxAnimTFrames;i++) {
+			gfxList[i] = new Tile;
+		}
+	}
+};
+
+struct InvEnt {
+	uint16 keep;
+	AIEntity *ent;
+
+	InvEnt() : keep(0), ent(NULL) {}
+};
+
 struct Waypoint {
 	int x, y, level;
 
@@ -881,6 +905,7 @@ private:
 
 	Common::Array<AIEntity *> *_ents;
 	Common::Array<AIEntity *> *_floats;
+	Common::Array<AnimTarget *> *_animTargets;
 	AIEntity *_player;
 
 	// Cinematics Variables


Commit: ab917b038acf9ddb79ec5b5e5ac10d7dee5cbb93
    https://github.com/scummvm/scummvm/commit/ab917b038acf9ddb79ec5b5e5ac10d7dee5cbb93
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:16:55+02:00

Commit Message:
HDB: Add addAnimTarget() and animateTargets()

Changed paths:
    engines/hdb/ai-lists.cpp
    engines/hdb/ai.h


diff --git a/engines/hdb/ai-lists.cpp b/engines/hdb/ai-lists.cpp
index 2d772a8..5bb8c0c 100644
--- a/engines/hdb/ai-lists.cpp
+++ b/engines/hdb/ai-lists.cpp
@@ -24,6 +24,116 @@
 
 namespace HDB {
 
+/*
+	Adds a tile to an animation list
+*/
+void AI::addAnimateTarget(int x, int y, int start, int end, AnimSpeed speed, bool killAuto, bool inMap, const char *tileName) {
+	AnimTarget *at = new AnimTarget;
+
+	at->x = x;
+	at->y = y;
+	at->start = start;
+	at->end = end;
+	at->killAuto = killAuto; // Doesn't actually kill it, deactivates it
+
+	// Set animCycle and animFrame as per speed
+	switch (speed) {
+	case ANIM_SLOW:
+		at->animCycle = 10;
+		at->animFrame = 10;
+		break;
+	case ANIM_NORMAL:
+		at->animCycle = 6;
+		at->animFrame = 6;
+		break;
+	case ANIM_FAST:
+		at->animCycle = 2;
+		at->animFrame = 2;
+		break;
+	}
+
+	// Set +1/-1 for tile anim direction
+	if ((end - start) > 0)
+		at->vel = 1;
+	else
+		at->vel = -1;
+
+	// Set Info if this is not an inMap animation
+	at->inMap = inMap;
+	if (!inMap) {
+
+		char name[32];
+		uint32 size;
+
+		for (int i = start;i <= end;i++) {
+			if (i < 10)
+				snprintf(name, 32, "%s0%d", tileName, i + 1);
+			else
+				snprintf(name, 32, "%s%d", tileName, i + 1);
+			debug("AddAnimateTarget: %s", name);
+			size = g_hdb->_fileMan->getLength(name, TYPE_TILE32);
+			at->gfxList[i] = g_hdb->_drawMan->getTileGfx(name, size);
+		}
+	}
+
+	// Insert in the beginning
+	_animTargets->insert_at(0, at);
+}
+
+/*
+	Animate _animTargets
+	Called every frame
+*/
+void AI::animateTargets() {
+	AnimTarget *at;
+	int mx, my;
+	int layer;
+
+	g_hdb->_map->getMapXY(&mx, &my);
+
+	for (Common::Array<AnimTarget *>::iterator it = _animTargets->begin(); it != _animTargets->end(); it++) {
+
+		at = *it;
+		// Draw Non-Map stuff every frame
+		if (!at->inMap)
+			at->gfxList[at->start]->drawMasked(at->x - mx, at->y - my);
+
+		// Frame Timer
+		if (at->animFrame-- < 1) {
+			at->animFrame = at->animCycle;
+
+			if (at->inMap) {
+				// Animate Map Tiles
+				layer = 0; // BG layer
+				if (!at->start == g_hdb->_map->getMapBGTileIndex(at->x, at->y))
+					layer = 1;
+
+				// Change Tile Anim
+				at->start += at->vel;
+
+				// Set it back in map
+				if (!layer)
+					g_hdb->_map->setMapBGTileIndex(at->x, at->y, at->start);
+				else
+					g_hdb->_map->setMapFGTileIndex(at->x, at->y, at->start);
+			} else {
+				// Animate non-map tiles
+				at->start++;
+			}
+
+			// Animation Finished ?
+			if (at->start == at->end) {
+
+				if (at->killAuto)
+					autoDeactivate(at->x, at->y);
+
+				_animTargets->erase(it);
+				continue;
+			}
+		}
+	}
+}
+
 void AI::addToAutoList(int x, int y, const char *luaFuncInit, const char *luaFuncUse) {
 
 	const char *get;
diff --git a/engines/hdb/ai.h b/engines/hdb/ai.h
index 754dfdf..0872938 100644
--- a/engines/hdb/ai.h
+++ b/engines/hdb/ai.h
@@ -615,6 +615,9 @@ public:
 	void drawEnts(int x, int y, int w, int h);
 	void animGrabbing();
 
+	void addAnimateTarget(int x, int y, int start, int end, AnimSpeed speed, bool killAuto, bool inMap, const char *tileName);
+	void animateTargets();
+
 	// List functions
 	void addToAutoList(int x, int y, const char *luaFuncInt, const char *luaFuncUse);
 	void autoDeactivate(int x, int y);


Commit: 7c823019be7d9eaf1b3c1692e85b993d05e31720
    https://github.com/scummvm/scummvm/commit/7c823019be7d9eaf1b3c1692e85b993d05e31720
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:16:55+02:00

Commit Message:
HDB: Add _dummyPlayer as Virtual Player

Changed paths:
    engines/hdb/ai-init.cpp
    engines/hdb/ai.h


diff --git a/engines/hdb/ai-init.cpp b/engines/hdb/ai-init.cpp
index 22cf729..b40b7ff 100644
--- a/engines/hdb/ai-init.cpp
+++ b/engines/hdb/ai-init.cpp
@@ -769,6 +769,7 @@ bool AI::init() {
 	_kcHolderBlackOff	= g_hdb->_drawMan->getTileIndex("anim_t32_kcholder_black_off1");
 	_kcHolderBlackOn	= g_hdb->_drawMan->getTileIndex("t32_kcholder_black_on");
 
+	_dummyPlayer.type = AI_GUY;
 	_playerRunning = false;
 
 	restartSystem();
diff --git a/engines/hdb/ai.h b/engines/hdb/ai.h
index 0872938..3bbb2d7 100644
--- a/engines/hdb/ai.h
+++ b/engines/hdb/ai.h
@@ -876,6 +876,9 @@ public:
 
 	AutoAction *_autoActions[kMaxAutoActions];
 
+	// Virtual Player
+	AIEntity _dummyPlayer;
+
 	// Cinematic Variables
 	Common::Array<CineCommand *> _cine;
 


Commit: dd6f33592500d35038ecd930cf7a34b292fa6edc
    https://github.com/scummvm/scummvm/commit/dd6f33592500d35038ecd930cf7a34b292fa6edc
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:16:55+02:00

Commit Message:
HDB: Remove _dummyPlayer stub from getPlayer()

Changed paths:
    engines/hdb/ai.h


diff --git a/engines/hdb/ai.h b/engines/hdb/ai.h
index 3bbb2d7..aff8476 100644
--- a/engines/hdb/ai.h
+++ b/engines/hdb/ai.h
@@ -634,7 +634,8 @@ public:
 
 	// Player Functions
 	AIEntity *getPlayer() {
-		warning("STUB: AI::getPlayer: dummyplayer not supported");
+		if (!_player)
+			return &_dummyPlayer;
 		return _player;
 	}
 


Commit: 00f125e7bdfd3414053bfc99347ff5eba2ee84d5
    https://github.com/scummvm/scummvm/commit/00f125e7bdfd3414053bfc99347ff5eba2ee84d5
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:16:55+02:00

Commit Message:
HDB: Unstub checkAutoList() from C_USEENTITY

Changed paths:
    engines/hdb/ai-cinematic.cpp


diff --git a/engines/hdb/ai-cinematic.cpp b/engines/hdb/ai-cinematic.cpp
index 8706981..b9a55a5 100644
--- a/engines/hdb/ai-cinematic.cpp
+++ b/engines/hdb/ai-cinematic.cpp
@@ -215,7 +215,10 @@ void AI::processCines() {
 				}
 			}
 			warning("STUB: PROCESSCINES: USEENTITY: CheckActionList required;");
-			warning("STUB: PROCESSCINES: USEENTITY: CheckAutoList required;");
+			for (int i = 0;i < kMaxAutoActions;i++) {
+				if (Common::matchString(_autoActions[i]->entityName, _cine[i]->string) && !_autoActions[i]->activated)
+					checkAutoList(&_dummyPlayer, _autoActions[i]->x, _autoActions[i]->y);
+			}
 			complete = true;
 			break;
 		case C_FADEIN:


Commit: 5cba8ae09c14b49ebfd2c060f7cae67b9def749a
    https://github.com/scummvm/scummvm/commit/5cba8ae09c14b49ebfd2c060f7cae67b9def749a
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:16:55+02:00

Commit Message:
HDB: Remove Player Gfx stub from lookAtEntityXY

Changed paths:
    engines/hdb/ai-funcs.cpp


diff --git a/engines/hdb/ai-funcs.cpp b/engines/hdb/ai-funcs.cpp
index ea02353..eab6538 100644
--- a/engines/hdb/ai-funcs.cpp
+++ b/engines/hdb/ai-funcs.cpp
@@ -1334,19 +1334,19 @@ void AI::lookAtXY(int x, int y) {
 	switch (_player->dir) {
 	case DIR_UP:
 		_player->state = STATE_STANDUP;
-		warning("STUB: Set _player->draw to Player standup_gfx");
+		_player->draw = _getGfx[DIR_UP];
 		break;
 	case DIR_DOWN:
 		_player->state = STATE_STANDDOWN;
-		warning("STUB: Set _player->draw to Player standdown_gfx");
+		_player->draw = _getGfx[DIR_DOWN];
 		break;
 	case DIR_LEFT:
 		_player->state = STATE_STANDLEFT;
-		warning("STUB: Set _player->draw to Player standleft_gfx");
+		_player->draw = _getGfx[DIR_LEFT];
 		break;
 	case DIR_RIGHT:
 		_player->state = STATE_STANDRIGHT;
-		warning("STUB: Set _player->draw to Player standright_gfx");
+		_player->draw = _getGfx[DIR_RIGHT];
 		break;
 	default:
 		warning("AI-FUNCS: lookAtXY: DIR_NONE");


Commit: 154fc3c7f3241f75c2d601e097c692f1b084fa3c
    https://github.com/scummvm/scummvm/commit/154fc3c7f3241f75c2d601e097c692f1b084fa3c
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:16:55+02:00

Commit Message:
HDB: Add _actions list and related data

Changed paths:
    engines/hdb/ai-init.cpp
    engines/hdb/ai.h


diff --git a/engines/hdb/ai-init.cpp b/engines/hdb/ai-init.cpp
index b40b7ff..18196b8 100644
--- a/engines/hdb/ai-init.cpp
+++ b/engines/hdb/ai-init.cpp
@@ -823,6 +823,9 @@ void AI::restartSystem() {
 	memset(_clubLeftGfx, NULL, kMaxAnimFrames * sizeof(Tile *));
 	memset(_clubRightGfx, NULL, kMaxAnimFrames * sizeof(Tile *));
 
+	// Clear the Action list
+	memset(_actions, 0, sizeof(_actions));
+
 	// Clear the Auto-Action list
 	memset(_autoActions, 0, sizeof(_autoActions));
 
diff --git a/engines/hdb/ai.h b/engines/hdb/ai.h
index aff8476..d11442b 100644
--- a/engines/hdb/ai.h
+++ b/engines/hdb/ai.h
@@ -35,6 +35,7 @@ enum {
 	kMaxInventory = 10,
 	kMaxDeliveries = 5,
 	kMaxWaypoints = 10,
+	kMaxActions = 20,
 	kMaxAutoActions = 30,
 	kPlayerMoveSpeed = 4,
 	kEnemyMoveSpeed = 2,
@@ -561,6 +562,16 @@ struct Waypoint {
 	Waypoint() : x(0), y(0), level(0) {}
 };
 
+struct ActionInfo {
+	uint16 x1, y1;
+	uint16 x2, y2;
+	char luaFuncInit[32];
+	char luaFuncUse[32];
+	char entityName[32];
+
+	ActionInfo() : x1(0), y1(0), x2(0), y2(0), luaFuncInit(""), luaFuncUse(""), entityName("") {}
+};
+
 struct AutoAction {
 	uint16 x, y;
 	bool activated;
@@ -875,6 +886,8 @@ public:
 	int _numWaypoints;
 	Tile *_waypointGfx[4]; // Animating waypoint gfx
 
+	ActionInfo *_actions[kMaxActions];
+
 	AutoAction *_autoActions[kMaxAutoActions];
 
 	// Virtual Player


Commit: 653960f58aa623d6155cda6a03632a718f47a2c5
    https://github.com/scummvm/scummvm/commit/653960f58aa623d6155cda6a03632a718f47a2c5
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:16:55+02:00

Commit Message:
HDB: Shift Action initialization to AI()

Changed paths:
    engines/hdb/ai-init.cpp
    engines/hdb/ai-lists.cpp


diff --git a/engines/hdb/ai-init.cpp b/engines/hdb/ai-init.cpp
index 18196b8..05e939f 100644
--- a/engines/hdb/ai-init.cpp
+++ b/engines/hdb/ai-init.cpp
@@ -671,9 +671,15 @@ AI::AI() {
 	_floats = new Common::Array<AIEntity *>;
 	_animTargets = new Common::Array<AnimTarget *>;
 
-	for (int i = 0; i < kMaxLevel2Ents;i++) {
+	for (int i = 0; i < kMaxLevel2Ents; i++) {
 		_entsLevel2[i] = new AIEntLevel2;
 	}
+	for (int i = 0; i < kMaxActions; i++) {
+		_actions[i] = new ActionInfo;
+	}
+	for (int i = 0; i < kMaxAutoActions; i++) {
+		_autoActions[i] = new AutoAction;
+	}
 
 	// REMOVE: Remove for final. Used here due to lack of a MENU
 	_numGems = _numGooCups = _numMonkeystones = _numInventory = 0;
diff --git a/engines/hdb/ai-lists.cpp b/engines/hdb/ai-lists.cpp
index 5bb8c0c..1ef2e41 100644
--- a/engines/hdb/ai-lists.cpp
+++ b/engines/hdb/ai-lists.cpp
@@ -139,8 +139,7 @@ void AI::addToAutoList(int x, int y, const char *luaFuncInit, const char *luaFun
 	const char *get;
 
 	for (int i = 0;i < kMaxAutoActions;i++) {
-		if (!_autoActions[i]) {
-			_autoActions[i] = new AutoAction;
+		if (!_autoActions[i]->x) {
 			_autoActions[i]->x = x;
 			_autoActions[i]->y = y;
 			_autoActions[i]->activated = false;


Commit: a39b9f373ca42c1ff25d2d479fee7efc071da498
    https://github.com/scummvm/scummvm/commit/a39b9f373ca42c1ff25d2d479fee7efc071da498
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:16:55+02:00

Commit Message:
HDB: Modify AI pointer arrays to be struct arrays

Changed paths:
    engines/hdb/ai-cinematic.cpp
    engines/hdb/ai-funcs.cpp
    engines/hdb/ai-init.cpp
    engines/hdb/ai-inventory.cpp
    engines/hdb/ai-lists.cpp
    engines/hdb/ai.h


diff --git a/engines/hdb/ai-cinematic.cpp b/engines/hdb/ai-cinematic.cpp
index b9a55a5..eb4b14c 100644
--- a/engines/hdb/ai-cinematic.cpp
+++ b/engines/hdb/ai-cinematic.cpp
@@ -216,8 +216,8 @@ void AI::processCines() {
 			}
 			warning("STUB: PROCESSCINES: USEENTITY: CheckActionList required;");
 			for (int i = 0;i < kMaxAutoActions;i++) {
-				if (Common::matchString(_autoActions[i]->entityName, _cine[i]->string) && !_autoActions[i]->activated)
-					checkAutoList(&_dummyPlayer, _autoActions[i]->x, _autoActions[i]->y);
+				if (Common::matchString(_autoActions[i].entityName, _cine[i]->string) && !_autoActions[i].activated)
+					checkAutoList(&_dummyPlayer, _autoActions[i].x, _autoActions[i].y);
 			}
 			complete = true;
 			break;
diff --git a/engines/hdb/ai-funcs.cpp b/engines/hdb/ai-funcs.cpp
index eab6538..6eadc92 100644
--- a/engines/hdb/ai-funcs.cpp
+++ b/engines/hdb/ai-funcs.cpp
@@ -569,7 +569,7 @@ void AI::initAllEnts() {
 	}
 
 	for (int i = 0; i < _numInventory; i++) {
-		AIEntity *temp = _inventory[i]->ent;
+		AIEntity *temp = _inventory[i].ent;
 
 		// Clear out all ptrs in entity before writing
 		for (int j = 0; i < kMaxAnimFrames; i++) {
@@ -1116,11 +1116,11 @@ void AI::drawEnts(int x, int y, int w, int h) {
 		if (e->type == AI_LASER || e->type == AI_DIVERTER) {
 			if (e->aiDraw) {
 				if (e->level == 2 && _numLevel2Ents < kMaxLevel2Ents) {
-					_entsLevel2[_numLevel2Ents]->aiDraw = e->aiDraw;
-					_entsLevel2[_numLevel2Ents]->x = x;
-					_entsLevel2[_numLevel2Ents]->y = y;
-					_entsLevel2[_numLevel2Ents]->e = e;
-					_entsLevel2[_numLevel2Ents]->stunnedWait = 0;
+					_entsLevel2[_numLevel2Ents].aiDraw = e->aiDraw;
+					_entsLevel2[_numLevel2Ents].x = x;
+					_entsLevel2[_numLevel2Ents].y = y;
+					_entsLevel2[_numLevel2Ents].e = e;
+					_entsLevel2[_numLevel2Ents].stunnedWait = 0;
 					_numLevel2Ents++;
 				} else {
 					e->aiDraw(e, x, y);
@@ -1132,12 +1132,12 @@ void AI::drawEnts(int x, int y, int w, int h) {
 			// If extra drawing func is present, call it
 			if (e->aiDraw && e->type != AI_LASER && e->type != AI_DIVERTER) {
 				if (e->level == 2 && _numLevel2Ents < kMaxLevel2Ents) {
-					_entsLevel2[_numLevel2Ents]->aiDraw = e->aiDraw;
-					_entsLevel2[_numLevel2Ents]->draw = e->draw;
-					_entsLevel2[_numLevel2Ents]->x = x;
-					_entsLevel2[_numLevel2Ents]->y = y;
-					_entsLevel2[_numLevel2Ents]->e = e;
-					_entsLevel2[_numLevel2Ents]->stunnedWait = 0;
+					_entsLevel2[_numLevel2Ents].aiDraw = e->aiDraw;
+					_entsLevel2[_numLevel2Ents].draw = e->draw;
+					_entsLevel2[_numLevel2Ents].x = x;
+					_entsLevel2[_numLevel2Ents].y = y;
+					_entsLevel2[_numLevel2Ents].e = e;
+					_entsLevel2[_numLevel2Ents].stunnedWait = 0;
 					_numLevel2Ents++;
 				} else
 					e->aiDraw(e, x, y);
@@ -1153,12 +1153,12 @@ void AI::drawEnts(int x, int y, int w, int h) {
 				break;
 			default:
 				if (e->level == 2 && _numLevel2Ents < kMaxLevel2Ents) {
-					_entsLevel2[_numLevel2Ents]->aiDraw = NULL;
-					_entsLevel2[_numLevel2Ents]->draw = e->draw;
-					_entsLevel2[_numLevel2Ents]->x = e->x - x + e->drawXOff;
-					_entsLevel2[_numLevel2Ents]->y = e->y - y + e->drawYOff;
-					_entsLevel2[_numLevel2Ents]->e = NULL;
-					_entsLevel2[_numLevel2Ents]->stunnedWait = e->stunnedWait;
+					_entsLevel2[_numLevel2Ents].aiDraw = NULL;
+					_entsLevel2[_numLevel2Ents].draw = e->draw;
+					_entsLevel2[_numLevel2Ents].x = e->x - x + e->drawXOff;
+					_entsLevel2[_numLevel2Ents].y = e->y - y + e->drawYOff;
+					_entsLevel2[_numLevel2Ents].e = NULL;
+					_entsLevel2[_numLevel2Ents].stunnedWait = e->stunnedWait;
 					_numLevel2Ents++;
 				} else {
 					if (e->draw)
diff --git a/engines/hdb/ai-init.cpp b/engines/hdb/ai-init.cpp
index 05e939f..7a7d47d 100644
--- a/engines/hdb/ai-init.cpp
+++ b/engines/hdb/ai-init.cpp
@@ -671,16 +671,6 @@ AI::AI() {
 	_floats = new Common::Array<AIEntity *>;
 	_animTargets = new Common::Array<AnimTarget *>;
 
-	for (int i = 0; i < kMaxLevel2Ents; i++) {
-		_entsLevel2[i] = new AIEntLevel2;
-	}
-	for (int i = 0; i < kMaxActions; i++) {
-		_actions[i] = new ActionInfo;
-	}
-	for (int i = 0; i < kMaxAutoActions; i++) {
-		_autoActions[i] = new AutoAction;
-	}
-
 	// REMOVE: Remove for final. Used here due to lack of a MENU
 	_numGems = _numGooCups = _numMonkeystones = _numInventory = 0;
 }
@@ -689,9 +679,6 @@ AI::~AI() {
 	delete _ents;
 	delete _floats;
 	delete _animTargets;
-	for (int i = 0; i < kMaxLevel2Ents;i++) {
-		delete _entsLevel2[i];
-	}
 }
 
 bool AI::init() {
diff --git a/engines/hdb/ai-inventory.cpp b/engines/hdb/ai-inventory.cpp
index 7505aef..25376bf 100644
--- a/engines/hdb/ai-inventory.cpp
+++ b/engines/hdb/ai-inventory.cpp
@@ -61,7 +61,7 @@ bool AI::addToInventory(AIEntity *e) {
 		return false;
 	}
 
-	_inventory[_numInventory]->ent = e;
+	_inventory[_numInventory].ent = e;
 	_numInventory++;
 
 	// If weapon, ready it
@@ -84,12 +84,14 @@ bool AI::addToInventory(AIEntity *e) {
 void AI::clearInventory() {
 	int keepslot = 0;
 	for (int i = 0; i < _numInventory; i++) {
-		if (!_inventory[i]->keep) {
-			_inventory[i] = NULL;
+		if (!_inventory[i].keep) {
+			memset(&_inventory[i], 0, sizeof(InvEnt));
 		} else {
 			if (i != keepslot) {
 				_inventory[keepslot] = _inventory[i];
-				_inventory[i] = NULL;
+				_inventory[keepslot].ent = _inventory[i].ent;
+				_inventory[keepslot].keep = _inventory[i].keep;
+				memset(&_inventory[i], 0, sizeof(InvEnt));
 			}
 			keepslot++;
 		}
diff --git a/engines/hdb/ai-lists.cpp b/engines/hdb/ai-lists.cpp
index 1ef2e41..5165313 100644
--- a/engines/hdb/ai-lists.cpp
+++ b/engines/hdb/ai-lists.cpp
@@ -139,25 +139,25 @@ void AI::addToAutoList(int x, int y, const char *luaFuncInit, const char *luaFun
 	const char *get;
 
 	for (int i = 0;i < kMaxAutoActions;i++) {
-		if (!_autoActions[i]->x) {
-			_autoActions[i]->x = x;
-			_autoActions[i]->y = y;
-			_autoActions[i]->activated = false;
+		if (!_autoActions[i].x) {
+			_autoActions[i].x = x;
+			_autoActions[i].y = y;
+			_autoActions[i].activated = false;
 			if (luaFuncInit[0] != '*')
-				strcpy(&_autoActions[i]->luaFuncInit[0], luaFuncInit);
+				strcpy(&_autoActions[i].luaFuncInit[0], luaFuncInit);
 			if (luaFuncUse[0] != '*')
-				strcpy(&_autoActions[i]->luaFuncUse[0], luaFuncUse);
+				strcpy(&_autoActions[i].luaFuncUse[0], luaFuncUse);
 
-			if (_autoActions[i]->luaFuncInit[0]) {
-				g_hdb->_lua->callFunction(_autoActions[i]->luaFuncInit, 2);
+			if (_autoActions[i].luaFuncInit[0]) {
+				g_hdb->_lua->callFunction(_autoActions[i].luaFuncInit, 2);
 				get = g_hdb->_lua->getStringOffStack();
 				if (!get)
 					return;
-				strcpy(&_autoActions[i]->entityName[0], get);
+				strcpy(&_autoActions[i].entityName[0], get);
 				get = g_hdb->_lua->getStringOffStack();
 				if (!get)
 					return;
-				strcpy(&_autoActions[i]->entityName[0], get);
+				strcpy(&_autoActions[i].entityName[0], get);
 			}
 			return;
 		}
@@ -166,8 +166,8 @@ void AI::addToAutoList(int x, int y, const char *luaFuncInit, const char *luaFun
 
 void AI::autoDeactivate(int x, int y) {
 	for (int i = 0; i < kMaxAutoActions;i++) {
-		if (_autoActions[i]->x == x && _autoActions[i]->y == y) {
-			_autoActions[i]->activated = false;
+		if (_autoActions[i].x == x && _autoActions[i].y == y) {
+			_autoActions[i].activated = false;
 			return;
 		}
 	}
@@ -299,12 +299,12 @@ bool AI::activateAction(AIEntity *e, int x, int y, int targetX, int targetY) {
 
 bool AI::checkAutoList(AIEntity *e, int x, int y) {
 	for (int i = 0;i < kMaxAutoActions;i++) {
-		if (_autoActions[i]->x == x && _autoActions[i]->y == y && !_autoActions[i]->activated) {
+		if (_autoActions[i].x == x && _autoActions[i].y == y && !_autoActions[i].activated) {
 			bool success = activateAction(e, x, y, 0, 0);
-			_autoActions[i]->activated = true;
+			_autoActions[i].activated = true;
 
-			if (success && _autoActions[i]->luaFuncUse[0])
-				g_hdb->_lua->callFunction(_autoActions[i]->luaFuncUse, 0);
+			if (success && _autoActions[i].luaFuncUse[0])
+				g_hdb->_lua->callFunction(_autoActions[i].luaFuncUse, 0);
 
 			if (e == _player) {
 				lookAtXY(x, y);
@@ -319,8 +319,8 @@ bool AI::checkAutoList(AIEntity *e, int x, int y) {
 
 bool AI::autoActive(int x, int y) {
 	for (int i = 0;i < kMaxAutoActions;i++) {
-		if (_autoActions[i]->x == x && _autoActions[i]->y == y) {
-			if (!_autoActions[i]->activated)
+		if (_autoActions[i].x == x && _autoActions[i].y == y) {
+			if (!_autoActions[i].activated)
 				return false;
 			return true;
 		}
diff --git a/engines/hdb/ai.h b/engines/hdb/ai.h
index d11442b..df70072 100644
--- a/engines/hdb/ai.h
+++ b/engines/hdb/ai.h
@@ -876,19 +876,19 @@ public:
 	int			_kcHolderBlackOff;
 	int			_kcHolderBlackOn;
 
-	AIEntLevel2 *_entsLevel2[kMaxLevel2Ents];
+	AIEntLevel2 _entsLevel2[kMaxLevel2Ents];
 	int _numLevel2Ents;
 
-	InvEnt *_inventory[kMaxInventory];
+	InvEnt _inventory[kMaxInventory];
 	int _numInventory;
 
 	Waypoint _waypoints[kMaxWaypoints];
 	int _numWaypoints;
 	Tile *_waypointGfx[4]; // Animating waypoint gfx
 
-	ActionInfo *_actions[kMaxActions];
+	ActionInfo _actions[kMaxActions];
 
-	AutoAction *_autoActions[kMaxAutoActions];
+	AutoAction _autoActions[kMaxAutoActions];
 
 	// Virtual Player
 	AIEntity _dummyPlayer;


Commit: 2cdf2a62decddc21cbb2c5a4d10f74c55ff32c17
    https://github.com/scummvm/scummvm/commit/2cdf2a62decddc21cbb2c5a4d10f74c55ff32c17
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:16:55+02:00

Commit Message:
HDB: Add stubbed addWaypoint()

Changed paths:
    engines/hdb/ai-waypoint.cpp
    engines/hdb/ai.h


diff --git a/engines/hdb/ai-waypoint.cpp b/engines/hdb/ai-waypoint.cpp
index ee053ed..9faa88c 100644
--- a/engines/hdb/ai-waypoint.cpp
+++ b/engines/hdb/ai-waypoint.cpp
@@ -24,6 +24,33 @@
 
 namespace HDB {
 
+void AI::addWaypoint(int px, int py, int x, int y, int level) {
+	if (_numWaypoints >= kMaxWaypoints || (playerOnIce() && _player->goalX))
+		return;
+
+	// Check for duplicates
+	for (int i = 0;i < _numWaypoints;i++)
+		if (_waypoints[i].x == x && _waypoints[i].y == y)
+			return;
+
+	// Check if path is clear
+	int nx = x;
+	int ny = y;
+	if (!_numWaypoints) {
+		warning("STUB: addWaypoint: Setup First Waypoint");
+	} else {
+		warning("STUB: addWaypoint: Setup additional Waypoints");
+	}
+
+	if (_numWaypoints < kMaxWaypoints) {
+		_waypoints[_numWaypoints].x = nx;
+		_waypoints[_numWaypoints].y = ny;
+		_waypoints[_numWaypoints].level = level;
+		_numWaypoints++;
+		warning("STUB: addWaypoint: Play SND_MENU_SLIDER");
+	}
+}
+
 void AI::removeFirstWaypoint() {
 	if (!_numWaypoints)
 		return;
diff --git a/engines/hdb/ai.h b/engines/hdb/ai.h
index df70072..f67fbd7 100644
--- a/engines/hdb/ai.h
+++ b/engines/hdb/ai.h
@@ -723,6 +723,7 @@ public:
 
 	// Waypoint & Movement Functions
 	void lookAtXY(int x, int y);
+	void addWaypoint(int px, int py, int x, int y, int level);
 	void removeFirstWaypoint();
 	void clearWaypoints();
 	Tile *getStandFrameDir(AIEntity *e);


Commit: 43f6a0a475dfd403db80c3645029f8f20e14ca2b
    https://github.com/scummvm/scummvm/commit/43f6a0a475dfd403db80c3645029f8f20e14ca2b
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:16:55+02:00

Commit Message:
HDB: Add checkForTouchplate()

Changed paths:
    engines/hdb/ai-funcs.cpp
    engines/hdb/ai.h


diff --git a/engines/hdb/ai-funcs.cpp b/engines/hdb/ai-funcs.cpp
index 6eadc92..9faafe1 100644
--- a/engines/hdb/ai-funcs.cpp
+++ b/engines/hdb/ai-funcs.cpp
@@ -1220,6 +1220,13 @@ void AI::animGrabbing() {
 	_player->animFrame = 5;
 }
 
+int AI::checkForTouchplate(int x, int y) {
+	int tileIndex = g_hdb->_map->getMapBGTileIndex(x, y);
+	if (tileIndex == _touchplateOff || tileIndex == _templeTouchpOff)
+		return tileIndex;
+	return 0;
+}
+
 bool AI::checkFloating(int x, int y) {
 	for (Common::Array<AIEntity *>::iterator it = _floats->begin(); it != _floats->end(); it++) {
 		if ((*it)->tileX == x && (*it)->tileY == y)
diff --git a/engines/hdb/ai.h b/engines/hdb/ai.h
index f67fbd7..632a955 100644
--- a/engines/hdb/ai.h
+++ b/engines/hdb/ai.h
@@ -626,6 +626,8 @@ public:
 	void drawEnts(int x, int y, int w, int h);
 	void animGrabbing();
 
+	int checkForTouchplate(int x, int y);
+
 	void addAnimateTarget(int x, int y, int start, int end, AnimSpeed speed, bool killAuto, bool inMap, const char *tileName);
 	void animateTargets();
 


Commit: ab0402622eb48d7df68466c98ff08686b1d46603
    https://github.com/scummvm/scummvm/commit/ab0402622eb48d7df68466c98ff08686b1d46603
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:16:55+02:00

Commit Message:
HDB: Add findEntity()

Changed paths:
    engines/hdb/ai-funcs.cpp
    engines/hdb/ai.h


diff --git a/engines/hdb/ai-funcs.cpp b/engines/hdb/ai-funcs.cpp
index 9faafe1..f81a65f 100644
--- a/engines/hdb/ai-funcs.cpp
+++ b/engines/hdb/ai-funcs.cpp
@@ -512,6 +512,23 @@ AIEntity *AI::locateEntity(const char *luaName) {
 	return NULL;
 }
 
+AIEntity *AI::findEntity(int x, int y) {
+	for (Common::Array<AIEntity *>::iterator it = _ents->begin(); it != _ents->end(); it++) {
+		if ((*it)->tileX == x && (*it)->tileY == y) {
+			return *it;
+		}
+	}
+
+	for (Common::Array<AIEntity *>::iterator it = _floats->begin(); it != _floats->end(); it++) {
+		if ((*it)->tileX == x && (*it)->tileY == y) {
+			return *it;
+		}
+	}
+
+	warning("STUB: findEntity: Check for Laser");
+	return NULL;
+}
+
 void AI::removeEntity(AIEntity *e) {
 	_ents->erase(&e);
 }
diff --git a/engines/hdb/ai.h b/engines/hdb/ai.h
index 632a955..334725c 100644
--- a/engines/hdb/ai.h
+++ b/engines/hdb/ai.h
@@ -615,6 +615,7 @@ public:
 	bool cacheEntGfx(AIEntity *e, bool init);
 	void stopEntity(AIEntity *e);
 	AIEntity *locateEntity(const char *luaName);
+	AIEntity *findEntity(int x, int y);
 	void removeEntity(AIEntity *e);
 	void setEntityGoal(AIEntity *e, int x, int y);
 	void initAllEnts();


Commit: c3755f74ceb5f8df2ad15d39d9874be0c2b47b18
    https://github.com/scummvm/scummvm/commit/c3755f74ceb5f8df2ad15d39d9874be0c2b47b18
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:16:55+02:00

Commit Message:
HDB: Add addToActionList() and checkActionList()

Changed paths:
    engines/hdb/ai-lists.cpp
    engines/hdb/ai.h
    engines/hdb/hdb.h


diff --git a/engines/hdb/ai-lists.cpp b/engines/hdb/ai-lists.cpp
index 5165313..79ad0a6 100644
--- a/engines/hdb/ai-lists.cpp
+++ b/engines/hdb/ai-lists.cpp
@@ -134,6 +134,94 @@ void AI::animateTargets() {
 	}
 }
 
+// Add an action location to the list of possible actions
+// Each action must be paired with another of the same number
+void AI::addToActionList(int actionIndex, int x, int y, char *luaFuncInt, char *luaFuncUse) {
+
+	if (!_actions[actionIndex].x1) {
+		_actions[actionIndex].x1 = x;
+		_actions[actionIndex].y1 = y;
+		if (luaFuncInt[0] != '*')
+			strcpy(_actions[actionIndex].luaFuncInit, luaFuncInt);
+		if (luaFuncInt[0] != '*')
+			strcpy(_actions[actionIndex].luaFuncUse, luaFuncUse);
+
+		if (_actions[actionIndex].luaFuncInit[0]) {
+			g_hdb->_lua->callFunction(_actions[actionIndex].luaFuncInit, 2);
+			strcpy(_actions[actionIndex].entityName, g_hdb->_lua->getStringOffStack());
+			strcpy(_actions[actionIndex].entityName, g_hdb->_lua->getStringOffStack());
+		}
+		return;
+	}
+
+	if (!_actions[actionIndex].x2) {
+		_actions[actionIndex].x2 = x;
+		_actions[actionIndex].y2 = y;
+		if (luaFuncInt[0] != '*')
+			strcpy(_actions[actionIndex].luaFuncInit, luaFuncInt);
+		if (luaFuncInt[0] != '*')
+			strcpy(_actions[actionIndex].luaFuncUse, luaFuncUse);
+
+		if (_actions[actionIndex].luaFuncInit[0]) {
+			g_hdb->_lua->callFunction(_actions[actionIndex].luaFuncInit, 2);
+			strcpy(_actions[actionIndex].entityName, g_hdb->_lua->getStringOffStack());
+			strcpy(_actions[actionIndex].entityName, g_hdb->_lua->getStringOffStack());
+		}
+		return;
+	}
+
+	warning("Adding a 3rd action to ACTION-%d is illegal", actionIndex);
+}
+
+// Checks if the location passed-in matches an action pair.
+// If so, activate it if possible. Returns TRUE for finding pair.
+bool AI::checkActionList(AIEntity *e, int x, int y, bool lookAndGrab) {
+	for (int i = 0;i < kMaxActions;i++) {
+		if ((_actions[i].x1 == x && _actions[i].y1 == y) || (_actions[i].x2 == x && _actions[i].y2 == y)) {
+			int targetX = _actions[i].x2;
+			int targetY = _actions[i].y2;
+			bool success;
+
+			// Choose target co-ordinates
+			if (x == targetX && y == targetY) {
+				targetX = _actions[i].x1;
+				targetY = _actions[i].y1;
+			}
+
+			// Is this an actual switch?
+			uint32 flags = g_hdb->_map->getMapFGTileFlags(x, y);
+			if (!flags)
+				flags = g_hdb->_map->getMapBGTileFlags(x, y);
+			if (!(flags & kFlagSolid) && (_player->tileX != x && _player->tileY != y))
+				return false;
+			// Closing on something?
+			if (findEntity(targetX, targetY))
+				return false;
+
+			success = activateAction(e, x, y, targetX, targetY);
+
+			// If successful, remove action from list
+			if (success) {
+				_actions[i].x1 = _actions[i].y1 = _actions[i].x2 = _actions[i].y2 = 0;
+
+				// Call Lua Use function if it exists
+				if (_actions[i].luaFuncUse[0])
+					g_hdb->_lua->callFunction(_actions[i].luaFuncUse, 0);
+			} else if (e == _player && !checkForTouchplate(x, y))
+				addWaypoint(e->tileX, e->tileY, x, y, e->level);
+
+			if (lookAndGrab && e == _player) {
+				lookAtXY(x, y);
+				animGrabbing();
+			}
+
+			return true;
+		}
+	}
+
+	return false;
+}
+
 void AI::addToAutoList(int x, int y, const char *luaFuncInit, const char *luaFuncUse) {
 
 	const char *get;
diff --git a/engines/hdb/ai.h b/engines/hdb/ai.h
index 334725c..2a12061 100644
--- a/engines/hdb/ai.h
+++ b/engines/hdb/ai.h
@@ -633,6 +633,8 @@ public:
 	void animateTargets();
 
 	// List functions
+	void addToActionList(int actionIndex, int x, int y, char *funcLuaInit, char *funcLuaUse);
+	bool checkActionList(AIEntity *e, int x, int y, bool lookAndGrab);
 	void addToAutoList(int x, int y, const char *luaFuncInt, const char *luaFuncUse);
 	void autoDeactivate(int x, int y);
 	bool activateAction(AIEntity *e, int x, int y, int targetX, int targetY);
diff --git a/engines/hdb/hdb.h b/engines/hdb/hdb.h
index 0a3e0a4..bd2f82d 100644
--- a/engines/hdb/hdb.h
+++ b/engines/hdb/hdb.h
@@ -69,6 +69,7 @@ enum GameState {
 };
 
 enum Flag {
+	kFlagSolid			= 0x3,
 	kFlagPlayerDie		= 0x8,
 	kFlagInvisible		= 0x20,
 	kFlagForeground		= 0x80,


Commit: 070a1c45b2cd99912680913d059197a9e1ef3e17
    https://github.com/scummvm/scummvm/commit/070a1c45b2cd99912680913d059197a9e1ef3e17
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:16:55+02:00

Commit Message:
HDB: Comment out C_USEENTITY

It seems that some Entities are being loaded with
a null name. This is causing a crash.

Changed paths:
    engines/hdb/ai-cinematic.cpp


diff --git a/engines/hdb/ai-cinematic.cpp b/engines/hdb/ai-cinematic.cpp
index eb4b14c..46754e1 100644
--- a/engines/hdb/ai-cinematic.cpp
+++ b/engines/hdb/ai-cinematic.cpp
@@ -215,10 +215,12 @@ void AI::processCines() {
 				}
 			}
 			warning("STUB: PROCESSCINES: USEENTITY: CheckActionList required;");
+#if 0
 			for (int i = 0;i < kMaxAutoActions;i++) {
 				if (Common::matchString(_autoActions[i].entityName, _cine[i]->string) && !_autoActions[i].activated)
 					checkAutoList(&_dummyPlayer, _autoActions[i].x, _autoActions[i].y);
 			}
+#endif
 			complete = true;
 			break;
 		case C_FADEIN:


Commit: 2b2d37502716ac3b22e507282e3000693d3c3563
    https://github.com/scummvm/scummvm/commit/2b2d37502716ac3b22e507282e3000693d3c3563
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:16:55+02:00

Commit Message:
HDB: Fix initialization warnings

Changed paths:
    engines/hdb/ai-funcs.cpp


diff --git a/engines/hdb/ai-funcs.cpp b/engines/hdb/ai-funcs.cpp
index f81a65f..ff0c4f9 100644
--- a/engines/hdb/ai-funcs.cpp
+++ b/engines/hdb/ai-funcs.cpp
@@ -1209,7 +1209,7 @@ void AI::animGrabbing() {
 		_player->state == STATE_GRABRIGHT)
 		return;
 
-	AIState s;
+	AIState s = STATE_NONE;
 
 	switch (_player->dir) {
 	case DIR_UP:


Commit: d1a48b9d6f43fb5a69eb474dc509c3dcd49253b1
    https://github.com/scummvm/scummvm/commit/d1a48b9d6f43fb5a69eb474dc509c3dcd49253b1
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:16:55+02:00

Commit Message:
HDB: Fix CineCommand string and title values

Changed paths:
    engines/hdb/ai-cinematic.cpp
    engines/hdb/ai.h


diff --git a/engines/hdb/ai-cinematic.cpp b/engines/hdb/ai-cinematic.cpp
index 46754e1..819b9e2 100644
--- a/engines/hdb/ai-cinematic.cpp
+++ b/engines/hdb/ai-cinematic.cpp
@@ -210,14 +210,14 @@ void AI::processCines() {
 		}
 		case C_USEENTITY:
 			for (Common::Array<AIEntity *>::iterator it = _ents->begin(); it != _ents->end(); it++) {
-				if (Common::matchString((*it)->entityName, _cine[i]->string)) {
+				if ((*it)->entityName && Common::matchString((*it)->entityName, _cine[i]->string)) {
 					g_hdb->useEntity((*it));
 				}
 			}
 			warning("STUB: PROCESSCINES: USEENTITY: CheckActionList required;");
 #if 0
 			for (int i = 0;i < kMaxAutoActions;i++) {
-				if (Common::matchString(_autoActions[i].entityName, _cine[i]->string) && !_autoActions[i].activated)
+				if (_autoActions[i].entityName && Common::matchString(_autoActions[i].entityName, _cine[i]->string) && !_autoActions[i].activated)
 					checkAutoList(&_dummyPlayer, _autoActions[i].x, _autoActions[i].y);
 			}
 #endif
@@ -335,7 +335,7 @@ void AI::cineWaitUntilDone() {
 
 void AI::cineSetEntity(const char *entName, int x, int y, int level) {
 	CineCommand *cmd = new CineCommand;
-	cmd->string = entName;
+	strcpy(cmd->string, entName);
 	cmd->x = x * kTileWidth;
 	cmd->y = y * kTileHeight;
 	cmd->x2 = level;
@@ -350,14 +350,14 @@ void AI::cineMoveEntity(const char *entName, int x, int y, int level, int speed)
 	cmd->x2 = level;
 	cmd->start = 0;
 	cmd->speed = speed;
-	cmd->title = entName;
+	strcpy(cmd->title, entName);
 	cmd->cmdType = C_MOVEENTITY;
 	_cine.push_back(cmd);
 }
 
 void AI::cineEntityFace(const char *luaName, double dir) {
 	CineCommand *cmd = new CineCommand;
-	cmd->title = luaName;
+	strcpy(cmd->title, luaName);
 	cmd->x = dir;
 	cmd->cmdType = C_ENTITYFACE;
 	_cine.push_back(cmd);
@@ -365,7 +365,7 @@ void AI::cineEntityFace(const char *luaName, double dir) {
 
 void AI::cineUse(const char *entName) {
 	CineCommand *cmd = new CineCommand;
-	cmd->string = entName;
+	strcpy(cmd->string, entName);
 	cmd->cmdType = C_USEENTITY;
 	_cine.push_back(cmd);
 }
diff --git a/engines/hdb/ai.h b/engines/hdb/ai.h
index 2a12061..012ed91 100644
--- a/engines/hdb/ai.h
+++ b/engines/hdb/ai.h
@@ -590,13 +590,13 @@ struct CineCommand {
 	int start, end;
 	uint32	delay;
 	int	speed;
-	const char *title;
-	const char *string;
+	char title[32];
+	char string[32];
 	char *id;
 	AIEntity *e;
 
 	CineCommand() : cmdType(C_NO_COMMAND), x(0.0), y(0.0), x2(0.0), y2(0.0), xv(0.0), yv(0.0),
-				start(0), end(0), delay(0), speed(0), title(NULL), string(NULL), id(NULL), e(NULL) {}
+				start(0), end(0), delay(0), speed(0), title(""), string(""), id(NULL), e(NULL) {}
 };
 
 #define onEvenTile(x, y)	( !(x & 31) && !(y & 31) )


Commit: 996ae929fa27b6f7693770a3064a6b40d73a4923
    https://github.com/scummvm/scummvm/commit/996ae929fa27b6f7693770a3064a6b40d73a4923
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:16:55+02:00

Commit Message:
HDB: Add checkAutoList calls to C_USENTITY

Changed paths:
    engines/hdb/ai-cinematic.cpp


diff --git a/engines/hdb/ai-cinematic.cpp b/engines/hdb/ai-cinematic.cpp
index 819b9e2..753386c 100644
--- a/engines/hdb/ai-cinematic.cpp
+++ b/engines/hdb/ai-cinematic.cpp
@@ -214,13 +214,16 @@ void AI::processCines() {
 					g_hdb->useEntity((*it));
 				}
 			}
-			warning("STUB: PROCESSCINES: USEENTITY: CheckActionList required;");
-#if 0
+			for (int i = 0; i < kMaxActions; i++) {
+				if (_actions[i].entityName && Common::matchString(_actions[i].entityName, "door1")) {
+					checkActionList(&_dummyPlayer, _actions[i].x1, _actions[i].y1, false);
+					checkActionList(&_dummyPlayer, _actions[i].x2, _actions[i].y2, false);
+				}
+			}
 			for (int i = 0;i < kMaxAutoActions;i++) {
 				if (_autoActions[i].entityName && Common::matchString(_autoActions[i].entityName, _cine[i]->string) && !_autoActions[i].activated)
 					checkAutoList(&_dummyPlayer, _autoActions[i].x, _autoActions[i].y);
 			}
-#endif
 			complete = true;
 			break;
 		case C_FADEIN:


Commit: 776b257e52477d5b161c5fc3cc1ad8a994def112
    https://github.com/scummvm/scummvm/commit/776b257e52477d5b161c5fc3cc1ad8a994def112
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:16:55+02:00

Commit Message:
HDB: Add cacheTileSequence()

Changed paths:
    engines/hdb/draw-manager.cpp
    engines/hdb/draw-manager.h


diff --git a/engines/hdb/draw-manager.cpp b/engines/hdb/draw-manager.cpp
index 97a4cca..8be1e8b 100644
--- a/engines/hdb/draw-manager.cpp
+++ b/engines/hdb/draw-manager.cpp
@@ -153,6 +153,11 @@ Tile *DrawMan::getTile(int index) {
 	return _tLookupArray[index].tData;
 }
 
+void DrawMan::cacheTileSequence(int tileIndex, int count) {
+	for (int i = tileIndex;i < tileIndex + count;i++)
+		getTile(i);
+}
+
 int DrawMan::getTileIndex(const char *name) {
 	if (!name) {
 		return -1;
diff --git a/engines/hdb/draw-manager.h b/engines/hdb/draw-manager.h
index 3f97d1b..ceae357 100644
--- a/engines/hdb/draw-manager.h
+++ b/engines/hdb/draw-manager.h
@@ -79,6 +79,7 @@ public:
 	void turnOffFade() { _fadeInfo.active = _fadeInfo.stayFaded = false; }
 
 	Tile *getTile(int index);
+	void cacheTileSequence(int index, int count);
 	int getTileIndex(const char *name);
 	Picture *getPicture(const char *name);
 


Commit: ef7eaa925748c17765079b837eae5d42e6dd948e
    https://github.com/scummvm/scummvm/commit/ef7eaa925748c17765079b837eae5d42e6dd948e
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:16:55+02:00

Commit Message:
HDB: Add NULL checking to getMapBG/FGTileFlags()

Changed paths:
    engines/hdb/map-loader.cpp


diff --git a/engines/hdb/map-loader.cpp b/engines/hdb/map-loader.cpp
index 0e18a71e..0cf84e4 100644
--- a/engines/hdb/map-loader.cpp
+++ b/engines/hdb/map-loader.cpp
@@ -691,14 +691,20 @@ uint32 Map::getMapBGTileFlags(int x, int y) {
 	if (x < 0 || x >= _width || y < 0 || y >= _height) {
 		return 0;
 	}
-	return g_hdb->_drawMan->getTile(_background[y * _width + x])->_flags;
+	Tile* tile = g_hdb->_drawMan->getTile(_foreground[y * _width + x]);
+	if (tile)
+		return tile->_flags;
+	return 0;
 }
 
 uint32 Map::getMapFGTileFlags(int x, int y) {
 	if (x < 0 || x >= _width || y < 0 || y >= _height) {
 		return 0;
 	}
-	return g_hdb->_drawMan->getTile(_foreground[y * _width + x])->_flags;
+	Tile* tile = g_hdb->_drawMan->getTile(_foreground[y * _width + x]);
+	if (tile)
+		return tile->_flags;
+	return 0;
 }
 
 uint16 Map::getMapBGTileIndex(int x, int y) {


Commit: b2ee1c680292b0a16544d2a583db2fd730522878
    https://github.com/scummvm/scummvm/commit/b2ee1c680292b0a16544d2a583db2fd730522878
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:16:56+02:00

Commit Message:
HDB: Add checkOneTileExistInRange()

Changed paths:
    engines/hdb/map-loader.cpp
    engines/hdb/map-loader.h


diff --git a/engines/hdb/map-loader.cpp b/engines/hdb/map-loader.cpp
index 0cf84e4..17da352 100644
--- a/engines/hdb/map-loader.cpp
+++ b/engines/hdb/map-loader.cpp
@@ -916,4 +916,14 @@ void Map::centerMapXY(int x, int y) {
 	setMapXY(x, y);
 }
 
+bool Map::checkOneTileExistInRange(int tileIndex, int count) {
+	for (int i = 0; i < _width*_height;i++) {
+		if (_background[i] >= tileIndex && _background[i] < tileIndex + count)
+			return true;
+		if (_foreground[i] >= tileIndex && _foreground[i] < tileIndex + count)
+			return true;
+	}
+	return true;
+}
+
 }
diff --git a/engines/hdb/map-loader.h b/engines/hdb/map-loader.h
index da8b7d6..f59159a 100644
--- a/engines/hdb/map-loader.h
+++ b/engines/hdb/map-loader.h
@@ -92,6 +92,9 @@ public:
 	void setMapXY(int x, int y);
 	void centerMapXY(int x, int y);
 
+	// Check if one of the tiles in a range exists in the map on either layer
+	bool checkOneTileExistInRange(int tileIndex, int count);
+
 	int _mapX, _mapY; // Coordinates of Map
 	int _mapTileX, _mapTileY; // Tile Coordinates of Map
 	int _mapTileXOff, _mapTileYOff; // Tile Coordinates Offset (0-31)


Commit: 0b4a6fd1b039fdcd38c3837c39e551e0a96db1da
    https://github.com/scummvm/scummvm/commit/0b4a6fd1b039fdcd38c3837c39e551e0a96db1da
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:16:56+02:00

Commit Message:
HDB: Add initAnimInfo()

Changed paths:
    engines/hdb/ai-init.cpp
    engines/hdb/ai.h


diff --git a/engines/hdb/ai-init.cpp b/engines/hdb/ai-init.cpp
index 7a7d47d..89be28d 100644
--- a/engines/hdb/ai-init.cpp
+++ b/engines/hdb/ai-init.cpp
@@ -832,4 +832,99 @@ void AI::restartSystem() {
 	memset(&_waypoints[0], 0, sizeof(_waypoints));
 	_numWaypoints = 0;
 }
+
+void AI::initAnimInfo() {
+	if (g_hdb->_map->checkOneTileExistInRange(_useSwitchOff, 2))
+		g_hdb->_drawMan->getTile(_useSwitchOn);
+	if (g_hdb->_map->checkOneTileExistInRange(_useSwitch2Off, 2))
+		g_hdb->_drawMan->getTile(_useSwitch2On);
+	if (g_hdb->_map->checkOneTileExistInRange(_useHolderEmpty, 2))
+		g_hdb->_drawMan->getTile(_useHolderFull);
+	if (g_hdb->_map->checkOneTileExistInRange(_useHandswitchOff, 2))
+		g_hdb->_drawMan->getTile(_useHandswitchOn);
+
+	if (g_hdb->_map->checkOneTileExistInRange(_targetDoorN, 4))
+		g_hdb->_drawMan->cacheTileSequence(_targetDoorN, 4);
+	if (g_hdb->_map->checkOneTileExistInRange(_targetDoorP, 4))
+		g_hdb->_drawMan->cacheTileSequence(_targetDoorP, 4);
+	if (g_hdb->_map->checkOneTileExistInRange(_targetDoorS, 4))
+		g_hdb->_drawMan->cacheTileSequence(_targetDoorS, 4);
+	if (g_hdb->_map->checkOneTileExistInRange(_targetDoorNv, 4))
+		g_hdb->_drawMan->cacheTileSequence(_targetDoorNv, 4);
+	if (g_hdb->_map->checkOneTileExistInRange(_targetDoorPv, 4))
+		g_hdb->_drawMan->cacheTileSequence(_targetDoorPv, 4);
+	if (g_hdb->_map->checkOneTileExistInRange(_targetDoorSv, 4))
+		g_hdb->_drawMan->cacheTileSequence(_targetDoorSv, 4);
+
+	if (g_hdb->_map->checkOneTileExistInRange(_targetDoor2N, 4))
+		g_hdb->_drawMan->cacheTileSequence(_targetDoor2N, 4);
+	if (g_hdb->_map->checkOneTileExistInRange(_targetDoor2P, 4))
+		g_hdb->_drawMan->cacheTileSequence(_targetDoor2P, 4);
+	if (g_hdb->_map->checkOneTileExistInRange(_targetDoor2S, 4))
+		g_hdb->_drawMan->cacheTileSequence(_targetDoor2S, 4);
+	if (g_hdb->_map->checkOneTileExistInRange(_targetDoor2Nv, 4))
+		g_hdb->_drawMan->cacheTileSequence(_targetDoor2Nv, 4);
+	if (g_hdb->_map->checkOneTileExistInRange(_targetDoor2Pv, 4))
+		g_hdb->_drawMan->cacheTileSequence(_targetDoor2Pv, 4);
+	if (g_hdb->_map->checkOneTileExistInRange(_targetDoor2Sv, 4))
+		g_hdb->_drawMan->cacheTileSequence(_targetDoor2Sv, 4);
+
+	if (g_hdb->_map->checkOneTileExistInRange(_target2DoorN, 4))
+		g_hdb->_drawMan->cacheTileSequence(_target2DoorN, 4);
+	if (g_hdb->_map->checkOneTileExistInRange(_target2DoorP, 4))
+		g_hdb->_drawMan->cacheTileSequence(_target2DoorP, 4);
+	if (g_hdb->_map->checkOneTileExistInRange(_target2DoorS, 4))
+		g_hdb->_drawMan->cacheTileSequence(_target2DoorS, 4);
+	if (g_hdb->_map->checkOneTileExistInRange(_target2DoorNv, 4))
+		g_hdb->_drawMan->cacheTileSequence(_target2DoorNv, 4);
+	if (g_hdb->_map->checkOneTileExistInRange(_target2DoorPv, 4))
+		g_hdb->_drawMan->cacheTileSequence(_target2DoorPv, 4);
+	if (g_hdb->_map->checkOneTileExistInRange(_target2DoorSv, 4))
+		g_hdb->_drawMan->cacheTileSequence(_target2DoorSv, 4);
+
+	if (g_hdb->_map->checkOneTileExistInRange(_target3DoorN, 4))
+		g_hdb->_drawMan->cacheTileSequence(_target3DoorN, 4);
+	if (g_hdb->_map->checkOneTileExistInRange(_target3DoorP, 4))
+		g_hdb->_drawMan->cacheTileSequence(_target3DoorP, 4);
+	if (g_hdb->_map->checkOneTileExistInRange(_target3DoorS, 4))
+		g_hdb->_drawMan->cacheTileSequence(_target3DoorS, 4);
+	if (g_hdb->_map->checkOneTileExistInRange(_target3DoorNv, 4))
+		g_hdb->_drawMan->cacheTileSequence(_target3DoorNv, 4);
+	if (g_hdb->_map->checkOneTileExistInRange(_target3DoorPv, 4))
+		g_hdb->_drawMan->cacheTileSequence(_target3DoorPv, 4);
+	if (g_hdb->_map->checkOneTileExistInRange(_target3DoorSv, 4))
+		g_hdb->_drawMan->cacheTileSequence(_target3DoorSv, 4);
+
+	if (g_hdb->_map->checkOneTileExistInRange(_targetBridgeU, 3))
+		g_hdb->_drawMan->cacheTileSequence(_targetBridgeU, 3);
+	if (g_hdb->_map->checkOneTileExistInRange(_targetBridgeD, 3))
+		g_hdb->_drawMan->cacheTileSequence(_targetBridgeD, 3);
+	if (g_hdb->_map->checkOneTileExistInRange(_targetBridgeL, 3))
+		g_hdb->_drawMan->cacheTileSequence(_targetBridgeL, 3);
+	if (g_hdb->_map->checkOneTileExistInRange(_targetBridgeR, 3))
+		g_hdb->_drawMan->cacheTileSequence(_targetBridgeR, 3);
+
+	g_hdb->_drawMan->cacheTileSequence(_targetBridgeMidLR, 1);
+	g_hdb->_drawMan->cacheTileSequence(_targetBridgeMidUD, 1);
+
+	if (g_hdb->_map->checkOneTileExistInRange(_touchplateOff, 2))
+		g_hdb->_drawMan->cacheTileSequence(_touchplateOff, 2);
+	if (g_hdb->_map->checkOneTileExistInRange(_templeTouchpOff, 2))
+		g_hdb->_drawMan->cacheTileSequence(_templeTouchpOff, 2);
+	if (g_hdb->_map->checkOneTileExistInRange(_blockpole, 4))
+		g_hdb->_drawMan->cacheTileSequence(_blockpole, 4);
+
+	if (g_hdb->_map->checkOneTileExistInRange(_kcHolderWhiteOff, 2))
+		g_hdb->_drawMan->getTile(_kcHolderWhiteOn);
+	if (g_hdb->_map->checkOneTileExistInRange(_kcHolderBlueOff, 2))
+		g_hdb->_drawMan->getTile(_kcHolderBlueOn);
+	if (g_hdb->_map->checkOneTileExistInRange(_kcHolderRedOff, 2))
+		g_hdb->_drawMan->getTile(_kcHolderRedOn);
+	if (g_hdb->_map->checkOneTileExistInRange(_kcHolderGreenOff, 2))
+		g_hdb->_drawMan->getTile(_kcHolderGreenOn);
+	if (g_hdb->_map->checkOneTileExistInRange(_kcHolderPurpleOff, 2))
+		g_hdb->_drawMan->getTile(_kcHolderPurpleOn);
+	if (g_hdb->_map->checkOneTileExistInRange(_kcHolderBlackOff, 2))
+		g_hdb->_drawMan->getTile(_kcHolderBlackOn);
+}
 } // End of Namespace
diff --git a/engines/hdb/ai.h b/engines/hdb/ai.h
index 012ed91..1631a51 100644
--- a/engines/hdb/ai.h
+++ b/engines/hdb/ai.h
@@ -609,6 +609,7 @@ public:
 	bool init();
 	void clearPersistent();
 	void restartSystem();
+	void initAnimInfo();
 
 	// Entity Functions
 	AIEntity *spawn(AIType type, AIDir dir, int x, int y, char *funcInit, char *funcAction, char *funcUse, AIDir dir2, int level, int value1, int value2, int callInit);


Commit: b351bec867798872bfe351d0aac149a9d0084d05
    https://github.com/scummvm/scummvm/commit/b351bec867798872bfe351d0aac149a9d0084d05
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:16:56+02:00

Commit Message:
HDB: Call initAnimInfo() from hdb.cpp

Changed paths:
    engines/hdb/hdb.cpp


diff --git a/engines/hdb/hdb.cpp b/engines/hdb/hdb.cpp
index 66bffa7..6e339eb 100644
--- a/engines/hdb/hdb.cpp
+++ b/engines/hdb/hdb.cpp
@@ -264,6 +264,7 @@ Common::Error HDBGame::run() {
 	}
 
 	_map->load(mapStream);
+	_ai->initAnimInfo();
 
 #if 0
 	lua->executeFile("test.lua");


Commit: 168dd1098101ee5daa96590ecf930be64415d3f1
    https://github.com/scummvm/scummvm/commit/168dd1098101ee5daa96590ecf930be64415d3f1
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:16:56+02:00

Commit Message:
HDB: Add entityName to _dummyPlayer

Changed paths:
    engines/hdb/ai-init.cpp


diff --git a/engines/hdb/ai-init.cpp b/engines/hdb/ai-init.cpp
index 89be28d..32d45ef 100644
--- a/engines/hdb/ai-init.cpp
+++ b/engines/hdb/ai-init.cpp
@@ -763,6 +763,7 @@ bool AI::init() {
 	_kcHolderBlackOn	= g_hdb->_drawMan->getTileIndex("t32_kcholder_black_on");
 
 	_dummyPlayer.type = AI_GUY;
+	strcpy(_dummyPlayer.entityName, "Virtual Player");
 	_playerRunning = false;
 
 	restartSystem();


Commit: 2e820d0e69fc766f5997e0bb64a50636989a24bf
    https://github.com/scummvm/scummvm/commit/2e820d0e69fc766f5997e0bb64a50636989a24bf
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:16:56+02:00

Commit Message:
HDB: Add debug output for activateAction

Changed paths:
    engines/hdb/ai-lists.cpp


diff --git a/engines/hdb/ai-lists.cpp b/engines/hdb/ai-lists.cpp
index 79ad0a6..40bb458 100644
--- a/engines/hdb/ai-lists.cpp
+++ b/engines/hdb/ai-lists.cpp
@@ -388,6 +388,7 @@ bool AI::activateAction(AIEntity *e, int x, int y, int targetX, int targetY) {
 bool AI::checkAutoList(AIEntity *e, int x, int y) {
 	for (int i = 0;i < kMaxAutoActions;i++) {
 		if (_autoActions[i].x == x && _autoActions[i].y == y && !_autoActions[i].activated) {
+			debug(1, "Activating action for Entity: %s, x: %d, y: %d", e->entityName, x, y);
 			bool success = activateAction(e, x, y, 0, 0);
 			_autoActions[i].activated = true;
 


Commit: 6e9647eab5fdc5b7b996149159952489721a0459
    https://github.com/scummvm/scummvm/commit/6e9647eab5fdc5b7b996149159952489721a0459
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:16:56+02:00

Commit Message:
HDB: Fix local variable warnings

Changed paths:
    engines/hdb/ai-cinematic.cpp


diff --git a/engines/hdb/ai-cinematic.cpp b/engines/hdb/ai-cinematic.cpp
index 753386c..9a62d44 100644
--- a/engines/hdb/ai-cinematic.cpp
+++ b/engines/hdb/ai-cinematic.cpp
@@ -214,15 +214,15 @@ void AI::processCines() {
 					g_hdb->useEntity((*it));
 				}
 			}
-			for (int i = 0; i < kMaxActions; i++) {
-				if (_actions[i].entityName && Common::matchString(_actions[i].entityName, "door1")) {
-					checkActionList(&_dummyPlayer, _actions[i].x1, _actions[i].y1, false);
-					checkActionList(&_dummyPlayer, _actions[i].x2, _actions[i].y2, false);
+			for (int k = 0; k < kMaxActions; k++) {
+				if (_actions[k].entityName && Common::matchString(_actions[k].entityName, "door1")) {
+					checkActionList(&_dummyPlayer, _actions[k].x1, _actions[k].y1, false);
+					checkActionList(&_dummyPlayer, _actions[k].x2, _actions[k].y2, false);
 				}
 			}
-			for (int i = 0;i < kMaxAutoActions;i++) {
-				if (_autoActions[i].entityName && Common::matchString(_autoActions[i].entityName, _cine[i]->string) && !_autoActions[i].activated)
-					checkAutoList(&_dummyPlayer, _autoActions[i].x, _autoActions[i].y);
+			for (int j = 0; j < kMaxAutoActions; j++) {
+				if (_autoActions[j].entityName && Common::matchString(_autoActions[j].entityName, _cine[i]->string) && !_autoActions[j].activated)
+					checkAutoList(&_dummyPlayer, _autoActions[j].x, _autoActions[j].y);
 			}
 			complete = true;
 			break;


Commit: a990792f9af52f4d7d66c22995f77edd33995af1
    https://github.com/scummvm/scummvm/commit/a990792f9af52f4d7d66c22995f77edd33995af1
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:16:56+02:00

Commit Message:
HDB: Add the loadPic() helper

Changed paths:
    engines/hdb/draw-manager.cpp
    engines/hdb/draw-manager.h


diff --git a/engines/hdb/draw-manager.cpp b/engines/hdb/draw-manager.cpp
index 8be1e8b..4a74e3d 100644
--- a/engines/hdb/draw-manager.cpp
+++ b/engines/hdb/draw-manager.cpp
@@ -130,6 +130,15 @@ void DrawMan::updateFade() {
 	debug(9, "STUB: DrawMan::updateFade incomplete");
 }
 
+Picture *DrawMan::loadPic(const char *picName) {
+	Picture *pic = new Picture;
+	Common::SeekableReadStream *stream = g_hdb->_fileMan->findFirstData(picName, TYPE_PIC);
+	if (!stream)
+		return NULL;
+	pic->load(stream);
+	return pic;
+}
+
 Tile *DrawMan::getTile(int index) {
 
 	if (index < 0 || index > _numTiles) {
diff --git a/engines/hdb/draw-manager.h b/engines/hdb/draw-manager.h
index ceae357..ee53df4 100644
--- a/engines/hdb/draw-manager.h
+++ b/engines/hdb/draw-manager.h
@@ -78,6 +78,8 @@ public:
 	bool isFadeStaying() { return _fadeInfo.stayFaded; }
 	void turnOffFade() { _fadeInfo.active = _fadeInfo.stayFaded = false; }
 
+	Picture *loadPic(const char *picName);
+
 	Tile *getTile(int index);
 	void cacheTileSequence(int index, int count);
 	int getTileIndex(const char *name);


Commit: 3ffbcec87e186fa1b81034273ea8d6beef8134ab
    https://github.com/scummvm/scummvm/commit/3ffbcec87e186fa1b81034273ea8d6beef8134ab
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:16:56+02:00

Commit Message:
HDB: Add Window Class

Changed paths:
  A engines/hdb/window.cpp
  A engines/hdb/window.h
    engines/hdb/module.mk


diff --git a/engines/hdb/module.mk b/engines/hdb/module.mk
index 137ff04..c037495 100644
--- a/engines/hdb/module.mk
+++ b/engines/hdb/module.mk
@@ -13,7 +13,8 @@ MODULE_OBJS := \
 	file-manager.o \
 	hdb.o \
 	lua-script.o \
-	map-loader.o
+	map-loader.o \
+	window.o
 
 MODULE_DIRS += \
 	engines/hdb
diff --git a/engines/hdb/window.cpp b/engines/hdb/window.cpp
new file mode 100644
index 0000000..048ea06
--- /dev/null
+++ b/engines/hdb/window.cpp
@@ -0,0 +1,88 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "hdb/hdb.h"
+
+namespace HDB {
+
+bool Window::init() {
+
+	warning("STUB: Window::init: Incomplete");
+
+	_gfxTL = g_hdb->_drawMan->loadPic("menu_back_topleft");
+	_gfxTM = g_hdb->_drawMan->loadPic("menu_back_top");
+	_gfxTR = g_hdb->_drawMan->loadPic("menu_back_topright");
+
+	_gfxL = g_hdb->_drawMan->loadPic("menu_back_left");
+	_gfxM = g_hdb->_drawMan->loadPic("menu_back_middle");
+	_gfxR = g_hdb->_drawMan->loadPic("menu_back_right");
+
+	_gfxBL = g_hdb->_drawMan->loadPic("menu_back_btmleft");
+	_gfxBM = g_hdb->_drawMan->loadPic("menu_back_bottom");
+	_gfxBR = g_hdb->_drawMan->loadPic("menu_back_btmright");
+
+	_gfxTitleL = g_hdb->_drawMan->loadPic("menu_title_left");
+	_gfxTitleM = g_hdb->_drawMan->loadPic("menu_title_mid");
+	_gfxTitleR = g_hdb->_drawMan->loadPic("menu_title_right");
+
+	_gGfxTL = g_hdb->_drawMan->loadPic("g_menu_back_topleft");
+	_gGfxTM = g_hdb->_drawMan->loadPic("g_menu_back_top");
+	_gGfxTR = g_hdb->_drawMan->loadPic("g_menu_back_topright");
+	
+	_gGfxL = g_hdb->_drawMan->loadPic("g_menu_back_left");
+	_gGfxM = g_hdb->_drawMan->loadPic("g_menu_back_middle");
+	_gGfxR = g_hdb->_drawMan->loadPic("g_menu_back_right");
+	
+	_gGfxBL = g_hdb->_drawMan->loadPic("g_menu_back_btmleft");
+	_gGfxBM = g_hdb->_drawMan->loadPic("g_menu_back_bottom");
+	_gGfxBR = g_hdb->_drawMan->loadPic("g_menu_back_btmright");
+	
+	_gGfxTitleL = g_hdb->_drawMan->loadPic("g_menu_title_left");
+	_gGfxTitleM = g_hdb->_drawMan->loadPic("g_menu_title_mid");
+	_gGfxTitleR = g_hdb->_drawMan->loadPic("g_menu_title_right");
+
+	_gfxIndent = g_hdb->_drawMan->loadPic("menu_delivery_indentation");
+	_gfxArrowTo = g_hdb->_drawMan->loadPic("menu_arrow_deliverto");
+
+	_gfxTry = _gfxAgain = NULL; // They will be loaded when needed
+
+	_gfxInvSelect = g_hdb->_drawMan->loadPic("inventory_normal");
+	_gfxHandright = g_hdb->_drawMan->loadPic("menu_hand_pointright");
+
+	restartSystem();
+
+	return true;
+}
+
+void Window::restartSystem() {
+	_dialogDelay = 0;
+}
+
+void Window::openDialog(const char *title, int tileIndex, const char *string, int more, const char *luaMore) {
+	warning("STUB: Window::openDialog() required");
+}
+
+void Window::setDialogDelay(int seconds) {
+	warning("STUB: Window::setDialogDelay() required");
+}
+
+} // End of Namespace
diff --git a/engines/hdb/window.h b/engines/hdb/window.h
new file mode 100644
index 0000000..32df5be
--- /dev/null
+++ b/engines/hdb/window.h
@@ -0,0 +1,65 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef HDB_WINDOW_H
+#define HDB_WINDOW_H
+
+namespace HDB {
+
+class Window {
+public:
+
+	bool init();
+	void restartSystem();
+
+	// Dialog Functions
+
+	void openDialog(const char *title, int tileIndex, const char *string, int more, const char *luaMore);
+	void setDialogDelay(int delay);
+	uint32 getDialogDelay() {
+		return _dialogDelay;
+	}
+
+private:
+
+	uint32 _dialogDelay;	// Used for Cinematics
+
+	// Windows GFX
+	Picture *_gfxTL, *_gfxTM, *_gfxTR;
+	Picture *_gfxL, *_gfxM, *_gfxR;
+	Picture *_gfxBL, *_gfxBM, *_gfxBR;
+	Picture *_gfxTitleL, *_gfxTitleM, *_gfxTitleR;
+	Picture *_gGfxTL, *_gGfxTM, *_gGfxTR;
+	Picture *_gGfxL, *_gGfxM, *_gGfxR;
+	Picture *_gGfxBL, *_gGfxBM, *_gGfxBR;
+	Picture *_gGfxTitleL, *_gGfxTitleM, *_gGfxTitleR;
+	Picture *_gfxResources, *_gfxDeliveries;
+	Picture *_gfxIndent, *_gfxArrowTo, *_gfxHandright;
+	Picture *_gfxTry, *_gfxAgain, *_gfxInvSelect;
+	Tile *_gfxMonkeystone;
+	Picture *_gfxLevelRestart, *_gfxPuasePlaque;
+
+};
+
+} // End of Namespace
+
+#endif // !HDB_WINDOW_H


Commit: 28ab1f95491b1abec0af3b8d74c117fb6b2dee84
    https://github.com/scummvm/scummvm/commit/28ab1f95491b1abec0af3b8d74c117fb6b2dee84
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:16:56+02:00

Commit Message:
HDB: Add and init the _window subsystem

Changed paths:
    engines/hdb/hdb.cpp
    engines/hdb/hdb.h


diff --git a/engines/hdb/hdb.cpp b/engines/hdb/hdb.cpp
index 6e339eb..e92aab3 100644
--- a/engines/hdb/hdb.cpp
+++ b/engines/hdb/hdb.cpp
@@ -47,6 +47,7 @@ HDBGame::HDBGame(OSystem *syst, const ADGameDescription *gameDesc) : Engine(syst
 	_lua = new LuaScript;
 	_map = new Map;
 	_ai = new AI;
+	_window = new Window;
 	_rnd = new Common::RandomSource("hdb");
 
 	DebugMan.addDebugChannel(kDebugExample1, "Example1", "This is just an example to test");
@@ -60,6 +61,7 @@ HDBGame::~HDBGame() {
 	delete _lua;
 	delete _map;
 	delete _ai;
+	delete _window;
 	delete _rnd;
 
 	DebugMan.clearAllDebugChannels();
@@ -84,6 +86,9 @@ bool HDBGame::init() {
 	if (!_lua->init()) {
 		error("LuaScript::init: Couldn't load the GLOBAL_LUA code.");
 	}
+	if (!_window->init()) {
+		error("Window::init: Couldn't initialize Window");
+	}
 
 	// REMOVE: Putting this here since Menu hasn't been implemented yet.
 	// Defaults the game into Action Mode
diff --git a/engines/hdb/hdb.h b/engines/hdb/hdb.h
index bd2f82d..139d610 100644
--- a/engines/hdb/hdb.h
+++ b/engines/hdb/hdb.h
@@ -37,12 +37,13 @@
 #include "engines/util.h"
 #include "console.h"
 
-#include "hdb/file-manager.h"
 #include "hdb/draw-manager.h"
-#include "hdb/lua-script.h"
-#include "hdb/map-loader.h"
 #include "hdb/ai.h"
 #include "hdb/ai-player.h"
+#include "hdb/file-manager.h"
+#include "hdb/lua-script.h"
+#include "hdb/map-loader.h"
+#include "hdb/window.h"
 
 #define MAX_SNDCACHE_MEM	0x400000	// 4Mb of sounds in memory
 #define MAX_TILES_CACHED	3500		// Max no of tiles in memory at once
@@ -119,6 +120,7 @@ public:
 	LuaScript *_lua;
 	Map *_map;
 	AI *_ai;
+	Window *_window;
 
 	// Random Source
 	Common::RandomSource *_rnd;


Commit: 21cbd050d4adf2911ac60a15b7982e97d1707b47
    https://github.com/scummvm/scummvm/commit/21cbd050d4adf2911ac60a15b7982e97d1707b47
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:16:56+02:00

Commit Message:
HDB: Fix wrong code introduced during debugging

Changed paths:
    engines/hdb/ai-cinematic.cpp


diff --git a/engines/hdb/ai-cinematic.cpp b/engines/hdb/ai-cinematic.cpp
index 9a62d44..2b3ad71 100644
--- a/engines/hdb/ai-cinematic.cpp
+++ b/engines/hdb/ai-cinematic.cpp
@@ -215,7 +215,7 @@ void AI::processCines() {
 				}
 			}
 			for (int k = 0; k < kMaxActions; k++) {
-				if (_actions[k].entityName && Common::matchString(_actions[k].entityName, "door1")) {
+				if (_actions[k].entityName && Common::matchString(_actions[k].entityName, _cine[i]->string)) {
 					checkActionList(&_dummyPlayer, _actions[k].x1, _actions[k].y1, false);
 					checkActionList(&_dummyPlayer, _actions[k].x2, _actions[k].y2, false);
 				}


Commit: fcd8b6e00a122338a3a19c4b16dbaee3bc61b010
    https://github.com/scummvm/scummvm/commit/fcd8b6e00a122338a3a19c4b16dbaee3bc61b010
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:16:56+02:00

Commit Message:
HDB: Update module.mk

Changed paths:
    engines/hdb/module.mk


diff --git a/engines/hdb/module.mk b/engines/hdb/module.mk
index c037495..432998d 100644
--- a/engines/hdb/module.mk
+++ b/engines/hdb/module.mk
@@ -1,11 +1,13 @@
 MODULE := engines/hdb
 
 MODULE_OBJS := \
-	ai-init.o \
-	ai-inventory.o \
 	ai-cinematic.o \
 	ai-funcs.o \
+	ai-init.o \
+	ai-inventory.o \
+	ai-lists.o \
 	ai-player.o \
+	ai-use.o \
 	ai-waypoint.o \
 	console.o \
 	draw-manager.o \


Commit: 38e5b71668405bc74cc35139945c4aa38e3330a2
    https://github.com/scummvm/scummvm/commit/38e5b71668405bc74cc35139945c4aa38e3330a2
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:16:56+02:00

Commit Message:
HDB: Correct const-ness

Changed paths:
    engines/hdb/ai-use.cpp
    engines/hdb/ai.h


diff --git a/engines/hdb/ai-use.cpp b/engines/hdb/ai-use.cpp
index fa78aed..4abb102 100644
--- a/engines/hdb/ai-use.cpp
+++ b/engines/hdb/ai-use.cpp
@@ -41,7 +41,7 @@ bool AI::useSwitch2(AIEntity *e, int x, int y, int targetX, int targetY) {
 }
 
 // Colored Keycard Switch
-bool AI::useLockedSwitch(AIEntity *e, int x, int y, int targetX, int targetY, int onTile, AIType item, char *keyerror) {
+bool AI::useLockedSwitch(AIEntity *e, int x, int y, int targetX, int targetY, int onTile, AIType item, const char *keyerror) {
 	warning("STUB: Define useLockedSwitch");
 	return false;
 }
@@ -83,4 +83,4 @@ bool AI::useDoorOpenCloseBot(AIEntity *e, int x, int y) {
 	return false;
 }
 
-} // End of Namespace
\ No newline at end of file
+} // End of Namespace
diff --git a/engines/hdb/ai.h b/engines/hdb/ai.h
index 1631a51..a88a703 100644
--- a/engines/hdb/ai.h
+++ b/engines/hdb/ai.h
@@ -913,7 +913,7 @@ private:
 	bool useSwitch2(AIEntity *e, int x, int y, int targetX, int targetY);
 
 	// Colored Keycard Switch
-	bool useLockedSwitch(AIEntity *e, int x, int y, int targetX, int targetY, int onTile, AIType item, char *keyerror);
+	bool useLockedSwitch(AIEntity *e, int x, int y, int targetX, int targetY, int onTile, AIType item, const char *keyerror);
 	bool useLockedSwitchOn(AIEntity *e, int x, int y, int targetX, int targetY, int offTile, AIType item);
 
 	// Purple Cell Holder Switch


Commit: a3b650be3644cbc4c4e2205be4b9d8e719e8d3e1
    https://github.com/scummvm/scummvm/commit/a3b650be3644cbc4c4e2205be4b9d8e719e8d3e1
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:16:56+02:00

Commit Message:
HDB: Added warning to catch ambigious code

Changed paths:
    engines/hdb/ai-lists.cpp


diff --git a/engines/hdb/ai-lists.cpp b/engines/hdb/ai-lists.cpp
index 40bb458..b113f4a 100644
--- a/engines/hdb/ai-lists.cpp
+++ b/engines/hdb/ai-lists.cpp
@@ -105,6 +105,7 @@ void AI::animateTargets() {
 			if (at->inMap) {
 				// Animate Map Tiles
 				layer = 0; // BG layer
+				warning("FIXME: Ambigious animateTargets() code.");
 				if (!at->start == g_hdb->_map->getMapBGTileIndex(at->x, at->y))
 					layer = 1;
 


Commit: 86cc1df32d616c074b793efdc8dfbf851cb5f70b
    https://github.com/scummvm/scummvm/commit/86cc1df32d616c074b793efdc8dfbf851cb5f70b
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:16:56+02:00

Commit Message:
HDB: Fix crash when executing Lua with debug options

Changed paths:
    engines/hdb/lua-script.cpp


diff --git a/engines/hdb/lua-script.cpp b/engines/hdb/lua-script.cpp
index 9691763..edd47bc 100644
--- a/engines/hdb/lua-script.cpp
+++ b/engines/hdb/lua-script.cpp
@@ -860,12 +860,12 @@ bool LuaScript::initScript(Common::SeekableReadStream *stream, const char *scrip
 		return false;
 	}
 
+	lua_getglobal(_state, "level_init");
+
 	// Error handling function to be executed after the function is put on the stack
 	lua_rawgeti(_state, LUA_REGISTRYINDEX, _pcallErrorhandlerRegistryIndex);
 	lua_insert(_state, -2);
 
-	lua_getglobal(_state, "level_init");
-
 	if (lua_pcall(_state, 0, 0, -2)) {
 		error("An error occured while executing \"%s\": %s.", "level_init", lua_tostring(_state, -1));
 		lua_pop(_state, -1);


Commit: 0cd1ffc34ef0d6943e8b97e7f22d9502b040a324
    https://github.com/scummvm/scummvm/commit/0cd1ffc34ef0d6943e8b97e7f22d9502b040a324
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:16:56+02:00

Commit Message:
HDB: Fix crash during initialisation

Changed paths:
    engines/hdb/hdb.cpp


diff --git a/engines/hdb/hdb.cpp b/engines/hdb/hdb.cpp
index e92aab3..a0c92d2 100644
--- a/engines/hdb/hdb.cpp
+++ b/engines/hdb/hdb.cpp
@@ -77,12 +77,12 @@ bool HDBGame::init() {
 	if (!_fileMan->openMPC(getGameFile())) {
 		error("FileMan::openMPC: Cannot find the hyperspace.mpc data file.");
 	}
-	if (!_ai->init()) {
-		error("AI::init: Couldn't initialize AI");
-	}
 	if (!_drawMan->init()) {
 		error("DrawMan::init: Couldn't initialize DrawMan");
 	}
+	if (!_ai->init()) {
+		error("AI::init: Couldn't initialize AI");
+	}
 	if (!_lua->init()) {
 		error("LuaScript::init: Couldn't load the GLOBAL_LUA code.");
 	}


Commit: 32b99eb8b8069ce68d46e8f00d21dd0edb95f985
    https://github.com/scummvm/scummvm/commit/32b99eb8b8069ce68d46e8f00d21dd0edb95f985
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:16:56+02:00

Commit Message:
HDB: Add struct DialogInfo and _dialogInfo

Changed paths:
    engines/hdb/window.cpp
    engines/hdb/window.h


diff --git a/engines/hdb/window.cpp b/engines/hdb/window.cpp
index 048ea06..559f380 100644
--- a/engines/hdb/window.cpp
+++ b/engines/hdb/window.cpp
@@ -74,6 +74,7 @@ bool Window::init() {
 }
 
 void Window::restartSystem() {
+	_dialogInfo.active = false;
 	_dialogDelay = 0;
 }
 
diff --git a/engines/hdb/window.h b/engines/hdb/window.h
index 32df5be..d725eb8 100644
--- a/engines/hdb/window.h
+++ b/engines/hdb/window.h
@@ -25,6 +25,23 @@
 
 namespace HDB {
 
+struct DialogInfo {
+	char		title[64];				// TITLE string
+	int			tileIndex;					// this is for a character picture
+	char		string[160];			// actual text in the dialog
+
+	bool		active;					// is it drawing or not?
+	int			x, y;					// where to draw dialog
+	int			width, height;			// size of the dialog itself
+	int			titleWidth;
+	Picture		*gfx;					// character tile (picture)
+	int			more;					// whether we want to draw the MORE icon or not
+	int			el, er, et, eb;			// saves the text edges
+	char		luaMore[64];			// the name of the function to call after clicking the MORE button
+
+	DialogInfo() : title(""), tileIndex(0), string(""), active(false), x(0), y(0), width(0), height(0), titleWidth(0), gfx(NULL), more(0), el(0), er(0), et(0), eb(0), luaMore("") {}
+};
+
 class Window {
 public:
 
@@ -41,6 +58,7 @@ public:
 
 private:
 
+	DialogInfo _dialogInfo;
 	uint32 _dialogDelay;	// Used for Cinematics
 
 	// Windows GFX


Commit: 5ae9b45489270c3af6c4d86446ac80b0d44abf37
    https://github.com/scummvm/scummvm/commit/5ae9b45489270c3af6c4d86446ac80b0d44abf37
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:16:56+02:00

Commit Message:
HDB: Add Font data

Addition includes structs, constants and member
variables.

Changed paths:
    engines/hdb/draw-manager.h


diff --git a/engines/hdb/draw-manager.h b/engines/hdb/draw-manager.h
index ee53df4..1d1c5d6 100644
--- a/engines/hdb/draw-manager.h
+++ b/engines/hdb/draw-manager.h
@@ -33,7 +33,9 @@ enum {
 	kTileWidth = 32,
 	kTileHeight = 32,
 	kMaxSkies = 10,
-	kNum3DStars = 300
+	kNum3DStars = 300,
+	kFontSpace = 5,
+	kFontIncrement = 1
 };
 
 class Tile;
@@ -60,6 +62,19 @@ struct GfxCache {
 	GfxCache() : name(""), tileGfx(NULL), size(0), loaded(0) {}
 };
 
+struct FontInfo {
+	uint16		type;		// 0 = mono, 1 = proportional
+	uint16		numChars;	// how many characters in font
+	uint16		height;		// height of entire font
+	uint16		kerning;	// space between chars
+	uint16		leading;	// space between lines
+};
+
+struct CharInfo {
+	uint16 width;	// Character width in pixels
+	uint32 offset;	// From the start of the font charInfo chunk
+};
+
 class DrawMan {
 public:
 
@@ -134,6 +149,17 @@ private:
 	Picture *_starField[4];
 	Picture *_skyClouds;
 
+	// Cursor
+	int _cursorX, _cursorY;
+
+	// Font Data
+
+	FontInfo _fontHeader;
+	Common::Array<CharInfo *> _charInfoBlocks;
+	Graphics::Surface _fontSurfaces[256];
+	uint16 _fontGfx;
+	int _eLeft, _eRight, _eTop, _eBottom;
+
 	bool _systemInit;
 
 };


Commit: 954d1c649c99e19a020de9ed764b88a7ced2c25d
    https://github.com/scummvm/scummvm/commit/954d1c649c99e19a020de9ed764b88a7ced2c25d
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:16:56+02:00

Commit Message:
HDB: Add getter-setter for the cursor

Changed paths:
    engines/hdb/draw-manager.cpp
    engines/hdb/draw-manager.h


diff --git a/engines/hdb/draw-manager.cpp b/engines/hdb/draw-manager.cpp
index 4a74e3d..534ca96 100644
--- a/engines/hdb/draw-manager.cpp
+++ b/engines/hdb/draw-manager.cpp
@@ -395,6 +395,16 @@ int DrawMan::animateTile(int tileIndex) {
 	return _tLookupArray[tileIndex].animIndex;
 }
 
+void DrawMan::setCursor(int x, int y) {
+	_cursorX = x;
+	_cursorY = y;
+}
+
+void DrawMan::getCursor(int *x, int *y) {
+	*x = _cursorX;
+	*y = _cursorY;
+}
+
 Picture::Picture() : _width(0), _height(0), _name("") {
 	_surface.create(_width, _height, g_hdb->_format);
 }
diff --git a/engines/hdb/draw-manager.h b/engines/hdb/draw-manager.h
index 1d1c5d6..350f865 100644
--- a/engines/hdb/draw-manager.h
+++ b/engines/hdb/draw-manager.h
@@ -115,6 +115,11 @@ public:
 
 	int animateTile(int tileIndex);
 
+	// Font Functions
+
+	void setCursor(int x, int y);
+	void getCursor(int *x, int *y);
+
 private:
 	int _numTiles;
 	TileLookup *_tLookupArray;


Commit: e7ddd0b52704fd904f58d9266a8081309873b6ce
    https://github.com/scummvm/scummvm/commit/e7ddd0b52704fd904f58d9266a8081309873b6ce
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:16:56+02:00

Commit Message:
HDB: Add getter-setter for Kerning and Leading

Changed paths:
    engines/hdb/draw-manager.cpp
    engines/hdb/draw-manager.h


diff --git a/engines/hdb/draw-manager.cpp b/engines/hdb/draw-manager.cpp
index 534ca96..6638296 100644
--- a/engines/hdb/draw-manager.cpp
+++ b/engines/hdb/draw-manager.cpp
@@ -395,6 +395,16 @@ int DrawMan::animateTile(int tileIndex) {
 	return _tLookupArray[tileIndex].animIndex;
 }
 
+void DrawMan::setKernLead(int kern, int lead) {
+	_fontHeader.kerning = kern;
+	_fontHeader.leading = lead;
+}
+
+void DrawMan::getKernLead(int *kern, int *lead) {
+	*kern = _fontHeader.kerning;
+	*lead = _fontHeader.leading;
+}
+
 void DrawMan::setCursor(int x, int y) {
 	_cursorX = x;
 	_cursorY = y;
diff --git a/engines/hdb/draw-manager.h b/engines/hdb/draw-manager.h
index 350f865..4790d03 100644
--- a/engines/hdb/draw-manager.h
+++ b/engines/hdb/draw-manager.h
@@ -117,6 +117,8 @@ public:
 
 	// Font Functions
 
+	void setKernLead(int kern, int lead);
+	void getKernLead(int *kern, int *lead);
 	void setCursor(int x, int y);
 	void getCursor(int *x, int *y);
 


Commit: 94747f0f76b509a1d3c00f5bc09315486d8840cf
    https://github.com/scummvm/scummvm/commit/94747f0f76b509a1d3c00f5bc09315486d8840cf
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:16:56+02:00

Commit Message:
HDB: Add getter-setter for Text Edges

Changed paths:
    engines/hdb/draw-manager.cpp
    engines/hdb/draw-manager.h


diff --git a/engines/hdb/draw-manager.cpp b/engines/hdb/draw-manager.cpp
index 6638296..1f88028 100644
--- a/engines/hdb/draw-manager.cpp
+++ b/engines/hdb/draw-manager.cpp
@@ -395,6 +395,20 @@ int DrawMan::animateTile(int tileIndex) {
 	return _tLookupArray[tileIndex].animIndex;
 }
 
+void DrawMan::setTextEdges(int left, int right, int top, int bottom) {
+	_eLeft = left;
+	_eRight = right;
+	_eTop = top;
+	_eBottom = bottom;
+}
+
+void DrawMan::getTextEdges(int *left, int *right, int *top, int *bottom) {
+	*left = _eLeft;
+	*right = _eRight;
+	*top = _eTop;
+	*bottom = _eBottom;
+}
+
 void DrawMan::setKernLead(int kern, int lead) {
 	_fontHeader.kerning = kern;
 	_fontHeader.leading = lead;
diff --git a/engines/hdb/draw-manager.h b/engines/hdb/draw-manager.h
index 4790d03..9bc2204 100644
--- a/engines/hdb/draw-manager.h
+++ b/engines/hdb/draw-manager.h
@@ -117,6 +117,8 @@ public:
 
 	// Font Functions
 
+	void setTextEdges(int left, int right, int top, int bottom);
+	void getTextEdges(int *left, int *right, int *top, int *bottom);
 	void setKernLead(int kern, int lead);
 	void getKernLead(int *kern, int *lead);
 	void setCursor(int x, int y);


Commit: ae872f35691773d412ac7bfff39d9e35f42b65d8
    https://github.com/scummvm/scummvm/commit/ae872f35691773d412ac7bfff39d9e35f42b65d8
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:16:56+02:00

Commit Message:
HDB: Add getDimensions() to calculate pixel width

Changed paths:
    engines/hdb/draw-manager.cpp
    engines/hdb/draw-manager.h


diff --git a/engines/hdb/draw-manager.cpp b/engines/hdb/draw-manager.cpp
index 1f88028..113f063 100644
--- a/engines/hdb/draw-manager.cpp
+++ b/engines/hdb/draw-manager.cpp
@@ -395,6 +395,61 @@ int DrawMan::animateTile(int tileIndex) {
 	return _tLookupArray[tileIndex].animIndex;
 }
 
+// Calculates pixel width of a string
+void DrawMan::getDimensions(const char *string, int *pixelsWide, int *lines) {
+	if (!string) {
+		*pixelsWide = kFontSpace;
+		*lines = 1;
+		return;
+	}
+
+	int width, maxWidth, height;
+	unsigned char c;
+	maxWidth = 0;
+	width = _eLeft;
+	height = 1;
+
+	for (int i = 0; i < (int)strlen(string); i++) {
+		c = string[i];
+		width += _charInfoBlocks[i]->width + _fontHeader.kerning + kFontIncrement;
+		if (c == ' ')
+			width += kFontSpace;
+
+		if (c == '\n') {
+			height++;
+			if (width > maxWidth)
+				maxWidth = width;
+			width = _eLeft;
+		} else if (width > _eRight) {
+			int oldWidth = width;
+			i--;
+			while (string[i] != ' ' && i > 0) {
+				c = string[i];
+				width -= _charInfoBlocks[c]->width + _fontHeader.kerning + kFontIncrement;
+				i--;
+			}
+			if (!i) {
+				maxWidth = oldWidth;
+				break;
+			}
+			height++;
+			if (width > maxWidth)
+				maxWidth = width;
+			width = _eLeft;
+		}
+	}
+
+	if (width > maxWidth)
+		maxWidth = width;
+
+	// If its one line, add 8 pixels
+	if (height == 1)
+		maxWidth += 8;
+
+	*pixelsWide = maxWidth - _eLeft;
+	*lines = height;
+}
+
 void DrawMan::setTextEdges(int left, int right, int top, int bottom) {
 	_eLeft = left;
 	_eRight = right;
diff --git a/engines/hdb/draw-manager.h b/engines/hdb/draw-manager.h
index 9bc2204..db09c17 100644
--- a/engines/hdb/draw-manager.h
+++ b/engines/hdb/draw-manager.h
@@ -117,6 +117,7 @@ public:
 
 	// Font Functions
 
+	void getDimensions(const char *string, int *pixelsWide, int *lines);
 	void setTextEdges(int left, int right, int top, int bottom);
 	void getTextEdges(int *left, int *right, int *top, int *bottom);
 	void setKernLead(int kern, int lead);


Commit: a427871168fe23340b483b921b40722ac084b4bb
    https://github.com/scummvm/scummvm/commit/a427871168fe23340b483b921b40722ac084b4bb
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:16:56+02:00

Commit Message:
HDB: Add loadFont()

Changed paths:
    engines/hdb/draw-manager.cpp
    engines/hdb/draw-manager.h


diff --git a/engines/hdb/draw-manager.cpp b/engines/hdb/draw-manager.cpp
index 113f063..e505759 100644
--- a/engines/hdb/draw-manager.cpp
+++ b/engines/hdb/draw-manager.cpp
@@ -395,6 +395,53 @@ int DrawMan::animateTile(int tileIndex) {
 	return _tLookupArray[tileIndex].animIndex;
 }
 
+bool DrawMan::loadFont(const char *string) {
+	Common::SeekableReadStream *stream = g_hdb->_fileMan->findFirstData(string, TYPE_FONT);
+	if (!stream)
+		return false;
+
+	// Loading _fontHeader
+	_fontHeader.type = stream->readUint16LE();
+	_fontHeader.numChars = stream->readUint16LE();
+	_fontHeader.height = stream->readUint16LE();
+	_fontHeader.kerning = stream->readUint16LE();
+	_fontHeader.leading = stream->readUint16LE();
+
+	// Loading _charInfoBlocks & creating character surfaces
+	CharInfo *cInfo;
+	int startPos = stream->pos();	// Position after _fontHeader
+	int curPos;						// Position after reading cInfo
+	uint16 *ptr;
+	for (int i = 0; i < _fontHeader.numChars;i++) {
+		cInfo = new CharInfo;
+		cInfo->width = stream->readUint16LE();
+		cInfo->offset = stream->readUint16LE();
+		curPos = stream->pos();
+
+		_fontSurfaces[i].create(cInfo->width, _fontHeader.height, g_hdb->_format);
+
+		// Go to character location
+		stream->seek(startPos+cInfo->offset);
+
+		for (uint y = 0; y < _fontHeader.height; y++) {
+			ptr = (uint16 *)_fontSurfaces[i].getBasePtr(0, y);
+			for (uint x = 0; x < cInfo->width; x++) {
+				*ptr = TO_LE_16(stream->readUint16LE());
+				ptr++;
+			}
+		}
+
+		stream->seek(curPos);
+
+		_charInfoBlocks.push_back(cInfo);
+	}
+
+	// Loading _fontGfx
+	_fontGfx = stream->readUint16LE();
+
+	return true;
+}
+
 // Calculates pixel width of a string
 void DrawMan::getDimensions(const char *string, int *pixelsWide, int *lines) {
 	if (!string) {
diff --git a/engines/hdb/draw-manager.h b/engines/hdb/draw-manager.h
index db09c17..3bfb3d7 100644
--- a/engines/hdb/draw-manager.h
+++ b/engines/hdb/draw-manager.h
@@ -117,6 +117,7 @@ public:
 
 	// Font Functions
 
+	bool loadFont(const char *string);
 	void getDimensions(const char *string, int *pixelsWide, int *lines);
 	void setTextEdges(int left, int right, int top, int bottom);
 	void getTextEdges(int *left, int *right, int *top, int *bottom);


Commit: 6d28554d2a96b30bbbf1759888882358f09e8557
    https://github.com/scummvm/scummvm/commit/6d28554d2a96b30bbbf1759888882358f09e8557
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:16:57+02:00

Commit Message:
HDB: Add drawText()

Changed paths:
    engines/hdb/draw-manager.cpp
    engines/hdb/draw-manager.h


diff --git a/engines/hdb/draw-manager.cpp b/engines/hdb/draw-manager.cpp
index e505759..e8b4e44 100644
--- a/engines/hdb/draw-manager.cpp
+++ b/engines/hdb/draw-manager.cpp
@@ -442,6 +442,69 @@ bool DrawMan::loadFont(const char *string) {
 	return true;
 }
 
+void DrawMan::drawText(const char *string) {
+	if (!_systemInit)
+		return;
+
+	if (_cursorX < _eLeft)
+		_cursorX = _eLeft;
+	if (_cursorY < _eTop)
+		_cursorY = _eTop;
+
+	// Word Wrapping
+	int width = _eLeft;
+	unsigned char c;
+	char cr[256];	// Carriage Return Array
+
+	for (int i = 0; i < (int)strlen(string);i++) {
+		c = string[i];
+		width += _charInfoBlocks[c]->width + _fontHeader.kerning + kFontIncrement;
+		if (c == ' ')
+			width += kFontSpace;
+
+		cr[i] = 0;
+		if (c == '\n') {
+			cr[i] = 1;
+			width = _eLeft;
+		} else if (width > _eRight) {
+			i--;
+			while (string[i] != ' ' && i > 0)
+				i--;
+			cr[i] = 1;
+			width = _eLeft;
+		}
+	}
+
+	// Draw the characters
+	for (int j = 0;j < (int)strlen(string);j++) {
+		c = string[j];
+		if (c == '\n' || cr[j]) {
+			_cursorX = _eLeft;
+			_cursorY += _fontHeader.height + _fontHeader.leading;
+			if (_cursorY + _fontHeader.height > _eBottom)
+				_cursorY = _eTop;
+			continue;
+		}
+
+		width = _charInfoBlocks[c]->width;
+		if (c == ' ')
+			width = kFontSpace;
+
+		// Blit the character
+		g_hdb->_drawMan->_globalSurface.transBlitFrom(_fontSurfaces[c], Common::Point(_cursorX, _cursorY));
+		g_system->copyRectToScreen(g_hdb->_drawMan->_globalSurface.getBasePtr(0, 0), g_hdb->_drawMan->_globalSurface.pitch, 0, 0, width, _fontHeader.height);
+
+		// Advance the cursor
+		_cursorX += width + _fontHeader.kerning * kFontIncrement;
+		if (_cursorX > kScreenWidth) {
+			_cursorX = 0;
+			_cursorY += _fontHeader.height + _fontHeader.leading;
+			if (_cursorY + _fontHeader.height > kScreenHeight)
+				_cursorY = 0;
+		}
+	}
+}
+
 // Calculates pixel width of a string
 void DrawMan::getDimensions(const char *string, int *pixelsWide, int *lines) {
 	if (!string) {
diff --git a/engines/hdb/draw-manager.h b/engines/hdb/draw-manager.h
index 3bfb3d7..f252ed2 100644
--- a/engines/hdb/draw-manager.h
+++ b/engines/hdb/draw-manager.h
@@ -118,6 +118,7 @@ public:
 	// Font Functions
 
 	bool loadFont(const char *string);
+	void drawText(const char *string);
 	void getDimensions(const char *string, int *pixelsWide, int *lines);
 	void setTextEdges(int left, int right, int top, int bottom);
 	void getTextEdges(int *left, int *right, int *top, int *bottom);


Commit: fbc5dffc10f2563e94ebdc03ff269c7f9da75386
    https://github.com/scummvm/scummvm/commit/fbc5dffc10f2563e94ebdc03ff269c7f9da75386
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:16:57+02:00

Commit Message:
HDB: Init Cursor, Text Edges and load Game Font

Changed paths:
    engines/hdb/draw-manager.cpp


diff --git a/engines/hdb/draw-manager.cpp b/engines/hdb/draw-manager.cpp
index e8b4e44..0cdc7e3 100644
--- a/engines/hdb/draw-manager.cpp
+++ b/engines/hdb/draw-manager.cpp
@@ -38,6 +38,18 @@ DrawMan::~DrawMan() {
 
 bool DrawMan::init() {
 
+	// Set the default cursor pos & char clipping
+	setCursor(0, 0);
+
+	_eLeft = 0;
+	_eRight = kScreenWidth;
+	_eTop = 0;
+	_eBottom = kScreenHeight;
+
+	// Load Game Font
+	if (!loadFont("normalprop"))
+		return false;
+
 	// Read total number of tiles in game
 	_numTiles = g_hdb->_fileMan->getCount("t32_", TYPE_TILE32);
 	if (!_numTiles) {


Commit: a9314535c8e16af992e0c8fd0ae9019c989cef18
    https://github.com/scummvm/scummvm/commit/a9314535c8e16af992e0c8fd0ae9019c989cef18
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:16:57+02:00

Commit Message:
HDB: Remove 'Add Animating Info' stub

Changed paths:
    engines/hdb/draw-manager.cpp


diff --git a/engines/hdb/draw-manager.cpp b/engines/hdb/draw-manager.cpp
index 0cdc7e3..bc297ee 100644
--- a/engines/hdb/draw-manager.cpp
+++ b/engines/hdb/draw-manager.cpp
@@ -76,9 +76,28 @@ bool DrawMan::init() {
 		}
 	}
 
-	/*
-		TODO: Add Animating Tile Info
-	*/
+
+	// Add Animating Tile Info
+	int found = -1;
+	char search[32];
+	strcpy(search, "anim_");
+	for (index = 0; index < _numTiles; index++) {
+		// IF we have not found a start, look for it
+		// ELSE IF we have found a start and are in the middle of an anim group
+		// ELSE IF we're in an anim group and have just reached the end
+		if (!strncmp(_tLookupArray[index].filename, search, strlen(search)) && found == -1) {
+			found = index;
+			strncpy(search, _tLookupArray[index].filename, strlen(_tLookupArray[index].filename) - 2);
+		} else if (!strncmp(_tLookupArray[index].filename, search, strlen(search)) && found >= 0)
+			_tLookupArray[index - 1].animIndex = index;
+		else if (strncmp(_tLookupArray[index].filename, search, strlen(search)) && found >= 0) {
+			_tLookupArray[index - 1].animIndex = found;
+			strcpy(search, "anim_");
+			found = -1;
+			if (!strncmp(_tLookupArray[index].filename, search, strlen(search)))
+				index--;
+		}
+	}
 
 	// Init Sky Data
 	_currentSky = 0;


Commit: 6336ce6f42ebe5a8b8b6f303be25e06529dec605
    https://github.com/scummvm/scummvm/commit/6336ce6f42ebe5a8b8b6f303be25e06529dec605
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:16:57+02:00

Commit Message:
HDB: Add Dialog constants

Changed paths:
    engines/hdb/window.h


diff --git a/engines/hdb/window.h b/engines/hdb/window.h
index d725eb8..3306e82 100644
--- a/engines/hdb/window.h
+++ b/engines/hdb/window.h
@@ -25,6 +25,11 @@
 
 namespace HDB {
 
+enum {
+	kDialogTextLeft = 64,
+	kDialogTextRight = (kDialogTextLeft + kTileWidth * 9)
+};
+
 struct DialogInfo {
 	char		title[64];				// TITLE string
 	int			tileIndex;					// this is for a character picture


Commit: ae32825243138f8c12faf6bc3bc81629da479291
    https://github.com/scummvm/scummvm/commit/ae32825243138f8c12faf6bc3bc81629da479291
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:16:57+02:00

Commit Message:
HDB: Add openDialog()

Changed paths:
    engines/hdb/window.cpp


diff --git a/engines/hdb/window.cpp b/engines/hdb/window.cpp
index 559f380..f157ed6 100644
--- a/engines/hdb/window.cpp
+++ b/engines/hdb/window.cpp
@@ -79,7 +79,49 @@ void Window::restartSystem() {
 }
 
 void Window::openDialog(const char *title, int tileIndex, const char *string, int more, const char *luaMore) {
-	warning("STUB: Window::openDialog() required");
+	if (_dialogInfo.active)
+		return;
+
+	_dialogInfo.tileIndex = tileIndex;
+	strcpy(_dialogInfo.title, title);
+	_dialogInfo.active = true;
+
+	int e1, e2, e3, e4;
+	int width, height;
+	int titleWidth, titleHeight;
+	int w;
+
+	if (strlen(string) > sizeof(_dialogInfo.string))
+		strncpy(_dialogInfo.string, string, sizeof(_dialogInfo.string) - 1);
+	else
+		strcpy(_dialogInfo.string, string);
+	g_hdb->_drawMan->getTextEdges(&e1, &e2, &e3, &e4);
+	g_hdb->_drawMan->setTextEdges(kDialogTextLeft, kDialogTextRight, 0, 480);
+	g_hdb->_drawMan->getDimensions(string, &width, &height);
+	g_hdb->_drawMan->getDimensions(title, &titleWidth, &titleHeight);
+	g_hdb->_drawMan->setTextEdges(e1, e2, e3, e4);
+	_dialogInfo.height = (height + 2) * 16;
+	w = _dialogInfo.width = width + 32;
+	_dialogInfo.titleWidth = titleWidth;
+	if (titleWidth > w)
+		w = titleWidth;
+
+	_dialogInfo.x = (480 >> 1) - (w >> 1);
+
+	int px, py;
+	g_hdb->_ai->getPlayerXY(&px, &py);
+	if (py < (kScreenHeight >> 1) - 16)
+		_dialogInfo.y = (kScreenHeight >> 1) + 16;
+	else
+		_dialogInfo.y = (kScreenHeight >> 1) - (_dialogInfo.height + 64);
+
+	if (_dialogInfo.y < 16)
+		_dialogInfo.y = 16;
+
+	_dialogInfo.more = more;
+	if (luaMore)
+		strcpy(_dialogInfo.luaMore, luaMore);
+	warning("STUB: openDialog: Play SND_MOVE_SELECTION");
 }
 
 void Window::setDialogDelay(int seconds) {


Commit: 66a7c617df1be61beed21134b057765460d8bea2
    https://github.com/scummvm/scummvm/commit/66a7c617df1be61beed21134b057765460d8bea2
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:16:57+02:00

Commit Message:
HDB: Add setDialogDelay()`

Changed paths:
    engines/hdb/window.cpp


diff --git a/engines/hdb/window.cpp b/engines/hdb/window.cpp
index f157ed6..23f5b24 100644
--- a/engines/hdb/window.cpp
+++ b/engines/hdb/window.cpp
@@ -124,8 +124,8 @@ void Window::openDialog(const char *title, int tileIndex, const char *string, in
 	warning("STUB: openDialog: Play SND_MOVE_SELECTION");
 }
 
-void Window::setDialogDelay(int seconds) {
-	warning("STUB: Window::setDialogDelay() required");
+void Window::setDialogDelay(int delay) {
+	_dialogDelay = g_system->getMillis() + 1000 * delay;
 }
 
 } // End of Namespace


Commit: da528445f905011a93b9346a9345aa39abc98acb
    https://github.com/scummvm/scummvm/commit/da528445f905011a93b9346a9345aa39abc98acb
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:16:57+02:00

Commit Message:
HDB: Add cineDialog()

Changed paths:
    engines/hdb/ai-cinematic.cpp
    engines/hdb/ai.h


diff --git a/engines/hdb/ai-cinematic.cpp b/engines/hdb/ai-cinematic.cpp
index 2b3ad71..6dbe669 100644
--- a/engines/hdb/ai-cinematic.cpp
+++ b/engines/hdb/ai-cinematic.cpp
@@ -366,6 +366,18 @@ void AI::cineEntityFace(const char *luaName, double dir) {
 	_cine.push_back(cmd);
 }
 
+void AI::cineDialog(const char *title, const char *string, int seconds) {
+	CineCommand *cmd = new CineCommand;
+	strcpy(cmd->title, title);
+	strcpy(cmd->string, string);
+	cmd->delay = seconds;
+	cmd->start = 1;
+	if (!title || !string)
+		warning("cineDialog: Missing Title or Text");
+	cmd->cmdType = C_DIALOG;
+	_cine.push_back(cmd);
+}
+
 void AI::cineUse(const char *entName) {
 	CineCommand *cmd = new CineCommand;
 	strcpy(cmd->string, entName);
diff --git a/engines/hdb/ai.h b/engines/hdb/ai.h
index a88a703..76126f8 100644
--- a/engines/hdb/ai.h
+++ b/engines/hdb/ai.h
@@ -720,6 +720,7 @@ public:
 	void cineSetEntity(const char *entName, int x, int y, int level);
 	void cineMoveEntity(const char *entName, int x, int y, int level, int speed);
 	void cineEntityFace(const char *luaName, double dir);
+	void cineDialog(const char *title, const char *string, int seconds);
 	void cineUse(const char *entName);
 	void cineFadeIn(bool isBlack, int steps);
 	void cineFadeOut(bool isBlack, int steps);


Commit: 22d4f60b3ac40684f67ad1399fef02686b4ade4f
    https://github.com/scummvm/scummvm/commit/22d4f60b3ac40684f67ad1399fef02686b4ade4f
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:16:57+02:00

Commit Message:
HDB: Process cineDialog()

Changed paths:
    engines/hdb/ai-cinematic.cpp


diff --git a/engines/hdb/ai-cinematic.cpp b/engines/hdb/ai-cinematic.cpp
index 6dbe669..c6c8674 100644
--- a/engines/hdb/ai-cinematic.cpp
+++ b/engines/hdb/ai-cinematic.cpp
@@ -208,6 +208,16 @@ void AI::processCines() {
 			complete = true;
 			break;
 		}
+		case C_DIALOG:
+			if (_cine[i]->start) {
+				g_hdb->_window->openDialog(_cine[i]->title, -1, _cine[i]->string, 0, NULL);
+				g_hdb->_window->setDialogDelay(_cine[i]->delay);
+				_cine[i]->start = 0;
+			} else {
+				if (g_hdb->_window->getDialogDelay() < g_hdb->getTimeSlice())
+					complete = true;
+			}
+			break;
 		case C_USEENTITY:
 			for (Common::Array<AIEntity *>::iterator it = _ents->begin(); it != _ents->end(); it++) {
 				if ((*it)->entityName && Common::matchString((*it)->entityName, _cine[i]->string)) {


Commit: a53b2c95508df218900d1b5953d4b18319c982e1
    https://github.com/scummvm/scummvm/commit/a53b2c95508df218900d1b5953d4b18319c982e1
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:16:57+02:00

Commit Message:
HDB: Call animateTargets() from hdb.cpp

Changed paths:
    engines/hdb/hdb.cpp


diff --git a/engines/hdb/hdb.cpp b/engines/hdb/hdb.cpp
index a0c92d2..cae6b6d 100644
--- a/engines/hdb/hdb.cpp
+++ b/engines/hdb/hdb.cpp
@@ -297,6 +297,7 @@ Common::Error HDBGame::run() {
 		_map->drawEnts();
 		_map->drawGratings();
 		_map->drawForegrounds();
+		_ai->animateTargets();
 
 		// Update Timer that's NOT used for in-game Timing
 		_prevTimeSlice = _timeSlice;


Commit: 538efcad6b814393cdcfc6d6b4cfb9075dbb38ae
    https://github.com/scummvm/scummvm/commit/538efcad6b814393cdcfc6d6b4cfb9075dbb38ae
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:16:57+02:00

Commit Message:
HDB: Add cineDialog() Lua function

Changed paths:
    engines/hdb/lua-script.cpp


diff --git a/engines/hdb/lua-script.cpp b/engines/hdb/lua-script.cpp
index edd47bc..7ea1a2f 100644
--- a/engines/hdb/lua-script.cpp
+++ b/engines/hdb/lua-script.cpp
@@ -258,7 +258,14 @@ static int cineSetAnimFrame(lua_State *L) {
 }
 
 static int cineDialog(lua_State *L) {
-	warning("STUB: CINE DIALOG");
+	const char *title = lua_tostring(L, 1);
+	const char *string = lua_tostring(L, 1);
+	double seconds = lua_tonumber(L, 3);
+
+	g_hdb->_lua->checkParameters("cineDialog", 3);
+
+	lua_pop(L, 3);
+	g_hdb->_ai->cineDialog(title, string, (int)seconds);
 	return 0;
 }
 


Commit: 0c8dad3a40b7491df5ea4560f113eb7fa56b29d2
    https://github.com/scummvm/scummvm/commit/0c8dad3a40b7491df5ea4560f113eb7fa56b29d2
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:16:57+02:00

Commit Message:
HDB: Add cinematicsActive()

Changed paths:
    engines/hdb/ai.h


diff --git a/engines/hdb/ai.h b/engines/hdb/ai.h
index 76126f8..a064088 100644
--- a/engines/hdb/ai.h
+++ b/engines/hdb/ai.h
@@ -708,6 +708,9 @@ public:
 	}
 
 	// Cinematic Functions
+	bool cinematicsActive() {
+		return _cineActive;
+	}
 	void processCines();
 	void cineStart(bool abortable, const char *abortFunc);
 	void cineLockPlayer();


Commit: 535c56aa4dbe36689d68363937c70fd17404aa94
    https://github.com/scummvm/scummvm/commit/535c56aa4dbe36689d68363937c70fd17404aa94
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:16:57+02:00

Commit Message:
HDB: Add closeDialog()

Changed paths:
    engines/hdb/window.cpp
    engines/hdb/window.h


diff --git a/engines/hdb/window.cpp b/engines/hdb/window.cpp
index 23f5b24..b0b66b6 100644
--- a/engines/hdb/window.cpp
+++ b/engines/hdb/window.cpp
@@ -124,6 +124,16 @@ void Window::openDialog(const char *title, int tileIndex, const char *string, in
 	warning("STUB: openDialog: Play SND_MOVE_SELECTION");
 }
 
+void Window::closeDialog() {
+	if (_dialogInfo.active) {
+		warning("STUB: closeDialog: Play SND_SWITCH_USE");
+		_dialogInfo.active = false;
+		_dialogDelay = 0;
+		if (_dialogInfo.luaMore[0] && !g_hdb->_ai->cinematicsActive())
+			g_hdb->_lua->callFunction(_dialogInfo.luaMore, 0);
+	}
+}
+
 void Window::setDialogDelay(int delay) {
 	_dialogDelay = g_system->getMillis() + 1000 * delay;
 }
diff --git a/engines/hdb/window.h b/engines/hdb/window.h
index 3306e82..60a2e66 100644
--- a/engines/hdb/window.h
+++ b/engines/hdb/window.h
@@ -56,6 +56,7 @@ public:
 	// Dialog Functions
 
 	void openDialog(const char *title, int tileIndex, const char *string, int more, const char *luaMore);
+	void closeDialog();
 	void setDialogDelay(int delay);
 	uint32 getDialogDelay() {
 		return _dialogDelay;


Commit: d48404d087f1e04ff6d1f730c006fbaad34e548c
    https://github.com/scummvm/scummvm/commit/d48404d087f1e04ff6d1f730c006fbaad34e548c
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:16:57+02:00

Commit Message:
HDB: Add checkDialogClose()

Changed paths:
    engines/hdb/window.cpp
    engines/hdb/window.h


diff --git a/engines/hdb/window.cpp b/engines/hdb/window.cpp
index b0b66b6..606cf78 100644
--- a/engines/hdb/window.cpp
+++ b/engines/hdb/window.cpp
@@ -134,6 +134,31 @@ void Window::closeDialog() {
 	}
 }
 
+bool Window::checkDialogClose(int x, int y) {
+	if (!_dialogInfo.active)
+		return false;
+
+	if (x >= _dialogInfo.x && x < _dialogInfo.x + _dialogInfo.width && y >= _dialogInfo.y && y < _dialogInfo.y + _dialogInfo.height) {
+		closeDialog();
+		return true;
+	}
+
+	// If Cinematics are on, we need to timeout instead of get a click
+	if (g_hdb->_ai->cinematicsActive()) {
+		if (_dialogDelay < g_hdb->getTimeSlice()) {
+			closeDialog();
+			_dialogDelay = 0;
+			return true;
+		}
+	}
+
+	return false;
+}
+
+void Window::drawBorder() {
+
+}
+
 void Window::setDialogDelay(int delay) {
 	_dialogDelay = g_system->getMillis() + 1000 * delay;
 }
diff --git a/engines/hdb/window.h b/engines/hdb/window.h
index 60a2e66..fa478e7 100644
--- a/engines/hdb/window.h
+++ b/engines/hdb/window.h
@@ -57,6 +57,7 @@ public:
 
 	void openDialog(const char *title, int tileIndex, const char *string, int more, const char *luaMore);
 	void closeDialog();
+	bool checkDialogClose(int x, int y);
 	void setDialogDelay(int delay);
 	uint32 getDialogDelay() {
 		return _dialogDelay;


Commit: a1b1275764f493ccf25eb44e1a67a4d6b28e311e
    https://github.com/scummvm/scummvm/commit/a1b1275764f493ccf25eb44e1a67a4d6b28e311e
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:16:57+02:00

Commit Message:
HDB: Add and modify debug output

Changed paths:
    engines/hdb/ai-cinematic.cpp
    engines/hdb/file-manager.cpp


diff --git a/engines/hdb/ai-cinematic.cpp b/engines/hdb/ai-cinematic.cpp
index c6c8674..bc7ec51 100644
--- a/engines/hdb/ai-cinematic.cpp
+++ b/engines/hdb/ai-cinematic.cpp
@@ -209,6 +209,7 @@ void AI::processCines() {
 			break;
 		}
 		case C_DIALOG:
+			debug("In processCines: C_DIALOG: _cine[i]->start: %d", _cine[i]->start);
 			if (_cine[i]->start) {
 				g_hdb->_window->openDialog(_cine[i]->title, -1, _cine[i]->string, 0, NULL);
 				g_hdb->_window->setDialogDelay(_cine[i]->delay);
@@ -385,6 +386,7 @@ void AI::cineDialog(const char *title, const char *string, int seconds) {
 	if (!title || !string)
 		warning("cineDialog: Missing Title or Text");
 	cmd->cmdType = C_DIALOG;
+	debug("In cineDialog: C_DIALOG created. cmd->start: %d", cmd->start);
 	_cine.push_back(cmd);
 }
 
diff --git a/engines/hdb/file-manager.cpp b/engines/hdb/file-manager.cpp
index 622d2c0..0a23812 100644
--- a/engines/hdb/file-manager.cpp
+++ b/engines/hdb/file-manager.cpp
@@ -96,7 +96,7 @@ Common::SeekableReadStream *FileMan::findFirstData(const char *string, DataType
 	Common::String fileString;
 	MPCEntry *file = NULL;
 
-	debug(2, "Looking for Data: '%s'", string);
+	debug(4, "Looking for Data: '%s'", string);
 
 	// Find MPC Entry
 	for (MPCIterator it = _dir.begin(); it != _dir.end(); it++) {
@@ -106,13 +106,13 @@ Common::SeekableReadStream *FileMan::findFirstData(const char *string, DataType
 				file = *it;
 				break;
 			} else {
-				debug(2, "Found Data but type mismatch: '%s', target: %d, found: %d", string, type, (*it)->type);
+				debug(4, "Found Data but type mismatch: '%s', target: %d, found: %d", string, type, (*it)->type);
 			}
 		}
 	}
 
 	if (file == NULL) {
-		debug(2, "Couldn't find Data: '%s'", string);
+		debug(4, "Couldn't find Data: '%s'", string);
 		return NULL;
 	}
 


Commit: 2f5367b0df2d46de82cfad60e000847c1153705c
    https://github.com/scummvm/scummvm/commit/2f5367b0df2d46de82cfad60e000847c1153705c
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:16:57+02:00

Commit Message:
HDB: Add drawBorder()

Changed paths:
    engines/hdb/window.cpp
    engines/hdb/window.h


diff --git a/engines/hdb/window.cpp b/engines/hdb/window.cpp
index 606cf78..dc3702a 100644
--- a/engines/hdb/window.cpp
+++ b/engines/hdb/window.cpp
@@ -155,8 +155,69 @@ bool Window::checkDialogClose(int x, int y) {
 	return false;
 }
 
-void Window::drawBorder() {
-
+void Window::drawBorder(int x, int y, int width, int height, bool guyTalking) {
+	int wide, high, i, j;
+	if (!guyTalking) {
+		wide = (width / 16) + 1;
+		high = height / 16;
+		for(j = 0; j < high; j++)
+			for (i = 0;i < wide;i++) {
+				// Top Line
+				if (!i && !j)
+					_gfxTL->drawMasked(x, y);
+				else if ((i == wide - 1) && !j)
+					_gfxTR->drawMasked(x + i * 16, y + j * 16);
+				else if (!j)
+					_gfxTM->draw(x + i * 16, y + j * 16);
+
+				// Bottom Lines
+				if ((j == high - 1) && !i)
+					_gfxBL->drawMasked(x + i * 16, y + j * 16);
+				else if ((j == high - 1) && (i == wide - 1))
+					_gfxBR->drawMasked(x + i * 16, y + j * 16);
+				else if ((j == high - 1) && i < wide)
+					_gfxBM->draw(x + i * 16, y + j * 16);
+
+				// Middle lines
+				if (!i && j < high)
+					_gfxL->draw(x + i * 16, y + j * 16);
+				else if ((i == wide - 1) && j < high)
+					_gfxR->draw(x + i * 16, y + j * 16);
+
+				// Most drawn = middle block
+				_gfxM->draw(x + i * 16, y + j * 16);
+			}
+	} else {
+		wide = (width / 16) + 1;
+		high = height / 16;
+		for (j = 0; j < high; j++)
+			for (i = 0;i < wide;i++) {
+				// Top Line
+				if (!i && !j)
+					_gGfxTL->drawMasked(x, y);
+				else if ((i == wide - 1) && !j)
+					_gGfxTR->drawMasked(x + i * 16, y + j * 16);
+				else if (!j)
+					_gGfxTM->draw(x + i * 16, y + j * 16);
+
+				// Bottom Lines
+				if ((j == high - 1) && !i)
+					_gGfxBL->drawMasked(x + i * 16, y + j * 16);
+				else if ((j == high - 1) && (i == wide - 1))
+					_gGfxBR->drawMasked(x + i * 16, y + j * 16);
+				else if ((j == high - 1) && i < wide)
+					_gGfxBM->draw(x + i * 16, y + j * 16);
+
+				// Middle lines
+				if (!i && j < high)
+					_gGfxL->draw(x + i * 16, y + j * 16);
+				else if ((i == wide - 1) && j < high)
+					_gGfxR->draw(x + i * 16, y + j * 16);
+
+				// Most drawn = middle block
+				_gGfxM->draw(x + i * 16, y + j * 16);
+			}
+	}
 }
 
 void Window::setDialogDelay(int delay) {
diff --git a/engines/hdb/window.h b/engines/hdb/window.h
index fa478e7..1a8f1f1 100644
--- a/engines/hdb/window.h
+++ b/engines/hdb/window.h
@@ -58,6 +58,7 @@ public:
 	void openDialog(const char *title, int tileIndex, const char *string, int more, const char *luaMore);
 	void closeDialog();
 	bool checkDialogClose(int x, int y);
+	void drawBorder(int x, int y, int width, int height, bool guyTalking);
 	void setDialogDelay(int delay);
 	uint32 getDialogDelay() {
 		return _dialogDelay;


Commit: 4b28b535bc3c1c28ba273f460eae89b0424e04fb
    https://github.com/scummvm/scummvm/commit/4b28b535bc3c1c28ba273f460eae89b0424e04fb
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:16:57+02:00

Commit Message:
HDB: Add drawDialog()

Changed paths:
    engines/hdb/window.cpp
    engines/hdb/window.h


diff --git a/engines/hdb/window.cpp b/engines/hdb/window.cpp
index dc3702a..ff72b16 100644
--- a/engines/hdb/window.cpp
+++ b/engines/hdb/window.cpp
@@ -124,6 +124,49 @@ void Window::openDialog(const char *title, int tileIndex, const char *string, in
 	warning("STUB: openDialog: Play SND_MOVE_SELECTION");
 }
 
+void Window::drawDialog() {
+
+	if (g_hdb->getActionMode())
+		warning("STUB: drawDialog: Draw Player Weapon");
+
+	if (!_dialogInfo.active)
+		return;
+	bool guyTalking = !_stricmp(_dialogInfo.title, "guy");
+
+	int w = _dialogInfo.width;
+	if (_dialogInfo.titleWidth > w)
+		w = _dialogInfo.titleWidth;
+
+	drawBorder(_dialogInfo.x, _dialogInfo.y, w, _dialogInfo.height, guyTalking);
+
+	int blocks;
+	if (!guyTalking) {
+		_gfxTitleL->drawMasked(_dialogInfo.x, _dialogInfo.y - 10);
+		blocks = _dialogInfo.titleWidth / 16;
+		for (int i = 0; i < blocks;i++)
+			_gfxTitleM->drawMasked(_dialogInfo.x + 16 * (i + 1), _dialogInfo.y - 10);
+		_gfxTitleR->drawMasked(_dialogInfo.x + (blocks + 1) * 16, _dialogInfo.y - 10);
+	} else {
+		_gGfxTitleL->drawMasked(_dialogInfo.x, _dialogInfo.y - 10);
+		blocks = _dialogInfo.titleWidth / 16;
+		for (int i = 0; i < blocks;i++)
+			_gGfxTitleM->drawMasked(_dialogInfo.x + 16 * (i + 1), _dialogInfo.y - 10);
+		_gGfxTitleR->drawMasked(_dialogInfo.x + (blocks + 1) * 16, _dialogInfo.y - 10);
+	}
+
+	int e1, e2, e3, e4;
+	g_hdb->_drawMan->getTextEdges(&e1, &e2, &e3, &e4);
+	g_hdb->_drawMan->setTextEdges(_dialogInfo.x + 10, 480, 0, kScreenHeight);
+	g_hdb->_drawMan->setCursor(0, _dialogInfo.y - 7);
+	if (_dialogInfo.title)
+		g_hdb->_drawMan->drawText(_dialogInfo.title);
+	g_hdb->_drawMan->setTextEdges(_dialogInfo.x + 16, _dialogInfo.x + _dialogInfo.width - 16, 0, kScreenHeight);
+	g_hdb->_drawMan->setCursor(0, _dialogInfo.y + 16);
+	if (_dialogInfo.string)
+		g_hdb->_drawMan->drawText(_dialogInfo.string);
+	g_hdb->_drawMan->setTextEdges(e1, e2, e3, e4);
+}
+
 void Window::closeDialog() {
 	if (_dialogInfo.active) {
 		warning("STUB: closeDialog: Play SND_SWITCH_USE");
diff --git a/engines/hdb/window.h b/engines/hdb/window.h
index 1a8f1f1..8a22b9d 100644
--- a/engines/hdb/window.h
+++ b/engines/hdb/window.h
@@ -56,6 +56,7 @@ public:
 	// Dialog Functions
 
 	void openDialog(const char *title, int tileIndex, const char *string, int more, const char *luaMore);
+	void drawDialog();
 	void closeDialog();
 	bool checkDialogClose(int x, int y);
 	void drawBorder(int x, int y, int width, int height, bool guyTalking);


Commit: 8cdd69ba4175cdff5e711c53c87ddec36c6eae13
    https://github.com/scummvm/scummvm/commit/8cdd69ba4175cdff5e711c53c87ddec36c6eae13
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:16:57+02:00

Commit Message:
HDB: Call drawDialog() from hdb.cpp

Changed paths:
  A engines/hdb/font.h
    engines/hdb/hdb.cpp


diff --git a/engines/hdb/font.h b/engines/hdb/font.h
new file mode 100644
index 0000000..6f70f09
--- /dev/null
+++ b/engines/hdb/font.h
@@ -0,0 +1 @@
+#pragma once
diff --git a/engines/hdb/hdb.cpp b/engines/hdb/hdb.cpp
index cae6b6d..f72a3f2 100644
--- a/engines/hdb/hdb.cpp
+++ b/engines/hdb/hdb.cpp
@@ -299,6 +299,8 @@ Common::Error HDBGame::run() {
 		_map->drawForegrounds();
 		_ai->animateTargets();
 
+		_window->drawDialog();
+
 		// Update Timer that's NOT used for in-game Timing
 		_prevTimeSlice = _timeSlice;
 		_timeSlice = g_system->getMillis();


Commit: fd5d7ae477e237e7b3c3748613c714eb22833433
    https://github.com/scummvm/scummvm/commit/fd5d7ae477e237e7b3c3748613c714eb22833433
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:16:57+02:00

Commit Message:
HDB: Add moveEnts()

Changed paths:
    engines/hdb/ai-funcs.cpp
    engines/hdb/ai.h


diff --git a/engines/hdb/ai-funcs.cpp b/engines/hdb/ai-funcs.cpp
index ff0c4f9..20d84fd 100644
--- a/engines/hdb/ai-funcs.cpp
+++ b/engines/hdb/ai-funcs.cpp
@@ -1237,6 +1237,50 @@ void AI::animGrabbing() {
 	_player->animFrame = 5;
 }
 
+void AI::moveEnts() {
+	static int frameDelay = kAnimFrameDelay;
+	AIEntity *e;
+
+	if (frameDelay-- > 0)
+		return;
+
+	// Call aiAction for Floating Entities
+	for (Common::Array<AIEntity *>::iterator it = _floats->begin(); it != _floats->end(); it++) {
+		if ((*it)->aiAction)
+			(*it)->aiAction((*it));
+	}
+
+	// Call aiAction for all other Entities
+	for (Common::Array<AIEntity *>::iterator it = _ents->begin(); it != _ents->end(); it++) {
+		e = (*it);
+		if (e->aiAction) {
+			// NPC Touchplate Counter
+			if (e != _player && e->touchpWait) {
+				e->touchpWait--;
+				if (!e->touchpWait) {
+					if (e->tileX == e->touchpX && e->tileY == e->touchpY && onEvenTile(e->x, e->y))
+						e->touchpWait = 1;
+					else {
+						checkActionList(e, e->touchpX, e->touchpY, false);
+						g_hdb->_map->setMapBGTileIndex(e->touchpX, e->touchpY, e->touchpTile);
+						e->touchpX = e->touchpY = e->touchpTile = 0;
+					}
+				}
+			}
+			// Stunned Entity Timer
+			if (!e->stunnedWait)
+				e->aiAction(e);
+			else {
+				if (e->stunnedWait < g_hdb->getTimeSlice())
+					e->stunnedWait = 0;
+			}
+		}
+	}
+
+	warning("STUB: moveEnts: Laser Rescan");
+	warning("STUB: moveEnts: Laser Looping Sound Channel");
+}
+
 int AI::checkForTouchplate(int x, int y) {
 	int tileIndex = g_hdb->_map->getMapBGTileIndex(x, y);
 	if (tileIndex == _touchplateOff || tileIndex == _templeTouchpOff)
diff --git a/engines/hdb/ai.h b/engines/hdb/ai.h
index a064088..6601df3 100644
--- a/engines/hdb/ai.h
+++ b/engines/hdb/ai.h
@@ -628,6 +628,8 @@ public:
 	void drawEnts(int x, int y, int w, int h);
 	void animGrabbing();
 
+	void moveEnts();
+
 	int checkForTouchplate(int x, int y);
 
 	void addAnimateTarget(int x, int y, int start, int end, AnimSpeed speed, bool killAuto, bool inMap, const char *tileName);


Commit: 3522d6f3347b1d3b83824b3db4eebeb381e3eee0
    https://github.com/scummvm/scummvm/commit/3522d6f3347b1d3b83824b3db4eebeb381e3eee0
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:16:57+02:00

Commit Message:
HDB: Add debug output

Changed paths:
    engines/hdb/ai-cinematic.cpp


diff --git a/engines/hdb/ai-cinematic.cpp b/engines/hdb/ai-cinematic.cpp
index bc7ec51..5a4bebb 100644
--- a/engines/hdb/ai-cinematic.cpp
+++ b/engines/hdb/ai-cinematic.cpp
@@ -174,6 +174,7 @@ void AI::processCines() {
 					warning("Can't locate '%s' in moveEntity", _cine[i]->title);
 				}
 			} else {
+				debug(3, "C_MOVEENTITY: _cine[%d]->e->goalX: %d", i, _cine[i]->e->goalX);
 				if (!_cine[i]->e->goalX) {
 					complete = true;
 				}


Commit: 11b19dd013b0dd107c4ad0c1b1cc3475b9440d5e
    https://github.com/scummvm/scummvm/commit/11b19dd013b0dd107c4ad0c1b1cc3475b9440d5e
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:16:57+02:00

Commit Message:
HDB: Call moveEnts()

Changed paths:
    engines/hdb/hdb.cpp


diff --git a/engines/hdb/hdb.cpp b/engines/hdb/hdb.cpp
index f72a3f2..1f05b33 100644
--- a/engines/hdb/hdb.cpp
+++ b/engines/hdb/hdb.cpp
@@ -292,6 +292,9 @@ Common::Error HDBGame::run() {
 		}
 
 		_drawMan->drawSky();
+
+		_ai->moveEnts();
+
 		_map->draw();
 		_ai->processCines();
 		_map->drawEnts();


Commit: 9165641d69f4145ed4531828bf55359671e0c2de
    https://github.com/scummvm/scummvm/commit/9165641d69f4145ed4531828bf55359671e0c2de
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:16:57+02:00

Commit Message:
HDB: Fix portability issue

Changed paths:
    engines/hdb/window.cpp


diff --git a/engines/hdb/window.cpp b/engines/hdb/window.cpp
index ff72b16..5650d76 100644
--- a/engines/hdb/window.cpp
+++ b/engines/hdb/window.cpp
@@ -131,7 +131,7 @@ void Window::drawDialog() {
 
 	if (!_dialogInfo.active)
 		return;
-	bool guyTalking = !_stricmp(_dialogInfo.title, "guy");
+	bool guyTalking = !scumm_stricmp(_dialogInfo.title, "guy");
 
 	int w = _dialogInfo.width;
 	if (_dialogInfo.titleWidth > w)


Commit: 8a6608979691aa6907919f0402349033106c8bf1
    https://github.com/scummvm/scummvm/commit/8a6608979691aa6907919f0402349033106c8bf1
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:16:57+02:00

Commit Message:
JANITORIAL: Remove trailing spaces

Changed paths:
    engines/hdb/window.cpp


diff --git a/engines/hdb/window.cpp b/engines/hdb/window.cpp
index 5650d76..6070f75 100644
--- a/engines/hdb/window.cpp
+++ b/engines/hdb/window.cpp
@@ -47,15 +47,15 @@ bool Window::init() {
 	_gGfxTL = g_hdb->_drawMan->loadPic("g_menu_back_topleft");
 	_gGfxTM = g_hdb->_drawMan->loadPic("g_menu_back_top");
 	_gGfxTR = g_hdb->_drawMan->loadPic("g_menu_back_topright");
-	
+
 	_gGfxL = g_hdb->_drawMan->loadPic("g_menu_back_left");
 	_gGfxM = g_hdb->_drawMan->loadPic("g_menu_back_middle");
 	_gGfxR = g_hdb->_drawMan->loadPic("g_menu_back_right");
-	
+
 	_gGfxBL = g_hdb->_drawMan->loadPic("g_menu_back_btmleft");
 	_gGfxBM = g_hdb->_drawMan->loadPic("g_menu_back_bottom");
 	_gGfxBR = g_hdb->_drawMan->loadPic("g_menu_back_btmright");
-	
+
 	_gGfxTitleL = g_hdb->_drawMan->loadPic("g_menu_title_left");
 	_gGfxTitleM = g_hdb->_drawMan->loadPic("g_menu_title_mid");
 	_gGfxTitleR = g_hdb->_drawMan->loadPic("g_menu_title_right");


Commit: a23fbd7b6b089d673072324159379e59f303a1d7
    https://github.com/scummvm/scummvm/commit/a23fbd7b6b089d673072324159379e59f303a1d7
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:16:57+02:00

Commit Message:
HDB: Adding tracing of entity drawing

Changed paths:
    engines/hdb/ai-funcs.cpp
    engines/hdb/ai-init.cpp
    engines/hdb/ai.h


diff --git a/engines/hdb/ai-funcs.cpp b/engines/hdb/ai-funcs.cpp
index 20d84fd..a04af9a 100644
--- a/engines/hdb/ai-funcs.cpp
+++ b/engines/hdb/ai-funcs.cpp
@@ -1130,6 +1130,8 @@ void AI::drawEnts(int x, int y, int w, int h) {
 
 	for (Common::Array<AIEntity *>::iterator it = _ents->begin(); it != _ents->end(); it++) {
 		AIEntity *e = (*it);
+		debugN(5, "AI::drawEnts: enity %s(%d)...", AIType2Str(e->type), e->type);
+
 		if (e->type == AI_LASER || e->type == AI_DIVERTER) {
 			if (e->aiDraw) {
 				if (e->level == 2 && _numLevel2Ents < kMaxLevel2Ents) {
@@ -1178,8 +1180,15 @@ void AI::drawEnts(int x, int y, int w, int h) {
 					_entsLevel2[_numLevel2Ents].stunnedWait = e->stunnedWait;
 					_numLevel2Ents++;
 				} else {
-					if (e->draw)
+					debugN(5, "trying to draw...");
+
+					if (e->draw) {
+						debugN(5, "at %d %d", e->x, e->y);
+
 						e->draw->drawMasked(e->x - x + e->drawXOff, e->y - y + e->drawYOff);
+					} else {
+						debugN(5, "no draw function");
+					}
 
 					if (e->stunnedWait)
 						g_hdb->_ai->_stunnedGfx[stunAnim]->drawMasked(e->x - x, e->y - y);
@@ -1187,8 +1196,11 @@ void AI::drawEnts(int x, int y, int w, int h) {
 				break;
 			}
 			e->onScreen = 1;
-		} else
+		} else {
 			e->onScreen = 0;
+			debugN(5, "not on screen");
+		}
+		debug(5, ""); // newline
 	}
 
 	if (stunTimer < g_hdb->getTimeSlice()) {
diff --git a/engines/hdb/ai-init.cpp b/engines/hdb/ai-init.cpp
index 32d45ef..201c8fa 100644
--- a/engines/hdb/ai-init.cpp
+++ b/engines/hdb/ai-init.cpp
@@ -928,4 +928,164 @@ void AI::initAnimInfo() {
 	if (g_hdb->_map->checkOneTileExistInRange(_kcHolderBlackOff, 2))
 		g_hdb->_drawMan->getTile(_kcHolderBlackOn);
 }
+
+const char *AITypeStr[] = {
+	"AI_NONE",
+	"AI_GUY",
+	"AI_DOLLY",
+	"AI_SPACEDUDE",
+	"AI_SERGEANT",
+	"AI_SCIENTIST",
+	"AI_WORKER",
+	"AI_DEADWORKER",
+	"AI_ACCOUNTANT",
+	"AI_RAILRIDER",
+	"AI_RAILRIDER_ON",
+	"AI_VORTEXIAN",
+	"AI_CHICKEN",
+	"AI_GEM_ATTACK",
+	"AI_SLUG_ATTACK",
+
+	"AI_LASER",
+	"AI_LASERBEAM",
+	"AI_DIVERTER",
+	"AI_FOURFIRER",
+	"AI_OMNIBOT",
+	"AI_TURNBOT",
+	"AI_SHOCKBOT",
+	"AI_RIGHTBOT",
+	"AI_PUSHBOT",
+	"AI_LISTENBOT",
+	"AI_MAINTBOT",
+	"AI_OMNIBOT_MISSILE",
+	"AI_DEADEYE",
+	"AI_MEERKAT",
+	"AI_FATFROG",
+	"AI_GOODFAIRY",
+	"AI_BADFAIRY",
+	"AI_ICEPUFF",
+	"AI_BUZZFLY",
+	"AI_DRAGON",
+	"AI_GATEPUDDLE",
+
+	"AI_CRATE",
+	"AI_LIGHTBARREL",
+	"AI_HEAVYBARREL",
+	"AI_BOOMBARREL",
+	"AI_FROGSTATUE",
+
+	"AI_MAGIC_EGG",
+	"AI_ICE_BLOCK",
+
+	"ITEM_CELL",
+	"ITEM_ENV_WHITE",
+	"ITEM_ENV_RED",
+	"ITEM_ENV_BLUE",
+	"ITEM_ENV_GREEN",
+	"ITEM_TRANSCEIVER",
+	"ITEM_CLUB",
+	"ITEM_ROBOSTUNNER",
+	"ITEM_SLUGSLINGER",
+	"ITEM_MONKEYSTONE",
+	"ITEM_GEM_WHITE",
+	"ITEM_GEM_BLUE",
+	"ITEM_GEM_RED",
+	"ITEM_GEM_GREEN",
+	"ITEM_GOO_CUP",
+	"ITEM_TEACUP",
+	"ITEM_COOKIE",
+	"ITEM_BURGER",
+	"ITEM_PDA",
+	"ITEM_BOOK",
+	"ITEM_CLIPBOARD",
+	"ITEM_NOTE",
+	"ITEM_KEYCARD_WHITE",
+	"ITEM_KEYCARD_BLUE",
+	"ITEM_KEYCARD_RED",
+	"ITEM_KEYCARD_GREEN",
+	"ITEM_KEYCARD_PURPLE",
+	"ITEM_KEYCARD_BLACK",
+	"ITEM_CABKEY",
+	"ITEM_DOLLYTOOL1",
+	"ITEM_DOLLYTOOL2",
+	"ITEM_DOLLYTOOL3",
+	"ITEM_DOLLYTOOL4",
+	"ITEM_SEED",
+	"ITEM_SODA",
+	"ITEM_ROUTER",
+	"ITEM_SLICER",
+	"ITEM_CHICKEN",
+	"ITEM_PACKAGE",
+
+	"INFO_FAIRY_SRC",
+	"INFO_FAIRY_SRC2",
+	"INFO_FAIRY_SRC3",
+	"INFO_FAIRY_SRC4",
+	"INFO_FAIRY_SRC5",
+	"INFO_FAIRY_DEST",
+	"INFO_FAIRY_DEST2",
+	"INFO_FAIRY_DEST3",
+	"INFO_FAIRY_DEST4",
+	"INFO_FAIRY_DEST5",
+	"INFO_TRIGGER",
+	"INFO_SET_MUSIC",
+	"INFO_PROMOTE",
+	"INFO_DEMOTE",
+	"INFO_LUA",
+	"INFO_HERE",
+	"INFO_ARROW_TURN",
+	"INFO_ARROW_STOP",
+	"INFO_ARROW_4WAY",
+	"INFO_TELEPORTER1",
+	"INFO_TELEPORTER2",
+	"INFO_TELEPORTER3",
+	"INFO_TELEPORTER4",
+	"INFO_TELEPORTER5",
+	"INFO_TELEPORTER6",
+	"INFO_TELEPORTER7",
+	"INFO_TELEPORTER8",
+	"INFO_TELEPORTER9",
+	"INFO_TELEPORTER10",
+	"INFO_TELEPORTER11",
+	"INFO_TELEPORTER12",
+	"INFO_TELEPORTER13",
+	"INFO_TELEPORTER14",
+	"INFO_TELEPORTER15",
+	"INFO_TELEPORTER16",
+	"INFO_TELEPORTER17",
+	"INFO_TELEPORTER18",
+	"INFO_TELEPORTER19",
+	"INFO_TELEPORTER20",
+	"INFO_LEVELEXIT",
+	"INFO_ACTION1",
+	"INFO_ACTION2",
+	"INFO_ACTION3",
+	"INFO_ACTION4",
+	"INFO_ACTION5",
+	"INFO_ACTION6",
+	"INFO_ACTION7",
+	"INFO_ACTION8",
+	"INFO_ACTION9",
+	"INFO_ACTION10",
+	"INFO_ACTION11",
+	"INFO_ACTION12",
+	"INFO_ACTION13",
+	"INFO_ACTION14",
+	"INFO_ACTION15",
+	"INFO_ACTION16",
+	"INFO_ACTION17",
+	"INFO_ACTION18",
+	"INFO_ACTION19",
+	"INFO_ACTION20",
+	"INFO_ACTION_AUTO",
+
+	"INFO_QMARK",
+	"INFO_DEBUG",
+	"END_AI_TYPES"
+};
+
+const char *AIType2Str(AIType v) {
+	return AITypeStr[v];
+}
+
 } // End of Namespace
diff --git a/engines/hdb/ai.h b/engines/hdb/ai.h
index 6601df3..db0869f 100644
--- a/engines/hdb/ai.h
+++ b/engines/hdb/ai.h
@@ -952,6 +952,8 @@ private:
 
 };
 
+const char *AIType2Str(AIType v);
+
 } // End of Namespace
 
 #endif // !HDB_AI_H


Commit: d973d258dd7909240f3b37500c1b5b99de929771
    https://github.com/scummvm/scummvm/commit/d973d258dd7909240f3b37500c1b5b99de929771
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:16:57+02:00

Commit Message:
HDB: Add debug output for font data

Changed paths:
    engines/hdb/draw-manager.cpp


diff --git a/engines/hdb/draw-manager.cpp b/engines/hdb/draw-manager.cpp
index bc297ee..474f071 100644
--- a/engines/hdb/draw-manager.cpp
+++ b/engines/hdb/draw-manager.cpp
@@ -438,6 +438,13 @@ bool DrawMan::loadFont(const char *string) {
 	_fontHeader.kerning = stream->readUint16LE();
 	_fontHeader.leading = stream->readUint16LE();
 
+	debug(3, "Loaded _fontHeader with following data");
+	debug(3, "type: %d", _fontHeader.type);
+	debug(3, "numChars: %d", _fontHeader.numChars);
+	debug(3, "height: %d", _fontHeader.height);
+	debug(3, "kerning: %d", _fontHeader.kerning);
+	debug(3, "leading: %d", _fontHeader.leading);
+
 	// Loading _charInfoBlocks & creating character surfaces
 	CharInfo *cInfo;
 	int startPos = stream->pos();	// Position after _fontHeader
@@ -447,6 +454,9 @@ bool DrawMan::loadFont(const char *string) {
 		cInfo = new CharInfo;
 		cInfo->width = stream->readUint16LE();
 		cInfo->offset = stream->readUint16LE();
+
+		debug(3, "Loaded _charInfoBlocks[%d]: width: %d, offset: %d", i, cInfo->width, cInfo->offset);
+
 		curPos = stream->pos();
 
 		_fontSurfaces[i].create(cInfo->width, _fontHeader.height, g_hdb->_format);


Commit: b7c5c2e8157e736e8e902c2f3f93aa3e0e7aae35
    https://github.com/scummvm/scummvm/commit/b7c5c2e8157e736e8e902c2f3f93aa3e0e7aae35
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:16:57+02:00

Commit Message:
HDB: Fix type and reading errors

Changed paths:
    engines/hdb/draw-manager.cpp
    engines/hdb/draw-manager.h


diff --git a/engines/hdb/draw-manager.cpp b/engines/hdb/draw-manager.cpp
index 474f071..368aa2d 100644
--- a/engines/hdb/draw-manager.cpp
+++ b/engines/hdb/draw-manager.cpp
@@ -432,11 +432,11 @@ bool DrawMan::loadFont(const char *string) {
 		return false;
 
 	// Loading _fontHeader
-	_fontHeader.type = stream->readUint16LE();
-	_fontHeader.numChars = stream->readUint16LE();
-	_fontHeader.height = stream->readUint16LE();
-	_fontHeader.kerning = stream->readUint16LE();
-	_fontHeader.leading = stream->readUint16LE();
+	_fontHeader.type = (int)stream->readUint32LE();
+	_fontHeader.numChars = (int)stream->readUint32LE();
+	_fontHeader.height = (int)stream->readUint32LE();
+	_fontHeader.kerning = (int)stream->readUint32LE();
+	_fontHeader.leading = (int)stream->readUint32LE();
 
 	debug(3, "Loaded _fontHeader with following data");
 	debug(3, "type: %d", _fontHeader.type);
@@ -452,8 +452,8 @@ bool DrawMan::loadFont(const char *string) {
 	uint16 *ptr;
 	for (int i = 0; i < _fontHeader.numChars;i++) {
 		cInfo = new CharInfo;
-		cInfo->width = stream->readUint16LE();
-		cInfo->offset = stream->readUint16LE();
+		cInfo->width = (int16)stream->readUint32LE();
+		cInfo->offset = (int32)stream->readUint32LE();
 
 		debug(3, "Loaded _charInfoBlocks[%d]: width: %d, offset: %d", i, cInfo->width, cInfo->offset);
 
@@ -464,9 +464,9 @@ bool DrawMan::loadFont(const char *string) {
 		// Go to character location
 		stream->seek(startPos+cInfo->offset);
 
-		for (uint y = 0; y < _fontHeader.height; y++) {
+		for (int y = 0; y < _fontHeader.height; y++) {
 			ptr = (uint16 *)_fontSurfaces[i].getBasePtr(0, y);
-			for (uint x = 0; x < cInfo->width; x++) {
+			for (int x = 0; x < cInfo->width; x++) {
 				*ptr = TO_LE_16(stream->readUint16LE());
 				ptr++;
 			}
diff --git a/engines/hdb/draw-manager.h b/engines/hdb/draw-manager.h
index f252ed2..e70b673 100644
--- a/engines/hdb/draw-manager.h
+++ b/engines/hdb/draw-manager.h
@@ -63,16 +63,16 @@ struct GfxCache {
 };
 
 struct FontInfo {
-	uint16		type;		// 0 = mono, 1 = proportional
-	uint16		numChars;	// how many characters in font
-	uint16		height;		// height of entire font
-	uint16		kerning;	// space between chars
-	uint16		leading;	// space between lines
+	int		type;		// 0 = mono, 1 = proportional
+	int		numChars;	// how many characters in font
+	int		height;		// height of entire font
+	int		kerning;	// space between chars
+	int		leading;	// space between lines
 };
 
 struct CharInfo {
-	uint16 width;	// Character width in pixels
-	uint32 offset;	// From the start of the font charInfo chunk
+	int16 width;	// Character width in pixels
+	int32 offset;	// From the start of the font charInfo chunk
 };
 
 class DrawMan {


Commit: 7389d7d819db53d7672701df29f751c9b0e1fa1b
    https://github.com/scummvm/scummvm/commit/7389d7d819db53d7672701df29f751c9b0e1fa1b
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:16:57+02:00

Commit Message:
HDB: Add openDialog() call to hdb.cpp

Changed paths:
    engines/hdb/hdb.cpp


diff --git a/engines/hdb/hdb.cpp b/engines/hdb/hdb.cpp
index 1f05b33..0b6eefb 100644
--- a/engines/hdb/hdb.cpp
+++ b/engines/hdb/hdb.cpp
@@ -271,6 +271,8 @@ Common::Error HDBGame::run() {
 	_map->load(mapStream);
 	_ai->initAnimInfo();
 
+	_window->openDialog("Title", 0, "String", 0, NULL);
+
 #if 0
 	lua->executeFile("test.lua");
 #endif


Commit: 87f8ed55b17b9ce2dbda339f7601b87a48ebd215
    https://github.com/scummvm/scummvm/commit/87f8ed55b17b9ce2dbda339f7601b87a48ebd215
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:16:58+02:00

Commit Message:
HDB: Fix character blitting

Changed paths:
    engines/hdb/draw-manager.cpp


diff --git a/engines/hdb/draw-manager.cpp b/engines/hdb/draw-manager.cpp
index 368aa2d..f4edcb7 100644
--- a/engines/hdb/draw-manager.cpp
+++ b/engines/hdb/draw-manager.cpp
@@ -517,7 +517,7 @@ void DrawMan::drawText(const char *string) {
 	}
 
 	// Draw the characters
-	for (int j = 0;j < (int)strlen(string);j++) {
+	for (int j = 0; j < (int)strlen(string);j++) {
 		c = string[j];
 		if (c == '\n' || cr[j]) {
 			_cursorX = _eLeft;
@@ -532,8 +532,8 @@ void DrawMan::drawText(const char *string) {
 			width = kFontSpace;
 
 		// Blit the character
-		g_hdb->_drawMan->_globalSurface.transBlitFrom(_fontSurfaces[c], Common::Point(_cursorX, _cursorY));
-		g_system->copyRectToScreen(g_hdb->_drawMan->_globalSurface.getBasePtr(0, 0), g_hdb->_drawMan->_globalSurface.pitch, 0, 0, width, _fontHeader.height);
+		g_hdb->_drawMan->_globalSurface.transBlitFrom(_fontSurfaces[c], Common::Point(_cursorX, _cursorY), 0xf81f);
+		g_system->copyRectToScreen(g_hdb->_drawMan->_globalSurface.getBasePtr(_cursorX, _cursorY), g_hdb->_drawMan->_globalSurface.pitch, _cursorX, _cursorY, width, _fontHeader.height);
 
 		// Advance the cursor
 		_cursorX += width + _fontHeader.kerning * kFontIncrement;


Commit: e625ce1ccd4f5013744c5a2809aab39401f910ae
    https://github.com/scummvm/scummvm/commit/e625ce1ccd4f5013744c5a2809aab39401f910ae
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:16:58+02:00

Commit Message:
JANITORIAL: Whitespace fixes

Changed paths:
    engines/hdb/window.cpp


diff --git a/engines/hdb/window.cpp b/engines/hdb/window.cpp
index 6070f75..5e4482b 100644
--- a/engines/hdb/window.cpp
+++ b/engines/hdb/window.cpp
@@ -143,13 +143,13 @@ void Window::drawDialog() {
 	if (!guyTalking) {
 		_gfxTitleL->drawMasked(_dialogInfo.x, _dialogInfo.y - 10);
 		blocks = _dialogInfo.titleWidth / 16;
-		for (int i = 0; i < blocks;i++)
+		for (int i = 0; i < blocks; i++)
 			_gfxTitleM->drawMasked(_dialogInfo.x + 16 * (i + 1), _dialogInfo.y - 10);
 		_gfxTitleR->drawMasked(_dialogInfo.x + (blocks + 1) * 16, _dialogInfo.y - 10);
 	} else {
 		_gGfxTitleL->drawMasked(_dialogInfo.x, _dialogInfo.y - 10);
 		blocks = _dialogInfo.titleWidth / 16;
-		for (int i = 0; i < blocks;i++)
+		for (int i = 0; i < blocks; i++)
 			_gGfxTitleM->drawMasked(_dialogInfo.x + 16 * (i + 1), _dialogInfo.y - 10);
 		_gGfxTitleR->drawMasked(_dialogInfo.x + (blocks + 1) * 16, _dialogInfo.y - 10);
 	}
@@ -203,8 +203,8 @@ void Window::drawBorder(int x, int y, int width, int height, bool guyTalking) {
 	if (!guyTalking) {
 		wide = (width / 16) + 1;
 		high = height / 16;
-		for(j = 0; j < high; j++)
-			for (i = 0;i < wide;i++) {
+		for (j = 0; j < high; j++)
+			for (i = 0; i < wide; i++) {
 				// Top Line
 				if (!i && !j)
 					_gfxTL->drawMasked(x, y);
@@ -234,7 +234,7 @@ void Window::drawBorder(int x, int y, int width, int height, bool guyTalking) {
 		wide = (width / 16) + 1;
 		high = height / 16;
 		for (j = 0; j < high; j++)
-			for (i = 0;i < wide;i++) {
+			for (i = 0; i < wide; i++) {
 				// Top Line
 				if (!i && !j)
 					_gGfxTL->drawMasked(x, y);


Commit: 8be8ef73df89c1b53b62cae3209b938b36125540
    https://github.com/scummvm/scummvm/commit/8be8ef73df89c1b53b62cae3209b938b36125540
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:16:58+02:00

Commit Message:
HDB: Add Infobar data

Changed paths:
    engines/hdb/window.cpp
    engines/hdb/window.h


diff --git a/engines/hdb/window.cpp b/engines/hdb/window.cpp
index 5e4482b..db24552 100644
--- a/engines/hdb/window.cpp
+++ b/engines/hdb/window.cpp
@@ -68,6 +68,12 @@ bool Window::init() {
 	_gfxInvSelect = g_hdb->_drawMan->loadPic("inventory_normal");
 	_gfxHandright = g_hdb->_drawMan->loadPic("menu_hand_pointright");
 
+	_gfxInfobar = g_hdb->_drawMan->loadPic("pic_infobar");
+	_gfxDarken = g_hdb->_drawMan->loadPic("screen_darken");
+	_gfxPausePlaque = g_hdb->_drawMan->loadPic("pause_plaque");
+
+	_infobarDimmed = 0;
+
 	restartSystem();
 
 	return true;
@@ -76,6 +82,7 @@ bool Window::init() {
 void Window::restartSystem() {
 	_dialogInfo.active = false;
 	_dialogDelay = 0;
+	_infobarDimmed = 0;
 }
 
 void Window::openDialog(const char *title, int tileIndex, const char *string, int more, const char *luaMore) {
diff --git a/engines/hdb/window.h b/engines/hdb/window.h
index 8a22b9d..a498ac3 100644
--- a/engines/hdb/window.h
+++ b/engines/hdb/window.h
@@ -83,8 +83,11 @@ private:
 	Picture *_gfxIndent, *_gfxArrowTo, *_gfxHandright;
 	Picture *_gfxTry, *_gfxAgain, *_gfxInvSelect;
 	Tile *_gfxMonkeystone;
-	Picture *_gfxLevelRestart, *_gfxPuasePlaque;
+	Picture *_gfxLevelRestart, *_gfxPausePlaque;
 
+	// Info Bar
+	Picture *_gfxInfobar, *_gfxDarken;
+	int _infobarDimmed;
 };
 
 } // End of Namespace


Commit: c0d9281b45ae1ebde5c1d0ad8173fb53af4bcbac
    https://github.com/scummvm/scummvm/commit/c0d9281b45ae1ebde5c1d0ad8173fb53af4bcbac
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:16:58+02:00

Commit Message:
HDB: Add setInfobarDark()

Changed paths:
    engines/hdb/window.cpp
    engines/hdb/window.h


diff --git a/engines/hdb/window.cpp b/engines/hdb/window.cpp
index db24552..a30289d 100644
--- a/engines/hdb/window.cpp
+++ b/engines/hdb/window.cpp
@@ -85,6 +85,10 @@ void Window::restartSystem() {
 	_infobarDimmed = 0;
 }
 
+void Window::setInfobarDark(int value) {
+	_infobarDimmed = value;
+}
+
 void Window::openDialog(const char *title, int tileIndex, const char *string, int more, const char *luaMore) {
 	if (_dialogInfo.active)
 		return;
diff --git a/engines/hdb/window.h b/engines/hdb/window.h
index a498ac3..f3b57c4 100644
--- a/engines/hdb/window.h
+++ b/engines/hdb/window.h
@@ -52,6 +52,7 @@ public:
 
 	bool init();
 	void restartSystem();
+	void setInfobarDark(int value);
 
 	// Dialog Functions
 


Commit: 0dcf1568ee7deeba1f5dbfad3e0f96f5a3d36af1
    https://github.com/scummvm/scummvm/commit/0dcf1568ee7deeba1f5dbfad3e0f96f5a3d36af1
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:16:58+02:00

Commit Message:
HDB: Add setInfobarDark() Lua function

Changed paths:
    engines/hdb/lua-script.cpp


diff --git a/engines/hdb/lua-script.cpp b/engines/hdb/lua-script.cpp
index 7ea1a2f..4986cd5 100644
--- a/engines/hdb/lua-script.cpp
+++ b/engines/hdb/lua-script.cpp
@@ -623,7 +623,14 @@ static int gotoMenu(lua_State *L) {
 }
 
 static int setInfobarDark(lua_State *L) {
-	warning("STUB: SET INFOBAR DARK");
+	double	value = lua_tonumber(L, 1);
+
+	g_hdb->_lua->checkParameters("setInfobarDark", 1);
+
+	lua_pop(L, 1);
+
+	g_hdb->_window->setInfobarDark((int)value);
+
 	return 0;
 }
 


Commit: f3bfdf42958f77a360e019cf54cd83d0f7f5d4d3
    https://github.com/scummvm/scummvm/commit/f3bfdf42958f77a360e019cf54cd83d0f7f5d4d3
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:16:58+02:00

Commit Message:
HDB: Fix dialog border drawing

Changed paths:
    engines/hdb/window.cpp


diff --git a/engines/hdb/window.cpp b/engines/hdb/window.cpp
index a30289d..95fc21f 100644
--- a/engines/hdb/window.cpp
+++ b/engines/hdb/window.cpp
@@ -223,23 +223,26 @@ void Window::drawBorder(int x, int y, int width, int height, bool guyTalking) {
 					_gfxTR->drawMasked(x + i * 16, y + j * 16);
 				else if (!j)
 					_gfxTM->draw(x + i * 16, y + j * 16);
-
-				// Bottom Lines
-				if ((j == high - 1) && !i)
-					_gfxBL->drawMasked(x + i * 16, y + j * 16);
-				else if ((j == high - 1) && (i == wide - 1))
-					_gfxBR->drawMasked(x + i * 16, y + j * 16);
-				else if ((j == high - 1) && i < wide)
-					_gfxBM->draw(x + i * 16, y + j * 16);
-
-				// Middle lines
-				if (!i && j < high)
-					_gfxL->draw(x + i * 16, y + j * 16);
-				else if ((i == wide - 1) && j < high)
-					_gfxR->draw(x + i * 16, y + j * 16);
-
-				// Most drawn = middle block
-				_gfxM->draw(x + i * 16, y + j * 16);
+				else {
+
+					// Bottom Lines
+					if ((j == high - 1) && !i)
+						_gfxBL->drawMasked(x + i * 16, y + j * 16);
+					else if ((j == high - 1) && (i == wide - 1))
+						_gfxBR->drawMasked(x + i * 16, y + j * 16);
+					else if ((j == high - 1) && i < wide)
+						_gfxBM->draw(x + i * 16, y + j * 16);
+					else {
+						// Middle lines
+						if (!i && j < high)
+							_gfxL->draw(x + i * 16, y + j * 16);
+						else if ((i == wide - 1) && j < high)
+							_gfxR->draw(x + i * 16, y + j * 16);
+						else
+							// Most drawn = middle block
+							_gfxM->draw(x + i * 16, y + j * 16);
+					}
+				}
 			}
 	} else {
 		wide = (width / 16) + 1;
@@ -253,23 +256,29 @@ void Window::drawBorder(int x, int y, int width, int height, bool guyTalking) {
 					_gGfxTR->drawMasked(x + i * 16, y + j * 16);
 				else if (!j)
 					_gGfxTM->draw(x + i * 16, y + j * 16);
-
-				// Bottom Lines
-				if ((j == high - 1) && !i)
-					_gGfxBL->drawMasked(x + i * 16, y + j * 16);
-				else if ((j == high - 1) && (i == wide - 1))
-					_gGfxBR->drawMasked(x + i * 16, y + j * 16);
-				else if ((j == high - 1) && i < wide)
-					_gGfxBM->draw(x + i * 16, y + j * 16);
-
-				// Middle lines
-				if (!i && j < high)
-					_gGfxL->draw(x + i * 16, y + j * 16);
-				else if ((i == wide - 1) && j < high)
-					_gGfxR->draw(x + i * 16, y + j * 16);
-
-				// Most drawn = middle block
-				_gGfxM->draw(x + i * 16, y + j * 16);
+				else {
+
+					// Bottom Lines
+					if ((j == high - 1) && !i)
+						_gGfxBL->drawMasked(x + i * 16, y + j * 16);
+					else if ((j == high - 1) && (i == wide - 1))
+						_gGfxBR->drawMasked(x + i * 16, y + j * 16);
+					else if ((j == high - 1) && i < wide)
+						_gGfxBM->draw(x + i * 16, y + j * 16);
+					else {
+
+						// Middle lines
+						if (!i && j < high)
+							_gGfxL->draw(x + i * 16, y + j * 16);
+						else if ((i == wide - 1) && j < high)
+							_gGfxR->draw(x + i * 16, y + j * 16);
+						else
+
+							// Most drawn = middle block
+							_gGfxM->draw(x + i * 16, y + j * 16);
+
+					}
+				}
 			}
 	}
 }


Commit: 727c0b81adcd9fc1812c48cc16a027356cb69235
    https://github.com/scummvm/scummvm/commit/727c0b81adcd9fc1812c48cc16a027356cb69235
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:16:58+02:00

Commit Message:
HDB: More debug output for entity drawing

Changed paths:
    engines/hdb/ai-funcs.cpp
    engines/hdb/ai-init.cpp
    engines/hdb/ai.h


diff --git a/engines/hdb/ai-funcs.cpp b/engines/hdb/ai-funcs.cpp
index a04af9a..cfbe166 100644
--- a/engines/hdb/ai-funcs.cpp
+++ b/engines/hdb/ai-funcs.cpp
@@ -1081,7 +1081,7 @@ void AI::animEntFrames(AIEntity *e) {
 		max = e->special1Frames;
 		break;
 	default:
-		warning("AI-FUNCS: animEntFrames: Unintended State");
+		warning("AI-FUNCS: animEntFrames: Unintended State for entity %s", AIType2Str(e->type));
 		break;
 	}
 
@@ -1130,7 +1130,7 @@ void AI::drawEnts(int x, int y, int w, int h) {
 
 	for (Common::Array<AIEntity *>::iterator it = _ents->begin(); it != _ents->end(); it++) {
 		AIEntity *e = (*it);
-		debugN(5, "AI::drawEnts: enity %s(%d)...", AIType2Str(e->type), e->type);
+		debugN(5, "AI::drawEnts: enity %s(%d) state %s(%d)...", AIType2Str(e->type), e->type, AIState2Str(e->state), e->state);
 
 		if (e->type == AI_LASER || e->type == AI_DIVERTER) {
 			if (e->aiDraw) {
diff --git a/engines/hdb/ai-init.cpp b/engines/hdb/ai-init.cpp
index 201c8fa..8f4ed86 100644
--- a/engines/hdb/ai-init.cpp
+++ b/engines/hdb/ai-init.cpp
@@ -1088,4 +1088,98 @@ const char *AIType2Str(AIType v) {
 	return AITypeStr[v];
 }
 
+const char *AIStateStr[] = {
+	"STATE_NONE",
+	"STATE_STANDDOWN",
+	"STATE_STANDUP",
+	"STATE_STANDLEFT",
+	"STATE_STANDRIGHT",
+	"STATE_BLINK",
+	"STATE_MOVEUP",
+	"STATE_MOVEDOWN",
+	"STATE_MOVELEFT",
+	"STATE_MOVERIGHT",
+	"STATE_DYING",
+	"STATE_DEAD",
+	"STATE_HORRIBLE1",
+	"STATE_HORRIBLE2",
+	"STATE_HORRIBLE3",
+	"STATE_HORRIBLE4",
+	"STATE_GOODJOB",
+	"STATE_PLUMMET",
+
+	"STATE_PUSHUP",
+	"STATE_PUSHDOWN",
+	"STATE_PUSHLEFT",
+	"STATE_PUSHRIGHT",
+	"STATE_GRABUP",
+	"STATE_GRABDOWN",
+	"STATE_GRABLEFT",
+	"STATE_GRABRIGHT",
+	"STATE_ATK_CLUB_UP",
+	"STATE_ATK_CLUB_DOWN",
+	"STATE_ATK_CLUB_LEFT",
+	"STATE_ATK_CLUB_RIGHT",
+	"STATE_ATK_STUN_DOWN",
+	"STATE_ATK_STUN_UP",
+	"STATE_ATK_STUN_LEFT",
+	"STATE_ATK_STUN_RIGHT",
+	"STATE_ATK_SLUG_DOWN",
+	"STATE_ATK_SLUG_UP",
+	"STATE_ATK_SLUG_LEFT",
+	"STATE_ATK_SLUG_RIGHT",
+
+	"STATE_FLOATING",
+	"STATE_FLOATDOWN",
+	"STATE_FLOATUP",
+	"STATE_FLOATLEFT",
+	"STATE_FLOATRIGHT",
+	"STATE_MELTED",
+	"STATE_SLIDING",
+	"STATE_SHOCKING",
+	"STATE_EXPLODING",
+
+	"STATE_USEDOWN",
+	"STATE_USEUP",
+	"STATE_USELEFT",
+	"STATE_USERIGHT",
+
+	"STATE_MEER_MOVE",
+	"STATE_MEER_APPEAR",
+	"STATE_MEER_BITE",
+	"STATE_MEER_DISAPPEAR",
+	"STATE_MEER_LOOK",
+
+	"STATE_ICEP_PEEK",
+	"STATE_ICEP_APPEAR",
+	"STATE_ICEP_THROWDOWN",
+	"STATE_ICEP_THROWRIGHT",
+	"STATE_ICEP_THROWLEFT",
+	"STATE_ICEP_DISAPPEAR",
+
+	"STATE_LICKDOWN",
+	"STATE_LICKLEFT",
+	"STATE_LICKRIGHT",
+
+	"STATE_DIVERTER_BL",
+	"STATE_DIVERTER_BR",
+	"STATE_DIVERTER_TL",
+	"STATE_DIVERTER_TR",
+
+	"STATE_KISSRIGHT",
+	"STATE_KISSLEFT",
+	"STATE_ANGRY",
+	"STATE_PANIC",
+	"STATE_LAUGH",
+	"STATE_DOLLYUSERIGHT",
+
+	"STATE_YELL",
+
+	"STATE_ENDSTATES"
+};
+
+const char *AIState2Str(AIState v) {
+	return AIStateStr[v];
+}
+
 } // End of Namespace
diff --git a/engines/hdb/ai.h b/engines/hdb/ai.h
index db0869f..03d0b5e 100644
--- a/engines/hdb/ai.h
+++ b/engines/hdb/ai.h
@@ -953,6 +953,7 @@ private:
 };
 
 const char *AIType2Str(AIType v);
+const char *AIState2Str(AIState v);
 
 } // End of Namespace
 


Commit: 9671f336cfe4c581770143af6585983b53d96e77
    https://github.com/scummvm/scummvm/commit/9671f336cfe4c581770143af6585983b53d96e77
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:16:58+02:00

Commit Message:
HDB: Fix drawing function calls

Changed paths:
    engines/hdb/window.cpp


diff --git a/engines/hdb/window.cpp b/engines/hdb/window.cpp
index 95fc21f..d7221fc 100644
--- a/engines/hdb/window.cpp
+++ b/engines/hdb/window.cpp
@@ -222,7 +222,7 @@ void Window::drawBorder(int x, int y, int width, int height, bool guyTalking) {
 				else if ((i == wide - 1) && !j)
 					_gfxTR->drawMasked(x + i * 16, y + j * 16);
 				else if (!j)
-					_gfxTM->draw(x + i * 16, y + j * 16);
+					_gfxTM->drawMasked(x + i * 16, y + j * 16);
 				else {
 
 					// Bottom Lines
@@ -231,16 +231,16 @@ void Window::drawBorder(int x, int y, int width, int height, bool guyTalking) {
 					else if ((j == high - 1) && (i == wide - 1))
 						_gfxBR->drawMasked(x + i * 16, y + j * 16);
 					else if ((j == high - 1) && i < wide)
-						_gfxBM->draw(x + i * 16, y + j * 16);
+						_gfxBM->drawMasked(x + i * 16, y + j * 16);
 					else {
 						// Middle lines
 						if (!i && j < high)
-							_gfxL->draw(x + i * 16, y + j * 16);
+							_gfxL->drawMasked(x + i * 16, y + j * 16);
 						else if ((i == wide - 1) && j < high)
-							_gfxR->draw(x + i * 16, y + j * 16);
+							_gfxR->drawMasked(x + i * 16, y + j * 16);
 						else
 							// Most drawn = middle block
-							_gfxM->draw(x + i * 16, y + j * 16);
+							_gfxM->drawMasked(x + i * 16, y + j * 16);
 					}
 				}
 			}


Commit: 8419b988556905d912133286fb85b43fcf0bf4d5
    https://github.com/scummvm/scummvm/commit/8419b988556905d912133286fb85b43fcf0bf4d5
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:16:58+02:00

Commit Message:
HDB: Add picture debugging code

Changed paths:
    engines/hdb/draw-manager.h
    engines/hdb/window.cpp


diff --git a/engines/hdb/draw-manager.h b/engines/hdb/draw-manager.h
index e70b673..3b908e7 100644
--- a/engines/hdb/draw-manager.h
+++ b/engines/hdb/draw-manager.h
@@ -186,9 +186,10 @@ public:
 	void draw(int x, int y);
 	void drawMasked(int x, int y);
 
+	uint _width, _height;
+
 private:
 
-	uint _width, _height;
 	char _name[64];
 
 	Graphics::ManagedSurface _surface;
diff --git a/engines/hdb/window.cpp b/engines/hdb/window.cpp
index d7221fc..d2dc204 100644
--- a/engines/hdb/window.cpp
+++ b/engines/hdb/window.cpp
@@ -137,6 +137,20 @@ void Window::openDialog(const char *title, int tileIndex, const char *string, in
 
 void Window::drawDialog() {
 
+#if 0
+	_gfxTL->drawMasked(0, 0);
+	_gfxTM->drawMasked(_gfxTL->_width, 0);
+	_gfxTR->drawMasked(_gfxTL->_width + _gfxTM->_width, 0);
+
+	_gfxL->drawMasked(0, _gfxTL->_height);
+	_gfxM->drawMasked(_gfxL->_width, _gfxTL->_height);
+	_gfxR->drawMasked(_gfxL->_width + _gfxM->_width, _gfxTL->_height);
+
+	_gfxBL->drawMasked(0, _gfxTL->_height + _gfxL->_height);
+	_gfxBM->drawMasked(_gfxBL->_width, _gfxTL->_height + _gfxL->_height);
+	_gfxBR->drawMasked(_gfxBL->_width + _gfxBM->_width, _gfxTL->_height + _gfxL->_height);
+#endif
+
 	if (g_hdb->getActionMode())
 		warning("STUB: drawDialog: Draw Player Weapon");
 


Commit: 7d4cc693b4df7e33f8afc5d068fc1afa79e27c0c
    https://github.com/scummvm/scummvm/commit/7d4cc693b4df7e33f8afc5d068fc1afa79e27c0c
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:16:58+02:00

Commit Message:
HDB: Add _cineBlitList and _cineFreeList

Addition includes related data such as constants
and structs

Changed paths:
    engines/hdb/ai-cinematic.cpp
    engines/hdb/ai.h


diff --git a/engines/hdb/ai-cinematic.cpp b/engines/hdb/ai-cinematic.cpp
index 5a4bebb..0529fe9 100644
--- a/engines/hdb/ai-cinematic.cpp
+++ b/engines/hdb/ai-cinematic.cpp
@@ -292,6 +292,8 @@ void AI::cineStart(bool abortable, const char *abortFunc) {
 	_cineAbortable = abortable;
 	_cineAborted = false;
 	_cineAbortFunc = abortFunc;
+	_numCineBlitList = 0;
+	_numCineFreeList = 0;
 	_cineActive = true;
 	_playerLock = false;
 	_cameraLock = false;
diff --git a/engines/hdb/ai.h b/engines/hdb/ai.h
index 03d0b5e..ca3a3da 100644
--- a/engines/hdb/ai.h
+++ b/engines/hdb/ai.h
@@ -39,7 +39,8 @@ enum {
 	kMaxAutoActions = 30,
 	kPlayerMoveSpeed = 4,
 	kEnemyMoveSpeed = 2,
-	kPushMoveSpeed = (kPlayerMoveSpeed >> 1)
+	kPushMoveSpeed = (kPlayerMoveSpeed >> 1),
+	kMaxCineGfx = 10
 };
 
 enum AIType {
@@ -596,7 +597,17 @@ struct CineCommand {
 	AIEntity *e;
 
 	CineCommand() : cmdType(C_NO_COMMAND), x(0.0), y(0.0), x2(0.0), y2(0.0), xv(0.0), yv(0.0),
-				start(0), end(0), delay(0), speed(0), title(""), string(""), id(NULL), e(NULL) {}
+				start(0), end(0), delay(0), speed(0), title(""), string(""), id(NULL), e(NULL), pic(NULL) {}
+};
+
+struct CineBlit {
+	double x, y;
+	Picture *pic;
+	const char *name;
+	const char *id;
+	bool masked;
+
+	CineBlit() : x(0), y(0), pic(NULL), name(""), id(""), masked(false) {}
 };
 
 #define onEvenTile(x, y)	( !(x & 31) && !(y & 31) )
@@ -909,6 +920,12 @@ public:
 	// Cinematic Variables
 	Common::Array<CineCommand *> _cine;
 
+	Picture *_cineFreeList[kMaxCineGfx];
+	int _numCineFreeList;
+
+	CineBlit *_cineBlitList[kMaxCineGfx];
+	int _numCineBlitList;
+
 private:
 
 	// Action Functions


Commit: 667641ed5740323b7b7edf48f724c87e98f45027
    https://github.com/scummvm/scummvm/commit/667641ed5740323b7b7edf48f724c87e98f45027
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:16:58+02:00

Commit Message:
HDB: Add _cineBlitList functions

Changed paths:
    engines/hdb/ai-cinematic.cpp
    engines/hdb/ai.h


diff --git a/engines/hdb/ai-cinematic.cpp b/engines/hdb/ai-cinematic.cpp
index 0529fe9..4f30b9d 100644
--- a/engines/hdb/ai-cinematic.cpp
+++ b/engines/hdb/ai-cinematic.cpp
@@ -288,6 +288,36 @@ void AI::processCines() {
 	}
 }
 
+void AI::cineAddToBlitList(const char *id, Picture *pic, int x, int y, bool masked) {
+	_cineBlitList[_numCineBlitList] = new CineBlit;
+	_cineBlitList[_numCineBlitList]->id = id;
+	_cineBlitList[_numCineBlitList]->pic = pic;
+	_cineBlitList[_numCineBlitList]->x = x;
+	_cineBlitList[_numCineBlitList]->y = y;
+	_cineBlitList[_numCineBlitList]->masked = masked;
+	_numCineBlitList++;
+}
+
+Picture *AI::cineFindInBlitList(const char *name) {
+	for (int i = 0; i < _numCineBlitList;i++) {
+		if (Common::matchString(_cineBlitList[i]->id, name))
+			return _cineBlitList[i]->pic;
+	}
+	return NULL;
+}
+
+void AI::cineRemoveFromBlitList(const char *name) {
+	for (int i = 0; i < _numCineBlitList;i++) {
+		if (Common::matchString(_cineBlitList[i]->id, name))
+			delete _cineBlitList[i];
+			for (; i < _numCineBlitList - 1; i++)
+				_cineBlitList[i] = _cineBlitList[i + 1];
+			_numCineBlitList--;
+			_cineBlitList[_numCineBlitList] = NULL;
+			return;
+	}
+}
+
 void AI::cineStart(bool abortable, const char *abortFunc) {
 	_cineAbortable = abortable;
 	_cineAborted = false;
diff --git a/engines/hdb/ai.h b/engines/hdb/ai.h
index ca3a3da..f56cc62 100644
--- a/engines/hdb/ai.h
+++ b/engines/hdb/ai.h
@@ -725,6 +725,9 @@ public:
 		return _cineActive;
 	}
 	void processCines();
+	void cineAddToBlitList(const char *id, Picture *pic, int x, int y, bool masked);
+	Picture *cineFindInBlitList(const char *name);
+	void cineRemoveFromBlitList(const char *name);
 	void cineStart(bool abortable, const char *abortFunc);
 	void cineLockPlayer();
 	void cineUnlockPlayer();


Commit: d41983e83726ed2e5fd1dc1a683909777e27e113
    https://github.com/scummvm/scummvm/commit/d41983e83726ed2e5fd1dc1a683909777e27e113
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:16:58+02:00

Commit Message:
HDB: Add _cineFreeList functions

Changed paths:
    engines/hdb/ai-cinematic.cpp
    engines/hdb/ai.h


diff --git a/engines/hdb/ai-cinematic.cpp b/engines/hdb/ai-cinematic.cpp
index 4f30b9d..053ba3c 100644
--- a/engines/hdb/ai-cinematic.cpp
+++ b/engines/hdb/ai-cinematic.cpp
@@ -318,6 +318,22 @@ void AI::cineRemoveFromBlitList(const char *name) {
 	}
 }
 
+void AI::cineAddToFreeList(Picture *pic) {
+	if (_numCineFreeList >= kMaxCineGfx) {
+		warning("cineAddToFreeList: Too many gfx in Cinematic!");
+		return;
+	}
+	_cineFreeList[_numCineFreeList] = pic;
+	_numCineFreeList++;
+}
+
+void AI::cineFreeGfx() {
+	for (int i = 0;i < _numCineFreeList;i++) {
+		delete _cineFreeList[i];
+	}
+	_numCineFreeList = 0;
+}
+
 void AI::cineStart(bool abortable, const char *abortFunc) {
 	_cineAbortable = abortable;
 	_cineAborted = false;
diff --git a/engines/hdb/ai.h b/engines/hdb/ai.h
index f56cc62..072199d 100644
--- a/engines/hdb/ai.h
+++ b/engines/hdb/ai.h
@@ -728,6 +728,8 @@ public:
 	void cineAddToBlitList(const char *id, Picture *pic, int x, int y, bool masked);
 	Picture *cineFindInBlitList(const char *name);
 	void cineRemoveFromBlitList(const char *name);
+	void cineAddToFreeList(Picture *pic);
+	void cineFreeGfx();
 	void cineStart(bool abortable, const char *abortFunc);
 	void cineLockPlayer();
 	void cineUnlockPlayer();


Commit: b3b5ef0b562060975e5a8e71eb4b1b7e538347fe
    https://github.com/scummvm/scummvm/commit/b3b5ef0b562060975e5a8e71eb4b1b7e538347fe
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:16:58+02:00

Commit Message:
HDB: Add cineAbort() and cineCleanUp()

Changed paths:
    engines/hdb/ai-cinematic.cpp
    engines/hdb/ai.h


diff --git a/engines/hdb/ai-cinematic.cpp b/engines/hdb/ai-cinematic.cpp
index 053ba3c..c7a4841 100644
--- a/engines/hdb/ai-cinematic.cpp
+++ b/engines/hdb/ai-cinematic.cpp
@@ -288,6 +288,36 @@ void AI::processCines() {
 	}
 }
 
+void AI::cineCleanup() {
+	cineFreeGfx();
+	_cineActive = false;
+	// If aborted and abort function specified, call it
+	if (_cineAborted && _cineAbortFunc)
+		g_hdb->_lua->callFunction(_cineAbortFunc, 0);
+
+	_cameraLock = false;
+	_playerLock = false;
+	g_hdb->_window->setInfobarDark(0);
+	warning("STUB: DrawMan:: Set Pointer State");
+
+	int px, py;
+	getPlayerXY(&px, &py);
+	g_hdb->_map->centerMapXY(px + 16, py + 16);
+}
+
+void AI::cineAbort() {
+	for (Common::Array<CineCommand *>::iterator it = _cine.begin(); it != _cine.end(); it++) {
+		if ((*it)->cmdType == C_STARTMAP || (*it)->cmdType == C_STOPCINE)
+			_cine[0] = *it;
+		if (it != _cine.begin())
+			_cine.erase(it);
+	}
+	warning("STUB: Window: closeAll() required");
+	if (_player)
+		stopEntity(_player);
+	_cineAborted = true;
+}
+
 void AI::cineAddToBlitList(const char *id, Picture *pic, int x, int y, bool masked) {
 	_cineBlitList[_numCineBlitList] = new CineBlit;
 	_cineBlitList[_numCineBlitList]->id = id;
diff --git a/engines/hdb/ai.h b/engines/hdb/ai.h
index 072199d..17e4241 100644
--- a/engines/hdb/ai.h
+++ b/engines/hdb/ai.h
@@ -725,6 +725,8 @@ public:
 		return _cineActive;
 	}
 	void processCines();
+	void cineCleanup();
+	void cineAbort();
 	void cineAddToBlitList(const char *id, Picture *pic, int x, int y, bool masked);
 	Picture *cineFindInBlitList(const char *name);
 	void cineRemoveFromBlitList(const char *name);


Commit: d5778951b54c97406d31521ced24d506a1e363d4
    https://github.com/scummvm/scummvm/commit/d5778951b54c97406d31521ced24d506a1e363d4
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:16:58+02:00

Commit Message:
HDB: Add cineMoveMaskedPic()

Changed paths:
    engines/hdb/ai-cinematic.cpp
    engines/hdb/ai.h


diff --git a/engines/hdb/ai-cinematic.cpp b/engines/hdb/ai-cinematic.cpp
index c7a4841..cc66e08 100644
--- a/engines/hdb/ai-cinematic.cpp
+++ b/engines/hdb/ai-cinematic.cpp
@@ -469,6 +469,27 @@ void AI::cineDialog(const char *title, const char *string, int seconds) {
 	_cine.push_back(cmd);
 }
 
+void AI::cineMoveMaskedPic(const char *id, const char *pic, int x1, int y1, int x2, int y2, int speed) {
+	if (!pic || !id) {
+		warning("cineMoveMaskedPic: Missing ID or PIC");
+		return;
+	}
+
+	CineCommand *cmd = new CineCommand;
+	cmd->x = x1;
+	cmd->y = y1;
+	cmd->x2 = x2;
+	cmd->y2 = y2;
+	cmd->speed = speed;
+	cmd->xv = ((double)(x2-x1)) / (double)speed;
+	cmd->yv = ((double)(y2-y1)) / (double)speed;
+	cmd->start = 0;
+	strcpy(cmd->string, pic);
+	strcpy(cmd->id, id);
+	cmd->cmdType = C_MOVEMASKEDPIC;
+	_cine.push_back(cmd);
+}
+
 void AI::cineUse(const char *entName) {
 	CineCommand *cmd = new CineCommand;
 	strcpy(cmd->string, entName);
diff --git a/engines/hdb/ai.h b/engines/hdb/ai.h
index 17e4241..2e0a705 100644
--- a/engines/hdb/ai.h
+++ b/engines/hdb/ai.h
@@ -744,6 +744,7 @@ public:
 	void cineMoveEntity(const char *entName, int x, int y, int level, int speed);
 	void cineEntityFace(const char *luaName, double dir);
 	void cineDialog(const char *title, const char *string, int seconds);
+	void cineMoveMaskedPic(const char *id, const char *pic, int x1, int y1, int x2, int y2, int speed);
 	void cineUse(const char *entName);
 	void cineFadeIn(bool isBlack, int steps);
 	void cineFadeOut(bool isBlack, int steps);


Commit: e896fa8470bd1d35c7b3e1b29dd810c4afe1b641
    https://github.com/scummvm/scummvm/commit/e896fa8470bd1d35c7b3e1b29dd810c4afe1b641
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:16:58+02:00

Commit Message:
HDB: Process cineMoveMaskedPic()

Changed paths:
    engines/hdb/ai-cinematic.cpp
    engines/hdb/ai.h


diff --git a/engines/hdb/ai-cinematic.cpp b/engines/hdb/ai-cinematic.cpp
index cc66e08..8251abc 100644
--- a/engines/hdb/ai-cinematic.cpp
+++ b/engines/hdb/ai-cinematic.cpp
@@ -220,6 +220,25 @@ void AI::processCines() {
 					complete = true;
 			}
 			break;
+		case C_MOVEMASKEDPIC:
+			if (!_cine[i]->start) {
+				Picture *pic = cineFindInBlitList(_cine[i]->id);
+				if (!pic) {
+					pic = g_hdb->_drawMan->loadPic(_cine[i]->string);
+					cineAddToFreeList(pic);
+				} else
+					cineRemoveFromBlitList(_cine[i]->id);
+				_cine[i]->pic = pic;
+				_cine[i]->start = 1;
+			}
+
+			cineRemoveFromBlitList(_cine[i]->id);
+			_cine[i]->x += _cine[i]->xv;
+			_cine[i]->y += _cine[i]->yv;
+			cineAddToBlitList(_cine[i]->id, _cine[i]->pic, (int)_cine[i]->x, (int)_cine[i]->y, true);
+			if (abs((int)(_cine[i]->x - _cine[i]->x2)) <= 1 && abs((int)(_cine[i]->y - _cine[i]->y2)) <= 1)
+				complete = true;
+			break;
 		case C_USEENTITY:
 			for (Common::Array<AIEntity *>::iterator it = _ents->begin(); it != _ents->end(); it++) {
 				if ((*it)->entityName && Common::matchString((*it)->entityName, _cine[i]->string)) {
diff --git a/engines/hdb/ai.h b/engines/hdb/ai.h
index 2e0a705..1f6a7bc 100644
--- a/engines/hdb/ai.h
+++ b/engines/hdb/ai.h
@@ -595,6 +595,7 @@ struct CineCommand {
 	char string[32];
 	char *id;
 	AIEntity *e;
+	Picture *pic;
 
 	CineCommand() : cmdType(C_NO_COMMAND), x(0.0), y(0.0), x2(0.0), y2(0.0), xv(0.0), yv(0.0),
 				start(0), end(0), delay(0), speed(0), title(""), string(""), id(NULL), e(NULL), pic(NULL) {}


Commit: a2af042430112a22963c6fdace53d2dc11ef6f94
    https://github.com/scummvm/scummvm/commit/a2af042430112a22963c6fdace53d2dc11ef6f94
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:16:58+02:00

Commit Message:
HDB: Add cineMoveMaskedPic() Lua function

Changed paths:
    engines/hdb/lua-script.cpp
    engines/hdb/lua-script.h


diff --git a/engines/hdb/lua-script.cpp b/engines/hdb/lua-script.cpp
index 4986cd5..9a67f4b 100644
--- a/engines/hdb/lua-script.cpp
+++ b/engines/hdb/lua-script.cpp
@@ -285,7 +285,25 @@ static int cineMovePic(lua_State *L) {
 }
 
 static int cineMoveMaskedPic(lua_State *L) {
-	warning("STUB: CINE MOVE MASKED PIC");
+	const char *id = lua_tostring(L, 1);
+	const char *pic = lua_tostring(L, 2);
+	double	x1 = lua_tonumber(L, 3);
+	double	y1 = lua_tonumber(L, 4);
+	double	x2 = lua_tonumber(L, 5);
+	double	y2 = lua_tonumber(L, 6);
+	double	speed = lua_tonumber(L, 7);
+
+	g_hdb->_lua->checkParameters("cineMoveMaskedPic", 7);
+
+	x1 += kCameraXOff;
+	y1 += kCameraYOff;
+	x2 += kCameraXOff;
+	y2 += kCameraYOff;
+
+	lua_pop(L, 7);
+
+	g_hdb->_ai->cineMoveMaskedPic(id, pic, (int)x1, (int)y1, (int)x2, (int)y2, (int)speed);
+
 	return 0;
 }
 
diff --git a/engines/hdb/lua-script.h b/engines/hdb/lua-script.h
index 32830b3..32eb419 100644
--- a/engines/hdb/lua-script.h
+++ b/engines/hdb/lua-script.h
@@ -32,6 +32,11 @@ struct lua_State;
 
 namespace HDB {
 
+enum {
+	kCameraXOff = (32 * 3 + 24),	// 3.75 Tiles Extra
+	kCameraYOff = (32 * 2 + 16)		// 2.50 Tiles Extra
+};
+
 class LuaScript {
 public:
 	LuaScript();


Commit: 2a047176178228b609b9670410cb9ec929f68df2
    https://github.com/scummvm/scummvm/commit/2a047176178228b609b9670410cb9ec929f68df2
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:16:58+02:00

Commit Message:
HDB: Remove checkDialogsClose() stub

Changed paths:
    engines/hdb/ai-cinematic.cpp


diff --git a/engines/hdb/ai-cinematic.cpp b/engines/hdb/ai-cinematic.cpp
index 8251abc..a171997 100644
--- a/engines/hdb/ai-cinematic.cpp
+++ b/engines/hdb/ai-cinematic.cpp
@@ -72,9 +72,10 @@ void AI::processCines() {
 
 	bailOut = complete = false;
 
-	// TODO: Make sure Dialogs are timing out
 
 	// TODO: Make sure Cine Pics are drawing
+	// Make sure Dialogs are timing out
+	g_hdb->_window->checkDialogClose(0, 0);
 
 	// TODO: Check for Game Pause
 


Commit: 8e099fdc2d526a37c543db366ebb626017b64237
    https://github.com/scummvm/scummvm/commit/8e099fdc2d526a37c543db366ebb626017b64237
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:16:58+02:00

Commit Message:
HDB: Remove stub for _cineBlitList drawing

Changed paths:
    engines/hdb/ai-cinematic.cpp


diff --git a/engines/hdb/ai-cinematic.cpp b/engines/hdb/ai-cinematic.cpp
index a171997..4af3d9a 100644
--- a/engines/hdb/ai-cinematic.cpp
+++ b/engines/hdb/ai-cinematic.cpp
@@ -72,11 +72,17 @@ void AI::processCines() {
 
 	bailOut = complete = false;
 
-
-	// TODO: Make sure Cine Pics are drawing
 	// Make sure Dialogs are timing out
 	g_hdb->_window->checkDialogClose(0, 0);
 
+	// Make sure Cine Pics are drawing
+	for (int i = 0;i < _numCineBlitList;i++) {
+		if (_cineBlitList[i]->masked = false)
+			_cineBlitList[i]->pic->draw(_cine[i]->x, _cine[i]->y);
+		else
+			_cineBlitList[i]->pic->drawMasked(_cine[i]->x, _cine[i]->y);
+	}
+
 	// TODO: Check for Game Pause
 
 	for (uint i = 0; i < _cine.size();i++) {


Commit: 043cd2e129b1b183f70410368190d19986e72ac9
    https://github.com/scummvm/scummvm/commit/043cd2e129b1b183f70410368190d19986e72ac9
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:16:58+02:00

Commit Message:
HDB: Remove addToActionList() stub

Changed paths:
    engines/hdb/map-loader.cpp


diff --git a/engines/hdb/map-loader.cpp b/engines/hdb/map-loader.cpp
index 17da352..053ef6e 100644
--- a/engines/hdb/map-loader.cpp
+++ b/engines/hdb/map-loader.cpp
@@ -474,7 +474,13 @@ bool Map::load(Common::SeekableReadStream *stream) {
 		case INFO_ACTION18:
 		case INFO_ACTION19:
 		case INFO_ACTION20:
-			warning("STUB: Map::load: AddToActionList required");
+			g_hdb->_ai->addToActionList(
+				aiInfo[_iconList[i].icon].type - INFO_ACTION1,
+				_iconList[i].x,
+				_iconList[i].y,
+				_iconList[i].funcInit,
+				_iconList[i].funcUse
+			);
 			break;
 		case INFO_ACTION_AUTO:
 			warning("STUB: Map::load: AddToAutoList required");


Commit: 680b8ce8462623e05019b508cff7430edb34ad28
    https://github.com/scummvm/scummvm/commit/680b8ce8462623e05019b508cff7430edb34ad28
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:16:58+02:00

Commit Message:
HDB: Remove addToAutoActionList() stub

Changed paths:
    engines/hdb/map-loader.cpp


diff --git a/engines/hdb/map-loader.cpp b/engines/hdb/map-loader.cpp
index 053ef6e..182e761 100644
--- a/engines/hdb/map-loader.cpp
+++ b/engines/hdb/map-loader.cpp
@@ -483,7 +483,12 @@ bool Map::load(Common::SeekableReadStream *stream) {
 			);
 			break;
 		case INFO_ACTION_AUTO:
-			warning("STUB: Map::load: AddToAutoList required");
+			g_hdb->_ai->addToAutoList(
+				_iconList[i].x,
+				_iconList[i].y,
+				_iconList[i].funcInit,
+				_iconList[i].funcUse
+			);
 			break;
 
 		case INFO_TELEPORTER1:


Commit: d3d0ceee4135bd446d378dd0aa0b3cba5a5c1026
    https://github.com/scummvm/scummvm/commit/d3d0ceee4135bd446d378dd0aa0b3cba5a5c1026
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:16:58+02:00

Commit Message:
HDB: Add cineStop()

Changed paths:
    engines/hdb/ai-cinematic.cpp
    engines/hdb/ai.h


diff --git a/engines/hdb/ai-cinematic.cpp b/engines/hdb/ai-cinematic.cpp
index 4af3d9a..6897cff 100644
--- a/engines/hdb/ai-cinematic.cpp
+++ b/engines/hdb/ai-cinematic.cpp
@@ -401,6 +401,13 @@ void AI::cineStart(bool abortable, const char *abortFunc) {
 	_cameraLock = false;
 }
 
+void AI::cineStop(const char *funcNext) {
+	CineCommand *cmd = new CineCommand;
+	cmd->cmdType = C_STOPCINE;
+	strcpy(cmd->title, funcNext);
+	_cine.push_back(cmd);
+}
+
 void AI::cineLockPlayer() {
 	CineCommand *cmd = new CineCommand;
 	cmd->cmdType = C_LOCKPLAYER;
diff --git a/engines/hdb/ai.h b/engines/hdb/ai.h
index 1f6a7bc..82849a9 100644
--- a/engines/hdb/ai.h
+++ b/engines/hdb/ai.h
@@ -734,6 +734,7 @@ public:
 	void cineAddToFreeList(Picture *pic);
 	void cineFreeGfx();
 	void cineStart(bool abortable, const char *abortFunc);
+	void cineStop(const char *funcNext);
 	void cineLockPlayer();
 	void cineUnlockPlayer();
 	void cineSetCamera(int x, int y);


Commit: e46e8b45d897738f03a8455ba93ae9b78d46d8cc
    https://github.com/scummvm/scummvm/commit/e46e8b45d897738f03a8455ba93ae9b78d46d8cc
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:16:58+02:00

Commit Message:
HDB: Process stopCine()

Changed paths:
    engines/hdb/ai-cinematic.cpp


diff --git a/engines/hdb/ai-cinematic.cpp b/engines/hdb/ai-cinematic.cpp
index 6897cff..9d55df2 100644
--- a/engines/hdb/ai-cinematic.cpp
+++ b/engines/hdb/ai-cinematic.cpp
@@ -90,6 +90,17 @@ void AI::processCines() {
 				g_system->getMillis(), _cine[i]->start, _cine[i]->delay);
 
 		switch (_cine[i]->cmdType) {
+		case C_STOPCINE:
+			char func[64];
+			memset(func, 0, 64);
+
+			if (_cine[i]->title)
+				strcpy(func, _cine[i]->title);
+
+			cineCleanup();
+			if (func[0])
+				g_hdb->_lua->callFunction(func, 0);
+			break;
 		case C_LOCKPLAYER:
 			_playerLock = true;
 			complete = true;


Commit: d7cc3ab225873be825b01bb97be455244c5e020e
    https://github.com/scummvm/scummvm/commit/d7cc3ab225873be825b01bb97be455244c5e020e
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:16:58+02:00

Commit Message:
HDB: Add cineStop() Lua function

Changed paths:
    engines/hdb/ai-cinematic.cpp
    engines/hdb/lua-script.cpp


diff --git a/engines/hdb/ai-cinematic.cpp b/engines/hdb/ai-cinematic.cpp
index 9d55df2..a09eeb4 100644
--- a/engines/hdb/ai-cinematic.cpp
+++ b/engines/hdb/ai-cinematic.cpp
@@ -415,7 +415,8 @@ void AI::cineStart(bool abortable, const char *abortFunc) {
 void AI::cineStop(const char *funcNext) {
 	CineCommand *cmd = new CineCommand;
 	cmd->cmdType = C_STOPCINE;
-	strcpy(cmd->title, funcNext);
+	if (funcNext)
+		strcpy(cmd->title, funcNext);
 	_cine.push_back(cmd);
 }
 
diff --git a/engines/hdb/lua-script.cpp b/engines/hdb/lua-script.cpp
index 9a67f4b..b2eeb4d 100644
--- a/engines/hdb/lua-script.cpp
+++ b/engines/hdb/lua-script.cpp
@@ -82,7 +82,15 @@ static int cineStart(lua_State *L) {
 }
 
 static int cineStop(lua_State *L) {
-	warning("STUB: STOP CINE");
+	const char *funcNext = NULL;
+
+	int stackTop = lua_gettop(L);
+	if (stackTop) {
+		funcNext = lua_tostring(L, 1);
+		lua_pop(L, 1);
+	}
+
+	g_hdb->_ai->cineStop(funcNext);
 	return 0;
 }
 


Commit: 812878661af5aa502555c1e87e90c09dfafe5928
    https://github.com/scummvm/scummvm/commit/812878661af5aa502555c1e87e90c09dfafe5928
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:16:58+02:00

Commit Message:
HDB: Add cineAnimEntity()

Changed paths:
    engines/hdb/ai-cinematic.cpp
    engines/hdb/ai.h


diff --git a/engines/hdb/ai-cinematic.cpp b/engines/hdb/ai-cinematic.cpp
index a09eeb4..dd1f1e6 100644
--- a/engines/hdb/ai-cinematic.cpp
+++ b/engines/hdb/ai-cinematic.cpp
@@ -493,6 +493,16 @@ void AI::cineMoveEntity(const char *entName, int x, int y, int level, int speed)
 	_cine.push_back(cmd);
 }
 
+void AI::cineAnimEntity(const char *entName, AIState state, int loop) {
+	CineCommand *cmd = new CineCommand;
+	cmd->start = 0;
+	strcpy(cmd->title, entName);
+	cmd->speed = state;
+	cmd->end = loop;
+	cmd->cmdType = C_ANIMENTITY;
+	_cine.push_back(cmd);
+}
+
 void AI::cineEntityFace(const char *luaName, double dir) {
 	CineCommand *cmd = new CineCommand;
 	strcpy(cmd->title, luaName);
diff --git a/engines/hdb/ai.h b/engines/hdb/ai.h
index 82849a9..6269697 100644
--- a/engines/hdb/ai.h
+++ b/engines/hdb/ai.h
@@ -744,6 +744,7 @@ public:
 	void cineWaitUntilDone();
 	void cineSetEntity(const char *entName, int x, int y, int level);
 	void cineMoveEntity(const char *entName, int x, int y, int level, int speed);
+	void cineAnimEntity(const char *entName, AIState state, int loop);
 	void cineEntityFace(const char *luaName, double dir);
 	void cineDialog(const char *title, const char *string, int seconds);
 	void cineMoveMaskedPic(const char *id, const char *pic, int x1, int y1, int x2, int y2, int speed);


Commit: 2f54ef2f7f5f5c2c755e61b70a2333161bc4b112
    https://github.com/scummvm/scummvm/commit/2f54ef2f7f5f5c2c755e61b70a2333161bc4b112
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:16:58+02:00

Commit Message:
HDB: Process cineAnimEntity()

Changed paths:
    engines/hdb/ai-cinematic.cpp


diff --git a/engines/hdb/ai-cinematic.cpp b/engines/hdb/ai-cinematic.cpp
index dd1f1e6..45b58b4 100644
--- a/engines/hdb/ai-cinematic.cpp
+++ b/engines/hdb/ai-cinematic.cpp
@@ -198,6 +198,33 @@ void AI::processCines() {
 				}
 			}
 			break;
+		case C_ANIMENTITY:
+			AIEntity *e;
+			if (!_cine[i]->start) {
+				e = locateEntity(_cine[i]->title);
+				if (e) {
+					_cine[i]->e = e;
+					e->state = (AIState)_cine[i]->speed;
+					_cine[i]->start = 1;
+					if (_cine[i]->end) // Loop ?
+						complete = true;
+					e->animFrame = 0;
+					e->animDelay = e->animCycle;
+					animEntFrames(e);
+				} else {
+					warning("Can't locate '%s' in animEntity", _cine[i]->title);
+					complete = true;
+				}
+			} else {
+				e = _cine[i]->e;
+				if (!e->animFrame && e->animDelay == e->animCycle) {
+					e->state = STATE_STANDDOWN;
+					e->animFrame = 0;
+					e->animDelay = e->animCycle;
+					complete = true;
+				}
+			}
+			break;
 		case C_ENTITYFACE:
 		{
 			AIEntity *e = locateEntity(_cine[i]->title);


Commit: 6eab766f9948ea194914114374f931f2009c9ad6
    https://github.com/scummvm/scummvm/commit/6eab766f9948ea194914114374f931f2009c9ad6
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:16:58+02:00

Commit Message:
HDB: Add cineAnimEntity() Lua function

Changed paths:
    engines/hdb/lua-script.cpp


diff --git a/engines/hdb/lua-script.cpp b/engines/hdb/lua-script.cpp
index b2eeb4d..3713161 100644
--- a/engines/hdb/lua-script.cpp
+++ b/engines/hdb/lua-script.cpp
@@ -256,7 +256,15 @@ static int cineMoveEntity(lua_State *L) {
 }
 
 static int cineAnimEntity(lua_State *L) {
-	warning("STUB: CINE ANIM ENTITY");
+	const char *entName = lua_tostring(L, 1);
+	double state = lua_tonumber(L, 2);
+	double loop = lua_tonumber(L, 2);
+
+	g_hdb->_lua->checkParameters("cineAnimEntity", 3);
+
+	lua_pop(L, 3);
+	int s = (int)state;
+	g_hdb->_ai->cineAnimEntity(entName, (AIState)s, (int)loop);
 	return 0;
 }
 


Commit: e1b5fca018fc00974d11098915740b8a0262d57d
    https://github.com/scummvm/scummvm/commit/e1b5fca018fc00974d11098915740b8a0262d57d
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:16:59+02:00

Commit Message:
HDB: Add cineSetAnimFrame()

Changed paths:
    engines/hdb/ai-cinematic.cpp
    engines/hdb/ai.h


diff --git a/engines/hdb/ai-cinematic.cpp b/engines/hdb/ai-cinematic.cpp
index 45b58b4..ac2c785 100644
--- a/engines/hdb/ai-cinematic.cpp
+++ b/engines/hdb/ai-cinematic.cpp
@@ -530,6 +530,15 @@ void AI::cineAnimEntity(const char *entName, AIState state, int loop) {
 	_cine.push_back(cmd);
 }
 
+void AI::cineSetAnimFrame(const char *entName, AIState state, int frame) {
+	CineCommand *cmd = new CineCommand;
+	cmd->start = state;
+	strcpy(cmd->title, entName);
+	cmd->end = frame;
+	cmd->cmdType = C_SETANIMFRAME;
+	_cine.push_back(cmd);
+}
+
 void AI::cineEntityFace(const char *luaName, double dir) {
 	CineCommand *cmd = new CineCommand;
 	strcpy(cmd->title, luaName);
diff --git a/engines/hdb/ai.h b/engines/hdb/ai.h
index 6269697..c2efd02 100644
--- a/engines/hdb/ai.h
+++ b/engines/hdb/ai.h
@@ -745,6 +745,7 @@ public:
 	void cineSetEntity(const char *entName, int x, int y, int level);
 	void cineMoveEntity(const char *entName, int x, int y, int level, int speed);
 	void cineAnimEntity(const char *entName, AIState state, int loop);
+	void cineSetAnimFrame(const char *entName, AIState state, int frame);
 	void cineEntityFace(const char *luaName, double dir);
 	void cineDialog(const char *title, const char *string, int seconds);
 	void cineMoveMaskedPic(const char *id, const char *pic, int x1, int y1, int x2, int y2, int speed);


Commit: 9c0b5d939ecab9db168392c0a6bfc167856d0f6d
    https://github.com/scummvm/scummvm/commit/9c0b5d939ecab9db168392c0a6bfc167856d0f6d
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:16:59+02:00

Commit Message:
HDB: Process cineSetAnimFrame()

Changed paths:
    engines/hdb/ai-cinematic.cpp


diff --git a/engines/hdb/ai-cinematic.cpp b/engines/hdb/ai-cinematic.cpp
index ac2c785..9261699 100644
--- a/engines/hdb/ai-cinematic.cpp
+++ b/engines/hdb/ai-cinematic.cpp
@@ -64,6 +64,7 @@ static const char *cineTypeStr[] = {
 
 void AI::processCines() {
 
+	AIEntity *e;
 	bool complete, bailOut;
 
 	if (!_cineActive) {
@@ -181,7 +182,7 @@ void AI::processCines() {
 			break;
 		case C_MOVEENTITY:
 			if (!_cine[i]->start) {
-				AIEntity *e = locateEntity(_cine[i]->title);
+				e = locateEntity(_cine[i]->title);
 				if (e) {
 					_cine[i]->e = e;
 					_cine[i]->e->moveSpeed = _cine[i]->speed;
@@ -199,7 +200,6 @@ void AI::processCines() {
 			}
 			break;
 		case C_ANIMENTITY:
-			AIEntity *e;
 			if (!_cine[i]->start) {
 				e = locateEntity(_cine[i]->title);
 				if (e) {
@@ -225,9 +225,20 @@ void AI::processCines() {
 				}
 			}
 			break;
+		case C_SETANIMFRAME:
+			e = locateEntity(_cine[i]->title);
+			if (e) {
+				e->state = (AIState)_cine[i]->start;
+				e->animFrame = _cine[i]->end;
+				e->animDelay = e->animCycle;
+				animEntFrames(e);
+				e->state = STATE_NONE;
+				complete = true;
+			}
+			break;
 		case C_ENTITYFACE:
 		{
-			AIEntity *e = locateEntity(_cine[i]->title);
+			e = locateEntity(_cine[i]->title);
 
 			if (e) {
 				int d = (int)_cine[i]->x;


Commit: 5048f1b3ae2ed93d042b671c991bb4a4d1a7bc72
    https://github.com/scummvm/scummvm/commit/5048f1b3ae2ed93d042b671c991bb4a4d1a7bc72
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:16:59+02:00

Commit Message:
HDB: Add cineSetAnimFrame() Lua function

Changed paths:
    engines/hdb/lua-script.cpp


diff --git a/engines/hdb/lua-script.cpp b/engines/hdb/lua-script.cpp
index 3713161..62ad8d6 100644
--- a/engines/hdb/lua-script.cpp
+++ b/engines/hdb/lua-script.cpp
@@ -269,7 +269,15 @@ static int cineAnimEntity(lua_State *L) {
 }
 
 static int cineSetAnimFrame(lua_State *L) {
-	warning("STUB: CINE SET ANIM FRAME");
+	const char *entName = lua_tostring(L, 1);
+	double state = lua_tonumber(L, 2);
+	double frame = lua_tonumber(L, 2);
+
+	g_hdb->_lua->checkParameters("cineSetAnimFrame", 3);
+
+	lua_pop(L, 3);
+	int s = (int)state;
+	g_hdb->_ai->cineSetAnimFrame(entName, (AIState)s, (int)frame);
 	return 0;
 }
 


Commit: 91e74dca098bf2b346a02066e255f2c2c515d8d0
    https://github.com/scummvm/scummvm/commit/91e74dca098bf2b346a02066e255f2c2c515d8d0
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:16:59+02:00

Commit Message:
HDB: Fix boolean check

Changed paths:
    engines/hdb/ai-cinematic.cpp


diff --git a/engines/hdb/ai-cinematic.cpp b/engines/hdb/ai-cinematic.cpp
index 9261699..a48c43c 100644
--- a/engines/hdb/ai-cinematic.cpp
+++ b/engines/hdb/ai-cinematic.cpp
@@ -78,7 +78,7 @@ void AI::processCines() {
 
 	// Make sure Cine Pics are drawing
 	for (int i = 0;i < _numCineBlitList;i++) {
-		if (_cineBlitList[i]->masked = false)
+		if (_cineBlitList[i]->masked == false)
 			_cineBlitList[i]->pic->draw(_cine[i]->x, _cine[i]->y);
 		else
 			_cineBlitList[i]->pic->drawMasked(_cine[i]->x, _cine[i]->y);


Commit: f937418f6d02ce40ab9c776fc687a0fbc1cc922a
    https://github.com/scummvm/scummvm/commit/f937418f6d02ce40ab9c776fc687a0fbc1cc922a
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:16:59+02:00

Commit Message:
HDB: Add debug output

Changed paths:
    engines/hdb/ai-cinematic.cpp
    engines/hdb/ai-funcs.cpp


diff --git a/engines/hdb/ai-cinematic.cpp b/engines/hdb/ai-cinematic.cpp
index a48c43c..8d50259 100644
--- a/engines/hdb/ai-cinematic.cpp
+++ b/engines/hdb/ai-cinematic.cpp
@@ -193,7 +193,8 @@ void AI::processCines() {
 					warning("Can't locate '%s' in moveEntity", _cine[i]->title);
 				}
 			} else {
-				debug(3, "C_MOVEENTITY: _cine[%d]->e->goalX: %d", i, _cine[i]->e->goalX);
+				debug(3, "C_MOVEENTITY: _cine[%d]->e->tileX: %d, _cine[%d]->e->goalX: %d", i, _cine[i]->e->tileX, i, _cine[i]->e->goalX);
+				debug(3, "C_MOVEENTITY: _cine[%d]->e->tileY: %d, _cine[%d]->e->goalY: %d", i, _cine[i]->e->tileY, i, _cine[i]->e->goalY);
 				if (!_cine[i]->e->goalX) {
 					complete = true;
 				}
diff --git a/engines/hdb/ai-funcs.cpp b/engines/hdb/ai-funcs.cpp
index cfbe166..262fc05 100644
--- a/engines/hdb/ai-funcs.cpp
+++ b/engines/hdb/ai-funcs.cpp
@@ -682,11 +682,15 @@ void AI::animateEntity(AIEntity *e) {
 	int fgTileFlags, fgTileIndex;
 
 	// Move entity if player is not dead
+	debug(3, "Before animateEntity, e->x: %d, e->y: %d", e->x, e->y);
+	debug(3, "Before animateEntity, e->tileX: %d, e->tileY: %d", e->tileX, e->tileY);
 	if (!_playerDead) {
 		e->x += e->xVel;
 		e->y += e->yVel;
 		e->tileX = e->x / kTileWidth;
 		e->tileY = e->y / kTileHeight;
+		debug(3, "After animateEntity, e->x: %d, e->y: %d", e->x, e->y);
+		debug(3, "After animateEntity, e->tileX: %d, e->tileY: %d", e->tileX, e->tileY);
 	}
 
 	// For non-players, check for trigger being hit


Commit: f8d7dd18d01e4749310776ac16601765c8b9294e
    https://github.com/scummvm/scummvm/commit/f8d7dd18d01e4749310776ac16601765c8b9294e
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:16:59+02:00

Commit Message:
HDB: Fix setEntityGoal() direction

Changed paths:
    engines/hdb/ai-funcs.cpp


diff --git a/engines/hdb/ai-funcs.cpp b/engines/hdb/ai-funcs.cpp
index 262fc05..8e174ef 100644
--- a/engines/hdb/ai-funcs.cpp
+++ b/engines/hdb/ai-funcs.cpp
@@ -552,12 +552,12 @@ void AI::setEntityGoal(AIEntity *e, int x, int y) {
 	yv = y - e->tileY;
 	if (yv < 0) {
 		e->yVel = -e->moveSpeed;
-		e->state = STATE_MOVELEFT;
-		e->dir = DIR_LEFT;
+		e->state = STATE_MOVEUP;
+		e->dir = DIR_UP;
 	} else if (yv > 0) {
 		e->yVel = e->moveSpeed;
-		e->state = STATE_MOVERIGHT;
-		e->dir = DIR_RIGHT;
+		e->state = STATE_MOVEDOWN;
+		e->dir = DIR_DOWN;
 	}
 
 	if (e->type == AI_GUY && _playerRunning) {


Commit: 32e30366a4825eb5e8647f03d2ffa9116c4df0f7
    https://github.com/scummvm/scummvm/commit/32e30366a4825eb5e8647f03d2ffa9116c4df0f7
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:16:59+02:00

Commit Message:
HDB: Added more debug output and hid some noisy one

Changed paths:
    engines/hdb/ai-funcs.cpp
    engines/hdb/window.cpp


diff --git a/engines/hdb/ai-funcs.cpp b/engines/hdb/ai-funcs.cpp
index 8e174ef..e24ec34 100644
--- a/engines/hdb/ai-funcs.cpp
+++ b/engines/hdb/ai-funcs.cpp
@@ -1145,8 +1145,10 @@ void AI::drawEnts(int x, int y, int w, int h) {
 					_entsLevel2[_numLevel2Ents].e = e;
 					_entsLevel2[_numLevel2Ents].stunnedWait = 0;
 					_numLevel2Ents++;
+					debugN(5, "not drawing1...");
 				} else {
 					e->aiDraw(e, x, y);
+					debugN(5, "drawing1...");
 				}
 			}
 		}
@@ -1162,8 +1164,11 @@ void AI::drawEnts(int x, int y, int w, int h) {
 					_entsLevel2[_numLevel2Ents].e = e;
 					_entsLevel2[_numLevel2Ents].stunnedWait = 0;
 					_numLevel2Ents++;
-				} else
+					debugN(5, "not drawing2...");
+				} else {
 					e->aiDraw(e, x, y);
+					debugN(5, "drawing2...");
+				}
 			}
 
 			switch (e->type) {
@@ -1183,6 +1188,7 @@ void AI::drawEnts(int x, int y, int w, int h) {
 					_entsLevel2[_numLevel2Ents].e = NULL;
 					_entsLevel2[_numLevel2Ents].stunnedWait = e->stunnedWait;
 					_numLevel2Ents++;
+					debugN(5, "not trying to draw...");
 				} else {
 					debugN(5, "trying to draw...");
 
@@ -1293,8 +1299,8 @@ void AI::moveEnts() {
 		}
 	}
 
-	warning("STUB: moveEnts: Laser Rescan");
-	warning("STUB: moveEnts: Laser Looping Sound Channel");
+	debug(9, "STUB: moveEnts: Laser Rescan");
+	debug(9, "STUB: moveEnts: Laser Looping Sound Channel");
 }
 
 int AI::checkForTouchplate(int x, int y) {
diff --git a/engines/hdb/window.cpp b/engines/hdb/window.cpp
index d2dc204..8179190 100644
--- a/engines/hdb/window.cpp
+++ b/engines/hdb/window.cpp
@@ -152,7 +152,7 @@ void Window::drawDialog() {
 #endif
 
 	if (g_hdb->getActionMode())
-		warning("STUB: drawDialog: Draw Player Weapon");
+		debug(9, "STUB: drawDialog: Draw Player Weapon");
 
 	if (!_dialogInfo.active)
 		return;


Commit: 8d087a3c7f33b20989dc40a9f326966dc94e3b02
    https://github.com/scummvm/scummvm/commit/8d087a3c7f33b20989dc40a9f326966dc94e3b02
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:16:59+02:00

Commit Message:
HDB: Added rest of the stubs for the rendering pipeline

Changed paths:
    engines/hdb/ai-funcs.cpp
    engines/hdb/ai-waypoint.cpp
    engines/hdb/ai.h
    engines/hdb/hdb.cpp


diff --git a/engines/hdb/ai-funcs.cpp b/engines/hdb/ai-funcs.cpp
index e24ec34..be0977e 100644
--- a/engines/hdb/ai-funcs.cpp
+++ b/engines/hdb/ai-funcs.cpp
@@ -1224,6 +1224,10 @@ void AI::drawEnts(int x, int y, int w, int h) {
 	}
 }
 
+void AI::drawLevel2Ents() {
+	debug(9, "STUB: AI::drawLevel2Ents()");
+}
+
 void AI::animGrabbing() {
 	if (_player->state == STATE_GRABUP ||
 		_player->state == STATE_GRABDOWN ||
diff --git a/engines/hdb/ai-waypoint.cpp b/engines/hdb/ai-waypoint.cpp
index 9faa88c..976ba4b 100644
--- a/engines/hdb/ai-waypoint.cpp
+++ b/engines/hdb/ai-waypoint.cpp
@@ -104,4 +104,8 @@ Tile *AI::getStandFrameDir(AIEntity *e) {
 	return e->standdownGfx[0];
 }
 
+void AI::drawWayPoints() {
+	debug(9, "STUB: AI::drawWayPoints()");
+}
+
 } // End of Namespace
diff --git a/engines/hdb/ai.h b/engines/hdb/ai.h
index c2efd02..b64b2ab 100644
--- a/engines/hdb/ai.h
+++ b/engines/hdb/ai.h
@@ -638,6 +638,7 @@ public:
 	void animEntFrames(AIEntity *e);
 	void animLuaEntity(const char *initName, AIState st);
 	void drawEnts(int x, int y, int w, int h);
+	void drawLevel2Ents();
 	void animGrabbing();
 
 	void moveEnts();
@@ -762,6 +763,7 @@ public:
 	void removeFirstWaypoint();
 	void clearWaypoints();
 	Tile *getStandFrameDir(AIEntity *e);
+	void drawWayPoints();
 
 	// Inventory Functions
 	bool addToInventory(AIEntity *e);
diff --git a/engines/hdb/hdb.cpp b/engines/hdb/hdb.cpp
index 0b6eefb..0951eac 100644
--- a/engines/hdb/hdb.cpp
+++ b/engines/hdb/hdb.cpp
@@ -299,8 +299,20 @@ Common::Error HDBGame::run() {
 
 		_map->draw();
 		_ai->processCines();
+
+		AIEntity *e = _ai->getPlayer();
+
+		if (e && e->level < 2)
+			_ai->drawWayPoints();
+
 		_map->drawEnts();
 		_map->drawGratings();
+
+		if (e && e->level == 2)
+			_ai->drawWayPoints();
+
+		_ai->drawLevel2Ents();
+
 		_map->drawForegrounds();
 		_ai->animateTargets();
 


Commit: f49b4d3221bcf33b6907eda7b9cc8b892845043d
    https://github.com/scummvm/scummvm/commit/f49b4d3221bcf33b6907eda7b9cc8b892845043d
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:16:59+02:00

Commit Message:
HDB: Implemented AI::drawLevel2Ents()

Changed paths:
    engines/hdb/ai-funcs.cpp
    engines/hdb/ai-init.cpp
    engines/hdb/ai.h


diff --git a/engines/hdb/ai-funcs.cpp b/engines/hdb/ai-funcs.cpp
index be0977e..b35efdf 100644
--- a/engines/hdb/ai-funcs.cpp
+++ b/engines/hdb/ai-funcs.cpp
@@ -1225,7 +1225,34 @@ void AI::drawEnts(int x, int y, int w, int h) {
 }
 
 void AI::drawLevel2Ents() {
-	debug(9, "STUB: AI::drawLevel2Ents()");
+	int debug = 0; //game.GetDebug(); // FIXME
+
+	for (int i = 0; i < _numLevel2Ents; i++) {
+		// call custom drawing code?
+		if (_entsLevel2[i].aiDraw)
+			_entsLevel2[i].aiDraw(_entsLevel2[i].e, _entsLevel2[i].x, _entsLevel2[i].y);
+		else if (_entsLevel2[i].draw)
+			_entsLevel2[i].draw->drawMasked(_entsLevel2[i].x, _entsLevel2[i].y);
+		else if (debug)
+			_debugQMark->drawMasked(_entsLevel2[i].x, _entsLevel2[i].y );
+
+		if (_entsLevel2[i].stunnedWait)
+			 g_hdb->_ai->_stunnedGfx[_stunAnim]->drawMasked(_entsLevel2[i].x , _entsLevel2[i].y);
+	}
+
+	// always draw the player last
+	if (_player && _player->level == 2 && !_playerInvisible) {
+		int x, y;
+		g_hdb->_map->getMapXY(&x, &y);
+
+		if (_player->draw)
+			_player->draw->drawMasked((_player->x - x) + _player->drawXOff, (_player->y - y) + _player->drawYOff);
+	}
+
+	if (_stunTimer < g_system->getMillis()) {
+		_stunAnim = (_stunAnim + 1) & 3;
+		_stunTimer = g_system->getMillis() + 100;
+	}
 }
 
 void AI::animGrabbing() {
diff --git a/engines/hdb/ai-init.cpp b/engines/hdb/ai-init.cpp
index 8f4ed86..cc5bd94 100644
--- a/engines/hdb/ai-init.cpp
+++ b/engines/hdb/ai-init.cpp
@@ -673,6 +673,9 @@ AI::AI() {
 
 	// REMOVE: Remove for final. Used here due to lack of a MENU
 	_numGems = _numGooCups = _numMonkeystones = _numInventory = 0;
+
+	_stunAnim = 0;
+	_stunTimer = g_system->getMillis();
 }
 
 AI::~AI() {
@@ -684,6 +687,9 @@ AI::~AI() {
 bool AI::init() {
 	warning("STUB: AI::init incomplete");
 
+	_debugQMark = new Tile;
+	_debugQMark->load(g_hdb->_fileMan->findFirstData("icon_question_mark", TYPE_ICON32));
+
 	// Clear Waypoint list and load Waypoint graphics
 	_numWaypoints = 0;
 	_waypointGfx[0] = new Tile;
diff --git a/engines/hdb/ai.h b/engines/hdb/ai.h
index b64b2ab..32cca0a 100644
--- a/engines/hdb/ai.h
+++ b/engines/hdb/ai.h
@@ -923,6 +923,7 @@ public:
 	Waypoint _waypoints[kMaxWaypoints];
 	int _numWaypoints;
 	Tile *_waypointGfx[4]; // Animating waypoint gfx
+	Tile *_debugQMark;
 
 	ActionInfo _actions[kMaxActions];
 
@@ -940,6 +941,9 @@ public:
 	CineBlit *_cineBlitList[kMaxCineGfx];
 	int _numCineBlitList;
 
+	int _stunAnim;
+	uint32 _stunTimer;
+
 private:
 
 	// Action Functions


Commit: a28eb3e60e377a87d75b0760f07215eb7ea45848
    https://github.com/scummvm/scummvm/commit/a28eb3e60e377a87d75b0760f07215eb7ea45848
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:16:59+02:00

Commit Message:
HDB: Fix space formatting

Changed paths:
    engines/hdb/ai-cinematic.cpp
    engines/hdb/ai-lists.cpp
    engines/hdb/ai-waypoint.cpp
    engines/hdb/ai.h
    engines/hdb/draw-manager.cpp
    engines/hdb/map-loader.cpp


diff --git a/engines/hdb/ai-cinematic.cpp b/engines/hdb/ai-cinematic.cpp
index 8d50259..4b906bd 100644
--- a/engines/hdb/ai-cinematic.cpp
+++ b/engines/hdb/ai-cinematic.cpp
@@ -77,7 +77,7 @@ void AI::processCines() {
 	g_hdb->_window->checkDialogClose(0, 0);
 
 	// Make sure Cine Pics are drawing
-	for (int i = 0;i < _numCineBlitList;i++) {
+	for (int i = 0; i < _numCineBlitList; i++) {
 		if (_cineBlitList[i]->masked == false)
 			_cineBlitList[i]->pic->draw(_cine[i]->x, _cine[i]->y);
 		else
@@ -86,7 +86,7 @@ void AI::processCines() {
 
 	// TODO: Check for Game Pause
 
-	for (uint i = 0; i < _cine.size();i++) {
+	for (uint i = 0; i < _cine.size(); i++) {
 		debug(3, "processCines: [%d] %s now: %d  start: %d delay: %d", i, cineTypeStr[_cine[i]->cmdType],
 				g_system->getMillis(), _cine[i]->start, _cine[i]->delay);
 
@@ -405,7 +405,7 @@ void AI::cineAddToBlitList(const char *id, Picture *pic, int x, int y, bool mask
 }
 
 Picture *AI::cineFindInBlitList(const char *name) {
-	for (int i = 0; i < _numCineBlitList;i++) {
+	for (int i = 0; i < _numCineBlitList; i++) {
 		if (Common::matchString(_cineBlitList[i]->id, name))
 			return _cineBlitList[i]->pic;
 	}
@@ -413,7 +413,7 @@ Picture *AI::cineFindInBlitList(const char *name) {
 }
 
 void AI::cineRemoveFromBlitList(const char *name) {
-	for (int i = 0; i < _numCineBlitList;i++) {
+	for (int i = 0; i < _numCineBlitList; i++) {
 		if (Common::matchString(_cineBlitList[i]->id, name))
 			delete _cineBlitList[i];
 			for (; i < _numCineBlitList - 1; i++)
@@ -434,7 +434,7 @@ void AI::cineAddToFreeList(Picture *pic) {
 }
 
 void AI::cineFreeGfx() {
-	for (int i = 0;i < _numCineFreeList;i++) {
+	for (int i = 0; i < _numCineFreeList; i++) {
 		delete _cineFreeList[i];
 	}
 	_numCineFreeList = 0;
diff --git a/engines/hdb/ai-lists.cpp b/engines/hdb/ai-lists.cpp
index b113f4a..174729b 100644
--- a/engines/hdb/ai-lists.cpp
+++ b/engines/hdb/ai-lists.cpp
@@ -65,7 +65,7 @@ void AI::addAnimateTarget(int x, int y, int start, int end, AnimSpeed speed, boo
 		char name[32];
 		uint32 size;
 
-		for (int i = start;i <= end;i++) {
+		for (int i = start; i <= end; i++) {
 			if (i < 10)
 				snprintf(name, 32, "%s0%d", tileName, i + 1);
 			else
@@ -177,7 +177,7 @@ void AI::addToActionList(int actionIndex, int x, int y, char *luaFuncInt, char *
 // Checks if the location passed-in matches an action pair.
 // If so, activate it if possible. Returns TRUE for finding pair.
 bool AI::checkActionList(AIEntity *e, int x, int y, bool lookAndGrab) {
-	for (int i = 0;i < kMaxActions;i++) {
+	for (int i = 0; i < kMaxActions; i++) {
 		if ((_actions[i].x1 == x && _actions[i].y1 == y) || (_actions[i].x2 == x && _actions[i].y2 == y)) {
 			int targetX = _actions[i].x2;
 			int targetY = _actions[i].y2;
@@ -227,7 +227,7 @@ void AI::addToAutoList(int x, int y, const char *luaFuncInit, const char *luaFun
 
 	const char *get;
 
-	for (int i = 0;i < kMaxAutoActions;i++) {
+	for (int i = 0; i < kMaxAutoActions; i++) {
 		if (!_autoActions[i].x) {
 			_autoActions[i].x = x;
 			_autoActions[i].y = y;
@@ -254,7 +254,7 @@ void AI::addToAutoList(int x, int y, const char *luaFuncInit, const char *luaFun
 }
 
 void AI::autoDeactivate(int x, int y) {
-	for (int i = 0; i < kMaxAutoActions;i++) {
+	for (int i = 0; i < kMaxAutoActions; i++) {
 		if (_autoActions[i].x == x && _autoActions[i].y == y) {
 			_autoActions[i].activated = false;
 			return;
@@ -387,7 +387,7 @@ bool AI::activateAction(AIEntity *e, int x, int y, int targetX, int targetY) {
 }
 
 bool AI::checkAutoList(AIEntity *e, int x, int y) {
-	for (int i = 0;i < kMaxAutoActions;i++) {
+	for (int i = 0; i < kMaxAutoActions; i++) {
 		if (_autoActions[i].x == x && _autoActions[i].y == y && !_autoActions[i].activated) {
 			debug(1, "Activating action for Entity: %s, x: %d, y: %d", e->entityName, x, y);
 			bool success = activateAction(e, x, y, 0, 0);
@@ -408,7 +408,7 @@ bool AI::checkAutoList(AIEntity *e, int x, int y) {
 }
 
 bool AI::autoActive(int x, int y) {
-	for (int i = 0;i < kMaxAutoActions;i++) {
+	for (int i = 0; i < kMaxAutoActions; i++) {
 		if (_autoActions[i].x == x && _autoActions[i].y == y) {
 			if (!_autoActions[i].activated)
 				return false;
diff --git a/engines/hdb/ai-waypoint.cpp b/engines/hdb/ai-waypoint.cpp
index 976ba4b..70847ab 100644
--- a/engines/hdb/ai-waypoint.cpp
+++ b/engines/hdb/ai-waypoint.cpp
@@ -29,7 +29,7 @@ void AI::addWaypoint(int px, int py, int x, int y, int level) {
 		return;
 
 	// Check for duplicates
-	for (int i = 0;i < _numWaypoints;i++)
+	for (int i = 0; i < _numWaypoints; i++)
 		if (_waypoints[i].x == x && _waypoints[i].y == y)
 			return;
 
@@ -56,7 +56,7 @@ void AI::removeFirstWaypoint() {
 		return;
 
 	int i;
-	for (i = 0;i < _numWaypoints;i++) {
+	for (i = 0; i < _numWaypoints; i++) {
 		_waypoints[i] = _waypoints[i + 1];
 	}
 
diff --git a/engines/hdb/ai.h b/engines/hdb/ai.h
index 32cca0a..96f0e6d 100644
--- a/engines/hdb/ai.h
+++ b/engines/hdb/ai.h
@@ -544,7 +544,7 @@ struct AnimTarget {
 	Tile *gfxList[kMaxAnimTFrames];
 
 	AnimTarget() : x(0), y(0), start(0), end(0), vel(0), animCycle(0), animFrame(0), killAuto(false), inMap(false) {
-		for (int i = 0; i < kMaxAnimTFrames;i++) {
+		for (int i = 0; i < kMaxAnimTFrames; i++) {
 			gfxList[i] = new Tile;
 		}
 	}
diff --git a/engines/hdb/draw-manager.cpp b/engines/hdb/draw-manager.cpp
index f4edcb7..23bfb35 100644
--- a/engines/hdb/draw-manager.cpp
+++ b/engines/hdb/draw-manager.cpp
@@ -194,7 +194,7 @@ Tile *DrawMan::getTile(int index) {
 }
 
 void DrawMan::cacheTileSequence(int tileIndex, int count) {
-	for (int i = tileIndex;i < tileIndex + count;i++)
+	for (int i = tileIndex; i < tileIndex + count; i++)
 		getTile(i);
 }
 
@@ -450,7 +450,7 @@ bool DrawMan::loadFont(const char *string) {
 	int startPos = stream->pos();	// Position after _fontHeader
 	int curPos;						// Position after reading cInfo
 	uint16 *ptr;
-	for (int i = 0; i < _fontHeader.numChars;i++) {
+	for (int i = 0; i < _fontHeader.numChars; i++) {
 		cInfo = new CharInfo;
 		cInfo->width = (int16)stream->readUint32LE();
 		cInfo->offset = (int32)stream->readUint32LE();
@@ -497,7 +497,7 @@ void DrawMan::drawText(const char *string) {
 	unsigned char c;
 	char cr[256];	// Carriage Return Array
 
-	for (int i = 0; i < (int)strlen(string);i++) {
+	for (int i = 0; i < (int)strlen(string); i++) {
 		c = string[i];
 		width += _charInfoBlocks[c]->width + _fontHeader.kerning + kFontIncrement;
 		if (c == ' ')
diff --git a/engines/hdb/map-loader.cpp b/engines/hdb/map-loader.cpp
index 182e761..25ff4ea 100644
--- a/engines/hdb/map-loader.cpp
+++ b/engines/hdb/map-loader.cpp
@@ -27,21 +27,21 @@ namespace HDB {
 Map::Map() {
 	_mapLoaded = false;
 
-	for (int i = 0; i < kMaxGratings;i++) {
+	for (int i = 0; i < kMaxGratings; i++) {
 		_gratings[i] = new Foreground;
 	}
 
-	for (int i = 0; i < kMaxForegrounds;i++) {
+	for (int i = 0; i < kMaxForegrounds; i++) {
 		_foregrounds[i] = new Foreground;
 	}
 }
 
 Map::~Map() {
-	for (int i = 0; i < kMaxGratings;i++) {
+	for (int i = 0; i < kMaxGratings; i++) {
 		delete _gratings[i];
 	}
 
-	for (int i = 0; i < kMaxForegrounds;i++) {
+	for (int i = 0; i < kMaxForegrounds; i++) {
 		delete _foregrounds[i];
 	}
 }
@@ -145,7 +145,7 @@ bool Map::load(Common::SeekableReadStream *stream) {
 	_mapX = _mapY = 0;
 
 	// Setup animating Tile lists
-	for (int i = 0; i < _width*_height;i++) {
+	for (int i = 0; i < _width*_height; i++) {
 		addBGTileAnimation(i % _width, i / _width);
 		addFGTileAnimation(i % _width, i / _width);
 	}
@@ -408,7 +408,7 @@ bool Map::load(Common::SeekableReadStream *stream) {
 
 	// Scan all icons and init all Entities
 	warning("STUB: Map::load: SetupProgressBar");
-	for (int i = 0; i < _iconNum;i++) {
+	for (int i = 0; i < _iconNum; i++) {
 		// Don't spawn Action Mode Entities in Puzzle Mode
 		if (!g_hdb->getActionMode()) {
 			switch (aiInfo[_iconList[i].icon].type) {
@@ -683,7 +683,7 @@ void Map::drawEnts() {
 }
 
 void Map::drawGratings() {
-	for (int i = 0; i < kMaxGratings;i++) {
+	for (int i = 0; i < kMaxGratings; i++) {
 		g_hdb->_drawMan->getTile(_gratings[i]->tile)->drawMasked(_gratings[i]->x, _gratings[i]->y);
 	}
 
@@ -691,7 +691,7 @@ void Map::drawGratings() {
 }
 
 void Map::drawForegrounds() {
-	for (int i = 0; i < kMaxForegrounds;i++) {
+	for (int i = 0; i < kMaxForegrounds; i++) {
 		g_hdb->_drawMan->getTile(_foregrounds[i]->tile)->drawMasked(_foregrounds[i]->x, _foregrounds[i]->y);
 	}
 
@@ -928,7 +928,7 @@ void Map::centerMapXY(int x, int y) {
 }
 
 bool Map::checkOneTileExistInRange(int tileIndex, int count) {
-	for (int i = 0; i < _width*_height;i++) {
+	for (int i = 0; i < _width*_height; i++) {
 		if (_background[i] >= tileIndex && _background[i] < tileIndex + count)
 			return true;
 		if (_foreground[i] >= tileIndex && _foreground[i] < tileIndex + count)


Commit: 4be327e39470ffc35611e5746895540a8820a899
    https://github.com/scummvm/scummvm/commit/4be327e39470ffc35611e5746895540a8820a899
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:16:59+02:00

Commit Message:
HDB: Add findEntityIgnore() and findEntityType()

Changed paths:
    engines/hdb/ai-funcs.cpp
    engines/hdb/ai.h


diff --git a/engines/hdb/ai-funcs.cpp b/engines/hdb/ai-funcs.cpp
index b35efdf..4f6bf35 100644
--- a/engines/hdb/ai-funcs.cpp
+++ b/engines/hdb/ai-funcs.cpp
@@ -529,6 +529,40 @@ AIEntity *AI::findEntity(int x, int y) {
 	return NULL;
 }
 
+AIEntity *AI::findEntityIgnore(int x, int y, AIEntity *ignore) {
+	for (Common::Array<AIEntity *>::iterator it = _ents->begin(); it != _ents->end(); it++) {
+		if ((*it)->tileX == x && (*it)->tileY == y && (*it) != ignore) {
+			return *it;
+		}
+	}
+
+	for (Common::Array<AIEntity *>::iterator it = _floats->begin(); it != _floats->end(); it++) {
+		if ((*it)->tileX == x && (*it)->tileY == y && (*it) != ignore) {
+			return *it;
+		}
+	}
+
+	warning("STUB: findEntityIgnore: Check for Laser");
+	return NULL;
+}
+
+AIEntity *AI::findEntityType(AIType type, int x, int y) {
+	for (Common::Array<AIEntity *>::iterator it = _ents->begin(); it != _ents->end(); it++) {
+		if ((*it)->tileX == x && (*it)->tileY == y && (*it)->type == type) {
+			return *it;
+		}
+	}
+
+	for (Common::Array<AIEntity *>::iterator it = _floats->begin(); it != _floats->end(); it++) {
+		if ((*it)->tileX == x && (*it)->tileY == y && (*it)->type == type) {
+			return *it;
+		}
+	}
+
+	warning("STUB: findEntityType: Check for Laser");
+	return NULL;
+}
+
 void AI::removeEntity(AIEntity *e) {
 	_ents->erase(&e);
 }
diff --git a/engines/hdb/ai.h b/engines/hdb/ai.h
index 96f0e6d..e228ebd 100644
--- a/engines/hdb/ai.h
+++ b/engines/hdb/ai.h
@@ -629,6 +629,8 @@ public:
 	void stopEntity(AIEntity *e);
 	AIEntity *locateEntity(const char *luaName);
 	AIEntity *findEntity(int x, int y);
+	AIEntity *findEntityIgnore(int x, int y, AIEntity *ignore);
+	AIEntity *findEntityType(AIType type, int x, int y);
 	void removeEntity(AIEntity *e);
 	void setEntityGoal(AIEntity *e, int x, int y);
 	void initAllEnts();


Commit: 12a677d9007b93893fab0c223a297a5a5c207693
    https://github.com/scummvm/scummvm/commit/12a677d9007b93893fab0c223a297a5a5c207693
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:16:59+02:00

Commit Message:
HDB: Add legalMove functions

Changed paths:
    engines/hdb/ai-funcs.cpp
    engines/hdb/ai.h


diff --git a/engines/hdb/ai-funcs.cpp b/engines/hdb/ai-funcs.cpp
index 4f6bf35..4d265d1 100644
--- a/engines/hdb/ai-funcs.cpp
+++ b/engines/hdb/ai-funcs.cpp
@@ -1375,6 +1375,83 @@ int AI::checkForTouchplate(int x, int y) {
 	return 0;
 }
 
+AIEntity *AI::legalMove(int tileX, int tileY, int level, int *result) {
+	uint32 bgFlags = g_hdb->_map->getMapBGTileFlags(tileX, tileY);
+	uint32 fgFlags = g_hdb->_map->getMapFGTileFlags(tileX, tileY);
+	AIEntity *hit = findEntity(tileX, tileY);
+
+	if (hit && hit->state != STATE_FLOATING)
+		// If player and entity are not at the same level, are they on stairs?
+		if (hit->level != level)
+			if (level == 1 && !(bgFlags & kFlagStairTop))
+				hit = NULL;
+			else if (level == 1 && !(bgFlags & kFlagStairBot))
+				hit = NULL;
+
+	if (level == 1) {
+		if (bgFlags & kFlagSolid) {
+			*result = 0;
+			return hit;
+		}
+
+		if (bgFlags & (kFlagWater | kFlagSlime)) {
+			if (hit && hit->state == STATE_FLOATING) {
+				*result = 1;
+				return NULL;
+			} else
+				*result = 0;
+			return hit;
+		} else
+			*result = 1;
+	} else {
+		if (fgFlags & kFlagSolid) {
+			*result = 0;
+			return hit;
+		} else if (fgFlags & kFlagGrating) {
+			*result = 1;
+			return hit;
+		} else if (fgFlags & kFlagSolid) {
+			*result = 0;
+			return hit;
+		}
+
+		if (bgFlags & (kFlagWater | kFlagSlime | kFlagPlummet)) {
+			if (hit && hit->state == STATE_FLOATING) {
+				*result = 1;
+				return NULL;
+			} else
+				*result = 0;
+			return hit;
+		} else
+			*result = 1;
+	}
+	return hit;
+}
+
+AIEntity *AI::legalMoveOverWater(int tileX, int tileY, int level, int *result) {
+	uint32 bgFlags = g_hdb->_map->getMapBGTileFlags(tileX, tileY);
+	uint32 fgFlags = g_hdb->_map->getMapFGTileFlags(tileX, tileY);
+	AIEntity *hit = findEntity(tileX, tileY);
+
+	if (level == 1 ? (bgFlags & kFlagMonsterBlock) : (!(fgFlags &kFlagGrating) && ((fgFlags & kFlagSolid) || (bgFlags & kFlagMonsterBlock))))
+		*result = 0;
+	else
+		*result = 1;
+	return hit;
+}
+
+AIEntity *AI::legalMoveOverWaterIgnore(int tileX, int tileY, int level, int *result, AIEntity *ignore) {
+	uint32 bgFlags = g_hdb->_map->getMapBGTileFlags(tileX, tileY);
+	uint32 fgFlags = g_hdb->_map->getMapFGTileFlags(tileX, tileY);
+	AIEntity *hit = findEntityIgnore(tileX, tileY, ignore);
+
+	if (level == 1 ? (bgFlags & kFlagMonsterBlock) : (!(fgFlags &kFlagGrating) && ((fgFlags & kFlagSolid) || (bgFlags & kFlagMonsterBlock))))
+		*result = 0;
+	else
+		*result = 1;
+	return hit;
+}
+
 bool AI::checkFloating(int x, int y) {
 	for (Common::Array<AIEntity *>::iterator it = _floats->begin(); it != _floats->end(); it++) {
 		if ((*it)->tileX == x && (*it)->tileY == y)
diff --git a/engines/hdb/ai.h b/engines/hdb/ai.h
index e228ebd..04c2018 100644
--- a/engines/hdb/ai.h
+++ b/engines/hdb/ai.h
@@ -646,7 +646,9 @@ public:
 	void moveEnts();
 
 	int checkForTouchplate(int x, int y);
-
+	AIEntity *legalMove(int tileX, int tileY, int level, int *result);
+	AIEntity *legalMoveOverWater(int tileX, int tileY, int level, int *result);
+	AIEntity *legalMoveOverWaterIgnore(int tileX, int tileY, int level, int *result, AIEntity *ignore);
 	void addAnimateTarget(int x, int y, int start, int end, AnimSpeed speed, bool killAuto, bool inMap, const char *tileName);
 	void animateTargets();
 


Commit: 70888532f8d6ab04b612eafe7de0256f0ce39172
    https://github.com/scummvm/scummvm/commit/70888532f8d6ab04b612eafe7de0256f0ce39172
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:16:59+02:00

Commit Message:
HDB: Add checkPlayerCollision functions

Changed paths:
    engines/hdb/ai-funcs.cpp
    engines/hdb/ai.h


diff --git a/engines/hdb/ai-funcs.cpp b/engines/hdb/ai-funcs.cpp
index 4d265d1..585d333 100644
--- a/engines/hdb/ai-funcs.cpp
+++ b/engines/hdb/ai-funcs.cpp
@@ -1452,6 +1452,28 @@ AIEntity *AI::legalMoveOverWaterIgnore(int tileX, int tileY, int level, int *res
 	return hit;
 }
 
+AIEntity *AI::playerCollision(int topBorder, int bottomBorder, int leftBorder, int rightBorder) {
+	AIEntity *e;
+	for (Common::Array<AIEntity *>::iterator it = _ents->begin(); it != _ents->end(); it++) {
+		e = *it;
+		if (e == _player || !e->onScreen)
+			continue;
+		if (e->x > (_player->x - 32 - leftBorder) && e->x < (_player->x + 32 + rightBorder) && e->y >(_player->y - 32 - topBorder) && e->y < (_player->y + 32 + bottomBorder))
+			return e;
+	}
+	return NULL;
+}
+
+bool AI::checkPlayerTileCollision(int x, int y) {
+	debug(9, "STUB: checkPlayerTileCollison: g_hdb->getDebug() required");
+	return (_player->tileX == x && _player->tileY == y);
+}
+
+bool AI::checkPlayerCollision(int x, int y, int border) {
+	debug(9, "STUB: checkPlayerCollison: g_hdb->getDebug() required");
+	return (x > (_player->x - 32 + border) && x < (_player->x - 32 - border) && y >(_player->y - 32 + border) && y < (_player->y - 32 - border));
+}
+
 bool AI::checkFloating(int x, int y) {
 	for (Common::Array<AIEntity *>::iterator it = _floats->begin(); it != _floats->end(); it++) {
 		if ((*it)->tileX == x && (*it)->tileY == y)
diff --git a/engines/hdb/ai.h b/engines/hdb/ai.h
index 04c2018..9c49e3e 100644
--- a/engines/hdb/ai.h
+++ b/engines/hdb/ai.h
@@ -652,6 +652,10 @@ public:
 	void addAnimateTarget(int x, int y, int start, int end, AnimSpeed speed, bool killAuto, bool inMap, const char *tileName);
 	void animateTargets();
 
+	AIEntity *playerCollision(int topBorder, int bottomBorder, int leftBorder, int rightBorder);
+	bool checkPlayerTileCollision(int x, int y);
+	bool checkPlayerCollision(int x, int y, int border);
+
 	// List functions
 	void addToActionList(int actionIndex, int x, int y, char *funcLuaInit, char *funcLuaUse);
 	bool checkActionList(AIEntity *e, int x, int y, bool lookAndGrab);


Commit: ace7d2754616ce0df48bd1314095d0e8907d729a
    https://github.com/scummvm/scummvm/commit/ace7d2754616ce0df48bd1314095d0e8907d729a
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:16:59+02:00

Commit Message:
HDB: Add _arrowPaths data

Changed paths:
    engines/hdb/ai-init.cpp
    engines/hdb/ai.h


diff --git a/engines/hdb/ai-init.cpp b/engines/hdb/ai-init.cpp
index cc5bd94..c15f5a1 100644
--- a/engines/hdb/ai-init.cpp
+++ b/engines/hdb/ai-init.cpp
@@ -670,6 +670,7 @@ AI::AI() {
 	_ents = new Common::Array<AIEntity *>;
 	_floats = new Common::Array<AIEntity *>;
 	_animTargets = new Common::Array<AnimTarget *>;
+	_arrowPaths = new Common::Array<ArrowPath *>;
 
 	// REMOVE: Remove for final. Used here due to lack of a MENU
 	_numGems = _numGooCups = _numMonkeystones = _numInventory = 0;
@@ -682,6 +683,7 @@ AI::~AI() {
 	delete _ents;
 	delete _floats;
 	delete _animTargets;
+	delete _arrowPaths;
 }
 
 bool AI::init() {
@@ -832,6 +834,12 @@ void AI::restartSystem() {
 	// Clear the Entity List
 	_ents->clear();
 
+	// Clear Anim Targets List
+	_animTargets->clear();
+
+	// Clear ArrowPath List
+	_arrowPaths->clear();
+
 	// Clear Cinematic System
 	_cineActive = _cameraLock = _playerLock = _cineAborted = false;
 
diff --git a/engines/hdb/ai.h b/engines/hdb/ai.h
index 9c49e3e..fec5783 100644
--- a/engines/hdb/ai.h
+++ b/engines/hdb/ai.h
@@ -583,6 +583,14 @@ struct AutoAction {
 	AutoAction() : x(0), y(0), activated(false), luaFuncInit(""), luaFuncUse(""), entityName("") {}
 };
 
+struct ArrowPath {
+	uint16 type;
+	AIDir dir;
+	uint16 tileX, tileY;
+
+	ArrowPath() : type(0), dir(DIR_NONE), tileX(0), tileY(0) {}
+};
+
 struct CineCommand {
 	CineType cmdType;
 	double x, y;
@@ -937,6 +945,8 @@ public:
 
 	AutoAction _autoActions[kMaxAutoActions];
 
+	Common::Array<ArrowPath *> *_arrowPaths;
+
 	// Virtual Player
 	AIEntity _dummyPlayer;
 


Commit: 1bfa1c1d0e82dec80177e39aed0f7c2885ecaac4
    https://github.com/scummvm/scummvm/commit/1bfa1c1d0e82dec80177e39aed0f7c2885ecaac4
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:16:59+02:00

Commit Message:
HDB: Add addToPathList() and findArrowPath()

Changed paths:
    engines/hdb/ai-lists.cpp
    engines/hdb/ai.h


diff --git a/engines/hdb/ai-lists.cpp b/engines/hdb/ai-lists.cpp
index 174729b..d47bae7 100644
--- a/engines/hdb/ai-lists.cpp
+++ b/engines/hdb/ai-lists.cpp
@@ -418,4 +418,23 @@ bool AI::autoActive(int x, int y) {
 	return false;
 }
 
+void AI::addToPathList(int x, int y, int type, AIDir dir) {
+	ArrowPath *arrowPath = new ArrowPath;
+
+	arrowPath->type = type;
+	arrowPath->tileX = x;
+	arrowPath->tileX = y;
+	arrowPath->dir = dir;
+
+	_arrowPaths->push_back(arrowPath);
+}
+
+ArrowPath *AI::findArrowPath(int x, int y) {
+	for (Common::Array<ArrowPath *>::iterator it = _arrowPaths->begin(); it != _arrowPaths->end(); it++) {
+		if ((*it)->tileX == x && (*it)->tileY == y)
+			return *it;
+	}
+	return NULL;
+}
+
 } // End of Namespace
diff --git a/engines/hdb/ai.h b/engines/hdb/ai.h
index fec5783..b5cf719 100644
--- a/engines/hdb/ai.h
+++ b/engines/hdb/ai.h
@@ -672,6 +672,8 @@ public:
 	bool activateAction(AIEntity *e, int x, int y, int targetX, int targetY);
 	bool checkAutoList(AIEntity *e, int x, int y);
 	bool autoActive(int x, int y);
+	void addToPathList(int x, int y, int type, AIDir dir);
+	ArrowPath *findArrowPath(int x, int y);
 
 	bool checkFloating(int x, int y);
 


Commit: b9b19478942727f84e42df81295b61fff322780d
    https://github.com/scummvm/scummvm/commit/b9b19478942727f84e42df81295b61fff322780d
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:16:59+02:00

Commit Message:
HDB: Remove addToPathList stubs

Changed paths:
    engines/hdb/map-loader.cpp


diff --git a/engines/hdb/map-loader.cpp b/engines/hdb/map-loader.cpp
index 25ff4ea..c8a31f5 100644
--- a/engines/hdb/map-loader.cpp
+++ b/engines/hdb/map-loader.cpp
@@ -445,13 +445,28 @@ bool Map::load(Common::SeekableReadStream *stream) {
 			);
 			break;
 		case INFO_ARROW_4WAY:
-			warning("STUB: Map::load: AddToPathList required");
+			g_hdb->_ai->addToPathList(
+				_iconList[i].x,
+				_iconList[i].y,
+				2,
+				aiInfo[_iconList[i].icon].dir
+			);
 			break;
 		case INFO_ARROW_TURN:
-			warning("STUB: Map::load: AddToPathList required");
+			g_hdb->_ai->addToPathList(
+				_iconList[i].x,
+				_iconList[i].y,
+				1,
+				aiInfo[_iconList[i].icon].dir
+			);
 			break;
 		case INFO_ARROW_STOP:
-			warning("STUB: Map::load: AddToPathList required");
+			g_hdb->_ai->addToPathList(
+				_iconList[i].x,
+				_iconList[i].y,
+				0,
+				aiInfo[_iconList[i].icon].dir
+			);
 			break;
 
 		case INFO_ACTION1:


Commit: fcdd7511d1a9648b9692fb05cc93eeaa6fedfc02
    https://github.com/scummvm/scummvm/commit/fcdd7511d1a9648b9692fb05cc93eeaa6fedfc02
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:16:59+02:00

Commit Message:
HDB: Add findPath()

Changed paths:
    engines/hdb/ai-funcs.cpp
    engines/hdb/ai.h
    engines/hdb/hdb.h
    engines/hdb/map-loader.h


diff --git a/engines/hdb/ai-funcs.cpp b/engines/hdb/ai-funcs.cpp
index 585d333..f13e9d5 100644
--- a/engines/hdb/ai-funcs.cpp
+++ b/engines/hdb/ai-funcs.cpp
@@ -1375,6 +1375,60 @@ int AI::checkForTouchplate(int x, int y) {
 	return 0;
 }
 
+bool AI::findPath(AIEntity *e) {
+	int x, y, xv = 0, yv = 0, max;
+	ArrowPath *here;
+
+	// Initial Pointing Direction to search in
+	x = e->tileX;
+	y = e->tileY;
+	here = findArrowPath(x, y);
+	// Only look for GO arrows at this first location
+	if (here && here->type == 1)
+		e->dir = here->dir;
+
+	switch (e->dir) {
+	case DIR_UP:
+		yv = -1;
+		break;
+	case DIR_DOWN:
+		yv = 1;
+		break;
+	case DIR_LEFT:
+		xv = -1;
+		break;
+	case DIR_RIGHT:
+		xv = 1;
+		break;
+	case DIR_NONE:
+		warning("findPath: DIR_NONE found");
+		break;
+	}
+
+	if (xv)
+		max = g_hdb->_map->_width;
+	else
+		max = g_hdb->_map->_height;
+
+	ArrowPath *arrowPath;
+	uint32 flags;
+	while (max--) {
+		arrowPath = findArrowPath(x + xv, y + yv);
+		if (arrowPath) {
+			setEntityGoal(e, arrowPath->tileX, arrowPath->tileY);
+			return true;
+		} else {
+			flags = g_hdb->_map->getMapBGTileFlags(x + xv, y + yv);
+			if (flags & kFlagSolid)
+				return false;
+		}
+		x += xv;
+		y += yv;
+	}
+
+	return false;
+}
+
 AIEntity *AI::legalMove(int tileX, int tileY, int level, int *result) {
 	uint32 bgFlags = g_hdb->_map->getMapBGTileFlags(tileX, tileY);
 	uint32 fgFlags = g_hdb->_map->getMapFGTileFlags(tileX, tileY);
diff --git a/engines/hdb/ai.h b/engines/hdb/ai.h
index b5cf719..bd25f55 100644
--- a/engines/hdb/ai.h
+++ b/engines/hdb/ai.h
@@ -654,6 +654,7 @@ public:
 	void moveEnts();
 
 	int checkForTouchplate(int x, int y);
+	bool findPath(AIEntity *e);
 	AIEntity *legalMove(int tileX, int tileY, int level, int *result);
 	AIEntity *legalMoveOverWater(int tileX, int tileY, int level, int *result);
 	AIEntity *legalMoveOverWaterIgnore(int tileX, int tileY, int level, int *result, AIEntity *ignore);
diff --git a/engines/hdb/hdb.h b/engines/hdb/hdb.h
index 139d610..319db92 100644
--- a/engines/hdb/hdb.h
+++ b/engines/hdb/hdb.h
@@ -70,10 +70,13 @@ enum GameState {
 };
 
 enum Flag {
+	kFlagMonsterBlock	= 0x2,
 	kFlagSolid			= 0x3,
 	kFlagPlayerDie		= 0x8,
 	kFlagInvisible		= 0x20,
 	kFlagForeground		= 0x80,
+	kFlagSlime			= 0x201C,
+	kFlagWater			= 0x401C,
 	kFlagEnergyFloor	= 0x40000,
 	kFlagPlasmaFloor	= 0x6000D,
 	kFlagRadFloor		= 0x6800D,
@@ -81,9 +84,10 @@ enum Flag {
 	kFlagStairTop		= 0x400000,
 	kFlagAnimSlow		= 0x800000,
 	kFlagAnimMedium		= 0x1000000,
+	kFlagMasked			= 0x2000000,
 	kFlagAnimFast		= 0x1800000,
 	kFlagGrating		= 0x4000000,
-	kFlagMasked			= 0x2000000
+	kFlagPlummet		= 0x8000000
 };
 
 enum {
diff --git a/engines/hdb/map-loader.h b/engines/hdb/map-loader.h
index f59159a..69c82a8 100644
--- a/engines/hdb/map-loader.h
+++ b/engines/hdb/map-loader.h
@@ -77,6 +77,16 @@ public:
 	void drawGratings();
 	void drawForegrounds();
 
+	bool isLoaded() {
+		return _mapLoaded;
+	}
+
+	bool onScreen(int x, int y) {
+		if ((x >= _mapX / kTileWidth) && (x < (_mapX / kTileWidth) + kScreenXTiles) && (y >= _mapY / kTileHeight) && (y < (_mapY / kTileHeight) + kScreenYTiles))
+			return true;
+		return false;
+	}
+
 	uint32 getMapBGTileFlags(int x, int y);
 	uint32 getMapFGTileFlags(int x, int y);
 	uint16 getMapBGTileIndex(int x, int y);
@@ -95,6 +105,7 @@ public:
 	// Check if one of the tiles in a range exists in the map on either layer
 	bool checkOneTileExistInRange(int tileIndex, int count);
 
+	uint16 _width, _height;
 	int _mapX, _mapY; // Coordinates of Map
 	int _mapTileX, _mapTileY; // Tile Coordinates of Map
 	int _mapTileXOff, _mapTileYOff; // Tile Coordinates Offset (0-31)
@@ -112,8 +123,6 @@ public:
 
 private:
 	char _name[32];
-	uint16 _width;
-	uint16 _height;
 	uint32 _backgroundOffset;
 	uint32 _foregroundOffset;
 	uint16 _iconNum;


Commit: bb674ec9c190bd19f4ce9e26c20e6ad92cb89986
    https://github.com/scummvm/scummvm/commit/bb674ec9c190bd19f4ce9e26c20e6ad92cb89986
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:16:59+02:00

Commit Message:
HDB: Add OmniBot functions

Changed paths:
  A engines/hdb/ai-bots.cpp
    engines/hdb/ai-player.cpp
    engines/hdb/module.mk


diff --git a/engines/hdb/ai-bots.cpp b/engines/hdb/ai-bots.cpp
new file mode 100644
index 0000000..25d734a
--- /dev/null
+++ b/engines/hdb/ai-bots.cpp
@@ -0,0 +1,132 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "hdb/hdb.h"
+
+namespace HDB {
+
+void aiOmniBotInit(AIEntity *e) {
+	if (e->value1 == 1)
+		e->aiAction = aiOmniBotMove;
+	else if (g_hdb->_ai->findPath(e))
+		e->aiAction = aiOmniBotAction;
+}
+
+void aiOmniBotInit2(AIEntity *e) {
+	e->standdownGfx[0] = e->movedownGfx[0];
+	e->standupGfx[0] = e->movedownGfx[0];
+	e->standleftGfx[0] = e->moveleftGfx[0];
+	e->standrightGfx[0] = e->moverightGfx[0];
+	e->standdownFrames = e->standupFrames = e->standleftFrames = e->standrightFrames = 1;
+	e->draw = g_hdb->_ai->getStandFrameDir(e);
+}
+
+void aiOmniBotMove(AIEntity *e) {
+	if (e->goalX)
+		g_hdb->_ai->animateEntity(e);
+	else
+		g_hdb->_ai->animEntFrames(e);
+}
+
+void aiOmniBotAction(AIEntity *e) {
+	AIEntity *p = g_hdb->_ai->getPlayer();
+	if (e->goalX) {
+		if (!e->sequence) {
+			g_hdb->_ai->animateEntity(e);
+			// Is the Player collding?
+			if (e->onScreen && (p->level = e->level) && g_hdb->_ai->checkPlayerCollision(e->x, e->y, 4) && !g_hdb->_ai->playerDead()) {
+				g_hdb->_ai->killPlayer(DEATH_FRIED);
+				return;
+			}
+
+			// Shoot player ?
+			if (onEvenTile(e->x, e->y) && g_hdb->getActionMode()) {
+				int xv = 0, yv = 0, result;
+				int shoot = 0;
+				AIEntity *omni;
+				// FIXME: Is reloading Player required here?
+				p = g_hdb->_ai->getPlayer();
+
+				// On same level/screen?
+				if ((e->level != p->level) || g_hdb->_ai->playerDead() || !e->onScreen)
+					return;
+
+				// Is Player in Line of Sight?
+				switch (e->dir) {
+				case DIR_UP:
+					if (p->x == e->x && p->y < e->y) {
+						shoot = 1;
+						yv = -1;
+					}
+					break;
+				case DIR_DOWN:
+					if (p->x == e->x && p->y > e->y) {
+						shoot = 1;
+						yv = 1;
+					}
+					break;
+				case DIR_LEFT:
+					if (p->x < e->x && p->y == e->y) {
+						shoot = 1;
+						xv = -1;
+					}
+					break;
+				case DIR_RIGHT:
+					if (p->x > e->x && p->y == e->y) {
+						shoot = 1;
+						xv = 1;
+					}
+					break;
+				case DIR_NONE:
+					warning("aiOmniBotAction: DIR_NONE found");
+					break;
+				}
+
+				// If shoot = 1, take the shot
+				// (1) Check we're not shooting into a solid tile
+				// (2) Check we're not shooting into an Entity unless it's the player
+				AIEntity *hit = g_hdb->_ai->legalMoveOverWater(e->tileX+xv, e->tileY + yv, e->level, &result);
+				if (shoot && !hit && result) {
+					omni = g_hdb->_ai->spawn(AI_OMNIBOT_MISSILE, e->dir, e->tileX + xv, e->tileY + yv, NULL, NULL, NULL, DIR_NONE, e->level, 0, 0, 1);
+					omni->xVel = xv * kPlayerMoveSpeed * 2;
+					omni->yVel = yv * kPlayerMoveSpeed * 2;
+					if (g_hdb->_map->onScreen(e->tileX, e->tileY))
+						warning("STUB: aiOmniBotAction: Play SND_OMNIBOT_FIRE");
+					if (!g_hdb->getActionMode()) {
+						omni->xVel >>= 1;
+						omni->yVel >>= 1;
+					}
+					e->sequence = 16;
+				}
+			}
+		}
+	} else {
+		g_hdb->_ai->findPath(e);
+		if (e->onScreen)
+			warning("STUB: aiOmniBotAction: Play SND_OMNIBOT_AMBIENT");
+	}
+
+	if (e->sequence)
+		e->sequence--;
+}
+
+} // End of Namespace
diff --git a/engines/hdb/ai-player.cpp b/engines/hdb/ai-player.cpp
index 4cace98..940ddcb 100644
--- a/engines/hdb/ai-player.cpp
+++ b/engines/hdb/ai-player.cpp
@@ -480,14 +480,6 @@ void aiPushBotAction(AIEntity *e) {
 	warning("STUB: AI: aiPushBotAction required");
 }
 
-void aiOmniBotAction(AIEntity *e) {
-	warning("STUB: AI: aiOmniBotAction required");
-}
-
-void aiOmniBotMove(AIEntity *e) {
-	warning("STUB: AI: aiOmniBotMove required");
-}
-
 void aiLaserAction(AIEntity *e) {
 	warning("STUB: AI: aiLaserAction required");
 }
@@ -588,14 +580,6 @@ void aiListenBotInit2(AIEntity *e) {
 	warning("STUB: AI: aiListenBotInit2 required");
 }
 
-void aiOmniBotInit(AIEntity *e) {
-	warning("STUB: AI: aiOmniBotInit required");
-}
-
-void aiOmniBotInit2(AIEntity *e) {
-	warning("STUB: AI: aiOmniBotInit2 required");
-}
-
 void aiLaserInit(AIEntity *e) {
 	warning("STUB: AI: aiLaserInit required");
 }
diff --git a/engines/hdb/module.mk b/engines/hdb/module.mk
index 432998d..bf53ad0 100644
--- a/engines/hdb/module.mk
+++ b/engines/hdb/module.mk
@@ -1,6 +1,7 @@
 MODULE := engines/hdb
 
 MODULE_OBJS := \
+	ai-bots.o \
 	ai-cinematic.o \
 	ai-funcs.o \
 	ai-init.o \


Commit: 087f84b38b94ee56e67c874cb281bec057f6cb80
    https://github.com/scummvm/scummvm/commit/087f84b38b94ee56e67c874cb281bec057f6cb80
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:16:59+02:00

Commit Message:
HDB: Add aiOmniBotMissile functions

Changed paths:
    engines/hdb/ai-bots.cpp
    engines/hdb/ai-player.cpp


diff --git a/engines/hdb/ai-bots.cpp b/engines/hdb/ai-bots.cpp
index 25d734a..24e9cfb 100644
--- a/engines/hdb/ai-bots.cpp
+++ b/engines/hdb/ai-bots.cpp
@@ -129,4 +129,44 @@ void aiOmniBotAction(AIEntity *e) {
 		e->sequence--;
 }
 
+void aiOmniBotMissileInit(AIEntity *e) {
+	e->state = STATE_MOVEDOWN;
+	e->aiAction = aiOmniBotMissileAction;
+}
+
+void aiOmniBotMissileInit2(AIEntity *e) {
+	for (int i = 0; i < e->movedownFrames;i++)
+		e->moveleftGfx[i] = e->moverightGfx[i] = e->moveupGfx[i] = e->movedownGfx[i];
+
+	e->moveleftFrames = e->moverightFrames = e->moveupFrames = e->movedownFrames;
+	e->draw = e->movedownGfx[0];
+}
+
+void aiOmniBotMissileAction(AIEntity *e) {
+	AIEntity *p = g_hdb->_ai->getPlayer();
+
+	g_hdb->_ai->animEntFrames(e);
+	e->x += e->xVel;
+	e->y += e->yVel;
+	e->tileX = e->x / kTileWidth;
+	e->tileY = e->y / kTileHeight;
+
+	// Did we hit a solid wall?
+	int result;
+	AIEntity *hit = g_hdb->_ai->legalMoveOverWaterIgnore(e->tileX, e->tileY, e->level, &result, e);
+
+	if (hit || !result) {
+		g_hdb->_ai->addAnimateTarget(e->x, e->y, 0, 3, ANIM_FAST, false, false, "steam_puff_sit");
+		g_hdb->_ai->removeEntity(e);
+	}
+
+	// On Even tiles, check for hitting player
+	if (onEvenTile(e->x, e->y))
+		if (e->onScreen && (p->level == e->level) && g_hdb->_ai->checkPlayerCollision(e->x, e->y, 4) && !g_hdb->_ai->playerDead()) {
+			g_hdb->_ai->killPlayer(DEATH_NORMAL);
+			g_hdb->_ai->addAnimateTarget(e->x, e->y, 0, 3, ANIM_FAST, false, false, "steam_puff_sit");
+			g_hdb->_ai->removeEntity(e);
+		}
+}
+
 } // End of Namespace
diff --git a/engines/hdb/ai-player.cpp b/engines/hdb/ai-player.cpp
index 940ddcb..32de22b 100644
--- a/engines/hdb/ai-player.cpp
+++ b/engines/hdb/ai-player.cpp
@@ -380,18 +380,6 @@ void aiRailRiderOnAction(AIEntity *e) {
 	warning("STUB: AI: aiRailRiderOnAction required");
 }
 
-void aiOmniBotMissileAction(AIEntity *e) {
-	warning("STUB: AI: aiOmniBotMissileAction required");
-}
-
-void aiOmniBotMissileInit(AIEntity *e) {
-	warning("STUB: AI: aiOmniBotMissileInit required");
-}
-
-void aiOmniBotMissileInit2(AIEntity *e) {
-	warning("STUB: AI: aiOmniBotMissileInit2 required");
-}
-
 void aiSlugAttackAction(AIEntity *e) {
 	warning("STUB: AI: aiSlugAttackAction required");
 }


Commit: 63358b754e54ed96324bd42bbb2780c8f0302cf3
    https://github.com/scummvm/scummvm/commit/63358b754e54ed96324bd42bbb2780c8f0302cf3
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:16:59+02:00

Commit Message:
HDB: Add aiTurnBot functions

Changed paths:
    engines/hdb/ai-bots.cpp
    engines/hdb/ai-player.cpp


diff --git a/engines/hdb/ai-bots.cpp b/engines/hdb/ai-bots.cpp
index 24e9cfb..f3c89dc 100644
--- a/engines/hdb/ai-bots.cpp
+++ b/engines/hdb/ai-bots.cpp
@@ -169,4 +169,57 @@ void aiOmniBotMissileAction(AIEntity *e) {
 		}
 }
 
+void aiTurnBotInit(AIEntity *e) {
+	e->aiAction = aiTurnBotAction;
+}
+
+void aiTurnBotInit2(AIEntity *e) {
+	e->draw = g_hdb->_ai->getStandFrameDir(e);
+}
+
+void aiTurnBotChoose(AIEntity *e) {
+	int xvAhead[5] = { 9, 0, 0, -1, 1 }, yvAhead[5] = { 9, -1, 1, 0, 0 };
+	AIDir turnRight[5] = { DIR_NONE, DIR_RIGHT, DIR_LEFT, DIR_UP, DIR_DOWN };
+	AIState dirState[5] = { STATE_NONE, STATE_MOVEUP, STATE_MOVEDOWN, STATE_MOVELEFT, STATE_MOVERIGHT };
+	int xv, yv;
+
+	xv = xvAhead[e->dir];
+	yv = yvAhead[e->dir];
+	if (g_hdb->_map->getMapBGTileFlags(e->tileX + xv, e->tileY + yv) & (kFlagSolid | kFlagWater)) {
+		e->xVel = e->yVel = 0;
+		e->animFrame = 0;
+		e->animDelay = e->animCycle;
+		e->dir = turnRight[e->dir];
+		e->state = dirState[e->dir];
+	} else {
+		e->xVel = xv * kPlayerMoveSpeed;
+		e->yVel = yv * kPlayerMoveSpeed;
+		if (!g_hdb->getActionMode()) {
+			e->xVel >>= 1;
+			e->yVel >>= 1;
+		}
+		e->goalX = e->tileX + xv;
+		e->goalY = e->tileY + yv;
+		e->state = dirState[e->dir];
+		if (e->dir == DIR_DOWN)
+			e->animFrame = 3;
+	}
+}
+
+
+void aiTurnBotAction(AIEntity *e) {
+	if (e->goalX)
+		g_hdb->_ai->animateEntity(e);
+	else {
+		aiTurnBotChoose(e);
+		g_hdb->_ai->animateEntity(e);
+		if (e->onScreen)
+			warning("STUB: aiTurnBotAction: Play SND_TURNBOT_TURN");
+	}
+
+	if (e->onScreen && onEvenTile(e->x, e->y) && g_hdb->_ai->checkPlayerCollision(e->x, e->y, 0) && !g_hdb->_ai->playerDead())
+		g_hdb->_ai->killPlayer(DEATH_NORMAL);
+}
+
+
 } // End of Namespace
diff --git a/engines/hdb/ai-player.cpp b/engines/hdb/ai-player.cpp
index 32de22b..d585d9b 100644
--- a/engines/hdb/ai-player.cpp
+++ b/engines/hdb/ai-player.cpp
@@ -460,10 +460,6 @@ void aiSlugSlingerInit2(AIEntity *e) {
 	warning("STUB: AI: aiSlugSlingerInit2 required");
 }
 
-void aiTurnBotAction(AIEntity *e) {
-	warning("STUB: AI: aiTurnBotAction required");
-}
-
 void aiPushBotAction(AIEntity *e) {
 	warning("STUB: AI: aiPushBotAction required");
 }
@@ -552,14 +548,6 @@ void aiDragonDraw(AIEntity *e, int mx, int my) {
 	warning("STUB: AI: aiDragonDraw required");
 }
 
-void aiTurnBotInit(AIEntity *e) {
-	warning("STUB: AI: aiTurnBotInit required");
-}
-
-void aiTurnBotInit2(AIEntity *e) {
-	warning("STUB: AI: aiTurnBotInit2 required");
-}
-
 void aiListenBotInit(AIEntity *e) {
 	warning("STUB: AI: aiListenBotInit required");
 }


Commit: 855fd3805cde972f6a702206b8ea2a16f95483af
    https://github.com/scummvm/scummvm/commit/855fd3805cde972f6a702206b8ea2a16f95483af
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:16:59+02:00

Commit Message:
HDB: Fix space formatting

Changed paths:
    engines/hdb/ai-bots.cpp
    engines/hdb/draw-manager.cpp


diff --git a/engines/hdb/ai-bots.cpp b/engines/hdb/ai-bots.cpp
index f3c89dc..54c0d18 100644
--- a/engines/hdb/ai-bots.cpp
+++ b/engines/hdb/ai-bots.cpp
@@ -135,7 +135,7 @@ void aiOmniBotMissileInit(AIEntity *e) {
 }
 
 void aiOmniBotMissileInit2(AIEntity *e) {
-	for (int i = 0; i < e->movedownFrames;i++)
+	for (int i = 0; i < e->movedownFrames; i++)
 		e->moveleftGfx[i] = e->moverightGfx[i] = e->moveupGfx[i] = e->movedownGfx[i];
 
 	e->moveleftFrames = e->moverightFrames = e->moveupFrames = e->movedownFrames;
diff --git a/engines/hdb/draw-manager.cpp b/engines/hdb/draw-manager.cpp
index 23bfb35..133a24d 100644
--- a/engines/hdb/draw-manager.cpp
+++ b/engines/hdb/draw-manager.cpp
@@ -517,7 +517,7 @@ void DrawMan::drawText(const char *string) {
 	}
 
 	// Draw the characters
-	for (int j = 0; j < (int)strlen(string);j++) {
+	for (int j = 0; j < (int)strlen(string); j++) {
 		c = string[j];
 		if (c == '\n' || cr[j]) {
 			_cursorX = _eLeft;


Commit: 595b520f4aaff697b62d049928763eafab29f3c0
    https://github.com/scummvm/scummvm/commit/595b520f4aaff697b62d049928763eafab29f3c0
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:16:59+02:00

Commit Message:
HDB: Add checkEntOnScreen() and checkXYOnScreen()

Changed paths:
    engines/hdb/map-loader.cpp
    engines/hdb/map-loader.h


diff --git a/engines/hdb/map-loader.cpp b/engines/hdb/map-loader.cpp
index c8a31f5..04a5ee6 100644
--- a/engines/hdb/map-loader.cpp
+++ b/engines/hdb/map-loader.cpp
@@ -942,6 +942,14 @@ void Map::centerMapXY(int x, int y) {
 	setMapXY(x, y);
 }
 
+bool Map::checkEntOnScreen(AIEntity *e) {
+	return ((e->x > _mapX - 32) && (e->x < _mapX + kScreenXTiles * kTileWidth) && (e->y > _mapY - 32) && (e->y < kScreenYTiles * kTileHeight));
+}
+
+bool Map::checkXYOnScreen(int x, int y) {
+	return ((x > _mapX - 32) && (x < _mapX + kScreenXTiles * kTileWidth) && (y > _mapY - 32) && (y < kScreenYTiles * kTileHeight));
+}
+
 bool Map::checkOneTileExistInRange(int tileIndex, int count) {
 	for (int i = 0; i < _width*_height; i++) {
 		if (_background[i] >= tileIndex && _background[i] < tileIndex + count)
diff --git a/engines/hdb/map-loader.h b/engines/hdb/map-loader.h
index 69c82a8..f94c2a7 100644
--- a/engines/hdb/map-loader.h
+++ b/engines/hdb/map-loader.h
@@ -101,6 +101,8 @@ public:
 	void getMapXY(int *x, int *y);
 	void setMapXY(int x, int y);
 	void centerMapXY(int x, int y);
+	bool checkEntOnScreen(AIEntity *);
+	bool checkXYOnScreen(int x, int y);
 
 	// Check if one of the tiles in a range exists in the map on either layer
 	bool checkOneTileExistInRange(int tileIndex, int count);


Commit: 88bab8cc79ab5f13cec7124564224773b2026ef6
    https://github.com/scummvm/scummvm/commit/88bab8cc79ab5f13cec7124564224773b2026ef6
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:16:59+02:00

Commit Message:
HDB: Add getter-setter for _mapExplosions

Changed paths:
    engines/hdb/map-loader.h


diff --git a/engines/hdb/map-loader.h b/engines/hdb/map-loader.h
index f94c2a7..83307b9 100644
--- a/engines/hdb/map-loader.h
+++ b/engines/hdb/map-loader.h
@@ -107,6 +107,13 @@ public:
 	// Check if one of the tiles in a range exists in the map on either layer
 	bool checkOneTileExistInRange(int tileIndex, int count);
 
+	bool explosionExist(int x, int y) {
+		return _mapExplosions[y * _width + x];
+	}
+	void setExplosion(int x, int y, int value) {
+		_mapExplosions[y * _width + x] = value;
+	}
+
 	uint16 _width, _height;
 	int _mapX, _mapY; // Coordinates of Map
 	int _mapTileX, _mapTileY; // Tile Coordinates of Map


Commit: ca15646569b48f26a29707dbcdf186371377ec00
    https://github.com/scummvm/scummvm/commit/ca15646569b48f26a29707dbcdf186371377ec00
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:16:59+02:00

Commit Message:
HDB: Add getter-setter function for _mapExplosions

Changed paths:
    engines/hdb/map-loader.h


diff --git a/engines/hdb/map-loader.h b/engines/hdb/map-loader.h
index 83307b9..199d9fe 100644
--- a/engines/hdb/map-loader.h
+++ b/engines/hdb/map-loader.h
@@ -114,6 +114,16 @@ public:
 		_mapExplosions[y * _width + x] = value;
 	}
 
+	bool laserBeamExist(int x, int y) {
+		return _mapLaserBeams[y * _width + x];
+	}
+	void setLaserBeam(int x, int y, int value) {
+		_mapLaserBeams[y * _width + x] = value;
+	}
+	void clearLaserBeams() {
+		memset(_mapLaserBeams, 0, _width * _height);
+	}
+
 	uint16 _width, _height;
 	int _mapX, _mapY; // Coordinates of Map
 	int _mapTileX, _mapTileY; // Tile Coordinates of Map


Commit: 10246121e082f1c5dda7cf9b7171244d6811c27d
    https://github.com/scummvm/scummvm/commit/10246121e082f1c5dda7cf9b7171244d6811c27d
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:00+02:00

Commit Message:
HDB: Add getter-setter for _mapExpBarrels

Changed paths:
    engines/hdb/map-loader.h


diff --git a/engines/hdb/map-loader.h b/engines/hdb/map-loader.h
index 199d9fe..62d494c 100644
--- a/engines/hdb/map-loader.h
+++ b/engines/hdb/map-loader.h
@@ -114,6 +114,13 @@ public:
 		_mapExplosions[y * _width + x] = value;
 	}
 
+	bool boomBarrelExist(int x, int y) {
+		return _mapExpBarrels[y * _width + x];
+	}
+	void setBoomBarrel(int x, int y, int value) {
+		_mapExpBarrels[y * _width + x] = value;
+	}
+
 	bool laserBeamExist(int x, int y) {
 		return _mapLaserBeams[y * _width + x];
 	}


Commit: 4657593aa414616f2611680d1d0147619ef0330b
    https://github.com/scummvm/scummvm/commit/4657593aa414616f2611680d1d0147619ef0330b
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:00+02:00

Commit Message:
HDB: Add aiShockBot functions

Changed paths:
    engines/hdb/ai-bots.cpp
    engines/hdb/ai-player.cpp
    engines/hdb/hdb.h


diff --git a/engines/hdb/ai-bots.cpp b/engines/hdb/ai-bots.cpp
index 54c0d18..faa4331 100644
--- a/engines/hdb/ai-bots.cpp
+++ b/engines/hdb/ai-bots.cpp
@@ -221,5 +221,75 @@ void aiTurnBotAction(AIEntity *e) {
 		g_hdb->_ai->killPlayer(DEATH_NORMAL);
 }
 
+void aiShockBotInit(AIEntity *e) {
+	g_hdb->_ai->findPath(e);
+	e->aiAction = aiShockBotAction;
+	e->animCycle = 0;
+	e->sequence = 0;
+	e->aiDraw = aiShockBotShock;
+}
+
+void aiShockBotInit2(AIEntity *e) {
+	e->standupFrames = e->standdownFrames = e->standleftFrames = e->standrightFrames =
+		e->moveupFrames = e->moverightFrames = e->moveleftFrames = e->movedownFrames;
+
+	for (int i = 0; i < e->movedownFrames; i++)
+		e->standupGfx[i] = e->standleftGfx[i] = e->standrightGfx[i] = e->standdownGfx[i] = e->moveupGfx[i] = e->moveleftGfx[i] = e->moverightGfx[i] = e->movedownGfx[i];
+
+	e->draw = g_hdb->_ai->getStandFrameDir(e);
+}
+
+void aiShockBotAction(AIEntity *e) {
+	if (e->goalX) {
+		if (!e->sequence) {
+			if (e->onScreen && g_hdb->_ai->checkPlayerCollision(e->x, e->y, 4) && !g_hdb->_ai->playerDead())
+				g_hdb->_ai->killPlayer(DEATH_SHOCKED);
+			g_hdb->_ai->animateEntity(e);
+		} else
+			g_hdb->_ai->animEntFrames(e);
+	} else {
+		g_hdb->_ai->findPath(e);
+		e->sequence = 20;
+		g_hdb->_ai->animEntFrames(e);
+		if (e->onScreen)
+			warning("STUB: aiShockBotAction: Play SND_SHOCKBOT_AMBIENT");
+
+	}
+
+	if (e->sequence)
+		e->sequence--;
+}
+
+void aiShockBotShock(AIEntity *e, int mx, int my) {
+	int offX[8] = { -1, 0, 1, 1, 1, 0, -1, -1 };
+	int offY[8] = { -1, -1, -1, 0, 1, 1, 1, 0 };
+
+	// Only on a exact tile boundary do we change the shocked tiles
+	// Start at top left and go around
+	if (g_hdb->_map->getMapBGTileFlags(e->tileX, e->tileY) & kFlagMetal)
+		e->special1Gfx[e->animFrame]->drawMasked(e->tileX * kTileWidth - mx, e->tileY * kTileHeight - my);
+
+	uint32 flags;
+	for (int i = 0; i < 8; i++) {
+		flags = g_hdb->_map->getMapBGTileFlags(e->tileX + offX[i], e->tileY + offY[i]);
+		if (flags & kFlagMetal) {
+			// Is the shocking tile onScreen?
+			if (g_hdb->_map->checkXYOnScreen((e->tileX + offX[i]) * kTileWidth, (e->tileY + offY[i]) * kTileHeight)) {
+				// Draw shocking tile animation
+				e->special1Gfx[e->animFrame]->drawMasked((e->tileX + offX[i])*kTileWidth - mx, (e->tileY + offY[i])*kTileHeight - my);
+				// Did the player get fried?
+				// Check every 4 frames
+				if (e->onScreen && !e->animFrame && g_hdb->_ai->checkPlayerTileCollision(e->tileX + offX[i], e->tileY + offY[i]) && !g_hdb->_ai->playerDead()) {
+					g_hdb->_ai->killPlayer(DEATH_SHOCKED);
+					return;
+				}
+				if (!e->animFrame && g_hdb->_map->boomBarrelExist(e->tileX + offX[i], e->tileY + offY[i])) {
+					AIEntity *e2 = g_hdb->_ai->findEntityType(AI_BOOMBARREL, e->tileX + offX[i], e->tileY + offY[i]);
+					aiBarrelExplode(e2);
+				}
+			}
+		}
+	}
+}
 
 } // End of Namespace
diff --git a/engines/hdb/ai-player.cpp b/engines/hdb/ai-player.cpp
index d585d9b..ea02deb 100644
--- a/engines/hdb/ai-player.cpp
+++ b/engines/hdb/ai-player.cpp
@@ -320,22 +320,6 @@ void aiMaintBotInitAction(AIEntity *e) {
 	warning("STUB: AI: aiMaintBotInitAction required");
 }
 
-void aiShockBotAction(AIEntity *e) {
-	warning("STUB: AI: aiShockBotAction required");
-}
-
-void aiShockBotShock(AIEntity *e, int mx, int my) {
-	warning("STUB: AI: aiShockBotShock required");
-}
-
-void aiShockBotInit(AIEntity *e) {
-	warning("STUB: AI: aiShockBotInit required");
-}
-
-void aiShockBotInit2(AIEntity *e) {
-	warning("STUB: AI: aiShockBotInit2 required");
-}
-
 void aiScientistInit(AIEntity *e) {
 	warning("STUB: AI: aiScientistInit required");
 }
diff --git a/engines/hdb/hdb.h b/engines/hdb/hdb.h
index 319db92..ab8cb24 100644
--- a/engines/hdb/hdb.h
+++ b/engines/hdb/hdb.h
@@ -74,6 +74,7 @@ enum Flag {
 	kFlagSolid			= 0x3,
 	kFlagPlayerDie		= 0x8,
 	kFlagInvisible		= 0x20,
+	kFlagMetal			= 0x40,
 	kFlagForeground		= 0x80,
 	kFlagSlime			= 0x201C,
 	kFlagWater			= 0x401C,


Commit: c01eb1a61e43e0e366f9649c699dc74e4788dbad
    https://github.com/scummvm/scummvm/commit/c01eb1a61e43e0e366f9649c699dc74e4788dbad
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:00+02:00

Commit Message:
HDB: Add RightBot functions

Changed paths:
    engines/hdb/ai-bots.cpp
    engines/hdb/ai-player.cpp
    engines/hdb/hdb.h


diff --git a/engines/hdb/ai-bots.cpp b/engines/hdb/ai-bots.cpp
index faa4331..098dedb 100644
--- a/engines/hdb/ai-bots.cpp
+++ b/engines/hdb/ai-bots.cpp
@@ -206,7 +206,6 @@ void aiTurnBotChoose(AIEntity *e) {
 	}
 }
 
-
 void aiTurnBotAction(AIEntity *e) {
 	if (e->goalX)
 		g_hdb->_ai->animateEntity(e);
@@ -292,4 +291,181 @@ void aiShockBotShock(AIEntity *e, int mx, int my) {
 	}
 }
 
+void aiRightBotInit(AIEntity *e) {
+	e->moveSpeed = kPlayerMoveSpeed;
+	if (!g_hdb->getActionMode())
+		e->moveSpeed >>= 1;
+	e->aiAction = aiRightBotAction;
+}
+
+void aiRightBotInit2(AIEntity *e) {
+	switch (e->dir) {
+	case DIR_UP:
+		e->draw = e->moveupGfx[0];
+		e->state = STATE_MOVEUP;
+		break;
+	case DIR_DOWN:
+		e->draw = e->movedownGfx[0];
+		e->state = STATE_MOVEDOWN;
+		break;
+	case DIR_LEFT:
+		e->draw = e->moveleftGfx[0];
+		e->state = STATE_MOVELEFT;
+		break;
+	case DIR_RIGHT:
+		e->draw = e->moverightGfx[0];
+		e->state = STATE_MOVERIGHT;
+		break;
+	case DIR_NONE:
+		warning("aiRightBotInit2: DIR_NONE found");
+		break;
+	}
+}
+
+void aiRightBotFindGoal(AIEntity *e) {
+	int	xv, yv, xv2, yv2, xv3, yv3;
+	int	bg, bg2, bg3;
+	AIEntity *e1, *e2, *e3, *p;
+	int	hit, sx, sy, rotate;
+
+	int		xvAhead[5]	= { 9, 0, 0,-1, 1 }, yvAhead[5]	= { 9,-1, 1, 0, 0 };
+	int		xvAToR[5]	= { 9, 1,-1,-1, 1 }, yvAToR[5]	= { 9,-1, 1,-1, 1 };
+	int		xvToR[5]	= { 9, 1,-1, 0, 0 }, yvToR[5]	= { 9, 0, 0,-1, 1 };
+	int		xvToL[5]	= { 9,-1, 1, 0, 0 }, yvToL[5]	= { 9, 0, 0, 1,-1 };
+
+	p = g_hdb->_ai->getPlayer();
+	rotate = 0;
+
+	do {
+		xv = xvAhead[e->dir];	// Search Ahead
+		yv = yvAhead[e->dir];
+		xv2 = xvAToR[e->dir];	// Search Ahead and to the Right
+		yv2 = yvAToR[e->dir];
+		xv3 = xvToR[e->dir];	// Search to the Right
+		yv3 = yvToR[e->dir];
+
+		// Search until we hit a wall...or empty space to our right (and forward)
+		hit = 0;
+		sx = e->tileX;
+		sy = e->tileY;
+
+		while (!hit) {
+			bg = g_hdb->_map->getMapBGTileFlags(sx + xv, sy + yv) & (kFlagSolid | kFlagWater | kFlagSlime | kFlagSpecial);
+			e1 = g_hdb->_ai->findEntity(sx + xv, sy + yv);
+			if (e1 && e1 == p)
+				e1 = NULL;
+			bg2 = g_hdb->_map->getMapBGTileFlags(sx + xv2, sy + yv2) & (kFlagSolid | kFlagWater | kFlagSlime | kFlagSpecial);
+			e2 = g_hdb->_ai->findEntity(sx + xv2, sy + yv2);
+			if (e2 && e2 == p)
+				e2 = NULL;
+			bg3 = g_hdb->_map->getMapBGTileFlags(sx + xv3, sy + yv3) & (kFlagSolid | kFlagWater | kFlagSlime | kFlagSpecial);
+			e3 = g_hdb->_ai->findEntity(sx + xv3, sy + yv3);
+			if (e3 && e3 == p)
+				e3 = NULL;
+
+			// Okay to move forward?
+			if ((!bg && !e1) && (bg2 || e2 || bg3 || e3)) {
+				sx += xv;
+				sy += yv;
+				rotate = 0;
+			} else
+				hit = 1;
+		}
+
+		// Are we stuck in a corner?
+		if (sx == e->tileX && sy == e->tileY) {
+			sx = e->tileX;
+			sy = e->tileY;
+			rotate += 1;
+
+			// Need to check for turning RIGHT when we're in a corner
+			xv = xvToL[e->dir];
+			yv = yvToL[e->dir];
+
+			// Check Tile flags to our left and right
+			bg = g_hdb->_map->getMapBGTileFlags(sx + xv, sy + yv) & (kFlagSolid | kFlagWater | kFlagSlime | kFlagSpecial);
+			e1 = g_hdb->_ai->findEntity(sx + xv, sy + yv);
+			bg2 = g_hdb->_map->getMapBGTileFlags(sx + xv3, sy + yv3) & (kFlagSolid | kFlagWater | kFlagSlime | kFlagSpecial);
+			e2 = g_hdb->_ai->findEntity(sx + xv3, sy + yv3);
+			if (e1 && e1->type == AI_GUY)
+				e1 = NULL;
+			if (e2 && e2->type == AI_GUY)
+				e2 = NULL;
+
+			// Is tile to the right clear?
+			// Is tile to the left clear?
+			// If neither, go backwards
+			if (!bg2 && !e2) {
+				switch (e->dir) {
+				case DIR_UP: e->dir = DIR_RIGHT; break;
+				case DIR_DOWN: e->dir = DIR_LEFT; break;
+				case DIR_LEFT: e->dir = DIR_UP; break;
+				case DIR_RIGHT: e->dir = DIR_DOWN; break;
+				case DIR_NONE:
+					warning("aiRightBotFindGoal: DIR_NONE found");
+				}
+			} else if (!bg && !e1) {
+				switch (e->dir) {
+				case DIR_UP: e->dir = DIR_LEFT; break;
+				case DIR_DOWN: e->dir = DIR_RIGHT; break;
+				case DIR_LEFT: e->dir = DIR_DOWN; break;
+				case DIR_RIGHT: e->dir = DIR_UP; break;
+				case DIR_NONE:
+					warning("aiRightBotFindGoal: DIR_NONE found");
+				}
+			} else {
+				switch (e->dir) {
+				case DIR_UP: e->dir = DIR_DOWN; yv = 1; xv = 0; break;
+				case DIR_DOWN: e->dir = DIR_UP; yv = -1; xv = 0; break;
+				case DIR_LEFT: e->dir = DIR_RIGHT; yv = 0; xv = 1; break;
+				case DIR_RIGHT: e->dir = DIR_LEFT; yv = 0; xv = -1; break;
+				case DIR_NONE:
+					warning("aiRightBotFindGoal: DIR_NONE found");
+				}
+				sx += xv;
+				sy += yv;
+				rotate = 4;
+			}
+		}
+	} while (rotate >= 1 && rotate < 4);
+
+	switch (e->dir) {
+	case DIR_UP:
+		e->state = STATE_MOVEUP;
+		break;
+	case DIR_DOWN:
+		e->state = STATE_MOVEDOWN;
+		break;
+	case DIR_LEFT:
+		e->state = STATE_MOVELEFT;
+		break;
+	case DIR_RIGHT:
+		e->state = STATE_MOVERIGHT;
+		break;
+	case DIR_NONE:
+		warning("aiRightBotFindGoal: DIR_NONE found");
+		break;
+	}
+
+	e->goalX = sx;
+	e->goalY = sy;
+	e->xVel = xv * e->moveSpeed;
+	e->yVel = yv * e->moveSpeed;
+	if (e->onScreen)
+		warning("STUB: aiRightBotFindGoal: Play SND_RIGHTBOT_TURN");
+}
+
+void aiRightBotAction(AIEntity *e) {
+	AIEntity *p = g_hdb->_ai->getPlayer();
+
+	if (e->goalX) {
+		if (e->onScreen && g_hdb->_ai->checkPlayerCollision(e->x, e->y, 0) && p->state != STATE_DEAD && p->level == e->level && !g_hdb->_ai->playerDead())
+			g_hdb->_ai->killPlayer(DEATH_NORMAL);
+		g_hdb->_ai->animateEntity(e);
+	} else {
+		aiRightBotFindGoal(e);
+		g_hdb->_ai->animEntFrames(e);
+	}
+}
+
 } // End of Namespace
diff --git a/engines/hdb/ai-player.cpp b/engines/hdb/ai-player.cpp
index ea02deb..f16765c 100644
--- a/engines/hdb/ai-player.cpp
+++ b/engines/hdb/ai-player.cpp
@@ -464,10 +464,6 @@ void aiDiverterDraw(AIEntity *e, int mx, int my) {
 	warning("STUB: AI: aiDiverterDraw required");
 }
 
-void aiRightBotAction(AIEntity *e) {
-	warning("STUB: AI: aiRightBotAction required");
-}
-
 void aiDeadEyeAction(AIEntity *e) {
 	warning("STUB: AI: aiDeadEyeAction required");
 }
@@ -556,14 +552,6 @@ void aiDiverterInit2(AIEntity *e) {
 	warning("STUB: AI: aiDiverterInit2 required");
 }
 
-void aiRightBotInit(AIEntity *e) {
-	warning("STUB: AI: aiRightBotInit required");
-}
-
-void aiRightBotInit2(AIEntity *e) {
-	warning("STUB: AI: aiRightBotInit2 required");
-}
-
 void aiPushBotInit(AIEntity *e) {
 	warning("STUB: AI: aiPushBotInit required");
 }
diff --git a/engines/hdb/hdb.h b/engines/hdb/hdb.h
index ab8cb24..e831ab8 100644
--- a/engines/hdb/hdb.h
+++ b/engines/hdb/hdb.h
@@ -81,6 +81,7 @@ enum Flag {
 	kFlagEnergyFloor	= 0x40000,
 	kFlagPlasmaFloor	= 0x6000D,
 	kFlagRadFloor		= 0x6800D,
+	kFlagSpecial		= 0x100000,
 	kFlagStairBot		= 0x200000,
 	kFlagStairTop		= 0x400000,
 	kFlagAnimSlow		= 0x800000,


Commit: 9be8ac9d35f1b54cb573b9cfda3ad74bc802e689
    https://github.com/scummvm/scummvm/commit/9be8ac9d35f1b54cb573b9cfda3ad74bc802e689
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:00+02:00

Commit Message:
HDB: Add dialogActive()

Changed paths:
    engines/hdb/window.h


diff --git a/engines/hdb/window.h b/engines/hdb/window.h
index f3b57c4..2b4e5eb 100644
--- a/engines/hdb/window.h
+++ b/engines/hdb/window.h
@@ -65,6 +65,9 @@ public:
 	uint32 getDialogDelay() {
 		return _dialogDelay;
 	}
+	bool dialogActive() {
+		return _dialogInfo.active;
+	}
 
 private:
 


Commit: 43e738ec1798b1f7a3ded8feb6b9108f636e1c1d
    https://github.com/scummvm/scummvm/commit/43e738ec1798b1f7a3ded8feb6b9108f636e1c1d
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:00+02:00

Commit Message:
HDB: Add _hereList data

Changed paths:
    engines/hdb/ai.h


diff --git a/engines/hdb/ai.h b/engines/hdb/ai.h
index bd25f55..4c59ac6 100644
--- a/engines/hdb/ai.h
+++ b/engines/hdb/ai.h
@@ -591,6 +591,11 @@ struct ArrowPath {
 	ArrowPath() : type(0), dir(DIR_NONE), tileX(0), tileY(0) {}
 };
 
+struct HereT {
+	uint16 x, y;
+	char entName[32];
+};
+
 struct CineCommand {
 	CineType cmdType;
 	double x, y;
@@ -949,6 +954,7 @@ public:
 	AutoAction _autoActions[kMaxAutoActions];
 
 	Common::Array<ArrowPath *> *_arrowPaths;
+	Common::Array<HereT *> *_hereList;
 
 	// Virtual Player
 	AIEntity _dummyPlayer;


Commit: a65936283d8fd6a8f6cfedf122d0f0c41d5f9e59
    https://github.com/scummvm/scummvm/commit/a65936283d8fd6a8f6cfedf122d0f0c41d5f9e59
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:00+02:00

Commit Message:
HDB: Add _hereList functions

Changed paths:
    engines/hdb/ai-lists.cpp
    engines/hdb/ai.h


diff --git a/engines/hdb/ai-lists.cpp b/engines/hdb/ai-lists.cpp
index d47bae7..e296102 100644
--- a/engines/hdb/ai-lists.cpp
+++ b/engines/hdb/ai-lists.cpp
@@ -223,6 +223,22 @@ bool AI::checkActionList(AIEntity *e, int x, int y, bool lookAndGrab) {
 	return false;
 }
 
+void AI::addToHereList(const char *entName, int x, int y) {
+	HereT *h = new HereT;
+	strcpy(h->entName, entName);
+	h->x = x;
+	h->y = y;
+	_hereList->push_back(h);
+}
+
+HereT *AI::findHere(int x, int y) {
+	for (Common::Array<HereT *>::iterator it = _hereList->begin(); it != _hereList->end(); it++) {
+		if ((*it)->x == x && (*it)->y == y)
+			return *it;
+	}
+	return NULL;
+}
+
 void AI::addToAutoList(int x, int y, const char *luaFuncInit, const char *luaFuncUse) {
 
 	const char *get;
diff --git a/engines/hdb/ai.h b/engines/hdb/ai.h
index 4c59ac6..7a3038b 100644
--- a/engines/hdb/ai.h
+++ b/engines/hdb/ai.h
@@ -673,6 +673,8 @@ public:
 	// List functions
 	void addToActionList(int actionIndex, int x, int y, char *funcLuaInit, char *funcLuaUse);
 	bool checkActionList(AIEntity *e, int x, int y, bool lookAndGrab);
+	void addToHereList(const char *entName, int x, int y);
+	HereT *findHere(int x, int y);
 	void addToAutoList(int x, int y, const char *luaFuncInt, const char *luaFuncUse);
 	void autoDeactivate(int x, int y);
 	bool activateAction(AIEntity *e, int x, int y, int targetX, int targetY);


Commit: 69235618f248167f81054eaa599d53b1062f13fc
    https://github.com/scummvm/scummvm/commit/69235618f248167f81054eaa599d53b1062f13fc
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:00+02:00

Commit Message:
HDB: Add _teleporters data

Changed paths:
    engines/hdb/ai-init.cpp
    engines/hdb/ai.h


diff --git a/engines/hdb/ai-init.cpp b/engines/hdb/ai-init.cpp
index c15f5a1..ade5ff4 100644
--- a/engines/hdb/ai-init.cpp
+++ b/engines/hdb/ai-init.cpp
@@ -671,6 +671,7 @@ AI::AI() {
 	_floats = new Common::Array<AIEntity *>;
 	_animTargets = new Common::Array<AnimTarget *>;
 	_arrowPaths = new Common::Array<ArrowPath *>;
+	_hereList = new Common::Array<HereT *>;
 
 	// REMOVE: Remove for final. Used here due to lack of a MENU
 	_numGems = _numGooCups = _numMonkeystones = _numInventory = 0;
@@ -684,6 +685,7 @@ AI::~AI() {
 	delete _floats;
 	delete _animTargets;
 	delete _arrowPaths;
+	delete _hereList;
 }
 
 bool AI::init() {
@@ -828,6 +830,10 @@ void AI::restartSystem() {
 	// Clear the Action list
 	memset(_actions, 0, sizeof(_actions));
 
+	// Clear Teleporter list
+	memset(_teleporters, 0, sizeof(_teleporters));
+	_numTeleporters = 0;
+
 	// Clear the Auto-Action list
 	memset(_autoActions, 0, sizeof(_autoActions));
 
@@ -840,6 +846,9 @@ void AI::restartSystem() {
 	// Clear ArrowPath List
 	_arrowPaths->clear();
 
+	// Clear Here List
+	_hereList->clear();
+
 	// Clear Cinematic System
 	_cineActive = _cameraLock = _playerLock = _cineAborted = false;
 
diff --git a/engines/hdb/ai.h b/engines/hdb/ai.h
index 7a3038b..5761fe4 100644
--- a/engines/hdb/ai.h
+++ b/engines/hdb/ai.h
@@ -36,6 +36,7 @@ enum {
 	kMaxDeliveries = 5,
 	kMaxWaypoints = 10,
 	kMaxActions = 20,
+	kMaxTeleporters = 20,
 	kMaxAutoActions = 30,
 	kPlayerMoveSpeed = 4,
 	kEnemyMoveSpeed = 2,
@@ -573,6 +574,27 @@ struct ActionInfo {
 	ActionInfo() : x1(0), y1(0), x2(0), y2(0), luaFuncInit(""), luaFuncUse(""), entityName("") {}
 };
 
+struct TeleInfo {
+	uint16 x1, y1;
+	uint16 x2, y2;
+	AIDir dir1;
+	AIDir dir2;
+	uint16 level1, level2;
+	uint16 usable1, usable2;
+	uint16 anim1, anim2;
+	char luaFuncUse1[32];
+	char luaFuncUse2[32];
+
+	TeleInfo() : x1(0), y1(0), x2(0), y2(0), dir1(DIR_NONE), dir2(DIR_NONE), level1(0), level2(0), usable1(0), usable2(0), anim1(0), anim2(0), luaFuncUse1(""), luaFuncUse2("") {}
+};
+
+struct SingleTele {
+	uint16 x, y, level, usable, anim;
+	AIDir dir;
+
+	SingleTele() : x(0), y(0), level(0), usable(0), anim(0), dir(DIR_NONE) {}
+};
+
 struct AutoAction {
 	uint16 x, y;
 	bool activated;
@@ -953,6 +975,9 @@ public:
 
 	ActionInfo _actions[kMaxActions];
 
+	TeleInfo _teleporters[kMaxTeleporters];
+	int _numTeleporters;
+
 	AutoAction _autoActions[kMaxAutoActions];
 
 	Common::Array<ArrowPath *> *_arrowPaths;


Commit: dc0ad525cdad76368689282aab3772e5a5e464b5
    https://github.com/scummvm/scummvm/commit/dc0ad525cdad76368689282aab3772e5a5e464b5
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:00+02:00

Commit Message:
HDB: Add _teleporters related functions

Changed paths:
    engines/hdb/ai-lists.cpp
    engines/hdb/ai.h


diff --git a/engines/hdb/ai-lists.cpp b/engines/hdb/ai-lists.cpp
index e296102..3d1e235 100644
--- a/engines/hdb/ai-lists.cpp
+++ b/engines/hdb/ai-lists.cpp
@@ -434,6 +434,176 @@ bool AI::autoActive(int x, int y) {
 	return false;
 }
 
+void AI::addToTeleportList(int teleIndex, int x, int y, int dir, int level, int anim, int usable, const char *luaFuncUse) {
+	if (!level)
+		level = 1;
+
+	if (!_teleporters[teleIndex].x1) {
+		_teleporters[teleIndex].x1 = x;
+		_teleporters[teleIndex].y1 = y;
+		_teleporters[teleIndex].dir1 = (AIDir)dir;
+		_teleporters[teleIndex].level1 = level;
+		_teleporters[teleIndex].anim1 = anim;
+		_teleporters[teleIndex].usable1 = usable;
+		strcpy(_teleporters[teleIndex].luaFuncUse1, luaFuncUse);
+		if (_teleporters[teleIndex].luaFuncUse1[0] == '*')
+			_teleporters[teleIndex].luaFuncUse1[0] = 0;
+		_numTeleporters++;
+		return;
+	}
+	if (!_teleporters[teleIndex].x2) {
+		_teleporters[teleIndex].x2 = x;
+		_teleporters[teleIndex].y2 = y;
+		_teleporters[teleIndex].dir2 = (AIDir)dir;
+		_teleporters[teleIndex].level2 = level;
+		_teleporters[teleIndex].anim2 = anim;
+		_teleporters[teleIndex].usable2 = usable;
+		strcpy(_teleporters[teleIndex].luaFuncUse2, luaFuncUse);
+		if (_teleporters[teleIndex].luaFuncUse2[0] == '*')
+			_teleporters[teleIndex].luaFuncUse2[0] = 0;
+		_numTeleporters++;
+		return;
+	}
+
+	warning("addToTeleporterList: Adding a 3rd teleporter is illegal");
+}
+
+bool AI::findTeleporterDest(int tileX, int tileY, SingleTele *info) {
+	for (int i = 0;i < _numTeleporters; i++) {
+		if ((_teleporters[i].x1 == tileX) && (_teleporters[i].x1 == tileY)) {
+			info->anim = _teleporters[i].anim2;
+			info->x = _teleporters[i].x2;
+			info->y = _teleporters[i].y2;
+			info->dir = _teleporters[i].dir2;
+			info->level = _teleporters[i].level2;
+			info->usable = _teleporters[i].usable2;
+			return true;
+		}
+		if ((_teleporters[i].x1 == tileX) && (_teleporters[i].x1 == tileY)) {
+			info->anim = _teleporters[i].anim1;
+			info->x = _teleporters[i].x1;
+			info->y = _teleporters[i].y1;
+			info->dir = _teleporters[i].dir1;
+			info->level = _teleporters[i].level1;
+			info->usable = _teleporters[i].usable1;
+			return true;
+		}
+	}
+	return false;
+}
+
+bool AI::checkTeleportList(AIEntity *e, int x, int y) {
+	for (int i = 0; i < kMaxTeleporters; i++) {
+		if ((_teleporters[i].x1 == x && _teleporters[i].y1 == y) || (_teleporters[i].x2 == x && _teleporters[i].y2 == y)) {
+			int targetX = _teleporters[i].x1;
+			int targetY = _teleporters[i].y1;
+			int targetX2 = _teleporters[i].x2;
+			int targetY2 = _teleporters[i].y2;
+			AIDir dir1 = _teleporters[i].dir1;
+			AIDir dir2 = _teleporters[i].dir2;
+			int level1 = _teleporters[i].level1;
+			int level2 = _teleporters[i].level2;
+			int usable1 = _teleporters[i].usable1;
+			int usable2 = _teleporters[i].usable2;
+			int anim1 = _teleporters[i].anim1;
+			int anim2 = _teleporters[i].anim2;
+			const char *luaFuncUse1 = _teleporters[i].luaFuncUse1;
+			const char *luaFuncUse2 = _teleporters[i].luaFuncUse2;
+
+			// Choose which set of co-ordinates is the target
+			if (x != targetX || y != targetY) {
+				targetX = _teleporters[i].x2;
+				targetY = _teleporters[i].y2;
+				targetX2 = _teleporters[i].x1;
+				targetY2 = _teleporters[i].y1;
+				dir1 = _teleporters[i].dir2;
+				dir2 = _teleporters[i].dir1;
+				level1 = _teleporters[i].level2;
+				level2 = _teleporters[i].level1;
+				usable1 = _teleporters[i].usable2;
+				usable2 = _teleporters[i].usable1;
+				anim1 = _teleporters[i].anim2;
+				anim2 = _teleporters[i].anim1;
+				luaFuncUse1 = _teleporters[i].luaFuncUse2;
+				luaFuncUse2 = _teleporters[i].luaFuncUse1;
+			}
+
+			// We must be exactly on the teleporter
+			if (abs(targetX*kTileWidth - e->x) > 2 || abs(targetY*kTileHeight - e->y) > 2)
+				return false;
+
+			// Can this teleporter be used?
+			if (usable1)
+				return false;
+
+			// Move Entity to new Spot, then walk forward one tile
+			e->tileX = targetX2;
+			e->tileY = targetY2;
+			e->x = targetX2 * kTileWidth;
+			e->y = targetY2 * kTileHeight;
+			e->xVel = e->yVel = 0;
+			e->goalX = e->goalY = 0;
+			e->animFrame = 0;
+			e->drawXOff = e->drawYOff = 0;
+			e->dir = dir2;
+			e->level = level2;
+
+			if (luaFuncUse2[0])
+				g_hdb->_lua->callFunction(luaFuncUse2, 0);
+
+			e->draw = e->standdownGfx[0];
+			if (e == _player) {
+				memset(&_waypoints[0], 0, sizeof(_waypoints));
+				_numWaypoints = 0;
+			}
+
+			switch (e->dir) {
+			case DIR_UP:
+				setEntityGoal(e, e->tileX, e->tileY - 1);
+				break;
+			case DIR_DOWN:
+				setEntityGoal(e, e->tileX, e->tileY + 1);
+				break;
+			case DIR_LEFT:
+				setEntityGoal(e, e->tileX - 1, e->tileY);
+				break;
+			case DIR_RIGHT:
+				setEntityGoal(e, e->tileX + 1, e->tileY);
+				break;
+			case DIR_NONE:
+				warning("checkTeleporterList: DIR_NONE found");
+				break;
+			}
+
+			g_hdb->_map->centerMapXY(e->x + 16, e->y + 16);
+
+			// Start up Teleport flash animation only if value1 is set to 1
+			if (anim1 == 1 || anim2 == 2) {
+				addAnimateTarget(e->x, e->y, 0, 7, ANIM_NORMAL, false, false, "teleporter_flash_sit");
+				warning("STUB: checkTeleporterList: Play SND_TELEPORT");
+			}
+
+			// PANIC ZONE Teleports?
+			warning("STUB: checkTeleporterList: Toggle Panic Zone");
+
+			// Is there an attack gem still floating around?
+			for (Common::Array<AIEntity *>::iterator it = _ents->begin(); it != _ents->end(); it++) {
+				if ((*it)->type == AI_GEM_ATTACK) {
+					int amt = getGemAmount();
+					setGemAmount(amt + 1);
+					removeEntity(*it);
+					break;
+				}
+			}
+
+			_playerEmerging = true;
+			return true;
+		}
+	}
+
+	return false;
+}
+
 void AI::addToPathList(int x, int y, int type, AIDir dir) {
 	ArrowPath *arrowPath = new ArrowPath;
 
diff --git a/engines/hdb/ai.h b/engines/hdb/ai.h
index 5761fe4..a099dee 100644
--- a/engines/hdb/ai.h
+++ b/engines/hdb/ai.h
@@ -386,7 +386,7 @@ struct AIEntity {
 	uint16		goalX, goalY;							// where we're trying to go - TILE COORDS
 	uint16		touchpX, touchpY, touchpTile, touchpWait;		// ACTION index a touchplate is using, which you're on
 	uint32		stunnedWait;							// if we're stunned, this is the delay before being normal again
-	uint16		sequence;								// to use for specially-coded sequences
+	int16		sequence;								// to use for specially-coded sequences
 	char		entityName[32];						// the name of the entity, as registered by the Lua init function for the entity
 	char		printedName[32];						// the name of the entity/item, the way it should be printed
 
@@ -702,6 +702,9 @@ public:
 	bool activateAction(AIEntity *e, int x, int y, int targetX, int targetY);
 	bool checkAutoList(AIEntity *e, int x, int y);
 	bool autoActive(int x, int y);
+	void addToTeleportList(int teleIndex, int x, int y, int dir, int level, int anim, int usable, const char *luaFuncUse);
+	bool checkTeleportList(AIEntity *e, int x, int y);
+	bool findTeleporterDest(int tileX, int tileY, SingleTele *info);
 	void addToPathList(int x, int y, int type, AIDir dir);
 	ArrowPath *findArrowPath(int x, int y);
 
@@ -896,71 +899,71 @@ public:
 	// These variables hold the tile-indices set
 	// in ai-init.cpp
 
-	int			_useSwitchOff;			// the door opening switch
-	int			_useSwitchOn;			// state, when opened
-	int			_useHolderEmpty;		// cell holding switch
-	int			_useHolderFull;		// state, when full
-	int			_useSwitch2Off;		// another switch
-	int			_useSwitch2On;			// state, when opened
-	int			_useMailsorter;			// mailsorter entity
-	int			_useAskcomp;			// askcomp entitiy
-	int			_useTeleporter;			// teleporter entity
-	int			_useHandswitchOn;		// 2-sided handswitch
-	int			_useHandswitchOff;		// 2-sided handswitch
-
-	int			_targetDoorN;			// horz SILVER door
-	int			_targetDoorP;			// horz BLUE door
-	int			_targetDoorS;			// horz RED door
-	int			_targetDoorNv;			// vert SILVER door
-	int			_targetDoorPv;			// vert BLUE door
-	int			_targetDoorSv;			// vert RED door
-
-	int			_targetDoor2N;			// horz SILVER door
-	int			_targetDoor2P;			// horz BLUE door
-	int			_targetDoor2S;			// horz RED door
-	int			_targetDoor2Nv;			// vert SILVER door
-	int			_targetDoor2Pv;			// vert BLUE door
-	int			_targetDoor2Sv;			// vert RED door
-
-	int			_target2DoorN;			// horz SILVER door
-	int			_target2DoorP;			// horz BLUE door
-	int			_target2DoorS;			// horz RED door
-	int			_target2DoorNv;			// vert SILVER door
-	int			_target2DoorPv;			// vert BLUE door
-	int			_target2DoorSv;			// vert RED door
-
-	int			_target3DoorN;			// horz SILVER door
-	int			_target3DoorP;			// horz BLUE door
-	int			_target3DoorS;			// horz RED door
-	int			_target3DoorNv;			// vert SILVER door
-	int			_target3DoorPv;			// vert BLUE door
-	int			_target3DoorSv;			// vert RED door
-
-	int			_targetBridgeU;		// bridge extending UP
-	int			_targetBridgeD;		// bridge extending DOWN
-	int			_targetBridgeL;		// bridge extending LEFT
-	int			_targetBridgeR;		// bridge extending RIGHT
-
-	int			_targetBridgeMidLR;	// bridge grating plank LEFT/RIGHT
-	int			_targetBridgeMidUD;	// bridge grating plank UP/DOWN
-	int			_touchplateOn;			// touchplate ON
-	int			_touchplateOff;
-	int			_templeTouchpOn;		// touchplate ON
-	int			_templeTouchpOff;
-	int			_blockpole;				// blockpole
-
-	int			_kcHolderWhiteOff;	// keycard holders
-	int			_kcHolderWhiteOn;
-	int			_kcHolderBlueOff;
-	int			_kcHolderBlueOn;
-	int			_kcHolderRedOff;
-	int			_kcHolderRedOn;
-	int			_kcHolderGreenOff;
-	int			_kcHolderGreenOn;
-	int			_kcHolderPurpleOff;
-	int			_kcHolderPurpleOn;
-	int			_kcHolderBlackOff;
-	int			_kcHolderBlackOn;
+	int	_useSwitchOff;		// the door opening switch
+	int	_useSwitchOn;		// state, when opened
+	int	_useHolderEmpty;	// cell holding switch
+	int	_useHolderFull;		// state, when full
+	int	_useSwitch2Off;		// another switch
+	int	_useSwitch2On;		// state, when opened
+	int	_useMailsorter;		// mailsorter entity
+	int	_useAskcomp;		// askcomp entitiy
+	int	_useTeleporter;		// teleporter entity
+	int	_useHandswitchOn;	// 2-sided handswitch
+	int	_useHandswitchOff;	// 2-sided handswitch
+
+	int	_targetDoorN;		// horz SILVER door
+	int	_targetDoorP;		// horz BLUE door
+	int	_targetDoorS;		// horz RED door
+	int	_targetDoorNv;		// vert SILVER door
+	int	_targetDoorPv;		// vert BLUE door
+	int	_targetDoorSv;		// vert RED door
+
+	int	_targetDoor2N;		// horz SILVER door
+	int	_targetDoor2P;		// horz BLUE door
+	int	_targetDoor2S;		// horz RED door
+	int	_targetDoor2Nv;		// vert SILVER door
+	int	_targetDoor2Pv;		// vert BLUE door
+	int	_targetDoor2Sv;		// vert RED door
+
+	int	_target2DoorN;		// horz SILVER door
+	int	_target2DoorP;		// horz BLUE door
+	int	_target2DoorS;		// horz RED door
+	int	_target2DoorNv;		// vert SILVER door
+	int	_target2DoorPv;		// vert BLUE door
+	int	_target2DoorSv;		// vert RED door
+
+	int	_target3DoorN;		// horz SILVER door
+	int	_target3DoorP;		// horz BLUE door
+	int	_target3DoorS;		// horz RED door
+	int	_target3DoorNv;		// vert SILVER door
+	int	_target3DoorPv;		// vert BLUE door
+	int	_target3DoorSv;		// vert RED door
+
+	int	_targetBridgeU;		// bridge extending UP
+	int	_targetBridgeD;		// bridge extending DOWN
+	int	_targetBridgeL;		// bridge extending LEFT
+	int	_targetBridgeR;		// bridge extending RIGHT
+
+	int	_targetBridgeMidLR;	// bridge grating plank LEFT/RIGHT
+	int	_targetBridgeMidUD;	// bridge grating plank UP/DOWN
+	int	_touchplateOn;		// touchplate ON
+	int	_touchplateOff;
+	int	_templeTouchpOn;	// touchplate ON
+	int	_templeTouchpOff;
+	int	_blockpole;			// blockpole
+
+	int	_kcHolderWhiteOff;	// keycard holders
+	int	_kcHolderWhiteOn;
+	int	_kcHolderBlueOff;
+	int	_kcHolderBlueOn;
+	int	_kcHolderRedOff;
+	int	_kcHolderRedOn;
+	int	_kcHolderGreenOff;
+	int	_kcHolderGreenOn;
+	int	_kcHolderPurpleOff;
+	int	_kcHolderPurpleOn;
+	int	_kcHolderBlackOff;
+	int	_kcHolderBlackOn;
 
 	AIEntLevel2 _entsLevel2[kMaxLevel2Ents];
 	int _numLevel2Ents;


Commit: 72ee6a2bc5070ce1ee11b2732cabe601b702d6b8
    https://github.com/scummvm/scummvm/commit/72ee6a2bc5070ce1ee11b2732cabe601b702d6b8
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:00+02:00

Commit Message:
HDB: Add Inventory getter-setter functions

Changed paths:
    engines/hdb/ai.h


diff --git a/engines/hdb/ai.h b/engines/hdb/ai.h
index a099dee..815a1ef 100644
--- a/engines/hdb/ai.h
+++ b/engines/hdb/ai.h
@@ -819,6 +819,21 @@ public:
 	// Inventory Functions
 	bool addToInventory(AIEntity *e);
 	void clearInventory();
+	int getInvAmount() {
+		return _numInventory;
+	}
+	int getGemAmount() {
+		return _numGems;
+	}
+	int getMonkeystoneAmount() {
+		return _numMonkeystones;
+	}
+	int getGooCupAmount() {
+		return _numGooCups;
+	}
+	void setGemAmount(int amt) {
+		_numGems = amt;
+	}
 
 	// Player Variables
 	bool _playerDead;


Commit: 248099ec76e6f41e56cd449f026346280afaed16
    https://github.com/scummvm/scummvm/commit/248099ec76e6f41e56cd449f026346280afaed16
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:00+02:00

Commit Message:
HDB: Add PushBot functions

Changed paths:
    engines/hdb/ai-bots.cpp
    engines/hdb/ai-player.cpp


diff --git a/engines/hdb/ai-bots.cpp b/engines/hdb/ai-bots.cpp
index 098dedb..d63cd0b 100644
--- a/engines/hdb/ai-bots.cpp
+++ b/engines/hdb/ai-bots.cpp
@@ -468,4 +468,97 @@ void aiRightBotAction(AIEntity *e) {
 	}
 }
 
+void aiPushBotInit(AIEntity *e) {
+	if (e->value1 != 1)
+		e->aiAction = aiPushBotAction;
+}
+
+void aiPushBotInit2(AIEntity *e) {
+	e->draw = g_hdb->_ai->getStandFrameDir(e);
+}
+
+void aiPushBotAction(AIEntity *e) {
+	AIState moveState[5] = { STATE_NONE, STATE_MOVEUP, STATE_MOVEDOWN, STATE_MOVELEFT, STATE_MOVERIGHT };
+	int	xvAhead[5] = { 9, 0, 0,-1, 1 }, yvAhead[5] = { 9,-1, 1, 0, 0 };
+	AIDir oneEighty[5] = { DIR_NONE, DIR_DOWN, DIR_UP, DIR_RIGHT, DIR_LEFT };
+
+	uint32 bgFlags, fgFlags;
+	int nx, ny, nx2, ny2, result;
+	AIEntity *e1 = NULL, *e2;
+
+	if (e->goalX) {
+		g_hdb->_ai->animateEntity(e);
+		if (e->onScreen && g_hdb->_ai->checkPlayerCollision(e->x, e->y, 4) && !g_hdb->_ai->playerDead())
+			g_hdb->_ai->killPlayer(DEATH_NORMAL);
+	} else {
+		if (e->onScreen && g_hdb->_ai->checkPlayerCollision(e->x, e->y, 4) && !g_hdb->_ai->playerDead())
+			g_hdb->_ai->killPlayer(DEATH_NORMAL);
+
+		// Where to go next
+		nx = e->tileX + xvAhead[e->dir];
+		ny = e->tileY + yvAhead[e->dir];
+
+		e1 = g_hdb->_ai->legalMove(nx, ny, e->level, &result);
+
+		// Push something
+		// Turn Around
+		// Move Forward
+		if (e1 && onEvenTile(e1->x, e1->y) && (e1->type == AI_LIGHTBARREL || e1->type == AI_HEAVYBARREL || e1->type == AI_BOOMBARREL || e1->type == AI_CRATE)) {
+			// Actually going over a floating crate?
+			if (e1 && (e1->state == STATE_FLOATING || e1->state == STATE_MELTED)) {
+				e->state = moveState[e->dir];
+				g_hdb->_ai->setEntityGoal(e, nx, ny);
+				g_hdb->_ai->animateEntity(e);
+				return;
+			}
+
+			nx2 = nx + xvAhead[e->dir];
+			ny2 = ny + yvAhead[e->dir];
+
+			bgFlags = g_hdb->_map->getMapBGTileFlags(nx2, ny2);
+			fgFlags = g_hdb->_map->getMapFGTileFlags(nx2, ny2);
+			e2 = g_hdb->_ai->findEntity(nx2, ny2);
+			result = (e->level == 1) ? (bgFlags & kFlagSolid) : !(fgFlags & kFlagGrating) && (bgFlags & kFlagSolid);
+
+			// If we're going to push something onto a floating thing, that's ok
+			if (e2 && (e2->state == STATE_FLOATING || e2->state == STATE_MELTED))
+				e2 = NULL;
+
+			// If no walls in front & no entities
+			if (!result && !e2 && e1->state != STATE_EXPLODING) {
+				e->state = moveState[e->dir];
+				g_hdb->_ai->setEntityGoal(e, nx, ny);
+
+				e1->dir = e->dir;
+				e1->state = e->state;
+				e1->moveSpeed = e->moveSpeed;
+				g_hdb->_ai->setEntityGoal(e1, nx2, ny2);
+				warning("STUB: aiPushBotAction: Switch Case for Sound");
+			} else {
+				if (e->onScreen)
+					warning("STUB: aiPushBotAction: Play SND_PUSHBOT_STRAIN");
+				e->dir = oneEighty[e->dir];
+				e->state = moveState[e->dir];
+				nx = e->tileX + xvAhead[e->dir];
+				ny = e->tileY + yvAhead[e->dir];
+				e1 = g_hdb->_ai->legalMove(nx, ny, e->level, &result);
+				if (!e1 && result)
+					g_hdb->_ai->setEntityGoal(e, nx, ny);
+			}
+		} else if (!result || (e1 && !onEvenTile(e1->x, e1->y))) {
+			e->dir = oneEighty[e->dir];
+			e->state = moveState[e->dir];
+			nx = e->tileX + xvAhead[e->dir];
+			ny = e->tileY + yvAhead[e->dir];
+			e1 = g_hdb->_ai->legalMove(nx, ny, e->level, &result);
+			if (!e1 && result)
+				g_hdb->_ai->setEntityGoal(e, nx, ny);
+		} else {
+			e->state = moveState[e->dir];
+			g_hdb->_ai->setEntityGoal(e, nx, ny);
+		}
+		g_hdb->_ai->animateEntity(e);
+	}
+}
+
 } // End of Namespace
diff --git a/engines/hdb/ai-player.cpp b/engines/hdb/ai-player.cpp
index f16765c..442c902 100644
--- a/engines/hdb/ai-player.cpp
+++ b/engines/hdb/ai-player.cpp
@@ -444,10 +444,6 @@ void aiSlugSlingerInit2(AIEntity *e) {
 	warning("STUB: AI: aiSlugSlingerInit2 required");
 }
 
-void aiPushBotAction(AIEntity *e) {
-	warning("STUB: AI: aiPushBotAction required");
-}
-
 void aiLaserAction(AIEntity *e) {
 	warning("STUB: AI: aiLaserAction required");
 }
@@ -552,14 +548,6 @@ void aiDiverterInit2(AIEntity *e) {
 	warning("STUB: AI: aiDiverterInit2 required");
 }
 
-void aiPushBotInit(AIEntity *e) {
-	warning("STUB: AI: aiPushBotInit required");
-}
-
-void aiPushBotInit2(AIEntity *e) {
-	warning("STUB: AI: aiPushBotInit2 required");
-}
-
 void aiDeadEyeInit(AIEntity *e) {
 	warning("STUB: AI: aiDeadEyeInit required");
 }


Commit: 2a3ee7e2efb97f1e0dfbf230dc53db3ead27a50d
    https://github.com/scummvm/scummvm/commit/2a3ee7e2efb97f1e0dfbf230dc53db3ead27a50d
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:00+02:00

Commit Message:
HDB: Add RailRider functions

Changed paths:
    engines/hdb/ai-bots.cpp
    engines/hdb/ai-player.cpp


diff --git a/engines/hdb/ai-bots.cpp b/engines/hdb/ai-bots.cpp
index d63cd0b..7bd5c56 100644
--- a/engines/hdb/ai-bots.cpp
+++ b/engines/hdb/ai-bots.cpp
@@ -561,4 +561,241 @@ void aiPushBotAction(AIEntity *e) {
 	}
 }
 
+void aiRailRiderInit(AIEntity *e) {
+	if (e->type == AI_RAILRIDER_ON) {
+		// On the tracks already - spawn RED arrow
+		g_hdb->_ai->addToPathList(e->tileX, e->tileY, 0, e->dir);
+		e->state = STATE_STANDUP;
+		e->aiAction = aiRailRiderOnAction;
+		e->aiUse = aiRailRiderOnUse;
+	} else {
+		e->state = STATE_STANDDOWN;
+		e->sequence = 0;
+		e->aiAction = aiRailRiderAction;
+		e->aiUse = aiRailRiderUse;
+	}
+	e->moveSpeed = kPlayerMoveSpeed;
+}
+
+void aiRailRiderInit2(AIEntity *e) {
+	e->draw = e->standdownGfx[0];
+}
+
+// Talking to RailRider off track
+void aiRailRiderUse(AIEntity *e) {
+	e->sequence = 1;
+}
+
+void aiRailRiderAction(AIEntity *e) {
+	switch (e->sequence) {
+		// Waiting for Dialog to goaway
+	case 1:
+		// Dialog gone?
+		if (!g_hdb->_window->dialogActive()) {
+			e->sequence = 2;
+			switch (e->dir) {
+			case DIR_UP:	e->xVel = 0;	e->yVel = -1;	break;
+			case DIR_DOWN:	e->xVel = 0;	e->yVel = 1;	break;
+			case DIR_LEFT:	e->xVel = -1;	e->yVel = 0;	break;
+			case DIR_RIGHT:	e->xVel = 1;	e->yVel = 0;	break;
+			case DIR_NONE:
+				warning("aiRailRiderAction: DIR_NONE found");
+				break;
+			}
+		}
+		break;
+		// Walking over to track
+	case 2:
+		e->x += e->xVel;
+		e->y += e->yVel;
+		if (onEvenTile(e->x, e->y)) {
+			ArrowPath *arrowPath;
+			e->tileX = e->x / kTileWidth;
+			e->tileY = e->y / kTileHeight;
+			e->sequence = 3;	// Wait for use
+			e->type = AI_RAILRIDER_ON;
+			e->state = STATE_STANDUP;
+			e->aiAction = aiRailRiderOnAction;
+			e->aiUse = aiRailRiderOnUse;
+			arrowPath = g_hdb->_ai->findArrowPath(e->tileX, e->tileY);
+			e->dir = arrowPath->dir;
+			e->value1 = 0;	// Not in a tunnel
+		}
+		break;
+	}
+
+	// Cycle through animation frames
+	if (e->animDelay-- > 0)
+		return;
+	e->animDelay = e->animCycle;
+	e->animFrame++;
+	if (e->animFrame == e->standdownFrames)
+		e->animFrame = 0;
+
+	e->draw = e->standdownGfx[e->animFrame];
+}
+
+// Talking to RailRider on track
+void aiRailRiderOnUse(AIEntity *e) {
+	AIEntity *p = g_hdb->_ai->getPlayer();
+
+	if (p->tileX == e->tileX) {
+		if (p->tileY > e->tileY)
+			g_hdb->_ai->setEntityGoal(p, p->tileX, p->tileY - 1);
+		else
+			g_hdb->_ai->setEntityGoal(p, p->tileX, p->tileY + 1);
+	} else {
+		if (p->tileX > e->tileX)
+			g_hdb->_ai->setEntityGoal(p, p->tileX - 1, p->tileY);
+		else
+			g_hdb->_ai->setEntityGoal(p, p->tileX + 1, p->tileY);
+	}
+
+	e->sequence = -1;	// Waiting for player to board
+}
+
+void aiRailRiderOnAction(AIEntity *e) {
+	int	xv[5] = { 9, 0, 0, -1, 1 }, yv[5] = { 9, -1, 1, 0, 0 };
+	AIEntity*p = g_hdb->_ai->getPlayer();
+	SingleTele t;
+
+	switch (e->sequence) {
+	// Player is boarding
+	case -1:
+		if (!p->goalX)
+			e->sequence = 1; // Boarded yet?
+	// Cycle Animation Frames
+	case 3:
+		if (e->animDelay-- > 0)
+			return;
+		e->animDelay = e->animCycle;
+		e->animFrame++;
+		if (e->animFrame == e->standupFrames)
+			e->animFrame = 0;
+
+		e->draw = e->standupGfx[e->animFrame];
+		break;
+	// Player is in - lock him
+	case 1:
+		g_hdb->_ai->setPlayerInvisible(true);
+		g_hdb->_ai->setPlayerLock(true);
+		g_hdb->_ai->setEntityGoal(e, e->tileX + xv[e->dir], e->tileY + yv[e->dir]);
+		warning("STUB: aiRailRiderOnAction: Play SND_RAILRIDER_TASTE");
+		e->sequence = 2;
+		e->value1 = 0;
+
+	// New RailRider gfx
+	// Move the RailRider
+	case 2:
+		// Done moving to next spot?
+		if (!e->goalX) {
+			ArrowPath *arrowPath = g_hdb->_ai->findArrowPath(e->tileX, e->tileY);
+			if (arrowPath) {
+				// Stop Arrow?
+				if (!arrowPath->type) {
+					HereT *h;
+					e->sequence = 4;	// Get Player off RailRider - RIGHT SIDE ONLY
+					p->tileX = e->tileX;
+					p->tileY = e->tileY;
+					p->x = e->x;
+					p->y = e->y;
+					// Try to find a HERE icon to either side of the track and go there
+					switch (e->dir) {
+					case DIR_UP:
+						h = g_hdb->_ai->findHere(e->tileX - 1, e->tileY);
+						if (h)
+							g_hdb->_ai->setEntityGoal(p, e->tileX - 1, e->tileY);
+						else
+							g_hdb->_ai->setEntityGoal(p, e->tileX + 1, e->tileY);
+						break;
+					case DIR_DOWN:
+						h = g_hdb->_ai->findHere(e->tileX + 1, e->tileY);
+						if (h)
+							g_hdb->_ai->setEntityGoal(p, e->tileX + 1, e->tileY);
+						else
+							g_hdb->_ai->setEntityGoal(p, e->tileX - 1, e->tileY);
+						break;
+					case DIR_LEFT:
+						h = g_hdb->_ai->findHere(e->tileX, e->tileY + 1);
+						if (h)
+							g_hdb->_ai->setEntityGoal(p, e->tileX, e->tileY + 1);
+						else
+							g_hdb->_ai->setEntityGoal(p, e->tileX, e->tileY - 1);
+						break;
+					case DIR_RIGHT:
+						h = g_hdb->_ai->findHere(e->tileX, e->tileY - 1);
+						if (h)
+							g_hdb->_ai->setEntityGoal(p, e->tileX, e->tileY - 1);
+						else
+							g_hdb->_ai->setEntityGoal(p, e->tileX, e->tileY + 1);
+						break;
+					case DIR_NONE:
+						warning("aiRailRiderOnAction: DIR_NOW found");
+						break;
+					}
+					g_hdb->_ai->setPlayerInvisible(false);
+					warning("STUB: aiRailRiderOnAction: Play SND_RAILRIDER_EXIT");
+				} else if (arrowPath->type == 1) {
+					e->dir = arrowPath->dir;
+					g_hdb->_ai->setEntityGoal(e, e->tileX + xv[e->dir], e->tileY + yv[e->dir]);
+				}
+			} else
+				g_hdb->_ai->setEntityGoal(e, e->tileX + xv[e->dir], e->tileY + yv[e->dir]);
+
+			warning("STUB: aiRailRiderOnAction: Play SND_RAILRIDER_ONTRACK");
+		}
+
+		p->tileX = e->tileX;
+		p->tileY = e->tileY;
+		p->x = e->x;
+		p->y = e->y;
+		g_hdb->_ai->animateEntity(e);
+		switch (e->dir) {
+		case DIR_UP:	e->draw = e->moveupGfx[0]; break;
+		case DIR_DOWN:	e->draw = e->movedownGfx[0]; break;
+		case DIR_LEFT:	e->draw = e->moveleftGfx[0]; break;
+		case DIR_RIGHT: e->draw = e->moverightGfx[0]; break;
+		}
+		g_hdb->_map->centerMapXY(e->x + 16, e->y + 16);
+
+		// Did we hit a tunnel entrance?
+		if (onEvenTile(e->x, e->y) && g_hdb->_ai->findTeleporterDest(e->tileX, e->tileY, &t) && !e->value1 && !e->dir2) {
+			// Set tunnel destination
+			e->value1 = t.x;
+			e->value2 = t.y;
+			e->dir2 = (AIDir)(t.x + t.y);	// Flag for coming out of tunnel
+		}
+
+		// Are we going through a tunnel?
+		if (e->value1) {
+			// Reach the End?
+			// If not, don't draw RailRider
+			if (onEvenTile(e->x, e->y) && e->tileX == e->value1 && e->tileY == e->value2)
+				e->value1 = 0;
+			else
+				e->draw = NULL;
+		} else if (e->dir2 && e->dir2 != (AIDir)(e->tileX + e->tileY))
+			e->dir2 = DIR_NONE;
+		break;
+	// Waiting for Player to move to Dest
+	case 4:
+		if (!p->goalX) {
+			g_hdb->_ai->setPlayerLock(false);
+			e->sequence = 3;	// Wait for Use
+		}
+
+		// Cycle Animation frames
+		if (e->animDelay-- > 0)
+			return;
+
+		e->animDelay = e->animCycle;
+		e->animFrame++;
+		if (e->animFrame == e->standupFrames)
+			e->animFrame = 0;
+
+		e->draw = e->standupGfx[e->animFrame];
+		break;
+	}
+}
+
 } // End of Namespace
diff --git a/engines/hdb/ai-player.cpp b/engines/hdb/ai-player.cpp
index 442c902..898a20b 100644
--- a/engines/hdb/ai-player.cpp
+++ b/engines/hdb/ai-player.cpp
@@ -340,30 +340,6 @@ void aiFourFirerAction(AIEntity *e) {
 	warning("STUB: AI: aiFourFirerAction required");
 }
 
-void aiRailRiderInit(AIEntity *e) {
-	warning("STUB: AI: aiRailRiderInit required");
-}
-
-void aiRailRiderInit2(AIEntity *e) {
-	warning("STUB: AI: aiRailRiderInit2 required");
-}
-
-void aiRailRiderAction(AIEntity *e) {
-	warning("STUB: AI: aiRailRiderAction required");
-}
-
-void aiRailRiderUse(AIEntity *e) {
-	warning("STUB: AI: aiRailRiderUse required");
-}
-
-void aiRailRiderOnUse(AIEntity *e) {
-	warning("STUB: AI: aiRailRiderOnUse required");
-}
-
-void aiRailRiderOnAction(AIEntity *e) {
-	warning("STUB: AI: aiRailRiderOnAction required");
-}
-
 void aiSlugAttackAction(AIEntity *e) {
 	warning("STUB: AI: aiSlugAttackAction required");
 }


Commit: f45904ca3017b82ecdf8c740f24072afcc47d5d4
    https://github.com/scummvm/scummvm/commit/f45904ca3017b82ecdf8c740f24072afcc47d5d4
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:00+02:00

Commit Message:
HDB: Add inventory drawing data

Changed paths:
    engines/hdb/window.cpp
    engines/hdb/window.h


diff --git a/engines/hdb/window.cpp b/engines/hdb/window.cpp
index 8179190..eb36473 100644
--- a/engines/hdb/window.cpp
+++ b/engines/hdb/window.cpp
@@ -81,7 +81,9 @@ bool Window::init() {
 
 void Window::restartSystem() {
 	_dialogInfo.active = false;
-	_dialogDelay = 0;
+	_invWinInfo.active = false;
+	_dialogDelay = _invWinInfo.selection = 0;
+	_gemGfx = g_hdb->_drawMan->loadTile("ent_gem_white_sit01");
 	_infobarDimmed = 0;
 }
 
diff --git a/engines/hdb/window.h b/engines/hdb/window.h
index 2b4e5eb..8bfc38c 100644
--- a/engines/hdb/window.h
+++ b/engines/hdb/window.h
@@ -27,7 +27,12 @@ namespace HDB {
 
 enum {
 	kDialogTextLeft = 64,
-	kDialogTextRight = (kDialogTextLeft + kTileWidth * 9)
+	kDialogTextRight = (kDialogTextLeft + kTileWidth * 9),
+	kWeaponX = (480 - 34),
+	kWeaponY = 2,
+	kInvItemSpaceX = 48,
+	kInvItemSpaceY = 40,
+	kInvItemPerLine = 3
 };
 
 struct DialogInfo {
@@ -47,6 +52,13 @@ struct DialogInfo {
 	DialogInfo() : title(""), tileIndex(0), string(""), active(false), x(0), y(0), width(0), height(0), titleWidth(0), gfx(NULL), more(0), el(0), er(0), et(0), eb(0), luaMore("") {}
 };
 
+struct InvWinInfo {
+	int x, y;
+	int width, height;
+	int selection;
+	bool active;
+};
+
 class Window {
 public:
 
@@ -74,6 +86,8 @@ private:
 	DialogInfo _dialogInfo;
 	uint32 _dialogDelay;	// Used for Cinematics
 
+	InvWinInfo _invWinInfo;
+
 	// Windows GFX
 	Picture *_gfxTL, *_gfxTM, *_gfxTR;
 	Picture *_gfxL, *_gfxM, *_gfxR;
@@ -88,6 +102,8 @@ private:
 	Picture *_gfxTry, *_gfxAgain, *_gfxInvSelect;
 	Tile *_gfxMonkeystone;
 	Picture *_gfxLevelRestart, *_gfxPausePlaque;
+	Tile *_gemGfx;
+	Picture *_mstoneGfx;
 
 	// Info Bar
 	Picture *_gfxInfobar, *_gfxDarken;


Commit: 4344b2f8c8fd34994f28e86d7707f7803a811c61
    https://github.com/scummvm/scummvm/commit/4344b2f8c8fd34994f28e86d7707f7803a811c61
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:00+02:00

Commit Message:
HDB: Add getInvItem()

Changed paths:
    engines/hdb/ai-inventory.cpp
    engines/hdb/ai.h


diff --git a/engines/hdb/ai-inventory.cpp b/engines/hdb/ai-inventory.cpp
index 25376bf..09fee3b 100644
--- a/engines/hdb/ai-inventory.cpp
+++ b/engines/hdb/ai-inventory.cpp
@@ -98,4 +98,10 @@ void AI::clearInventory() {
 	}
 	_numInventory = keepslot;
 }
+
+AIEntity *AI::getInvItem(int which) {
+	if (which >= _numInventory)
+		return NULL;
+	return _inventory[which].ent;
+}
 } // End of Namespace
diff --git a/engines/hdb/ai.h b/engines/hdb/ai.h
index 815a1ef..4f18a57 100644
--- a/engines/hdb/ai.h
+++ b/engines/hdb/ai.h
@@ -835,6 +835,8 @@ public:
 		_numGems = amt;
 	}
 
+	AIEntity *getInvItem(int which);
+
 	// Player Variables
 	bool _playerDead;
 	bool _playerInvisible;	// While on RailRider for example


Commit: 9ba96ae83ef3ee972155af89915946012f386abc
    https://github.com/scummvm/scummvm/commit/9ba96ae83ef3ee972155af89915946012f386abc
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:00+02:00

Commit Message:
HDB: Add loadTile() and stringLength()

Changed paths:
    engines/hdb/draw-manager.cpp
    engines/hdb/draw-manager.h


diff --git a/engines/hdb/draw-manager.cpp b/engines/hdb/draw-manager.cpp
index 133a24d..c35514c 100644
--- a/engines/hdb/draw-manager.cpp
+++ b/engines/hdb/draw-manager.cpp
@@ -170,6 +170,15 @@ Picture *DrawMan::loadPic(const char *picName) {
 	return pic;
 }
 
+Tile *DrawMan::loadTile(const char *tileName) {
+	Tile *tile = new Tile;
+	Common::SeekableReadStream *stream = g_hdb->_fileMan->findFirstData(tileName, TYPE_TILE32);
+	if (!stream)
+		return NULL;
+	tile->load(stream);
+	return tile;
+}
+
 Tile *DrawMan::getTile(int index) {
 
 	if (index < 0 || index > _numTiles) {
@@ -601,6 +610,12 @@ void DrawMan::getDimensions(const char *string, int *pixelsWide, int *lines) {
 	*lines = height;
 }
 
+int DrawMan::stringLength(const char *string) {
+	int w, h;
+	getDimensions(string, &w, &h);
+	return w;
+}
+
 void DrawMan::setTextEdges(int left, int right, int top, int bottom) {
 	_eLeft = left;
 	_eRight = right;
diff --git a/engines/hdb/draw-manager.h b/engines/hdb/draw-manager.h
index 3b908e7..d63b582 100644
--- a/engines/hdb/draw-manager.h
+++ b/engines/hdb/draw-manager.h
@@ -94,6 +94,7 @@ public:
 	void turnOffFade() { _fadeInfo.active = _fadeInfo.stayFaded = false; }
 
 	Picture *loadPic(const char *picName);
+	Tile *loadTile(const char *tileName);
 
 	Tile *getTile(int index);
 	void cacheTileSequence(int index, int count);
@@ -120,6 +121,7 @@ public:
 	bool loadFont(const char *string);
 	void drawText(const char *string);
 	void getDimensions(const char *string, int *pixelsWide, int *lines);
+	int stringLength(const char *string);
 	void setTextEdges(int left, int right, int top, int bottom);
 	void getTextEdges(int *left, int *right, int *top, int *bottom);
 	void setKernLead(int kern, int lead);


Commit: 8f7e0479fc1d7152cb8f6847913701b9be1bed75
    https://github.com/scummvm/scummvm/commit/8f7e0479fc1d7152cb8f6847913701b9be1bed75
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:00+02:00

Commit Message:
HDB: Add drawInventory() and related functions

Changed paths:
    engines/hdb/window.cpp
    engines/hdb/window.h


diff --git a/engines/hdb/window.cpp b/engines/hdb/window.cpp
index eb36473..12810f8 100644
--- a/engines/hdb/window.cpp
+++ b/engines/hdb/window.cpp
@@ -303,4 +303,82 @@ void Window::setDialogDelay(int delay) {
 	_dialogDelay = g_system->getMillis() + 1000 * delay;
 }
 
+void Window::drawInventory() {
+	int baseX, drawX, drawY;
+	static uint32 timer = g_hdb->getTimeSlice() + 300;
+	AIEntity *e, *sel;
+	char string[8];
+	int gems, mstones;
+
+	// INFOBAR blit - only once per frame
+	// note: if 2, don't draw ANY info at all
+	if (_infobarDimmed > 1)
+		return;
+
+	_gfxInfobar->draw(kScreenWidth - _gfxInfobar->_width, 0);
+
+	baseX = drawX = _invWinInfo.x;
+	drawY = _invWinInfo.y;
+
+	// Draw Inv Items
+	sel = NULL;
+	if (_invWinInfo.selection >= g_hdb->_ai->getInvAmount())
+		_invWinInfo.selection = g_hdb->_ai->getInvAmount();
+
+	for (int inv = 0; inv < g_hdb->_ai->getInvAmount(); inv++) {
+		e = g_hdb->_ai->getInvItem(inv);
+		if (inv == _invWinInfo.selection)
+			sel = e;
+
+		e->standdownGfx[0]->drawMasked(drawX, drawY);
+
+		drawX += kInvItemSpaceX;
+		if (drawX >= baseX + (kInvItemSpaceX * kInvItemPerLine)) {
+			drawX = baseX;
+			drawY += kInvItemSpaceY;
+		}
+	}
+
+	// Draw the Gem
+	drawY = _invWinInfo.y + kInvItemSpaceY * 4 - 8;
+	drawX = baseX - 8;
+	_gemGfx->drawMasked(drawX, drawY);
+
+	// Draw the Gem Amount
+	gems = g_hdb->_ai->getGemAmount();
+	sprintf(string, "%d", gems);
+	g_hdb->_drawMan->setCursor(drawX + 32, drawY + 8);
+	g_hdb->_drawMan->drawText(string);
+
+	// Draw the mini monkeystone
+	mstones = g_hdb->_ai->getMonkeystoneAmount();
+	if (mstones) {
+		drawX = baseX + kInvItemSpaceX * 2 - 8;
+		_mstoneGfx->drawMasked(drawX, drawY + 8);
+
+		// Draw the monkeystone amount
+		sprintf(string, "%d", mstones);
+		g_hdb->_drawMan->setCursor(drawX + 28, drawY + 8);
+		g_hdb->_drawMan->drawText(string);
+	}
+
+	// If you have an inventory, draw the selection cursor
+	if (g_hdb->_ai->getInvAmount()) {
+		if (_invWinInfo.selection < 0)
+			_invWinInfo.selection = 0;
+
+		// Draw the Inventory Select Cursor
+		drawX = baseX + (_invWinInfo.selection % kInvItemPerLine) * kInvItemSpaceX;
+		drawY = _invWinInfo.y + (_invWinInfo.selection / kInvItemPerLine) * kInvItemSpaceY;
+		_gfxInvSelect->drawMasked(drawX, drawY);
+
+		if (sel) {
+			int centerX = baseX - 4 + (kScreenWidth - baseX) / 2;
+			drawY = _invWinInfo.y + (kInvItemSpaceY * 4) + 16;
+			g_hdb->_drawMan->setCursor(centerX - g_hdb->_drawMan->stringLength(sel->printedName) / 2, drawY);
+			g_hdb->_drawMan->drawText(sel->printedName);
+		}
+	}
+}
+
 } // End of Namespace
diff --git a/engines/hdb/window.h b/engines/hdb/window.h
index 8bfc38c..32a41ae 100644
--- a/engines/hdb/window.h
+++ b/engines/hdb/window.h
@@ -81,6 +81,15 @@ public:
 		return _dialogInfo.active;
 	}
 
+	// Inventory Functions
+	void drawInventory();
+	void setInvSelect(int status) {
+		_invWinInfo.selection = status;
+	}
+	int getInvSelect() {
+		return _invWinInfo.selection;
+	}
+
 private:
 
 	DialogInfo _dialogInfo;


Commit: 37a393e9e1f7e4b477caca016be707b82073d932
    https://github.com/scummvm/scummvm/commit/37a393e9e1f7e4b477caca016be707b82073d932
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:00+02:00

Commit Message:
HDB: Call drawInventory() from hdb.cpp

Changed paths:
    engines/hdb/hdb.cpp


diff --git a/engines/hdb/hdb.cpp b/engines/hdb/hdb.cpp
index 0951eac..1f5b11b 100644
--- a/engines/hdb/hdb.cpp
+++ b/engines/hdb/hdb.cpp
@@ -317,6 +317,7 @@ Common::Error HDBGame::run() {
 		_ai->animateTargets();
 
 		_window->drawDialog();
+		_window->drawInventory();
 
 		// Update Timer that's NOT used for in-game Timing
 		_prevTimeSlice = _timeSlice;


Commit: aa793bdcfdb95400cc159cac3afe30f0c332cae8
    https://github.com/scummvm/scummvm/commit/aa793bdcfdb95400cc159cac3afe30f0c332cae8
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:00+02:00

Commit Message:
HDB: Added more debug output and hid some verbose stubs

Changed paths:
    engines/hdb/ai-cinematic.cpp
    engines/hdb/ai-funcs.cpp
    engines/hdb/ai-player.cpp
    engines/hdb/draw-manager.h
    engines/hdb/map-loader.cpp


diff --git a/engines/hdb/ai-cinematic.cpp b/engines/hdb/ai-cinematic.cpp
index 4b906bd..85944a1 100644
--- a/engines/hdb/ai-cinematic.cpp
+++ b/engines/hdb/ai-cinematic.cpp
@@ -193,8 +193,7 @@ void AI::processCines() {
 					warning("Can't locate '%s' in moveEntity", _cine[i]->title);
 				}
 			} else {
-				debug(3, "C_MOVEENTITY: _cine[%d]->e->tileX: %d, _cine[%d]->e->goalX: %d", i, _cine[i]->e->tileX, i, _cine[i]->e->goalX);
-				debug(3, "C_MOVEENTITY: _cine[%d]->e->tileY: %d, _cine[%d]->e->goalY: %d", i, _cine[i]->e->tileY, i, _cine[i]->e->goalY);
+				debug(3, "C_MOVEENTITY: %d, %s tileX: %d, goalX: %d tileY %d, goalY: %d", i, AIType2Str(_cine[i]->e->type), _cine[i]->e->tileX, _cine[i]->e->goalX, _cine[i]->e->tileY, _cine[i]->e->goalY);
 				if (!_cine[i]->e->goalX) {
 					complete = true;
 				}
diff --git a/engines/hdb/ai-funcs.cpp b/engines/hdb/ai-funcs.cpp
index f13e9d5..c1f7da0 100644
--- a/engines/hdb/ai-funcs.cpp
+++ b/engines/hdb/ai-funcs.cpp
@@ -1209,7 +1209,7 @@ void AI::drawEnts(int x, int y, int w, int h) {
 			case AI_VORTEXIAN:
 				if (e->draw)
 					e->draw->drawMasked(e->x - x + e->drawXOff, e->y - y + e->drawYOff);
-				debug(1, "STUB: AI::drawEnts: Replace Masked Blitting with Alpha Masked Blitting");
+				debug(9, "STUB: AI::drawEnts: Replace Masked Blitting with Alpha Masked Blitting");
 				break;
 			case AI_GUY: // Draw Player Last
 				break;
@@ -1259,16 +1259,21 @@ void AI::drawEnts(int x, int y, int w, int h) {
 }
 
 void AI::drawLevel2Ents() {
-	int debug = 0; //game.GetDebug(); // FIXME
+	int debugging = 0; //game.GetDebug(); // FIXME
 
 	for (int i = 0; i < _numLevel2Ents; i++) {
 		// call custom drawing code?
-		if (_entsLevel2[i].aiDraw)
+		if (_entsLevel2[i].aiDraw) {
+			debug(5, "AI::drawLevel2Ents: entity %s(%d) at %d,%d", AIType2Str(_entsLevel2[i].e->type), _entsLevel2[i].e->type, _entsLevel2[i].x, _entsLevel2[i].y);
+
 			_entsLevel2[i].aiDraw(_entsLevel2[i].e, _entsLevel2[i].x, _entsLevel2[i].y);
-		else if (_entsLevel2[i].draw)
+		} else if (_entsLevel2[i].draw) {
+			debug(5, "AI::drawLevel2Ents: tile '%s' at %d,%d", _entsLevel2[i].draw->getName(), _entsLevel2[i].x, _entsLevel2[i].y);
+
 			_entsLevel2[i].draw->drawMasked(_entsLevel2[i].x, _entsLevel2[i].y);
-		else if (debug)
+		} else if (debugging) {
 			_debugQMark->drawMasked(_entsLevel2[i].x, _entsLevel2[i].y );
+		}
 
 		if (_entsLevel2[i].stunnedWait)
 			 g_hdb->_ai->_stunnedGfx[_stunAnim]->drawMasked(_entsLevel2[i].x , _entsLevel2[i].y);
@@ -1436,11 +1441,13 @@ AIEntity *AI::legalMove(int tileX, int tileY, int level, int *result) {
 
 	if (hit && hit->state != STATE_FLOATING)
 		// If player and entity are not at the same level, are they on stairs?
-		if (hit->level != level)
-			if (level == 1 && !(bgFlags & kFlagStairTop))
+		if (hit->level != level) {
+			if (level == 1 && !(bgFlags & kFlagStairTop)) {
 				hit = NULL;
-			else if (level == 1 && !(bgFlags & kFlagStairBot))
+			} else if (level == 1 && !(bgFlags & kFlagStairBot)) {
 				hit = NULL;
+			}
+		}
 
 	if (level == 1) {
 		if (bgFlags & kFlagSolid) {
diff --git a/engines/hdb/ai-player.cpp b/engines/hdb/ai-player.cpp
index 898a20b..3eda52a 100644
--- a/engines/hdb/ai-player.cpp
+++ b/engines/hdb/ai-player.cpp
@@ -128,7 +128,7 @@ void aiPlayerInit2(AIEntity *e) {
 }
 
 void aiPlayerAction(AIEntity *e) {
-	warning("STUB: AI: aiPlayerAction required");
+	debug(9, "STUB: AI: aiPlayerAction required");
 }
 
 void aiPlayerDraw(AIEntity *e, int mx, int my) {
@@ -226,7 +226,7 @@ void aiSergeantInit2(AIEntity *e) {
 
 void aiSergeantAction(AIEntity *e) {
 	if (e->goalX) {
-		warning("AI-PLAYER: aiSergeantAction: Play SND_FOOTSTEPS sounds");
+		debug(9, "STUB: AI-PLAYER: aiSergeantAction: Play SND_FOOTSTEPS sounds");
 		g_hdb->_ai->animateEntity(e);
 	} else
 		g_hdb->_ai->animEntFrames(e);
diff --git a/engines/hdb/draw-manager.h b/engines/hdb/draw-manager.h
index d63b582..05d6245 100644
--- a/engines/hdb/draw-manager.h
+++ b/engines/hdb/draw-manager.h
@@ -190,6 +190,8 @@ public:
 
 	uint _width, _height;
 
+	char *getName() { return _name; }
+
 private:
 
 	char _name[64];
@@ -210,6 +212,7 @@ public:
 
 	uint32 _flags;
 
+	char *getName() { return _name; }
 private:
 	char _name[64];
 
diff --git a/engines/hdb/map-loader.cpp b/engines/hdb/map-loader.cpp
index 04a5ee6..678c203 100644
--- a/engines/hdb/map-loader.cpp
+++ b/engines/hdb/map-loader.cpp
@@ -702,7 +702,7 @@ void Map::drawGratings() {
 		g_hdb->_drawMan->getTile(_gratings[i]->tile)->drawMasked(_gratings[i]->x, _gratings[i]->y);
 	}
 
-	debug(1, "Gratings Count: %d", _numGratings);
+	debug(8, "Gratings Count: %d", _numGratings);
 }
 
 void Map::drawForegrounds() {
@@ -710,7 +710,7 @@ void Map::drawForegrounds() {
 		g_hdb->_drawMan->getTile(_foregrounds[i]->tile)->drawMasked(_foregrounds[i]->x, _foregrounds[i]->y);
 	}
 
-	debug(1, "Foregrounds Count: %d", _numForegrounds);
+	debug(8, "Foregrounds Count: %d", _numForegrounds);
 }
 
 uint32 Map::getMapBGTileFlags(int x, int y) {


Commit: 8dbbb9b85c8845c4fbdd8412dbe872a159becf04
    https://github.com/scummvm/scummvm/commit/8dbbb9b85c8845c4fbdd8412dbe872a159becf04
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:00+02:00

Commit Message:
HDB: Added some code to stopping entity.

Now Sergeant stops, but she is in incorrect state. More code needs to be unstubbed

Changed paths:
    engines/hdb/ai-funcs.cpp


diff --git a/engines/hdb/ai-funcs.cpp b/engines/hdb/ai-funcs.cpp
index c1f7da0..093fbd5 100644
--- a/engines/hdb/ai-funcs.cpp
+++ b/engines/hdb/ai-funcs.cpp
@@ -821,6 +821,11 @@ void AI::animateEntity(AIEntity *e) {
 		// If entity not player, stop it here
 		// If entity is player and no waypoints are left, stop it here
 		if (e != _player || (!_numWaypoints && e == _player)) {
+			e->tileX = e->goalX;
+			e->tileY = e->goalY;
+
+			stopEntity(e);
+
 			warning("STUB: animateEntity: Stop entity");
 		} else if (onEvenTile(e->x, e->y))
 			setEntityGoal(e, _waypoints[0].x, _waypoints[0].y);


Commit: 11166ea5d3f623cf8d783061718e8f4ef29ccea5
    https://github.com/scummvm/scummvm/commit/11166ea5d3f623cf8d783061718e8f4ef29ccea5
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:00+02:00

Commit Message:
HDB: Added missing code to AI::stopEntity()

Now the level intro plays to the end. Yay!

Changed paths:
    engines/hdb/ai-funcs.cpp


diff --git a/engines/hdb/ai-funcs.cpp b/engines/hdb/ai-funcs.cpp
index 093fbd5..771279a 100644
--- a/engines/hdb/ai-funcs.cpp
+++ b/engines/hdb/ai-funcs.cpp
@@ -458,6 +458,7 @@ void AI::stopEntity(AIEntity *e) {
 	e->goalX = e->tileX;
 	e->goalY = e->tileY;
 	e->drawXOff = e->drawYOff = 0;
+	e->goalX = e->goalY = e->xVel = e->yVel = 0;
 
 	// Don't change the state of Diverters or Floating entities
 	switch (e->state) {


Commit: 578b063a9d391c0da6e6d1eacf67a0d703cfd17a
    https://github.com/scummvm/scummvm/commit/578b063a9d391c0da6e6d1eacf67a0d703cfd17a
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:00+02:00

Commit Message:
HDB: Add debug output to cineDialog

Changed paths:
    engines/hdb/ai-cinematic.cpp


diff --git a/engines/hdb/ai-cinematic.cpp b/engines/hdb/ai-cinematic.cpp
index 85944a1..5620f4f 100644
--- a/engines/hdb/ai-cinematic.cpp
+++ b/engines/hdb/ai-cinematic.cpp
@@ -567,7 +567,7 @@ void AI::cineDialog(const char *title, const char *string, int seconds) {
 	if (!title || !string)
 		warning("cineDialog: Missing Title or Text");
 	cmd->cmdType = C_DIALOG;
-	debug("In cineDialog: C_DIALOG created. cmd->start: %d", cmd->start);
+	debug("In cineDialog: C_DIALOG created. cmd->start: %d, cmd->title: %s", cmd->start, cmd->title);
 	_cine.push_back(cmd);
 }
 


Commit: a070e60617041a49a159706532b4169c35f56395
    https://github.com/scummvm/scummvm/commit/a070e60617041a49a159706532b4169c35f56395
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:00+02:00

Commit Message:
HDB: Fix Lua stack indices

Changed paths:
    engines/hdb/lua-script.cpp


diff --git a/engines/hdb/lua-script.cpp b/engines/hdb/lua-script.cpp
index 62ad8d6..a4e4749 100644
--- a/engines/hdb/lua-script.cpp
+++ b/engines/hdb/lua-script.cpp
@@ -258,7 +258,7 @@ static int cineMoveEntity(lua_State *L) {
 static int cineAnimEntity(lua_State *L) {
 	const char *entName = lua_tostring(L, 1);
 	double state = lua_tonumber(L, 2);
-	double loop = lua_tonumber(L, 2);
+	double loop = lua_tonumber(L, 3);
 
 	g_hdb->_lua->checkParameters("cineAnimEntity", 3);
 
@@ -271,7 +271,7 @@ static int cineAnimEntity(lua_State *L) {
 static int cineSetAnimFrame(lua_State *L) {
 	const char *entName = lua_tostring(L, 1);
 	double state = lua_tonumber(L, 2);
-	double frame = lua_tonumber(L, 2);
+	double frame = lua_tonumber(L, 3);
 
 	g_hdb->_lua->checkParameters("cineSetAnimFrame", 3);
 
@@ -338,7 +338,7 @@ static int cineSpawnEntity(lua_State *L) {
 
 static int cineClearForeground(lua_State *L) {
 	double x = lua_tonumber(L, 1);
-	double y = lua_tonumber(L, 1);
+	double y = lua_tonumber(L, 2);
 
 	g_hdb->_lua->checkParameters("cineClearForeground", 2);
 
@@ -349,7 +349,7 @@ static int cineClearForeground(lua_State *L) {
 
 static int cineSetForeground(lua_State *L) {
 	double x = lua_tonumber(L, 1);
-	double y = lua_tonumber(L, 1);
+	double y = lua_tonumber(L, 2);
 	const char *tileName = lua_tostring(L, 3);
 
 	g_hdb->_lua->checkParameters("cineSetForeground", 3);
@@ -363,7 +363,7 @@ static int cineSetForeground(lua_State *L) {
 
 static int cineSetBackground(lua_State *L) {
 	double x = lua_tonumber(L, 1);
-	double y = lua_tonumber(L, 1);
+	double y = lua_tonumber(L, 2);
 	const char *tileName = lua_tostring(L, 3);
 
 	g_hdb->_lua->checkParameters("cineSetBackground", 3);


Commit: cbf4888e2f63604c66b9398572dbc81c5f0e4342
    https://github.com/scummvm/scummvm/commit/cbf4888e2f63604c66b9398572dbc81c5f0e4342
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:00+02:00

Commit Message:
HDB: Fix index for _charInfoBlocks

Changed paths:
    engines/hdb/draw-manager.cpp


diff --git a/engines/hdb/draw-manager.cpp b/engines/hdb/draw-manager.cpp
index c35514c..1232f1c 100644
--- a/engines/hdb/draw-manager.cpp
+++ b/engines/hdb/draw-manager.cpp
@@ -571,7 +571,7 @@ void DrawMan::getDimensions(const char *string, int *pixelsWide, int *lines) {
 
 	for (int i = 0; i < (int)strlen(string); i++) {
 		c = string[i];
-		width += _charInfoBlocks[i]->width + _fontHeader.kerning + kFontIncrement;
+		width += _charInfoBlocks[c]->width + _fontHeader.kerning + kFontIncrement;
 		if (c == ' ')
 			width += kFontSpace;
 


Commit: 1c0da3526c7adc4e7f1d637892088473556c4611
    https://github.com/scummvm/scummvm/commit/1c0da3526c7adc4e7f1d637892088473556c4611
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:00+02:00

Commit Message:
HDB: Add statements for text render debugging

Changed paths:
    engines/hdb/hdb.cpp


diff --git a/engines/hdb/hdb.cpp b/engines/hdb/hdb.cpp
index 1f5b11b..ba0c2aa 100644
--- a/engines/hdb/hdb.cpp
+++ b/engines/hdb/hdb.cpp
@@ -271,7 +271,7 @@ Common::Error HDBGame::run() {
 	_map->load(mapStream);
 	_ai->initAnimInfo();
 
-	_window->openDialog("Title", 0, "String", 0, NULL);
+	//_window->openDialog("Title", 0, "abababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababab", 0, NULL);
 
 #if 0
 	lua->executeFile("test.lua");
@@ -299,6 +299,7 @@ Common::Error HDBGame::run() {
 
 		_map->draw();
 		_ai->processCines();
+		//_window->drawDialog();
 
 		AIEntity *e = _ai->getPlayer();
 


Commit: 9ef57f67de43063621b7446e9427d08b90a197ac
    https://github.com/scummvm/scummvm/commit/9ef57f67de43063621b7446e9427d08b90a197ac
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:00+02:00

Commit Message:
HDB: Fix the type of _foreground and _background

Changed paths:
    engines/hdb/map-loader.cpp
    engines/hdb/map-loader.h


diff --git a/engines/hdb/map-loader.cpp b/engines/hdb/map-loader.cpp
index 678c203..a5e7cf8 100644
--- a/engines/hdb/map-loader.cpp
+++ b/engines/hdb/map-loader.cpp
@@ -89,7 +89,7 @@ bool Map::load(Common::SeekableReadStream *stream) {
 			_iconListOffset, _infoNum, _infoNum, _infoListOffset);
 
 	// Reading Background
-	_background = new uint16[_width * _height];
+	_background = new int16[_width * _height];
 	stream->seek(_backgroundOffset);
 	for (int i = 0; i < _width * _height; i++) {
 		_background[i] = stream->readUint16LE();
@@ -100,7 +100,7 @@ bool Map::load(Common::SeekableReadStream *stream) {
 	}
 
 	// Reading Foreground
-	_foreground = new uint16[_width * _height];
+	_foreground = new int16[_width * _height];
 	stream->seek(_foregroundOffset);
 	for (int i = 0; i < _width * _height; i++) {
 		_foreground[i] = stream->readUint16LE();
@@ -611,7 +611,7 @@ void Map::draw() {
 		for (int i = 0; i < maxTileX; i++) {
 
 			// Draw Background Tile
-			uint16 tileIndex = _background[matrixY + _mapTileX + i];
+			int16 tileIndex = _background[matrixY + _mapTileX + i];
 			if (tileIndex < 0) {
 				tileIndex = 0;
 			}
diff --git a/engines/hdb/map-loader.h b/engines/hdb/map-loader.h
index 62d494c..3916ee7 100644
--- a/engines/hdb/map-loader.h
+++ b/engines/hdb/map-loader.h
@@ -156,8 +156,8 @@ private:
 	uint16 _infoNum;
 	uint32 _infoListOffset;
 
-	uint16 *_background;
-	uint16 *_foreground;
+	int16 *_background;
+	int16 *_foreground;
 	MSMIcon *_iconList;
 
 	byte *_mapExplosions;


Commit: 03f84464cb91d0914e375e5fcdcebe4c1120c120
    https://github.com/scummvm/scummvm/commit/03f84464cb91d0914e375e5fcdcebe4c1120c120
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:01+02:00

Commit Message:
HDB: Added test case for Dialog

Changed paths:
    engines/hdb/hdb.cpp


diff --git a/engines/hdb/hdb.cpp b/engines/hdb/hdb.cpp
index ba0c2aa..7eabd00 100644
--- a/engines/hdb/hdb.cpp
+++ b/engines/hdb/hdb.cpp
@@ -271,7 +271,7 @@ Common::Error HDBGame::run() {
 	_map->load(mapStream);
 	_ai->initAnimInfo();
 
-	//_window->openDialog("Title", 0, "abababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababab", 0, NULL);
+	//_window->openDialog("Sgt. Filibuster", 0, "You address me as 'sarge' or 'sergeant' or get your snappin' teeth kicked in! Got me?", 0, NULL);
 
 #if 0
 	lua->executeFile("test.lua");


Commit: 79e33b113a720ac8852c8960077288db265e8286
    https://github.com/scummvm/scummvm/commit/79e33b113a720ac8852c8960077288db265e8286
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:01+02:00

Commit Message:
HDB: Fix CineCommand struct, use const char * insted of preallocated arrays

Changed paths:
    engines/hdb/ai-cinematic.cpp
    engines/hdb/ai.h


diff --git a/engines/hdb/ai-cinematic.cpp b/engines/hdb/ai-cinematic.cpp
index 5620f4f..9be634c 100644
--- a/engines/hdb/ai-cinematic.cpp
+++ b/engines/hdb/ai-cinematic.cpp
@@ -453,8 +453,7 @@ void AI::cineStart(bool abortable, const char *abortFunc) {
 void AI::cineStop(const char *funcNext) {
 	CineCommand *cmd = new CineCommand;
 	cmd->cmdType = C_STOPCINE;
-	if (funcNext)
-		strcpy(cmd->title, funcNext);
+	cmd->title = funcNext;
 	_cine.push_back(cmd);
 }
 
@@ -511,7 +510,7 @@ void AI::cineWaitUntilDone() {
 
 void AI::cineSetEntity(const char *entName, int x, int y, int level) {
 	CineCommand *cmd = new CineCommand;
-	strcpy(cmd->string, entName);
+	cmd->string = entName;
 	cmd->x = x * kTileWidth;
 	cmd->y = y * kTileHeight;
 	cmd->x2 = level;
@@ -526,7 +525,7 @@ void AI::cineMoveEntity(const char *entName, int x, int y, int level, int speed)
 	cmd->x2 = level;
 	cmd->start = 0;
 	cmd->speed = speed;
-	strcpy(cmd->title, entName);
+	cmd->title = entName;
 	cmd->cmdType = C_MOVEENTITY;
 	_cine.push_back(cmd);
 }
@@ -534,7 +533,7 @@ void AI::cineMoveEntity(const char *entName, int x, int y, int level, int speed)
 void AI::cineAnimEntity(const char *entName, AIState state, int loop) {
 	CineCommand *cmd = new CineCommand;
 	cmd->start = 0;
-	strcpy(cmd->title, entName);
+	cmd->title = entName;
 	cmd->speed = state;
 	cmd->end = loop;
 	cmd->cmdType = C_ANIMENTITY;
@@ -544,7 +543,7 @@ void AI::cineAnimEntity(const char *entName, AIState state, int loop) {
 void AI::cineSetAnimFrame(const char *entName, AIState state, int frame) {
 	CineCommand *cmd = new CineCommand;
 	cmd->start = state;
-	strcpy(cmd->title, entName);
+	cmd->title = entName;
 	cmd->end = frame;
 	cmd->cmdType = C_SETANIMFRAME;
 	_cine.push_back(cmd);
@@ -552,7 +551,7 @@ void AI::cineSetAnimFrame(const char *entName, AIState state, int frame) {
 
 void AI::cineEntityFace(const char *luaName, double dir) {
 	CineCommand *cmd = new CineCommand;
-	strcpy(cmd->title, luaName);
+	cmd->title = luaName;
 	cmd->x = dir;
 	cmd->cmdType = C_ENTITYFACE;
 	_cine.push_back(cmd);
@@ -560,8 +559,8 @@ void AI::cineEntityFace(const char *luaName, double dir) {
 
 void AI::cineDialog(const char *title, const char *string, int seconds) {
 	CineCommand *cmd = new CineCommand;
-	strcpy(cmd->title, title);
-	strcpy(cmd->string, string);
+	cmd->title = title;
+	cmd->string = string;
 	cmd->delay = seconds;
 	cmd->start = 1;
 	if (!title || !string)
@@ -586,15 +585,15 @@ void AI::cineMoveMaskedPic(const char *id, const char *pic, int x1, int y1, int
 	cmd->xv = ((double)(x2-x1)) / (double)speed;
 	cmd->yv = ((double)(y2-y1)) / (double)speed;
 	cmd->start = 0;
-	strcpy(cmd->string, pic);
-	strcpy(cmd->id, id);
+	cmd->string = pic;
+	cmd->id = id;
 	cmd->cmdType = C_MOVEMASKEDPIC;
 	_cine.push_back(cmd);
 }
 
 void AI::cineUse(const char *entName) {
 	CineCommand *cmd = new CineCommand;
-	strcpy(cmd->string, entName);
+	cmd->string = entName;
 	cmd->cmdType = C_USEENTITY;
 	_cine.push_back(cmd);
 }
diff --git a/engines/hdb/ai.h b/engines/hdb/ai.h
index 4f18a57..51b8657 100644
--- a/engines/hdb/ai.h
+++ b/engines/hdb/ai.h
@@ -626,14 +626,14 @@ struct CineCommand {
 	int start, end;
 	uint32	delay;
 	int	speed;
-	char title[32];
-	char string[32];
-	char *id;
+	const char *title;
+	const char *string;
+	const char *id;
 	AIEntity *e;
 	Picture *pic;
 
 	CineCommand() : cmdType(C_NO_COMMAND), x(0.0), y(0.0), x2(0.0), y2(0.0), xv(0.0), yv(0.0),
-				start(0), end(0), delay(0), speed(0), title(""), string(""), id(NULL), e(NULL), pic(NULL) {}
+				start(0), end(0), delay(0), speed(0), title(NULL), string(NULL), id(NULL), e(NULL), pic(NULL) {}
 };
 
 struct CineBlit {


Commit: 7858f01170fe41e0c0d97e67d84105b388c5ec1f
    https://github.com/scummvm/scummvm/commit/7858f01170fe41e0c0d97e67d84105b388c5ec1f
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:01+02:00

Commit Message:
HDB: Fix parameters in cineSetAnimFrame()

Changed paths:
    engines/hdb/lua-script.cpp


diff --git a/engines/hdb/lua-script.cpp b/engines/hdb/lua-script.cpp
index a4e4749..780b55a 100644
--- a/engines/hdb/lua-script.cpp
+++ b/engines/hdb/lua-script.cpp
@@ -283,7 +283,7 @@ static int cineSetAnimFrame(lua_State *L) {
 
 static int cineDialog(lua_State *L) {
 	const char *title = lua_tostring(L, 1);
-	const char *string = lua_tostring(L, 1);
+	const char *string = lua_tostring(L, 2);
 	double seconds = lua_tonumber(L, 3);
 
 	g_hdb->_lua->checkParameters("cineDialog", 3);


Commit: fbf1af2654446aaae4ea3562a627a1a679fce155
    https://github.com/scummvm/scummvm/commit/fbf1af2654446aaae4ea3562a627a1a679fce155
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:01+02:00

Commit Message:
HDB: Unstub aiMaintBot functions

Changed paths:
    engines/hdb/ai-bots.cpp
    engines/hdb/ai-player.cpp


diff --git a/engines/hdb/ai-bots.cpp b/engines/hdb/ai-bots.cpp
index 7bd5c56..837b1e7 100644
--- a/engines/hdb/ai-bots.cpp
+++ b/engines/hdb/ai-bots.cpp
@@ -798,4 +798,155 @@ void aiRailRiderOnAction(AIEntity *e) {
 	}
 }
 
+void aiMaintBotInit(AIEntity *e) {
+	// value1 field determines whether the "MMM!" sound plays
+	// 1 means NO
+	e->int1 = e->value1;
+	e->aiAction = aiMaintBotAction;
+	e->value1 = 0;
+	g_hdb->_ai->findPath(e);
+}
+
+void aiMaintBotInit2(AIEntity *e) {
+	e->draw = g_hdb->_ai->getStandFrameDir(e);
+}
+
+void aiMaintBotAction(AIEntity *e) {
+	AIState useState[5] = {STATE_NONE, STATE_USEUP, STATE_USEDOWN, STATE_USELEFT, STATE_USERIGHT};
+	AIState standState[5] = {STATE_NONE, STATE_STANDUP, STATE_STANDDOWN, STATE_STANDLEFT, STATE_STANDRIGHT};
+	int	xvAhead[5] = {9, 0, 0,-1, 1}, yvAhead[5] = {9,-1, 1, 0, 0};
+	AIEntity *it;
+	int nx, ny;
+	warning("STUB: aiMaintBotAction: Add sounds");
+
+	// Waiting at an arrow (or hit by player)?
+	if (e->sequence) {
+		e->sequence--;
+		g_hdb->_ai->animEntFrames(e);
+
+		// Use Something here
+		if (!e->value2)
+			switch (e->sequence) {
+			case 50:
+				if (e->onScreen && !e->int1) {
+					warning("STUB: aiMaintBotAction: Play SND_MBOT_HMMM or SND_MBOT_HMMM2");
+				}
+				break;
+			// Need to USE the object
+			case 30:
+				e->state = useState[e->dir];
+				nx = e->tileX + xvAhead[e->dir];
+				ny = e->tileY + yvAhead[e->dir];
+				it = g_hdb->_ai->findEntity(nx, ny);
+				if (it) {
+					if (e->onScreen)
+						e->value1 = 1;
+					g_hdb->useEntity(it);
+					break;
+				}
+				// Did the MaintBot use an Action Tile?
+				if (g_hdb->_ai->checkActionList(e, nx, ny, true)) {
+					if (e->onScreen)
+						e->value1 = 1;
+					break;
+				}
+				// Did the MaintBot use an AutoAction Tile?
+				if (g_hdb->_ai->checkAutoList(e, nx, ny)) {
+					if (e->onScreen)
+						e->value1 = 1;
+					break;
+				}
+				// Did the MaintBot use a LUA Tile?
+				warning("STUB: aiMaintBotAction: Check in LUA List");
+				break;
+			// Play a sound if we used something
+			case 25:
+				e->value1 = 0;
+				break;
+			// Change to Standing frames
+			case 20:
+				e->state = standState[e->dir];
+				break;
+			// All done - find a new path
+			case 0:
+				e->dir = e->dir2;
+				g_hdb->_ai->findPath(e);
+				g_hdb->_ai->animateEntity(e);
+				break;
+			}
+		// Deciding where to go at 4-way
+		else {
+			AIDir lookRight[5] = {DIR_NONE, DIR_RIGHT, DIR_LEFT, DIR_UP, DIR_DOWN};
+			AIDir lookLeft[5] = {DIR_NONE, DIR_LEFT, DIR_RIGHT, DIR_DOWN, DIR_UP};
+			AIDir dirList[5] = {DIR_NONE, DIR_UP, DIR_DOWN, DIR_LEFT, DIR_RIGHT};
+			switch (e->sequence) {
+			// HMM
+			case 50:
+				if (e->onScreen && !e->int1)
+					warning("STUB: aiMaintBotAction: Play SND_MBOT_HMMM");
+				break;
+			// Look Right
+			case 40:
+				e->dir = lookRight[e->dir2];
+				e->state = standState[e->dir];
+				break;
+			// Look Left
+			case 30:
+				e->dir = lookLeft[e->dir];
+				e->state = standState[e->dir];
+				break;
+			// HMM2
+			case 25:
+				if (e->onScreen && !e->int1)
+					warning("STUB: aiMaintBotAction: Play SND_MBOT_HMM2");
+				break;
+			// Decide direction and GO
+			case 0:
+				int dir = (g_hdb->_rnd->getRandomNumber(4)) + 1;
+				e->dir = dirList[dir];
+				g_hdb->_ai->findPath(e);
+				if (e->onScreen)
+					warning("STUB: aiMaintBotAction: Play whistle");
+				break;
+			}
+		}
+		return;
+	}
+
+	// Moving already, keep going
+	if (e->goalX) {
+		g_hdb->_ai->animateEntity(e);
+		if (e->onScreen && g_hdb->_ai->checkPlayerCollision(e->x, e->y, 4) && !g_hdb->_ai->playerDead()) {
+			g_hdb->_ai->killPlayer(DEATH_GRABBED);
+			warning("STUB: aiMaintBotAction: Play SND_MBOT_DEATH");
+		}
+	} else {
+		// Check if there's an arrow UNDER the bot, and if its RED
+		// If so, turn in that direction and use something
+		ArrowPath *ar = g_hdb->_ai->findArrowPath(e->tileX, e->tileY);
+		if (ar) {
+			// STOP		Arrow
+			// GO		Arrow
+			// 4-way	Arrow
+			if (!ar->type) {
+				e->dir2 = e->dir; // dir2 holds the last direction we were travelling in
+				e->dir = ar->dir;
+				e->sequence = 64; // sequence is the timer of events
+				e->state = standState[e->dir];
+				e->value2 = 0;
+				return;
+			} else if (ar->type == 1) {
+				g_hdb->_ai->findPath(e);
+				warning("STUB: aiMaintBotAction: Play whistle");
+			} else {
+				e->sequence = 64;
+				e->dir2 = e->dir;
+				e->value2 = 1;
+				return;
+			}
+		}
+		g_hdb->_ai->animateEntity(e);
+	}
+}
+
 } // End of Namespace
diff --git a/engines/hdb/ai-player.cpp b/engines/hdb/ai-player.cpp
index 3eda52a..c74a393 100644
--- a/engines/hdb/ai-player.cpp
+++ b/engines/hdb/ai-player.cpp
@@ -308,18 +308,6 @@ void aiBarrelBlowup(AIEntity *e, int x, int y) {
 	warning("STUB: AI: aiBarrelBlowup required");
 }
 
-void aiMaintBotInit(AIEntity *e) {
-	warning("STUB: AI: aiMaintBotInit required");
-}
-
-void aiMaintBotInit2(AIEntity *e) {
-	warning("STUB: AI: aiMaintBotInit2 required");
-}
-
-void aiMaintBotInitAction(AIEntity *e) {
-	warning("STUB: AI: aiMaintBotInitAction required");
-}
-
 void aiScientistInit(AIEntity *e) {
 	warning("STUB: AI: aiScientistInit required");
 }


Commit: 9f3fab3b4e466738a38f71912f12726b34eff035
    https://github.com/scummvm/scummvm/commit/9f3fab3b4e466738a38f71912f12726b34eff035
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:01+02:00

Commit Message:
HDB: Add hitPlayer()

Changed paths:
    engines/hdb/ai.h


diff --git a/engines/hdb/ai.h b/engines/hdb/ai.h
index 51b8657..ec8c200 100644
--- a/engines/hdb/ai.h
+++ b/engines/hdb/ai.h
@@ -647,6 +647,7 @@ struct CineBlit {
 };
 
 #define onEvenTile(x, y)	( !(x & 31) && !(y & 31) )
+#define hitPlayer(x, y)		( e->onScreen && g_hdb->_ai->checkPlayerCollision( x, y, 4 ) && !g_hdb->_ai->playerDead() )
 
 class AI {
 public:


Commit: d3c2c935a52d59a088feaa82a3ac46fc356c8267
    https://github.com/scummvm/scummvm/commit/d3c2c935a52d59a088feaa82a3ac46fc356c8267
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:01+02:00

Commit Message:
HDB: Add aiFourFirer functions

Changed paths:
    engines/hdb/ai-bots.cpp
    engines/hdb/ai-player.cpp


diff --git a/engines/hdb/ai-bots.cpp b/engines/hdb/ai-bots.cpp
index 837b1e7..f7c6cbc 100644
--- a/engines/hdb/ai-bots.cpp
+++ b/engines/hdb/ai-bots.cpp
@@ -949,4 +949,74 @@ void aiMaintBotAction(AIEntity *e) {
 	}
 }
 
+void aiFourFirerInit(AIEntity *e) {
+	e->value1 = 0;
+	e->aiAction = aiFourFirerAction;
+}
+
+void aiFourFirerInit2(AIEntity *e) {
+	e->draw = g_hdb->_ai->getStandFrameDir(e);
+}
+
+void aiFourFirerAction(AIEntity *e) {
+	AIEntity *p = g_hdb->_ai->getPlayer(), *fire, *hit;
+	AIState state[5] = {STATE_NONE, STATE_STANDUP, STATE_STANDDOWN, STATE_STANDLEFT, STATE_STANDRIGHT};
+	AIDir turn[5] = {DIR_NONE, DIR_RIGHT, DIR_LEFT, DIR_UP, DIR_DOWN};
+	int	shoot, xv, yv, result;
+
+	// Time to turn right?
+	if (!e->value1) {
+		e->dir = turn[e->dir];
+		e->state = state[e->dir];
+		e->value1 = 16;
+		if (e->onScreen)
+			warning("STUB: aiFourFirerAction: Play SND_FOURFIRE_TURN");
+	}
+	e->value1--;
+
+	// Waiting before firing again?
+	if (e->sequence) {
+		e->sequence--;
+		return;
+	}
+
+	g_hdb->_ai->animEntFrames(e);
+
+	// Can we see the player on the same level?
+	if ((e->level != p->level) || g_hdb->_ai->playerDead() || !e->onScreen)
+		return;
+
+	// Check player direction
+	shoot = xv = yv = 0;
+	switch (e->dir) {
+	case DIR_UP:	if (p->x == e->x && p->y < e->y) { shoot = 1; yv = -1; } break;
+	case DIR_DOWN:	if (p->x == e->x && p->y > e->y) { shoot = 1; yv = 1; } break;
+	case DIR_LEFT:	if (p->y == e->y && p->x < e->x) { shoot = 1; xv = -1; } break;
+	case DIR_RIGHT:	if (p->y == e->y && p->x > e->x) { shoot = 1; xv = 1; } break;
+	case DIR_NONE: warning("aiFourFirerAction: DIR_NONE found"); break;
+	}
+
+	// Shoot if needed
+	// Make sure not shooting into solid tile
+	// Make sure if shooting at entity it is the player
+	hit = g_hdb->_ai->legalMoveOverWater(e->tileX + xv, e->tileY + yv, e->level, &result);
+	if (hit && hit->type == AI_GUY)
+		hit = NULL;
+
+	if (shoot && !hit && result) {
+		fire = g_hdb->_ai->spawn(AI_OMNIBOT_MISSILE, e->dir, e->tileX + xv, e->tileY + yv, NULL, NULL, NULL, DIR_NONE, e->level, 0, 0, 1);
+		if (g_hdb->_map->onScreen(e->tileX, e->tileY))
+			warning("STUB: aiFourFirerAction: Play SND_FOUR_FIRE");
+		fire->xVel = xv * kPlayerMoveSpeed * 2;
+		fire->yVel = yv * kPlayerMoveSpeed * 2;
+		if (!g_hdb->getActionMode()) {
+			fire->xVel >>= 1;
+			fire->yVel >>= 1;
+		}
+		e->sequence = 16;
+		if (hitPlayer(fire->tileX*kTileWidth, fire->tileY*kTileHeight))
+			g_hdb->_ai->killPlayer(DEATH_FRIED);
+	}
+}
+
 } // End of Namespace
diff --git a/engines/hdb/ai-player.cpp b/engines/hdb/ai-player.cpp
index c74a393..24ad5ed 100644
--- a/engines/hdb/ai-player.cpp
+++ b/engines/hdb/ai-player.cpp
@@ -316,18 +316,6 @@ void aiScientistInit2(AIEntity *e) {
 	warning("STUB: AI: aiScientistInit2 required");
 }
 
-void aiFourFirerInit(AIEntity *e) {
-	warning("STUB: AI: aiFourFirerInit required");
-}
-
-void aiFourFirerInit2(AIEntity *e) {
-	warning("STUB: AI: aiFourFirerInit2 required");
-}
-
-void aiFourFirerAction(AIEntity *e) {
-	warning("STUB: AI: aiFourFirerAction required");
-}
-
 void aiSlugAttackAction(AIEntity *e) {
 	warning("STUB: AI: aiSlugAttackAction required");
 }


Commit: 407c1913cc6f2327ee0721a5daa8c80b8dd8f98b
    https://github.com/scummvm/scummvm/commit/407c1913cc6f2327ee0721a5daa8c80b8dd8f98b
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:01+02:00

Commit Message:
HDB: Replace booleans with macro function

Changed paths:
    engines/hdb/ai-bots.cpp


diff --git a/engines/hdb/ai-bots.cpp b/engines/hdb/ai-bots.cpp
index f7c6cbc..b86cd4a 100644
--- a/engines/hdb/ai-bots.cpp
+++ b/engines/hdb/ai-bots.cpp
@@ -53,7 +53,7 @@ void aiOmniBotAction(AIEntity *e) {
 		if (!e->sequence) {
 			g_hdb->_ai->animateEntity(e);
 			// Is the Player collding?
-			if (e->onScreen && (p->level = e->level) && g_hdb->_ai->checkPlayerCollision(e->x, e->y, 4) && !g_hdb->_ai->playerDead()) {
+			if (hitPlayer(e->x, e->y) && (p->level == e->level)) {
 				g_hdb->_ai->killPlayer(DEATH_FRIED);
 				return;
 			}
@@ -162,7 +162,7 @@ void aiOmniBotMissileAction(AIEntity *e) {
 
 	// On Even tiles, check for hitting player
 	if (onEvenTile(e->x, e->y))
-		if (e->onScreen && (p->level == e->level) && g_hdb->_ai->checkPlayerCollision(e->x, e->y, 4) && !g_hdb->_ai->playerDead()) {
+		if (hitPlayer(e->x, e->y) && (p->level == e->level)) {
 			g_hdb->_ai->killPlayer(DEATH_NORMAL);
 			g_hdb->_ai->addAnimateTarget(e->x, e->y, 0, 3, ANIM_FAST, false, false, "steam_puff_sit");
 			g_hdb->_ai->removeEntity(e);
@@ -241,7 +241,7 @@ void aiShockBotInit2(AIEntity *e) {
 void aiShockBotAction(AIEntity *e) {
 	if (e->goalX) {
 		if (!e->sequence) {
-			if (e->onScreen && g_hdb->_ai->checkPlayerCollision(e->x, e->y, 4) && !g_hdb->_ai->playerDead())
+			if (hitPlayer(e->x, e->y))
 				g_hdb->_ai->killPlayer(DEATH_SHOCKED);
 			g_hdb->_ai->animateEntity(e);
 		} else
@@ -488,10 +488,10 @@ void aiPushBotAction(AIEntity *e) {
 
 	if (e->goalX) {
 		g_hdb->_ai->animateEntity(e);
-		if (e->onScreen && g_hdb->_ai->checkPlayerCollision(e->x, e->y, 4) && !g_hdb->_ai->playerDead())
+		if (hitPlayer(e->x, e->y))
 			g_hdb->_ai->killPlayer(DEATH_NORMAL);
 	} else {
-		if (e->onScreen && g_hdb->_ai->checkPlayerCollision(e->x, e->y, 4) && !g_hdb->_ai->playerDead())
+		if (hitPlayer(e->x, e->y))
 			g_hdb->_ai->killPlayer(DEATH_NORMAL);
 
 		// Where to go next
@@ -916,7 +916,7 @@ void aiMaintBotAction(AIEntity *e) {
 	// Moving already, keep going
 	if (e->goalX) {
 		g_hdb->_ai->animateEntity(e);
-		if (e->onScreen && g_hdb->_ai->checkPlayerCollision(e->x, e->y, 4) && !g_hdb->_ai->playerDead()) {
+		if (hitPlayer(e->x, e->y)) {
 			g_hdb->_ai->killPlayer(DEATH_GRABBED);
 			warning("STUB: aiMaintBotAction: Play SND_MBOT_DEATH");
 		}


Commit: f4ec024460b7857dc24f8997b5fa2bf9d82577d3
    https://github.com/scummvm/scummvm/commit/f4ec024460b7857dc24f8997b5fa2bf9d82577d3
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:01+02:00

Commit Message:
HDB: Add aiDeadEye functions

Changed paths:
    engines/hdb/ai-bots.cpp
    engines/hdb/ai-player.cpp


diff --git a/engines/hdb/ai-bots.cpp b/engines/hdb/ai-bots.cpp
index b86cd4a..1918a41 100644
--- a/engines/hdb/ai-bots.cpp
+++ b/engines/hdb/ai-bots.cpp
@@ -1019,4 +1019,193 @@ void aiFourFirerAction(AIEntity *e) {
 	}
 }
 
+void aiDeadEyeInit(AIEntity *e) {
+	e->sequence = 64;
+	e->blinkFrames = e->goalX = 0;
+	if (e->value1 == 1)
+		e->aiAction = aiDeadEyeWalkInPlace;
+	else
+		e->aiAction = aiDeadEyeAction;
+}
+
+void aiDeadEyeInit2(AIEntity *e) {
+	e->draw = g_hdb->_ai->getStandFrameDir(e);
+}
+
+void aiDeadEyeWalkInPlace(AIEntity *e) {
+	AIState state[5] = {STATE_NONE, STATE_MOVEUP, STATE_MOVEDOWN, STATE_MOVELEFT, STATE_MOVERIGHT};
+	AIDir dir;
+	AIState s;
+
+	e->sequence--;
+
+	switch (e->sequence) {
+	case 50:
+	case 40:
+	case 30:
+	case 20:
+	case 10:
+		dir = (AIDir)(g_hdb->_rnd->getRandomNumber(4) + 1);
+		s = state[dir];
+		e->dir = dir;
+		e->state = s;
+		if (e->onScreen)
+			if (e->sequence == 50)
+				warning("STUB: aiDeadEyeWalkInPlace: Play SND_DEADEYE_AMB01");
+			else if (e->sequence == 10)
+				warning("STUB: aiDeadEyeWalkInPlace: Play SND_DEADEYE_AMB02");
+		break;
+	case 0:
+		e->sequence = 64;
+	}
+	g_hdb->_ai->animEntFrames(e);
+}
+
+void aiDeadEyeAction(AIEntity *e) {
+	AIState state[5] = {STATE_NONE, STATE_MOVEUP, STATE_MOVEDOWN, STATE_MOVELEFT, STATE_MOVERIGHT};
+	int xvAhead[5] = {9, 0, 0, -1, 1}, yvAhead[5] = {9, -1, 1, 0, 0};
+	int result;
+	AIEntity *hit;
+	AIDir dir;
+	AIState s;
+
+	if (e->sequence) {
+		e->sequence--;
+
+		if (e->blinkFrames)	// Between attacks timer
+			e->blinkFrames--;
+
+		// Is player visible to us?
+		AIEntity *p = g_hdb->_ai->getPlayer();
+		if (e->onScreen && p->level == e->level && !e->blinkFrames) {
+			int nuts = 0;
+			switch (e->dir) {
+			case DIR_UP:	if (p->tileX == e->tileX && p->tileY < e->tileY) nuts = 1; break;
+			case DIR_DOWN:	if (p->tileX == e->tileX && p->tileY > e->tileY) nuts = 1; break;
+			case DIR_LEFT:	if (p->tileY == e->tileY && p->tileX < e->tileX) nuts = 1; break;
+			case DIR_RIGHT: if (p->tileY == e->tileY && p->tileX > e->tileX) nuts = 1; break;
+			case DIR_NONE:	warning("aiDeadEyeAction: DIR_NONE found"); break;
+			}
+
+			// Did we see the player (and we're done moving)?
+			if (nuts && e->aiAction != aiDeadEyeWalkInPlace) {
+				int newX, newY, xv, yv, done, okToMove;
+
+				e->sequence = 0;
+				e->blinkFrames = 20;
+
+				xv = xvAhead[e->dir];
+				yv = yvAhead[e->dir];
+				newX = e->tileX + xv;
+				newY = e->tileY + yv;
+
+				okToMove = done = 0;
+				do {
+					hit = g_hdb->_ai->legalMove(newX, newY, e->level, &result);
+					if (hit && hit->type == AI_GUY)
+						hit = NULL;
+					if (result && !hit) {
+						okToMove = 1;
+						newX += xv;
+						newY += yv;
+						if (newX == p->tileX && newY == p->tileY)
+							done = 1;
+					} else {
+						newX -= xv;
+						newY -= yv;
+						done = 1;
+					}
+				} while (!done);
+
+				// If we can move in the direction of the player, set our goal at him
+				if (okToMove) {
+					e->moveSpeed = kPlayerMoveSpeed << 1;
+					g_hdb->_ai->setEntityGoal(e, newX, newY);
+					p->tileX & 1 ? warning("STUB: aiDeadEyeAction: Play SND_DEADEYE_ATTACK01") : warning("STUB: aiDeadEyeAction: Play SND_DEADEYE_ATTACK02");
+				}
+				g_hdb->_ai->animateEntity(e);
+				return;
+			}
+		}
+
+		switch (e->sequence) {
+		// Look around
+		case 50:
+		case 40:
+		case 30:
+		case 20:
+		case 10:
+			dir = (AIDir)(g_hdb->_rnd->getRandomNumber(4)+1);
+			s = state[dir];
+			e->dir = dir;
+			e->state = s;
+
+			if (e->onScreen)
+				if (e->sequence == 50)
+					warning("STUB: aiDeadEyeAction: Play SND_DEADEYE_AMB01");
+				else if (e->sequence == 10)
+					warning("STUB: aiDeadEyeAction: Play SND_DEADEYE_AMB01");
+			break;
+		case 0:
+			// Pick a random direction and random number of tiles in that direction
+			dir = (AIDir)(g_hdb->_rnd->getRandomNumber(4) + 1);
+			int walk = g_hdb->_rnd->getRandomNumber(5) + 1;
+			int xv, yv;
+
+			e->dir = dir;
+			e->state = state[dir];
+
+			xv = xvAhead[dir] * walk;
+			if (e->tileX + xv < 1)
+				xv = 1 - e->tileX;
+			if (e->tileX + xv > g_hdb->_map->_width)
+				xv = g_hdb->_map->_width - e->tileX - 1;
+
+			yv = yvAhead[dir] * walk;
+			if (e->tileY + yv < 1)
+				yv = 1 - e->tileY;
+			if (e->tileY + yv > g_hdb->_map->_height)
+				yv = g_hdb->_map->_height - e->tileY - 1;
+
+			e->value1 = xvAhead[dir];
+			e->value2 = yvAhead[dir];
+			e->moveSpeed = kPlayerMoveSpeed;
+			hit = g_hdb->_ai->legalMove(e->tileX + xvAhead[e->dir], e->tileY + yvAhead[e->dir], e->level, &result);
+			if (hit && hit->type == AI_GUY)
+				hit = NULL;
+
+			if (!hit && result)
+				g_hdb->_ai->setEntityGoal(e, e->tileX + xv, e->tileY + yv);
+			break;
+		}
+		g_hdb->_ai->animEntFrames(e);
+		return;
+	}
+
+	// In the process of moving around
+	if (e->goalX) {
+		// Hit the player
+		if (hitPlayer(e->x, e->y)) {
+			g_hdb->_ai->killPlayer(DEATH_GRABBED);
+			return;
+		}
+		// Did we run into a wall, entity, water, slime etc?
+		// If so, Pick new direction
+		if (onEvenTile(e->x, e->y)) {
+			hit = g_hdb->_ai->legalMove(e->tileX + e->value1, e->tileY + e->value2, e->level, &result);
+			if (hit && hit->type == AI_GUY)
+				hit = NULL;
+			if (!result || hit) {
+				g_hdb->_ai->stopEntity(e);
+				e->state = STATE_MOVEDOWN;
+				e->sequence = 64;
+				return;
+			}
+		}
+		g_hdb->_ai->animateEntity(e);
+	} else
+		// If not, start looking around
+		e->sequence = 64;
+}
+
 } // End of Namespace
diff --git a/engines/hdb/ai-player.cpp b/engines/hdb/ai-player.cpp
index 24ad5ed..05e8035 100644
--- a/engines/hdb/ai-player.cpp
+++ b/engines/hdb/ai-player.cpp
@@ -412,10 +412,6 @@ void aiDiverterDraw(AIEntity *e, int mx, int my) {
 	warning("STUB: AI: aiDiverterDraw required");
 }
 
-void aiDeadEyeAction(AIEntity *e) {
-	warning("STUB: AI: aiDeadEyeAction required");
-}
-
 void aiMeerkatDraw(AIEntity *e, int mx, int my) {
 	warning("STUB: AI: aiMeerkatDraw required");
 }
@@ -428,10 +424,6 @@ void aiMeerkatLookAround(AIEntity *e) {
 	warning("STUB: AI: aiMeerkatLookAround required");
 }
 
-void aiDeadEyeWalkInPlace(AIEntity *e) {
-	warning("STUB: AI: aiDeadEyeWalkInPlace required");
-}
-
 void aiFatFrogAction(AIEntity *e) {
 	warning("STUB: AI: aiFatFrogAction required");
 }
@@ -500,14 +492,6 @@ void aiDiverterInit2(AIEntity *e) {
 	warning("STUB: AI: aiDiverterInit2 required");
 }
 
-void aiDeadEyeInit(AIEntity *e) {
-	warning("STUB: AI: aiDeadEyeInit required");
-}
-
-void aiDeadEyeInit2(AIEntity *e) {
-	warning("STUB: AI: aiDeadEyeInit2 required");
-}
-
 void aiMeerkatInit(AIEntity *e) {
 	warning("STUB: AI: aiMeerkatInit required");
 }


Commit: 3343787666b3347b586e101f0084b0638d7e236e
    https://github.com/scummvm/scummvm/commit/3343787666b3347b586e101f0084b0638d7e236e
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:01+02:00

Commit Message:
HDB: Fix dialog text spacing

Changed paths:
    engines/hdb/draw-manager.cpp


diff --git a/engines/hdb/draw-manager.cpp b/engines/hdb/draw-manager.cpp
index 1232f1c..c522d94 100644
--- a/engines/hdb/draw-manager.cpp
+++ b/engines/hdb/draw-manager.cpp
@@ -545,7 +545,7 @@ void DrawMan::drawText(const char *string) {
 		g_system->copyRectToScreen(g_hdb->_drawMan->_globalSurface.getBasePtr(_cursorX, _cursorY), g_hdb->_drawMan->_globalSurface.pitch, _cursorX, _cursorY, width, _fontHeader.height);
 
 		// Advance the cursor
-		_cursorX += width + _fontHeader.kerning * kFontIncrement;
+		_cursorX += width + _fontHeader.kerning + kFontIncrement;
 		if (_cursorX > kScreenWidth) {
 			_cursorX = 0;
 			_cursorY += _fontHeader.height + _fontHeader.leading;


Commit: c0413509f1d2f2eda6b5f5e93b6d4dc0b304603e
    https://github.com/scummvm/scummvm/commit/c0413509f1d2f2eda6b5f5e93b6d4dc0b304603e
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:01+02:00

Commit Message:
HDB: Fix tile loading

Changed paths:
    engines/hdb/file-manager.cpp


diff --git a/engines/hdb/file-manager.cpp b/engines/hdb/file-manager.cpp
index 0a23812..7888927 100644
--- a/engines/hdb/file-manager.cpp
+++ b/engines/hdb/file-manager.cpp
@@ -101,7 +101,7 @@ Common::SeekableReadStream *FileMan::findFirstData(const char *string, DataType
 	// Find MPC Entry
 	for (MPCIterator it = _dir.begin(); it != _dir.end(); it++) {
 		fileString = (*it)->filename;
-		if (fileString.contains(string)) {
+		if (fileString.equals(string)) {
 			if ((*it)->type == type) {
 				file = *it;
 				break;


Commit: 406185408f2024b39ff700ae752dc743f64e7db0
    https://github.com/scummvm/scummvm/commit/406185408f2024b39ff700ae752dc743f64e7db0
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:01+02:00

Commit Message:
JANITORIAL: Remove trailing whitespaces

Changed paths:
    engines/hdb/file-manager.cpp
    engines/hdb/window.cpp


diff --git a/engines/hdb/file-manager.cpp b/engines/hdb/file-manager.cpp
index 7888927..66543db 100644
--- a/engines/hdb/file-manager.cpp
+++ b/engines/hdb/file-manager.cpp
@@ -40,7 +40,7 @@ bool FileMan::openMPC(const Common::String &filename) {
 	}
 
 	_dataHeader.id = _mpcFile->readUint32BE();
-	
+
 	if (_dataHeader.id == MKTAG('M', 'P', 'C', 'C')) {
 		_compressed = true;
 		debug("COMPRESSED FILE");
@@ -48,13 +48,13 @@ bool FileMan::openMPC(const Common::String &filename) {
 	}
 	else if (_dataHeader.id == MKTAG('M', 'P', 'C', 'U')) {
 		_compressed = false;
-		
+
 		offset = _mpcFile->readUint32LE();
 		_mpcFile->seek((int32)offset);
 
 		// Note: The MPC archive format assumes the offset to be uint32,
-		// but Common::File::seek() takes the offset as int32. 
-		
+		// but Common::File::seek() takes the offset as int32.
+
 		_dataHeader.dirSize = _mpcFile->readUint32LE();
 
 		debug(8, "MPC: Read %d entries", _dataHeader.dirSize);
@@ -65,7 +65,7 @@ bool FileMan::openMPC(const Common::String &filename) {
 			for (int i = 0; i < 64; i++) {
 				dirEntry->filename[i] = _mpcFile->readByte();
 			}
-			
+
 			dirEntry->offset = _mpcFile->readUint32LE();
 			dirEntry->length = _mpcFile->readUint32LE();
 			dirEntry->ulength = _mpcFile->readUint32LE();
@@ -73,11 +73,11 @@ bool FileMan::openMPC(const Common::String &filename) {
 
 			_dir.push_back(dirEntry);
 		}
-		
+
 		return true;
 
 	}
-	
+
 	error("Invalid MPC File.");
 	return false;
 
diff --git a/engines/hdb/window.cpp b/engines/hdb/window.cpp
index 12810f8..5130769 100644
--- a/engines/hdb/window.cpp
+++ b/engines/hdb/window.cpp
@@ -289,10 +289,8 @@ void Window::drawBorder(int x, int y, int width, int height, bool guyTalking) {
 						else if ((i == wide - 1) && j < high)
 							_gGfxR->draw(x + i * 16, y + j * 16);
 						else
-
 							// Most drawn = middle block
 							_gGfxM->draw(x + i * 16, y + j * 16);
-
 					}
 				}
 			}


Commit: efe0071fb4c70d5ae5f22d4cba2b4f9ad8704a20
    https://github.com/scummvm/scummvm/commit/efe0071fb4c70d5ae5f22d4cba2b4f9ad8704a20
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:01+02:00

Commit Message:
HDB: Fix rendering surfaces without keycolor

Changed paths:
    engines/hdb/draw-manager.cpp


diff --git a/engines/hdb/draw-manager.cpp b/engines/hdb/draw-manager.cpp
index c522d94..fabadac 100644
--- a/engines/hdb/draw-manager.cpp
+++ b/engines/hdb/draw-manager.cpp
@@ -683,7 +683,7 @@ Graphics::Surface Picture::load(Common::SeekableReadStream *stream) {
 }
 
 void Picture::draw(int x, int y) {
-	g_hdb->_drawMan->_globalSurface.transBlitFrom(_surface, Common::Point(x, y));
+	g_hdb->_drawMan->_globalSurface.blitFrom(_surface, Common::Point(x, y));
 
 	Common::Rect clip(_surface.getBounds());
 	clip.moveTo(x, y);
@@ -733,7 +733,7 @@ Graphics::Surface Tile::load(Common::SeekableReadStream *stream) {
 }
 
 void Tile::draw(int x, int y) {
-	g_hdb->_drawMan->_globalSurface.transBlitFrom(_surface, Common::Point(x, y));
+	g_hdb->_drawMan->_globalSurface.blitFrom(_surface, Common::Point(x, y));
 
 	Common::Rect clip(_surface.getBounds());
 	clip.moveTo(x, y);


Commit: 8d4168ca58d99ff99a2080641910d53cdfbd1ab8
    https://github.com/scummvm/scummvm/commit/8d4168ca58d99ff99a2080641910d53cdfbd1ab8
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:01+02:00

Commit Message:
HDB: Hid noisy stubs

Changed paths:
    engines/hdb/ai-bots.cpp
    engines/hdb/ai-cinematic.cpp
    engines/hdb/ai-funcs.cpp


diff --git a/engines/hdb/ai-bots.cpp b/engines/hdb/ai-bots.cpp
index 1918a41..ff94cee 100644
--- a/engines/hdb/ai-bots.cpp
+++ b/engines/hdb/ai-bots.cpp
@@ -817,7 +817,7 @@ void aiMaintBotAction(AIEntity *e) {
 	int	xvAhead[5] = {9, 0, 0,-1, 1}, yvAhead[5] = {9,-1, 1, 0, 0};
 	AIEntity *it;
 	int nx, ny;
-	warning("STUB: aiMaintBotAction: Add sounds");
+	debug(9, "STUB: aiMaintBotAction: Add sounds");
 
 	// Waiting at an arrow (or hit by player)?
 	if (e->sequence) {
diff --git a/engines/hdb/ai-cinematic.cpp b/engines/hdb/ai-cinematic.cpp
index 9be634c..39a203b 100644
--- a/engines/hdb/ai-cinematic.cpp
+++ b/engines/hdb/ai-cinematic.cpp
@@ -266,7 +266,6 @@ void AI::processCines() {
 			break;
 		}
 		case C_DIALOG:
-			debug("In processCines: C_DIALOG: _cine[i]->start: %d", _cine[i]->start);
 			if (_cine[i]->start) {
 				g_hdb->_window->openDialog(_cine[i]->title, -1, _cine[i]->string, 0, NULL);
 				g_hdb->_window->setDialogDelay(_cine[i]->delay);
diff --git a/engines/hdb/ai-funcs.cpp b/engines/hdb/ai-funcs.cpp
index 771279a..c65c267 100644
--- a/engines/hdb/ai-funcs.cpp
+++ b/engines/hdb/ai-funcs.cpp
@@ -730,7 +730,7 @@ void AI::animateEntity(AIEntity *e) {
 
 	// For non-players, check for trigger being hit
 	if (onEvenTile(e->x, e->y)) {
-		warning("STUB: animateEntity: Check for Triggers being hit");
+		debug(9, "STUB: animateEntity: Check for Triggers being hit");
 	}
 
 	// If player, then scroll the screen with the player
@@ -1125,7 +1125,7 @@ void AI::animEntFrames(AIEntity *e) {
 		max = e->special1Frames;
 		break;
 	default:
-		warning("AI-FUNCS: animEntFrames: Unintended State for entity %s", AIType2Str(e->type));
+		debug(9, "AI-FUNCS: animEntFrames: Unintended State for entity %s", AIType2Str(e->type));
 		break;
 	}
 


Commit: 3f01af23cfad61bfe142c2b1b490d6d1ccd9895b
    https://github.com/scummvm/scummvm/commit/3f01af23cfad61bfe142c2b1b490d6d1ccd9895b
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:01+02:00

Commit Message:
HDB: Added several Lua global values

Changed paths:
    engines/hdb/lua-script.cpp


diff --git a/engines/hdb/lua-script.cpp b/engines/hdb/lua-script.cpp
index 780b55a..cbed8b5 100644
--- a/engines/hdb/lua-script.cpp
+++ b/engines/hdb/lua-script.cpp
@@ -701,9 +701,14 @@ struct VarInit {
 // For AI States, to be implemented
 struct NumberInit {
 	int value;
-	char *luaName;
+	const char *luaName;
 } luaGlobalValues[] = {
-	{NULL, NULL}
+	{ DIR_NONE,			"DIR_NONE"	},
+	{ DIR_DOWN,			"DIR_DOWN"	},
+	{ DIR_UP,			"DIR_UP"	},
+	{ DIR_LEFT,			"DIR_LEFT"	},
+	{ DIR_RIGHT,		"DIR_RIGHT"	},
+	{ NULL, NULL }
 };
 
 struct FuncInit {


Commit: e3808675d2ccbeb629da24623fc91ba733199701
    https://github.com/scummvm/scummvm/commit/e3808675d2ccbeb629da24623fc91ba733199701
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:01+02:00

Commit Message:
HDB: Add stubbed Input class

Changed paths:
  A engines/hdb/input.cpp
  A engines/hdb/input.h
    engines/hdb/module.mk


diff --git a/engines/hdb/input.cpp b/engines/hdb/input.cpp
new file mode 100644
index 0000000..d20a203
--- /dev/null
+++ b/engines/hdb/input.cpp
@@ -0,0 +1,61 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "hdb/hdb.h"
+
+namespace HDB {
+
+bool Input::init() {
+	_stylusDown = false;
+
+	warning("STUB: Input::init: Set the default key values");
+
+	_mouseX = kScreenWidth / 2;
+	_mouseY = kScreenHeight / 2;
+	_lastMouseX = _mouseX;
+	_lastMouseY = _mouseY;
+
+	return true;
+}
+
+void Input::setButtons(uint16 b) {
+	warning("STUB: Input: setButtons required");
+}
+
+uint16 Input::getButtons() {
+	warning("STUB: Input: getButtons required");
+	return 0;
+}
+
+void Input::stylusDown(int x, int y) {
+	warning("STUB: Input: stylusDown required");
+}
+
+void stylusUp(int x, int y) {
+	warning("STUB: Input: stylusUp required");
+}
+
+void stylusMove(int x, int y) {
+	warning("STUB: Input: stylusMove required");
+}
+
+}
\ No newline at end of file
diff --git a/engines/hdb/input.h b/engines/hdb/input.h
new file mode 100644
index 0000000..57e145b
--- /dev/null
+++ b/engines/hdb/input.h
@@ -0,0 +1,73 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef HDB_INPUT_H
+#define HDB_INPUT_H
+
+#include "common/system.h"
+
+namespace HDB {
+
+enum Button {
+	kButtonUp		= 2 << 0,
+	kButtonDown		= 2 << 1,
+	kButtonLeft		= 2 << 2,
+	kButtonRight	= 2 << 3,
+	kButtonA		= 2 << 4,
+	kButtonB		= 2 << 5,
+	kButtonC		= 2 << 6,
+	kButtonD		= 2 << 7,
+	kButtonMouseL	= 2 << 8,
+	kButtonMouseM	= 2 << 9,
+	kButtonMouseR	= 2 << 10,
+	kButtonExit		= 2 << 11
+};
+
+class Input {
+public:
+
+	bool init();
+
+	void setButtons(uint16 b);
+	uint16 getButtons();
+	void stylusDown(int x, int y);
+	void stylusUp(int x, int y);
+	void stylusMove(int x, int y);
+
+private:
+
+	uint16 _buttons;	// Flags for buttons
+	bool _stylusDown;
+	int _stylusDownX, _stylusDownY;
+	int _mouseX, _mouseY;
+	int _lastMouseX, _lastMouseY;
+
+	// Definable Keys
+	int _keyUp, _keyDown, _keyLeft, _keyRight;
+	int _keyInv, _keyUse, _keyMenu, _keyDebug;
+	int _keyQuit;
+};
+
+} // End of Namespace
+
+#endif // !HDB_INPUT_H
+
diff --git a/engines/hdb/module.mk b/engines/hdb/module.mk
index bf53ad0..af32361 100644
--- a/engines/hdb/module.mk
+++ b/engines/hdb/module.mk
@@ -15,6 +15,7 @@ MODULE_OBJS := \
 	detection.o \
 	file-manager.o \
 	hdb.o \
+	input.o \
 	lua-script.o \
 	map-loader.o \
 	window.o


Commit: 1b7034cd87e2caed6eef9816a1e026519ba3135d
    https://github.com/scummvm/scummvm/commit/1b7034cd87e2caed6eef9816a1e026519ba3135d
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:01+02:00

Commit Message:
HDB: Add _input subsytem and init it

Changed paths:
    engines/hdb/hdb.cpp
    engines/hdb/hdb.h


diff --git a/engines/hdb/hdb.cpp b/engines/hdb/hdb.cpp
index 7eabd00..238033c 100644
--- a/engines/hdb/hdb.cpp
+++ b/engines/hdb/hdb.cpp
@@ -47,6 +47,7 @@ HDBGame::HDBGame(OSystem *syst, const ADGameDescription *gameDesc) : Engine(syst
 	_lua = new LuaScript;
 	_map = new Map;
 	_ai = new AI;
+	_input = new Input;
 	_window = new Window;
 	_rnd = new Common::RandomSource("hdb");
 
@@ -61,6 +62,7 @@ HDBGame::~HDBGame() {
 	delete _lua;
 	delete _map;
 	delete _ai;
+	delete _input;
 	delete _window;
 	delete _rnd;
 
@@ -80,6 +82,9 @@ bool HDBGame::init() {
 	if (!_drawMan->init()) {
 		error("DrawMan::init: Couldn't initialize DrawMan");
 	}
+	if (!_input->init()) {
+		error("Input::init: Couldn't initialize Input");
+	}
 	if (!_ai->init()) {
 		error("AI::init: Couldn't initialize AI");
 	}
diff --git a/engines/hdb/hdb.h b/engines/hdb/hdb.h
index e831ab8..ef8a726 100644
--- a/engines/hdb/hdb.h
+++ b/engines/hdb/hdb.h
@@ -41,6 +41,7 @@
 #include "hdb/ai.h"
 #include "hdb/ai-player.h"
 #include "hdb/file-manager.h"
+#include "hdb/input.h"
 #include "hdb/lua-script.h"
 #include "hdb/map-loader.h"
 #include "hdb/window.h"
@@ -126,6 +127,7 @@ public:
 	LuaScript *_lua;
 	Map *_map;
 	AI *_ai;
+	Input *_input;
 	Window *_window;
 
 	// Random Source


Commit: d553a37e396fa85fa139b0ad33421dad62c8d7bb
    https://github.com/scummvm/scummvm/commit/d553a37e396fa85fa139b0ad33421dad62c8d7bb
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:01+02:00

Commit Message:
HDB: Fix type of getMapBG/FGTileIndex

Changed paths:
    engines/hdb/map-loader.cpp
    engines/hdb/map-loader.h


diff --git a/engines/hdb/map-loader.cpp b/engines/hdb/map-loader.cpp
index a5e7cf8..49a7c89 100644
--- a/engines/hdb/map-loader.cpp
+++ b/engines/hdb/map-loader.cpp
@@ -733,14 +733,14 @@ uint32 Map::getMapFGTileFlags(int x, int y) {
 	return 0;
 }
 
-uint16 Map::getMapBGTileIndex(int x, int y) {
+int16 Map::getMapBGTileIndex(int x, int y) {
 	if (x < 0 || x >= _width || y < 0 || y >= _height) {
 		return 0;
 	}
 	return _background[y * _width + x];
 }
 
-uint16 Map::getMapFGTileIndex(int x, int y) {
+int16 Map::getMapFGTileIndex(int x, int y) {
 	if (x < 0 || x >= _width || y < 0 || y >= _height) {
 		return 0;
 	}
diff --git a/engines/hdb/map-loader.h b/engines/hdb/map-loader.h
index 3916ee7..151bef9 100644
--- a/engines/hdb/map-loader.h
+++ b/engines/hdb/map-loader.h
@@ -89,8 +89,8 @@ public:
 
 	uint32 getMapBGTileFlags(int x, int y);
 	uint32 getMapFGTileFlags(int x, int y);
-	uint16 getMapBGTileIndex(int x, int y);
-	uint16 getMapFGTileIndex(int x, int y);
+	int16 getMapBGTileIndex(int x, int y);
+	int16 getMapFGTileIndex(int x, int y);
 	void setMapBGTileIndex(int x, int y, int index);
 	void setMapFGTileIndex(int x, int y, int index);
 	void addBGTileAnimation(int x, int y);


Commit: c946f42a927f91375602a13f58fdd8601472715b
    https://github.com/scummvm/scummvm/commit/c946f42a927f91375602a13f58fdd8601472715b
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:01+02:00

Commit Message:
HDB: Add remaining game Flags

Changed paths:
    engines/hdb/hdb.h


diff --git a/engines/hdb/hdb.h b/engines/hdb/hdb.h
index ef8a726..afc78b6 100644
--- a/engines/hdb/hdb.h
+++ b/engines/hdb/hdb.h
@@ -71,24 +71,40 @@ enum GameState {
 };
 
 enum Flag {
+	kFlagOK				= 0x0,
+	kFlagPlayerBlock	= 0x1,
 	kFlagMonsterBlock	= 0x2,
 	kFlagSolid			= 0x3,
+	kFlagItemDie		= 0x4,
 	kFlagPlayerDie		= 0x8,
+	kFlagMonsterDie		= 0x10,
 	kFlagInvisible		= 0x20,
 	kFlagMetal			= 0x40,
 	kFlagForeground		= 0x80,
+	kFlagMonsterHurt	= 0x100,
+	kFlagPushUp			= 0x200,
+	kFlagPushRight		= 0x400,
+	kFlagPushDown		= 0x800,
+	kFlagPushLeft		= 0x1000,
+	kFlagLightSink		= 0x2000,
 	kFlagSlime			= 0x201C,
+	kFlagHeavySink		= 0x4000,
 	kFlagWater			= 0x401C,
+	kFlagLightMelt		= 0x8000,
+	kFlagHeavyMelt		= 0x10000,
+	kFlagSlide			= 0x20000,
 	kFlagEnergyFloor	= 0x40000,
 	kFlagPlasmaFloor	= 0x6000D,
 	kFlagRadFloor		= 0x6800D,
+	kFlagTeleport		= 0x80000,
 	kFlagSpecial		= 0x100000,
+	kFlagIce			= 0x120000,
 	kFlagStairBot		= 0x200000,
 	kFlagStairTop		= 0x400000,
 	kFlagAnimSlow		= 0x800000,
 	kFlagAnimMedium		= 0x1000000,
-	kFlagMasked			= 0x2000000,
 	kFlagAnimFast		= 0x1800000,
+	kFlagMasked			= 0x2000000,
 	kFlagGrating		= 0x4000000,
 	kFlagPlummet		= 0x8000000
 };


Commit: 4153d92b5adc0935b22f138ff5e4fc79f76e9863
    https://github.com/scummvm/scummvm/commit/4153d92b5adc0935b22f138ff5e4fc79f76e9863
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:01+02:00

Commit Message:
HDB: Add mpc.h from source files

Changed paths:
  A engines/hdb/mpc.h
    engines/hdb/hdb.h


diff --git a/engines/hdb/hdb.h b/engines/hdb/hdb.h
index afc78b6..11ab000 100644
--- a/engines/hdb/hdb.h
+++ b/engines/hdb/hdb.h
@@ -37,6 +37,7 @@
 #include "engines/util.h"
 #include "console.h"
 
+#include "hdb/mpc.h"
 #include "hdb/draw-manager.h"
 #include "hdb/ai.h"
 #include "hdb/ai-player.h"
diff --git a/engines/hdb/mpc.h b/engines/hdb/mpc.h
new file mode 100644
index 0000000..ddfa365
--- /dev/null
+++ b/engines/hdb/mpc.h
@@ -0,0 +1,924 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef HDB_MPC_H
+#define HDB_MPC_H
+
+#endif // !HDB_MPC_H
+
+#define		TILE_TELEPORT1					"anim_t32_teleporter1"
+#define		TILE_TOUCHPLATE_OFF				"t32_touchplateoff"
+#define		TILE_TOUCHPLATE_ON				"t32_touchplateon"
+#define		TILE_SKY_STARS					"t32_sky_stars"
+#define		TILE_HOLDER1					"anim_t32_holder_empty1"
+#define		TILE_HOLDERFULL					"t32_holder_full"
+#define		TILE_SWITCH1					"anim_t32_switch_off01"
+#define		TILE_1SWITCH1					"anim_t32_1switch_off01"
+#define		TILE_DOOR_N						"t32_door_n_1"
+#define		TILE_DOOR_P						"t32_door_p_1"
+#define		TILE_DOOR_S						"t32_door_s_1"
+#define		TILE_ASKCOMP1					"anim_t32_askcomp1"
+#define		TILE_BRIDGE_U					"t32_bridgeup1"
+#define		TILE_SWITCH_ON					"t32_switch_on"
+#define		TILE_1SWITCH_ON					"t32_1switch_on"
+#define		TILE_BRIDGE_R					"t32_bridgeright1"
+#define		TILE_BRIDGE_D					"t32_bridgedown1"
+#define		TILE_BRIDGE_L					"t32_bridgeleft1"
+#define		TILE_FLOORSHOCK					"t32_floorshock3"
+#define		TILE_BEDR_CLOSED				"t32_bedr_r"
+#define		TILE_BEDL_CLOSED				"t32_bedl_l"
+#define		TILE_BEDR_OPEN					"t32_bedr_open"
+#define		TILE_BEDL_OPEN					"t32_bedl_open"
+#define		TILE_FERRET						"anim_t32_ferret1"
+#define		TILE_DOOR_NV					"t32_door_nv_1"
+#define		TILE_DOOR_PV					"t32_door_pv_1"
+#define		TILE_DOOR_SV					"t32_door_sv_1"
+#define		TILE_MAILSORT					"anim_t32_mailsort1"
+#define		TILE_INBOX						"t32_deco_inbox"
+#define		TILE_DOOR2_N					"t32_door2_n_1"
+#define		TILE_DOOR2_P					"t32_door2_p_1"
+#define		TILE_DOOR2_S					"t32_door2_s_1"
+#define		TILE_DOOR2_NV					"t32_door2_nv_1"
+#define		TILE_DOOR2_PV					"t32_door2_pv_1"
+#define		TILE_DOOR2_SV					"t32_door2_sv_1"
+#define		TILE_2DOOR_N					"t32_e2_door_n_1"
+#define		TILE_2DOOR_P					"t32_e2_door_p_1"
+#define		TILE_2DOOR_S					"t32_e2_door_s_1"
+#define		TILE_2DOOR_NV					"t32_e2_door_nv_1"
+#define		TILE_2DOOR_PV					"t32_e2_door_pv_1"
+#define		TILE_2DOOR_SV					"t32_e2_door_sv_1"
+#define		TILE_3DOOR_N					"t32_e3_door_n_1"
+#define		TILE_3DOOR_P					"t32_e3_door_p_1"
+#define		TILE_3DOOR_S					"t32_e3_door_s_1"
+#define		TILE_3DOOR_NV					"t32_e3_door_nv_1"
+#define		TILE_3DOOR_PV					"t32_e3_door_pv_1"
+#define		TILE_3DOOR_SV					"t32_e3_door_sv_1"
+#define		TILE_MEMOS						"t32_memos"
+#define		TILE_PACKAGE					"t32_package"
+#define		TILE_TYRANIUM					"t32_tyranium"
+#define		TILE_FOUR_TOOLS					"t32_four_tools"
+#define		TILE_GRATING_LR					"t32_mgrate_mid"
+#define		TILE_GRATING_UD					"t32_mgrate_tbmid"
+#define		TILE_BTUNNEL_BLOCK_B			"t32_btunnel_block_b"
+#define		TILE_BTUNNEL_BLOCK_L			"t32_btunnel_block_l"
+#define		TILE_BTUNNEL_BLOCK_R			"t32_btunnel_block_r"
+#define		TILE_BTUNNEL_BLOCK_T			"t32_btunnel_block_t"
+#define		TILE_BTUNNEL_DONE_B				"t32_btunnel_done_b"
+#define		TILE_BTUNNEL_DONE_L				"t32_btunnel_done_l"
+#define		TILE_BTUNNEL_DONE_R				"t32_btunnel_done_r"
+#define		TILE_BTUNNEL_DONE_T				"t32_btunnel_done_t"
+#define		TILE_A							"t32_alpha_a"
+#define		TILE_B							"t32_alpha_b"
+#define		TILE_C							"t32_alpha_c"
+#define		TILE_D							"t32_alpha_d"
+#define		TILE_E							"t32_alpha_e"
+#define		TILE_F							"t32_alpha_f"
+#define		TILE_G							"t32_alpha_g"
+#define		TILE_H							"t32_alpha_h"
+#define		TILE_I							"t32_alpha_i"
+#define		TILE_J							"t32_alpha_j"
+#define		TILE_K							"t32_alpha_k"
+#define		TILE_L							"t32_alpha_l"
+#define		TILE_M							"t32_alpha_m"
+#define		TILE_N							"t32_alpha_n"
+#define		TILE_O							"t32_alpha_o"
+#define		TILE_P							"t32_alpha_p"
+#define		TILE_Q							"t32_alpha_q"
+#define		TILE_R							"t32_alpha_r"
+#define		TILE_S							"t32_alpha_s"
+#define		TILE_T							"t32_alpha_t"
+#define		TILE_U							"t32_alpha_u"
+#define		TILE_V							"t32_alpha_v"
+#define		TILE_W							"t32_alpha_w"
+#define		TILE_X							"t32_alpha_x"
+#define		TILE_Y							"t32_alpha_y"
+#define		TILE_Z							"t32_alpha_z"
+#define		TILE_SKY_STARS_DOWN_SLOW		"t32_sky_stars_down_slow"
+#define		TILE_SKY_STARS_UP_SLOW			"t32_sky_stars_up_slow"
+#define		TILE_SKY_STARS_RIGHT_SLOW		"t32_sky_stars_right_slow"
+#define		TILE_SKY_STARS_LEFT_SLOW		"t32_sky_stars_left_slow"
+#define		TILE_SKY_STARS_STATIONARY		"t32_sky_stars_stationary"
+#define		TILE_CHAIR						"t32_brownchair_u"
+#define		TILE_PIZZA						"t32_deco_pizza"
+#define		TILE_CABOPEN_T					"t32_opencabinet_t"
+#define		TILE_CABOPEN_B					"t32_opencabinet_b"
+#define		TILE_BLOCKPOLE					"t32_blockpole_1"
+#define		TILE_SKY_CLOUDS					"t32_sky_clouds"
+#define		TILE_TEMPLE_TOUCHPLATE_OFF		"t32_temple_touchplate_off"
+#define		TILE_TEMPLE_TOUCHPLATE_ON		"t32_temple_touchplate_on"
+#define		TILE_KC_HOLDER_WHITE_OFF		"anim_t32_kcholder_white_off1"
+#define		TILE_KC_HOLDER_WHITE_ON			"t32_kcholder_white_on"
+#define		TILE_KC_HOLDER_BLUE_OFF			"anim_t32_kcholder_blue_off1"
+#define		TILE_KC_HOLDER_BLUE_ON			"t32_kcholder_blue_on"
+#define		TILE_KC_HOLDER_RED_OFF			"anim_t32_kcholder_red_off1"
+#define		TILE_KC_HOLDER_RED_ON			"t32_kcholder_red_on"
+#define		TILE_KC_HOLDER_GREEN_OFF		"anim_t32_kcholder_green_off1"
+#define		TILE_KC_HOLDER_GREEN_ON			"t32_kcholder_green_on"
+#define		TILE_KC_HOLDER_PURPLE_OFF		"anim_t32_kcholder_purple_off1"
+#define		TILE_KC_HOLDER_PURPLE_ON		"t32_kcholder_purple_on"
+#define		TILE_KC_HOLDER_BLACK_OFF		"anim_t32_kcholder_black_off1"
+#define		TILE_KC_HOLDER_BLACK_ON			"t32_kcholder_black_on"
+#define		TILE_SHIP_HANDSWITCH_OFF		"anim_t32_ship_handswitch_off1"
+#define		TILE_SHIP_HANDSWITCH_ON			"t32_ship_handswitch_on"
+#define		TILE_BLOCKING_VINES				"t32_blocking_vines"
+#define		TILE_WASTEBASKET				"t32_deco_wastebasket"
+#define		TILE_SNOWDOOR_B					"t32_snow_temple_opendoor_b"
+#define		TILE_PHAR_CARPET				"t32_phar_carpet_tb"
+#define		TILE_HEADSTATUE					"t32_phar_headstatue1"
+#define		TILE_ROUTER_HOLDER				"t32_router_holder"
+#define		TILE_WEAPON_EQUIPPED			"t32_weapon_equipped"
+#define		FORCEFIELD_LR					"anim_t32_forcefield_lr_"
+#define		FORCEFIELD_UD					"anim_t32_forcefield_ud_"
+#define		FORCESPLASH_TOP					"anim_t32_ff_splash_top"
+#define		FORCESPLASH_BTM					"anim_t32_ff_splash_btm"
+#define		FORCESPLASH_LEFT				"anim_t32_ff_splash_left"
+#define		FORCESPLASH_RIGHT				"anim_t32_ff_splash_right_"
+#define		DEMIGOD_FLOAT_T					"anim_t32_demigod_floats_t01"
+#define		DEMIGOD_FLOAT_B					"anim_t32_demigod_floats_t01"
+#define		TILE_FFTONGUE_UD_MIDDLE			"t32_tongue_ud_middle"
+#define		TILE_FFTONGUE_UD_WIGGLE_L		"t32_tongue_ud_wiggle_left"
+#define		TILE_FFTONGUE_UD_WIGGLE_M		"t32_tongue_ud_wiggle_mid"
+#define		TILE_FFTONGUE_UD_WIGGLE_R		"t32_tongue_ud_wiggle_right"
+#define		TILE_FFTONGUE_LR_MIDDLE			"t32_tongue_lr_middle"
+#define		TILE_FFTONGUE_R_WIGGLE_U		"t32_tongue_right_wiggle_up"
+#define		TILE_FFTONGUE_R_WIGGLE_M		"t32_tongue_right_wiggle_mid"
+#define		TILE_FFTONGUE_R_WIGGLE_D		"t32_tongue_right_wiggle_down"
+#define		TILE_FFTONGUE_L_WIGGLE_U		"t32_tongue_left_wiggle_up"
+#define		TILE_FFTONGUE_L_WIGGLE_M		"t32_tongue_left_wiggle_mid"
+#define		TILE_FFTONGUE_L_WIGGLE_D		"t32_tongue_left_wiggle_down"
+#define		TILE_CONDUCTOR					"t32_conductor"
+#define		GEM_WHITE						"t32_gem_white"
+#define		GEM_RED_GFX						"t32_gem_red"
+#define		GEM_BLUE_GFX					"t32_gem_blue"
+#define		GEM_GREEN_GFX					"t32_gem_green"
+#define		TILE_HEAD_SCIENTIST				"t32_head_scientist"
+#define		TILE_HEAD_SPACEDUDE				"t32_head_spacedude"
+#define		TILE_HEAD_WORKER				"t32_head_worker"
+#define		TILE_HEAD_ACCOUNTANT			"t32_head_accountant"
+#define		TILE_HEAD_DOLLY					"t32_head_dolly"
+#define		TILE_HEAD_SARGE					"t32_head_sarge"
+#define		TILE_SLOT_GOOD1					"t32_slot_good1"
+#define		TILE_SLOT_GOOD2					"t32_slot_good2"
+#define		TILE_SLOT_GOOD3					"t32_slot_good3"
+#define		TILE_SLOT_GOOD4					"t32_slot_good4"
+#define		TILE_SLOT_GOOD5					"t32_slot_good5"
+#define		TILE_SLOT_GOOD6					"t32_slot_good6"
+#define		TILE_SLOT_BAD					"t32_slot_bad"
+#define		GROUP_ENT_GUY					"ent_guy_"
+#define		GROUP_ENT_GUY_WALKDOWN			"ent_guy_walkdown"
+#define		GROUP_ENT_GUY_WALKUP			"ent_guy_walkup"
+#define		GROUP_ENT_GUY_WALKRIGHT			"ent_guy_walkright"
+#define		GROUP_ENT_GUY_WALKLEFT			"ent_guy_walkleft"
+#define		GROUP_ENT_GUY_DIE				"ent_guy_die"
+#define		GROUP_ENT_GUY_BLINK				"ent_guy_blink"
+#define		GROUP_ENT_GUY_STANDDOWN			"ent_guy_standdown"
+#define		GROUP_ENT_GUY_STANDUP			"ent_guy_standup"
+#define		GROUP_ENT_GUY_STANDRIGHT		"ent_guy_standright"
+#define		GROUP_ENT_GUY_STANDLEFT			"ent_guy_standleft"
+#define		GROUP_ENT_GUY_GOODJOB			"ent_guy_goodjob"
+#define		TILE_GUYSLEEPING				"t32_guysleep"
+#define		GROUP_ENT_GUY_PLUMMET			"ent_guy_plummet"
+#define		GROUP_ENT_GUY_HORRIBLE1			"ent_guy_horrible1"
+#define		GROUP_ENT_GUY_HORRIBLE2			"ent_guy_horrible2"
+#define		GROUP_ENT_GUY_HORRIBLE3			"ent_guy_horrible3"
+#define		GROUP_ENT_GUY_HORRIBLE4			"ent_guy_horrible4"
+#define		GROUP_ENT_GUY_PUSHDOWN			"ent_guy_pushdown"
+#define		GROUP_ENT_GUY_PUSHUP			"ent_guy_pushup"
+#define		GROUP_ENT_GUY_PUSHRIGHT			"ent_guy_pushright"
+#define		GROUP_ENT_GUY_PUSHLEFT			"ent_guy_pushleft"
+#define		GROUP_ENT_GUY_STUNDOWN			"ent_guy_stundown"
+#define		GROUP_ENT_GUY_STUNUP			"ent_guy_stunup"
+#define		GROUP_ENT_GUY_STUNRIGHT			"ent_guy_stunright"
+#define		GROUP_ENT_GUY_STUNLEFT			"ent_guy_stunleft"
+#define		GROUP_ENT_GUY_GETDOWN			"ent_guy_getdown"
+#define		GROUP_ENT_GUY_GETUP				"ent_guy_getup"
+#define		GROUP_ENT_GUY_GETRIGHT			"ent_guy_getright"
+#define		GROUP_ENT_GUY_GETLEFT			"ent_guy_getleft"
+#define		GROUP_ENT_GUY_SLINGDOWN			"ent_guy_slingdown"
+#define		GROUP_ENT_GUY_SLINGUP			"ent_guy_slingup"
+#define		GROUP_ENT_GUY_SLINGRIGHT		"ent_guy_slingright"
+#define		GROUP_ENT_GUY_SLINGLEFT			"ent_guy_slingleft"
+#define		CLUBLEFT1						"clubleft1"
+#define		CLUBLEFT2						"clubleft2"
+#define		CLUBLEFT3						"clubleft3"
+#define		CLUBRIGHT1						"clubright1"
+#define		CLUBRIGHT2						"clubright2"
+#define		CLUBRIGHT3						"clubright3"
+#define		CLUBDOWN1						"clubdown1"
+#define		CLUBDOWN2						"clubdown2"
+#define		CLUBDOWN3						"clubdown3"
+#define		CLUBUP1							"clubup1"
+#define		CLUBUP2							"clubup2"
+#define		CLUBUP3							"clubup3"
+#define		TILE_ENV_WHITE					"ent_envelope_white_sit01"
+#define		GROUP_ENT_ENVELOPE_WHITE        "ent_envelope_white_"
+#define		GROUP_ENT_ENVELOPE_WHITE_SIT    "ent_envelope_white_sit"
+#define		GROUP_ENT_ENVELOPE_BLUE         "ent_envelope_blue_"
+#define		GROUP_ENT_ENVELOPE_BLUE_SIT     "ent_envelope_blue_sit"
+#define		GROUP_ENT_ENVELOPE_RED          "ent_envelope_red_"
+#define		GROUP_ENT_ENVELOPE_RED_SIT      "ent_envelope_red_sit"
+#define		GROUP_ENT_ENVELOPE_GREEN        "ent_envelope_green_"
+#define		GROUP_ENT_ENVELOPE_GREEN_SIT    "ent_envelope_green_sit"
+#define		GROUP_ENT_SCIENTIST             "ent_scientist_"
+#define		GROUP_ENT_SCIENTIST_WALKDOWN    "ent_scientist_walkdown"
+#define		GROUP_ENT_SCIENTIST_WALKUP      "ent_scientist_walkup"
+#define		GROUP_ENT_SCIENTIST_WALKRIGHT   "ent_scientist_walkright"
+#define		GROUP_ENT_SCIENTIST_WALKLEFT    "ent_scientist_walkleft"
+#define		GROUP_ENT_SCIENTIST_DIE         "ent_scientist_die"
+#define		GROUP_ENT_SCIENTIST_STANDDOWN   "ent_scientist_standdown"
+#define		GROUP_ENT_SCIENTIST_STANDUP     "ent_scientist_standup"
+#define		GROUP_ENT_SCIENTIST_STANDRIGHT  "ent_scientist_standright"
+#define		GROUP_ENT_SCIENTIST_STANDLEFT   "ent_scientist_standleft"
+#define		GROUP_ENT_SCIENTIST_BLINK       "ent_scientist_blink"
+#define		GROUP_ENT_SCIENTIST_WIN         "ent_scientist_win"
+#define		GROUP_ENT_SERGEANT              "ent_sergeant_"
+#define		GROUP_ENT_SERGEANT_WALKDOWN     "ent_sergeant_walkdown"
+#define		GROUP_ENT_SERGEANT_WALKUP       "ent_sergeant_walkup"
+#define		GROUP_ENT_SERGEANT_WALKRIGHT    "ent_sergeant_walkright"
+#define		GROUP_ENT_SERGEANT_WALKLEFT     "ent_sergeant_walkleft"
+#define		GROUP_ENT_SERGEANT_STANDDOWN    "ent_sergeant_standdown"
+#define		GROUP_ENT_SERGEANT_STANDUP      "ent_sergeant_standup"
+#define		GROUP_ENT_SERGEANT_STANDRIGHT   "ent_sergeant_standright"
+#define		GROUP_ENT_SERGEANT_STANDLEFT    "ent_sergeant_standleft"
+#define		GROUP_ENT_SERGEANT_BLINK        "ent_sergeant_blink"
+#define		GROUP_ENT_SERGEANT_YELL         "ent_sergeant_yell"
+#define		GROUP_ENT_WORKER                "ent_worker_"
+#define		GROUP_ENT_WORKER_WALKDOWN       "ent_worker_walkdown"
+#define		GROUP_ENT_WORKER_WALKUP         "ent_worker_walkup"
+#define		GROUP_ENT_WORKER_WALKRIGHT      "ent_worker_walkright"
+#define		GROUP_ENT_WORKER_WALKLEFT       "ent_worker_walkleft"
+#define		GROUP_ENT_WORKER_DIE            "ent_worker_die"
+#define		GROUP_ENT_WORKER_STANDDOWN      "ent_worker_standdown"
+#define		GROUP_ENT_WORKER_STANDUP        "ent_worker_standup"
+#define		GROUP_ENT_WORKER_STANDRIGHT     "ent_worker_standright"
+#define		GROUP_ENT_WORKER_STANDLEFT      "ent_worker_standleft"
+#define		GROUP_ENT_WORKER_BLINK          "ent_worker_blink"
+#define		GROUP_ENT_DEAD_WORKER           "ent_dead_worker_"
+#define		GROUP_ENT_DEAD_WORKER_SIT       "ent_dead_worker_sit"
+#define		GROUP_ENT_SPACEDUDE             "ent_spacedude_"
+#define		GROUP_ENT_SPACEDUDE_WALKDOWN    "ent_spacedude_walkdown"
+#define		GROUP_ENT_SPACEDUDE_WALKUP      "ent_spacedude_walkup"
+#define		GROUP_ENT_SPACEDUDE_WALKRIGHT   "ent_spacedude_walkright"
+#define		GROUP_ENT_SPACEDUDE_WALKLEFT    "ent_spacedude_walkleft"
+#define		GROUP_ENT_DOLLY                 "ent_dolly_"
+#define		GROUP_ENT_DOLLY_WALKDOWN        "ent_dolly_walkdown"
+#define		GROUP_ENT_DOLLY_WALKUP          "ent_dolly_walkup"
+#define		GROUP_ENT_DOLLY_WALKRIGHT       "ent_dolly_walkright"
+#define		GROUP_ENT_DOLLY_WALKLEFT        "ent_dolly_walkleft"
+#define		GROUP_ENT_DOLLY_USERIGHT        "ent_dolly_useright"
+#define		GROUP_ENT_DOLLY_KISSRIGHT       "ent_dolly_kissright"
+#define		GROUP_ENT_DOLLY_KISSLEFT        "ent_dolly_kissleft"
+#define		GROUP_ENT_DOLLY_ANGRY           "ent_dolly_angry"
+#define		GROUP_ENT_DOLLY_LAUGH           "ent_dolly_laugh"
+#define		GROUP_ENT_DOLLY_PANIC           "ent_dolly_panic"
+#define		GROUP_ENT_CELL                  "ent_cell_"
+#define		GROUP_ENT_CELL_SIT              "ent_cell_sit"
+#define		GROUP_ENT_CRATE                 "ent_crate_"
+#define		GROUP_ENT_CRATE_SIT             "ent_crate_sit"
+#define		GROUP_ENT_CRATE_FLOAT           "ent_crate_float"
+#define		GROUP_ENT_BARREL_LIGHT          "ent_barrel_light_"
+#define		GROUP_ENT_BARREL_LIGHT_SIT      "ent_barrel_light_sit"
+#define		GROUP_ENT_BARREL_LIGHT_FLOAT    "ent_barrel_light_float"
+#define		GROUP_ENT_BARREL_LIGHT_MELT     "ent_barrel_light_melt"
+#define		GROUP_ENT_BARREL_HEAVY          "ent_barrel_heavy_"
+#define		GROUP_ENT_BARREL_HEAVY_SIT      "ent_barrel_heavy_sit"
+#define		GROUP_ENT_BARREL_HEAVY_FLOAT    "ent_barrel_heavy_float"
+#define		GROUP_ENT_BARREL_HEAVY_MELT     "ent_barrel_heavy_melt"
+#define		GROUP_ENT_BARREL_EXPLODE        "ent_barrel_explode_"
+#define		GROUP_ENT_BARREL_EXPLODE_SIT    "ent_barrel_explode_sit"
+#define		GROUP_ENT_TRANSCEIVER           "ent_transceiver_"
+#define		GROUP_ENT_TRANSCEIVER_SIT       "ent_transceiver_sit"
+#define		GROUP_ENT_GOO_CUP               "ent_goo_cup_"
+#define		GROUP_ENT_GOO_CUP_SIT           "ent_goo_cup_sit"
+#define		GROUP_ENT_CLUB                  "ent_club_"
+#define		GROUP_ENT_CLUB_SIT              "ent_club_sit"
+#define		GROUP_ENT_ROBOSTUNNER           "ent_robostunner_"
+#define		GROUP_ENT_ROBOSTUNNER_SIT       "ent_robostunner_sit"
+#define		GROUP_ENT_SLUGSLINGER           "ent_slugslinger_"
+#define		GROUP_ENT_SLUGSLINGER_SIT       "ent_slugslinger_sit"
+#define		GEM_WHITE_GFX					"ent_gem_white_sit01"
+#define		GROUP_ENT_GEM_WHITE             "ent_gem_white_"
+#define		GROUP_ENT_GEM_WHITE_SIT         "ent_gem_white_sit"
+#define		GROUP_ENT_GEM_BLUE              "ent_gem_blue_"
+#define		GROUP_ENT_GEM_BLUE_SIT          "ent_gem_blue_sit"
+#define		GROUP_ENT_GEM_RED               "ent_gem_red_"
+#define		GROUP_ENT_GEM_RED_SIT           "ent_gem_red_sit"
+#define		GROUP_ENT_GEM_GREEN             "ent_gem_green_"
+#define		GROUP_ENT_GEM_GREEN_SIT         "ent_gem_green_sit"
+#define		GROUP_ENT_TEACUP                "ent_teacup_"
+#define		GROUP_ENT_TEACUP_SIT            "ent_teacup_sit"
+#define		GROUP_ENT_COOKIE                "ent_cookie_"
+#define		GROUP_ENT_COOKIE_SIT            "ent_cookie_sit"
+#define		GROUP_ENT_BURGER                "ent_burger_"
+#define		GROUP_ENT_BURGER_SIT            "ent_burger_sit"
+#define		GROUP_ENT_PDA                   "ent_pda_"
+#define		GROUP_ENT_PDA_SIT               "ent_pda_sit"
+#define		GROUP_ENT_BOOK                  "ent_book_"
+#define		GROUP_ENT_BOOK_SIT              "ent_book_sit"
+#define		GROUP_ENT_CLIPBOARD             "ent_clipboard_"
+#define		GROUP_ENT_CLIPBOARD_SIT         "ent_clipboard_sit"
+#define		GROUP_ENT_NOTE                  "ent_note_"
+#define		GROUP_ENT_NOTE_SIT              "ent_note_sit"
+#define		GROUP_ENT_KEYCARD_WHITE         "ent_keycard_white_"
+#define		GROUP_ENT_KEYCARD_WHITE_SIT     "ent_keycard_white_sit"
+#define		GROUP_ENT_KEYCARD_BLUE          "ent_keycard_blue_"
+#define		GROUP_ENT_KEYCARD_BLUE_SIT      "ent_keycard_blue_sit"
+#define		GROUP_ENT_KEYCARD_RED           "ent_keycard_red_"
+#define		GROUP_ENT_KEYCARD_RED_SIT       "ent_keycard_red_sit"
+#define		GROUP_ENT_KEYCARD_GREEN         "ent_keycard_green_"
+#define		GROUP_ENT_KEYCARD_GREEN_SIT     "ent_keycard_green_sit"
+#define		GROUP_ENT_KEYCARD_PURPLE        "ent_keycard_purple_"
+#define		GROUP_ENT_KEYCARD_PURPLE_SIT    "ent_keycard_purple_sit"
+#define		GROUP_ENT_KEYCARD_BLACK         "ent_keycard_black_"
+#define		GROUP_ENT_KEYCARD_BLACK_SIT     "ent_keycard_black_sit"
+#define		GROUP_ENT_MAGIC_EGG             "ent_magic_egg_"
+#define		GROUP_ENT_MAGIC_EGG_SIT         "ent_magic_egg_sit"
+#define		GROUP_ENT_ICE_BLOCK             "ent_ice_block_"
+#define		GROUP_ENT_ICE_BLOCK_SIT         "ent_ice_block_sit"
+#define		GROUP_ENT_CABKEY                "ent_cabkey_"
+#define		GROUP_ENT_CABKEY_SIT            "ent_cabkey_sit"
+#define		GROUP_ENT_DOLLY_TOOL1           "ent_dolly_tool1_"
+#define		GROUP_ENT_DOLLY_TOOL1_SIT       "ent_dolly_tool1_sit"
+#define		GROUP_ENT_DOLLY_TOOL2           "ent_dolly_tool2_"
+#define		GROUP_ENT_DOLLY_TOOL2_SIT       "ent_dolly_tool2_sit"
+#define		GROUP_ENT_DOLLY_TOOL3           "ent_dolly_tool3_"
+#define		GROUP_ENT_DOLLY_TOOL3_SIT       "ent_dolly_tool3_sit"
+#define		GROUP_ENT_DOLLY_TOOL4           "ent_dolly_tool4_"
+#define		GROUP_ENT_DOLLY_TOOL4_SIT       "ent_dolly_tool4_sit"
+#define		GROUP_ENT_SEED                  "ent_seed_"
+#define		GROUP_ENT_SEED_SIT              "ent_seed_sit"
+#define		GROUP_ENT_SODA                  "ent_soda_"
+#define		GROUP_ENT_SODA_SIT              "ent_soda_sit"
+#define		GROUP_ENT_SLICER                "ent_slicer_"
+#define		GROUP_ENT_SLICER_SIT            "ent_slicer_sit"
+#define		GROUP_ENT_ROUTER                "ent_router_"
+#define		GROUP_ENT_ROUTER_SIT            "ent_router_sit"
+#define		GROUP_ENT_FROGSTATUE            "ent_frogstatue_"
+#define		GROUP_ENT_FROGSTATUE_SIT        "ent_frogstatue_sit"
+#define		GROUP_ENT_PACKAGE               "ent_package_"
+#define		GROUP_ENT_PACKAGE_SIT           "ent_package_sit"
+#define		GROUP_ENT_PUSHBOT               "ent_pushbot_"
+#define		GROUP_ENT_PUSHBOT_WALKDOWN      "ent_pushbot_walkdown"
+#define		GROUP_ENT_PUSHBOT_WALKUP        "ent_pushbot_walkup"
+#define		GROUP_ENT_PUSHBOT_WALKRIGHT     "ent_pushbot_walkright"
+#define		GROUP_ENT_PUSHBOT_WALKLEFT      "ent_pushbot_walkleft"
+#define		GROUP_ENT_OMNIBOT               "ent_omnibot_"
+#define		GROUP_ENT_OMNIBOT_WALKDOWN      "ent_omnibot_walkdown"
+#define		GROUP_ENT_OMNIBOT_WALKUP        "ent_omnibot_walkup"
+#define		GROUP_ENT_OMNIBOT_WALKRIGHT     "ent_omnibot_walkright"
+#define		GROUP_ENT_OMNIBOT_WALKLEFT      "ent_omnibot_walkleft"
+#define		GROUP_ENT_OMNIBOT_MISSILE       "ent_omnibot_missile"
+#define		GROUP_ENT_RIGHTBOT              "ent_rightbot_"
+#define		GROUP_ENT_RIGHTBOT_WALKDOWN     "ent_rightbot_walkdown"
+#define		GROUP_ENT_RIGHTBOT_WALKUP       "ent_rightbot_walkup"
+#define		GROUP_ENT_RIGHTBOT_WALKRIGHT    "ent_rightbot_walkright"
+#define		GROUP_ENT_RIGHTBOT_WALKLEFT     "ent_rightbot_walkleft"
+#define		GROUP_ENT_MAINTBOT              "ent_maintbot_"
+#define		GROUP_ENT_MAINTBOT_WALKDOWN     "ent_maintbot_walkdown"
+#define		GROUP_ENT_MAINTBOT_WALKUP       "ent_maintbot_walkup"
+#define		GROUP_ENT_MAINTBOT_WALKRIGHT    "ent_maintbot_walkright"
+#define		GROUP_ENT_MAINTBOT_WALKLEFT     "ent_maintbot_walkleft"
+#define		GROUP_ENT_MAINTBOT_USEDOWN      "ent_maintbot_usedown"
+#define		GROUP_ENT_MAINTBOT_USEUP        "ent_maintbot_useup"
+#define		GROUP_ENT_MAINTBOT_USERIGHT     "ent_maintbot_useright"
+#define		GROUP_ENT_MAINTBOT_USELEFT      "ent_maintbot_useleft"
+#define		GROUP_ENT_MAINTBOT_STANDDOWN    "ent_maintbot_standdown"
+#define		GROUP_ENT_MAINTBOT_STANDUP      "ent_maintbot_standup"
+#define		GROUP_ENT_MAINTBOT_STANDRIGHT   "ent_maintbot_standright"
+#define		GROUP_ENT_MAINTBOT_STANDLEFT    "ent_maintbot_standleft"
+#define		GROUP_ENT_RAILRIDER             "ent_railrider_"
+#define		GROUP_ENT_RAILRIDER_STANDDOWN   "ent_railrider_standdown"
+#define		GROUP_ENT_RAILRIDER_STANDUP     "ent_railrider_standup"
+#define		GROUP_ENT_RAILRIDER_WALKDOWN    "ent_railrider_walkdown"
+#define		GROUP_ENT_RAILRIDER_WALKUP      "ent_railrider_walkup"
+#define		GROUP_ENT_RAILRIDER_WALKRIGHT   "ent_railrider_walkright"
+#define		GROUP_ENT_RAILRIDER_WALKLEFT    "ent_railrider_walkleft"
+#define		GROUP_ENT_SHOCKBOT              "ent_shockbot_"
+#define		GROUP_ENT_SHOCKBOT_WALK         "ent_shockbot_walk"
+#define		GROUP_ENT_LASER                 "ent_laser_"
+#define		GROUP_ENT_LASER_UP              "ent_laser_up"
+#define		GROUP_ENT_LASER_DOWN            "ent_laser_down"
+#define		GROUP_ENT_LASER_LEFT            "ent_laser_left"
+#define		GROUP_ENT_LASER_RIGHT           "ent_laser_right"
+#define		GROUP_ENT_FOUR_LASER            "ent_four_laser_"
+#define		GROUP_ENT_FOUR_LASER_UP         "ent_four_laser_up"
+#define		GROUP_ENT_FOUR_LASER_DOWN       "ent_four_laser_down"
+#define		GROUP_ENT_FOUR_LASER_LEFT       "ent_four_laser_left"
+#define		GROUP_ENT_FOUR_LASER_RIGHT      "ent_four_laser_right"
+#define		GROUP_ENT_GREENBEAMLR           "ent_greenbeamlr_"
+#define		GROUP_ENT_GREENBEAMLR_ANIM      "ent_greenbeamlr_anim"
+#define		GROUP_ENT_GREENBEAMUD           "ent_greenbeamud_"
+#define		GROUP_ENT_GREENBEAMUD_ANIM      "ent_greenbeamud_anim"
+#define		GROUP_ENT_DEFLECTORBL           "ent_deflectorbl_"
+#define		GROUP_ENT_DEFLECTORBL_SIT       "ent_deflectorbl_sit"
+#define		GROUP_ENT_DEFLECTORBR           "ent_deflectorbr_"
+#define		GROUP_ENT_DEFLECTORBR_SIT       "ent_deflectorbr_sit"
+#define		GROUP_ENT_DEFLECTORTR           "ent_deflectortr_"
+#define		GROUP_ENT_DEFLECTORTR_SIT       "ent_deflectortr_sit"
+#define		GROUP_ENT_DEFLECTORTL           "ent_deflectortl_"
+#define		GROUP_ENT_DEFLECTORTL_SIT       "ent_deflectortl_sit"
+#define		GROUP_ENT_REDBEAMLR             "ent_redbeamlr_"
+#define		GROUP_ENT_REDBEAMLR_ANIM        "ent_redbeamlr_anim"
+#define		GROUP_ENT_REDBEAMUD             "ent_redbeamud_"
+#define		GROUP_ENT_REDBEAMUD_ANIM        "ent_redbeamud_anim"
+#define		GROUP_ENT_TURNBOT               "ent_turnbot_"
+#define		GROUP_ENT_TURNBOT_WALKDOWN      "ent_turnbot_walkdown"
+#define		GROUP_ENT_TURNBOT_WALKUP        "ent_turnbot_walkup"
+#define		GROUP_ENT_TURNBOT_WALKRIGHT     "ent_turnbot_walkright"
+#define		GROUP_ENT_TURNBOT_WALKLEFT      "ent_turnbot_walkleft"
+#define		GROUP_ENT_VORTEXIAN             "ent_vortexian_"
+#define		GROUP_ENT_VORTEXIAN_STANDDOWN   "ent_vortexian_standdown"
+#define		GROUP_ENT_CHICKEN               "ent_chicken_"
+#define		GROUP_ENT_CHICKEN_WALKDOWN      "ent_chicken_walkdown"
+#define		GROUP_ENT_CHICKEN_WALKUP        "ent_chicken_walkup"
+#define		GROUP_ENT_CHICKEN_WALKRIGHT     "ent_chicken_walkright"
+#define		GROUP_ENT_CHICKEN_WALKLEFT      "ent_chicken_walkleft"
+#define		GROUP_ENT_CHICKEN_STANDDOWN     "ent_chicken_standdown"
+#define		GROUP_ENT_CHICKEN_STANDUP       "ent_chicken_standup"
+#define		GROUP_ENT_CHICKEN_STANDRIGHT    "ent_chicken_standright"
+#define		GROUP_ENT_CHICKEN_STANDLEFT     "ent_chicken_standleft"
+#define		GROUP_ENT_CHICKEN_DIE           "ent_chicken_die"
+#define		GROUP_ENT_DEADEYE               "ent_deadeye_"
+#define		GROUP_ENT_DEADEYE_WALKDOWN      "ent_deadeye_walkdown"
+#define		GROUP_ENT_DEADEYE_WALKUP        "ent_deadeye_walkup"
+#define		GROUP_ENT_DEADEYE_WALKRIGHT     "ent_deadeye_walkright"
+#define		GROUP_ENT_DEADEYE_WALKLEFT      "ent_deadeye_walkleft"
+#define		GROUP_ENT_ICEPUFF               "ent_icepuff_"
+#define		GROUP_ENT_ICEPUFF_PEEK          "ent_icepuff_peek"
+#define		GROUP_ENT_ICEPUFF_APPEAR        "ent_icepuff_appear"
+#define		GROUP_ENT_ICEPUFF_THROWDOWN     "ent_icepuff_throwdown"
+#define		GROUP_ENT_ICEPUFF_THROWRIGHT    "ent_icepuff_throwright"
+#define		GROUP_ENT_ICEPUFF_THROWLEFT     "ent_icepuff_throwleft"
+#define		GROUP_ENT_ICEPUFF_DISAPPEAR     "ent_icepuff_disappear"
+#define		GROUP_ENT_ACCOUNTANT            "ent_accountant_"
+#define		GROUP_ENT_ACCOUNTANT_STANDDOWN  "ent_accountant_standdown"
+#define		GROUP_ENT_ACCOUNTANT_STANDUP    "ent_accountant_standup"
+#define		GROUP_ENT_ACCOUNTANT_STANDRIGHT "ent_accountant_standright"
+#define		GROUP_ENT_ACCOUNTANT_STANDLEFT  "ent_accountant_standleft"
+#define		GROUP_ENT_ACCOUNTANT_TALKDOWN   "ent_accountant_talkdown"
+#define		GROUP_ENT_ACCOUNTANT_TALKUP     "ent_accountant_talkup"
+#define		GROUP_ENT_ACCOUNTANT_TALKRIGHT  "ent_accountant_talkright"
+#define		GROUP_ENT_ACCOUNTANT_TALKLEFT   "ent_accountant_talkleft"
+#define		GROUP_ENT_MEERKAT               "ent_meerkat_"
+#define		GROUP_ENT_MEERKAT_DIRTMOVE      "ent_meerkat_dirtmove"
+#define		GROUP_ENT_MEERKAT_APPEAR        "ent_meerkat_appear"
+#define		GROUP_ENT_MEERKAT_BITE          "ent_meerkat_bite"
+#define		GROUP_ENT_MEERKAT_DISAPPEAR     "ent_meerkat_disappear"
+#define		GROUP_ENT_MEERKAT_LOOK          "ent_meerkat_look"
+#define		GROUP_ENT_GOODFAIRY             "ent_goodfairy_"
+#define		GROUP_ENT_GOODFAIRY_WALKDOWN    "ent_goodfairy_walkdown"
+#define		GROUP_ENT_GOODFAIRY_WALKUP      "ent_goodfairy_walkup"
+#define		GROUP_ENT_GOODFAIRY_WALKRIGHT   "ent_goodfairy_walkright"
+#define		GROUP_ENT_GOODFAIRY_WALKLEFT    "ent_goodfairy_walkleft"
+#define		GROUP_ENT_BADFAIRY              "ent_badfairy_"
+#define		GROUP_ENT_BADFAIRY_WALKDOWN     "ent_badfairy_walkdown"
+#define		GROUP_ENT_BADFAIRY_WALKUP       "ent_badfairy_walkup"
+#define		GROUP_ENT_BADFAIRY_WALKRIGHT    "ent_badfairy_walkright"
+#define		GROUP_ENT_BADFAIRY_WALKLEFT     "ent_badfairy_walkleft"
+#define		GROUP_ENT_GATEPUDDLE            "ent_gatepuddle_"
+#define		GROUP_ENT_GATEPUDDLE_STANDDOWN  "ent_gatepuddle_standdown"
+#define		GROUP_ENT_BUZZFLY               "ent_buzzfly_"
+#define		GROUP_ENT_BUZZFLY_WALKDOWN      "ent_buzzfly_walkdown"
+#define		GROUP_ENT_BUZZFLY_WALKUP        "ent_buzzfly_walkup"
+#define		GROUP_ENT_BUZZFLY_WALKRIGHT     "ent_buzzfly_walkright"
+#define		GROUP_ENT_BUZZFLY_WALKLEFT      "ent_buzzfly_walkleft"
+#define		GROUP_ENT_FATFROG               "ent_fatfrog_"
+#define		GROUP_ENT_FATFROG_STANDDOWN     "ent_fatfrog_standdown"
+#define		GROUP_ENT_FATFROG_LICKDOWN      "ent_fatfrog_lickdown"
+#define		GROUP_ENT_FATFROG_STANDRIGHT    "ent_fatfrog_standright"
+#define		GROUP_ENT_FATFROG_STANDLEFT     "ent_fatfrog_standleft"
+#define		GROUP_ENT_FATFROG_LICKRIGHT     "ent_fatfrog_lickright"
+#define		GROUP_ENT_FATFROG_LICKLEFT      "ent_fatfrog_lickleft"
+#define		GROUP_ENT_MONKEYSTONE           "ent_monkeystone_"
+#define		GROUP_ENT_MONKEYSTONE_SIT       "ent_monkeystone_sit"
+#define		GEM_FLASH						"get_gem_flash_sit"
+#define		GROUP_GET_GEM_FLASH             "get_gem_flash_"
+#define		GROUP_GET_GEM_FLASH_SIT         "get_gem_flash_sit"
+#define		TELEPORT_FLASH					"teleporter_flash_sit"
+#define		GROUP_TELEPORTER_FLASH          "teleporter_flash_"
+#define		GROUP_TELEPORTER_FLASH_SIT      "teleporter_flash_sit"
+#define		WATER_SPLASH					"water_splash_sit"
+#define		GROUP_WATER_SPLASH              "water_splash_"
+#define		GROUP_WATER_SPLASH_SIT          "water_splash_sit"
+#define		SLIME_SPLASH					"slime_splash_sit"
+#define		GROUP_SLIME_SPLASH              "slime_splash_"
+#define		GROUP_SLIME_SPLASH_SIT          "slime_splash_sit"
+#define		STEAM_PUFF						"steam_puff_sit"
+#define		GROUP_STEAM_PUFF                "steam_puff_"
+#define		GROUP_STEAM_PUFF_SIT            "steam_puff_sit"
+#define		STUNNED_STARS					"starstun_sit"
+#define		GROUP_STARSTUN                  "starstun_"
+#define		GROUP_STARSTUN_SIT              "starstun_sit"
+#define		SHOCK_SPARK						"shock_spark_sit"
+#define		GROUP_SHOCK_SPARK               "shock_spark_"
+#define		GROUP_SHOCK_SPARK_SIT           "shock_spark_sit"
+#define		EXPLOSION_BOOM					"explosion_boom_sit"
+#define		GROUP_EXPLOSION_BOOM            "explosion_boom_"
+#define		GROUP_EXPLOSION_BOOM_SIT        "explosion_boom_sit"
+#define		INVENTORY_NORMAL				"inventory_normal"
+#define		INVENTORY_SELECT				"inventory_select"
+#define		MINI_MSTONE						"mini_mstone"
+#define		TITLESCREEN						"titlescreen"
+#define		MENU_NEWGAME					"menu_newgame"
+#define		MENU_LOADGAME					"menu_loadgame"
+#define		MENU_OPTIONS					"menu_options"
+#define		MENU_QUIT						"menu_quit"
+#define		MENU_RESUME						"menu_resume"
+#define		STAR_1							"star_1"
+#define		STAR_2							"star_2"
+#define		STAR_3							"star_3"
+#define		MENU_ROCKETSHIP1				"menu_rocketship1"
+#define		MENU_ROCKETSHIP2				"menu_rocketship2"
+#define		MENU_EXHAUST1					"menu_exhaust1"
+#define		MENU_EXHAUST2					"menu_exhaust2"
+#define		TITLELOGO						"titlelogo"
+#define		CTRL_ASSIGN						"ctrl_assign"
+#define		CTRL_ARROWUP					"ctrl_arrowup"
+#define		CTRL_ARROWDN					"ctrl_arrowdn"
+#define		CTRL_ARROWLEFT					"ctrl_arrowleft"
+#define		CTRL_ARROWRIGHT					"ctrl_arrowright"
+#define		MENU_CONTROLS					"menu_controls"
+#define		MENU_BACK						"menu_back"
+#define		MENU_WARP						"menu_warp"
+#define		SCREEN_DARKEN					"screen_darken"
+#define		WARP_PLAQUE						"warp_plaque"
+#define		PAUSE_PLAQUE					"pause_plaque"
+#define		MONKEYLOGOSCREEN				"monkeylogoscreen"
+#define		MONKEYLOGO_OOHOOH				"monkeylogo_oohooh"
+#define		MONKEYLOGO_SMILE				"monkeylogo_smile"
+#define		BACKSCROLL_PLANET1				"backscroll_planet1"
+#define		BACKSCROLL_PLANET2				"backscroll_planet2"
+#define		BACKSCROLL_PLANET3				"backscroll_planet3"
+#define		BACKSCROLL_PLANET4				"backscroll_planet4"
+#define		BACKSCROLL_PLANET5				"backscroll_planet5"
+#define		BACKSCROLL_GALAXY1				"backscroll_galaxy1"
+#define		BACKSCROLL_GALAXY2				"backscroll_galaxy2"
+#define		MENU_BACK_TOPLEFT				"menu_back_topleft"
+#define		MENU_BACK_TOP					"menu_back_top"
+#define		MENU_BACK_TOPRIGHT				"menu_back_topright"
+#define		MENU_BACK_LEFT					"menu_back_left"
+#define		MENU_BACK_MIDDLE				"menu_back_middle"
+#define		MENU_BACK_RIGHT					"menu_back_right"
+#define		MENU_BACK_BTMLEFT				"menu_back_btmleft"
+#define		MENU_BACK_BOTTOM				"menu_back_bottom"
+#define		MENU_BACK_BTMRIGHT				"menu_back_btmright"
+#define		MENU_TITLE_LEFT					"menu_title_left"
+#define		MENU_TITLE_MID					"menu_title_mid"
+#define		MENU_TITLE_RIGHT				"menu_title_right"
+#define		G_MENU_BACK_TOPLEFT				"g_menu_back_topleft"
+#define		G_MENU_BACK_TOP					"g_menu_back_top"
+#define		G_MENU_BACK_TOPRIGHT			"g_menu_back_topright"
+#define		G_MENU_BACK_LEFT				"g_menu_back_left"
+#define		G_MENU_BACK_MIDDLE				"g_menu_back_middle"
+#define		G_MENU_BACK_RIGHT				"g_menu_back_right"
+#define		G_MENU_BACK_BTMLEFT				"g_menu_back_btmleft"
+#define		G_MENU_BACK_BOTTOM				"g_menu_back_bottom"
+#define		G_MENU_BACK_BTMRIGHT			"g_menu_back_btmright"
+#define		G_MENU_TITLE_LEFT				"g_menu_title_left"
+#define		G_MENU_TITLE_MID				"g_menu_title_mid"
+#define		G_MENU_TITLE_RIGHT				"g_menu_title_right"
+#define		G_CHECK_EMPTY					"g_check_empty"
+#define		G_CHECK_ON						"g_check_on"
+#define		G_CHECK_OFF						"g_check_off"
+#define		G_CHECK_LEFT					"g_check_left"
+#define		G_CHECK_RIGHT					"g_check_right"
+#define		MENU_HAND_POINTRIGHT			"menu_hand_pointright"
+#define		MENU_ARROW_DELIVERTO			"menu_arrow_deliverto"
+#define		MENU_SLIDER_LEFT				"menu_slider_left"
+#define		MENU_HAND_POINTER				"menu_hand_pointer"
+#define		MENU_SLIDER_MID					"menu_slider_mid"
+#define		MENU_SLIDER_RIGHT				"menu_slider_right"
+#define		MENU_SLIDER_KNOB				"menu_slider_knob"
+#define		MENU_DELIVERY_INDENTATION		"menu_delivery_indentation"
+#define		MENU_TITLE_DELIVERIES			"menu_title_deliveries"
+#define		MENU_TITLE_RESOURCES			"menu_title_resources"
+#define		MENU_RESTART					"menu_restart"
+#define		MODE_PUZZLE						"mode_puzzle"
+#define		MODE_ACTION						"mode_action"
+#define		GAMEFILE_SLOT					"gamefile_slot"
+#define		MENU_REGISTRATION				"menu_registration"
+#define		SECRETSTAR_RED1					"secretstar_red1"
+#define		SECRETSTAR_RED2					"secretstar_red2"
+#define		SECRETSTAR_GREEN1				"secretstar_green1"
+#define		SECRETSTAR_GREEN2				"secretstar_green2"
+#define		SECRETSTAR_BLUE1				"secretstar_blue1"
+#define		SECRETSTAR_BLUE2				"secretstar_blue2"
+#define		CINE_INTROSHIP					"cine_introship"
+#define		CINE_LITTLE_MBOT				"cine_little_mbot"
+#define		CINE_CLOCK						"cine_clock"
+#define		GAME_TRY						"game_try"
+#define		GAME_AGAIN						"game_again"
+#define		GAME_TA_LEVELRESTART			"game_ta_levelrestart"
+#define		PIC_LOADBAR		"pic_loadbar"
+#define		PIC_LOADSTAR		"pic_loadstar"
+#define		MENU_LOAD		"menu_load"
+#define		MENU_SAVE		"menu_save"
+#define		MENU_BACKSPACE		"menu_backspace"
+#define		MENU_VERSION_NUMBER		"menu_version_number"
+#define		CLOUDY_SKIES		"cloudy_skies"
+#define		TITLE_EPISODE1		"title_episode1"
+#define		TITLE_EPISODE2		"title_episode2"
+#define		TITLE_EPISODE3		"title_episode3"
+#define		PANIC_POINTER1		"panic_pointer1"
+#define		PANIC_POINTER2		"panic_pointer2"
+#define		PANIC_NUM0		"panic_num0"
+#define		PANIC_NUM1		"panic_num1"
+#define		PANIC_NUM2		"panic_num2"
+#define		PANIC_NUM3		"panic_num3"
+#define		PANIC_NUM4		"panic_num4"
+#define		PANIC_NUM5		"panic_num5"
+#define		PANIC_NUM6		"panic_num6"
+#define		PANIC_NUM7		"panic_num7"
+#define		PANIC_NUM8		"panic_num8"
+#define		PANIC_NUM9		"panic_num9"
+#define		PANIC_PANIC		"panic_panic"
+#define		PANIC_ZONE		"panic_zone"
+#define		PIC_RANK1		"pic_rank1"
+#define		PIC_RANK2		"pic_rank2"
+#define		PIC_RANK3		"pic_rank3"
+#define		PIC_RANK4		"pic_rank4"
+#define		PIC_RANK5		"pic_rank5"
+#define		DRAGON_ASLEEP		"dragon_asleep"
+#define		DRAGON_FLAP1		"dragon_flap1"
+#define		DRAGON_FLAP2		"dragon_flap2"
+#define		DRAGON_BREATHE_START		"dragon_breathe_start"
+#define		DRAGON_BREATHING_1		"dragon_breathing_1"
+#define		DRAGON_BREATHING_2		"dragon_breathing_2"
+#define		ICEPUFF_SNOWBALL_DOWN		"icepuff_snowball_down"
+#define		ICEPUFF_SNOWBALL_RIGHT		"icepuff_snowball_right"
+#define		ICEPUFF_SNOWBALL_LEFT		"icepuff_snowball_left"
+#define		SLUG_SHOT1		"slug_shot1"
+#define		SLUG_SHOT2		"slug_shot2"
+#define		SLUG_SHOT3		"slug_shot3"
+#define		SLUG_SHOT4		"slug_shot4"
+#define		PIC_ENV_WHITE		"pic_env_white"
+#define		PIC_FROG_STATUE		"pic_frog_statue"
+#define		PIC_JENKINS		"pic_jenkins"
+#define		PIC_TEAM_BRIAN		"pic_team_brian"
+#define		PIC_TEAM_STEVIE		"pic_team_stevie"
+#define		PIC_TEAM_JOSH		"pic_team_josh"
+#define		PIC_TEAM_TOM		"pic_team_tom"
+#define		PIC_TEAM_JOHN		"pic_team_john"
+#define		PIC_TEAM_LUCAS		"pic_team_lucas"
+#define		PIC_QUITSCREEN		"pic_quitscreen"
+#define		PIC_CONTROLSSCREEN		"pic_controlsscreen"
+#define		PIC_MOUSE_CURSOR1		"pic_mouse_cursor1"
+#define		PIC_MOUSE_CURSOR2		"pic_mouse_cursor2"
+#define		PIC_MOUSE_CURSOR3		"pic_mouse_cursor3"
+#define		PIC_MOUSE_CURSOR4		"pic_mouse_cursor4"
+#define		PIC_MOUSE_CURSOR5		"pic_mouse_cursor5"
+#define		PIC_MOUSE_CURSOR6		"pic_mouse_cursor6"
+#define		PIC_MOUSE_CURSOR7		"pic_mouse_cursor7"
+#define		PIC_MOUSE_CURSOR8		"pic_mouse_cursor8"
+#define		PIC_STAR256		"pic_star256"
+#define		PIC_STAR192		"pic_star192"
+#define		PIC_STAR128		"pic_star128"
+#define		PIC_STAR64		"pic_star64"
+#define		PIC_SNOWFLAKE		"pic_snowflake"
+#define		PIC_INFOBAR		"pic_infobar"
+#define		PIC_LOADSCREEN		"pic_loadscreen"
+#define		MENU_ACCEPT_WAV		"menu_accept.wav"
+
+enum IconList {
+	ICON_GUY_DOWN,
+	ICON_GUY_UP,
+	ICON_GUY_RIGHT,
+	ICON_GUY_LEFT,
+	ICON_ENVELOPE_WHITE,
+	ICON_ENVELOPE_BLUE,
+	ICON_ENVELOPE_RED,
+	ICON_ENVELOPE_GREEN,
+	ICON_LASER_RIGHT,
+	ICON_LASER_DOWN,
+	ICON_LASER_LEFT,
+	ICON_LASER_UP,
+	ICON_DIVERTER_LEFTDOWN,
+	ICON_DIVERTER_RIGHTDOWN,
+	ICON_DIVERTER_UPRIGHT,
+	ICON_DIVERTER_LEFTUP,
+	ICON_FOURFIRER_RIGHT,
+	ICON_FOURFIRER_DOWN,
+	ICON_FOURFIRER_LEFT,
+	ICON_FOURFIRER_UP,
+	ICON_ARROW_DOWN,
+	ICON_ARROW_UP,
+	ICON_ARROW_RIGHT,
+	ICON_ARROW_LEFT,
+	ICON_STOPARROW_DOWN,
+	ICON_STOPARROW_UP,
+	ICON_STOPARROW_RIGHT,
+	ICON_STOPARROW_LEFT,
+	ICON_ITEM_CELL,
+	ICON_ENVITEM_CRATE,
+	ICON_ENVITEM_LIGHTBARREL,
+	ICON_ENVITEM_HEAVYBARREL,
+	ICON_ENVITEM_BOOMBARREL,
+	ICON_ITEM_TRANSCEIVER,
+	ICON_E2_ITEM_CLUB,
+	ICON_E3_ITEM_ROBOSTUNNER,
+	ICON_E2_ITEM_SLUGSLINGER,
+	ICON_SCIENTIST_DOWN,
+	ICON_SCIENTIST_UP,
+	ICON_SCIENTIST_RIGHT,
+	ICON_SCIENTIST_LEFT,
+	ICON_WORKER_DOWN,
+	ICON_WORKER_UP,
+	ICON_WORKER_RIGHT,
+	ICON_WORKER_LEFT,
+	ICON_SHOCKBOT_DOWN,
+	ICON_SHOCKBOT_UP,
+	ICON_SHOCKBOT_RIGHT,
+	ICON_SHOCKBOT_LEFT,
+	ICON_RIGHTBOT_DOWN,
+	ICON_RIGHTBOT_UP,
+	ICON_RIGHTBOT_RIGHT,
+	ICON_RIGHTBOT_LEFT,
+	ICON_PUSHBOT_DOWN,
+	ICON_PUSHBOT_UP,
+	ICON_PUSHBOT_RIGHT,
+	ICON_PUSHBOT_LEFT,
+	ICON_LISTENBOT_DOWN,
+	ICON_LISTENBOT_UP,
+	ICON_LISTENBOT_RIGHT,
+	ICON_LISTENBOT_LEFT,
+	ICON_MONKEYSTONE,
+	ICON_TELEPORTER1,
+	ICON_TELEPORTER2,
+	ICON_TELEPORTER3,
+	ICON_TELEPORTER4,
+	ICON_TELEPORTER5,
+	ICON_TELEPORTER6,
+	ICON_TELEPORTER7,
+	ICON_TELEPORTER8,
+	ICON_TELEPORTER9,
+	ICON_TELEPORTER10,
+	ICON_TELEPORTER11,
+	ICON_TELEPORTER12,
+	ICON_TELEPORTER13,
+	ICON_TELEPORTER14,
+	ICON_TELEPORTER15,
+	ICON_TELEPORTER16,
+	ICON_TELEPORTER17,
+	ICON_TELEPORTER18,
+	ICON_TELEPORTER19,
+	ICON_TELEPORTER20,
+	ICON_LEVELEXIT,
+	ICON_ACTION1,
+	ICON_ACTION2,
+	ICON_ACTION3,
+	ICON_ACTION4,
+	ICON_ACTION5,
+	ICON_ACTION6,
+	ICON_ACTION7,
+	ICON_ACTION8,
+	ICON_ACTION9,
+	ICON_ACTION10,
+	ICON_ACTION11,
+	ICON_ACTION12,
+	ICON_ACTION13,
+	ICON_ACTION14,
+	ICON_ACTION15,
+	ICON_ACTION16,
+	ICON_ACTION17,
+	ICON_ACTION18,
+	ICON_ACTION19,
+	ICON_ACTION20,
+	ICON_SPACEDUDE_DOWN,
+	ICON_SPACEDUDE_UP,
+	ICON_SPACEDUDE_RIGHT,
+	ICON_SPACEDUDE_LEFT,
+	ICON_SERGEANT_DOWN,
+	ICON_SERGEANT_UP,
+	ICON_SERGEANT_RIGHT,
+	ICON_SERGEANT_LEFT,
+	ICON_MAINTBOT_DOWN,
+	ICON_MAINTBOT_UP,
+	ICON_MAINTBOT_RIGHT,
+	ICON_MAINTBOT_LEFT,
+	ICON_ACTION_AUTO,
+	ICON_GEM_WHITE,
+	ICON_GEM_BLUE,
+	ICON_GEM_RED,
+	ICON_GEM_GREEN,
+	ICON_SET_MUSIC,
+	ICON_LUA,
+	ICON_HERE,
+	ICON_VORTEXIAN,
+	ICON_CHICKEN_DOWN,
+	ICON_CHICKEN_UP,
+	ICON_CHICKEN_RIGHT,
+	ICON_CHICKEN_LEFT,
+	ICON_GOO_CUP,
+	ICON_TEACUP,
+	ICON_COOKIE,
+	ICON_BURGER,
+	ICON_PDA,
+	ICON_BOOK,
+	ICON_CLIPBOARD,
+	ICON_NOTE,
+	ICON_KEYCARD_WHITE,
+	ICON_KEYCARD_BLUE,
+	ICON_KEYCARD_RED,
+	ICON_KEYCARD_GREEN,
+	ICON_KEYCARD_PURPLE,
+	ICON_KEYCARD_BLACK,
+	ICON_MAGIC_EGG,
+	ICON_ICE_BLOCK,
+	ICON_CABKEY,
+	ICON_DEAD_WORKER,
+	ICON_OMNIBOT_DOWN,
+	ICON_OMNIBOT_UP,
+	ICON_OMNIBOT_RIGHT,
+	ICON_OMNIBOT_LEFT,
+	ICON_TURNBOT_DOWN,
+	ICON_TURNBOT_UP,
+	ICON_TURNBOT_RIGHT,
+	ICON_TURNBOT_LEFT,
+	ICON_DOLLY_DOWN,
+	ICON_DOLLY_UP,
+	ICON_DOLLY_RIGHT,
+	ICON_DOLLY_LEFT,
+	ICON_TRIGGER,
+	ICON_DOLLY_TOOL1,
+	ICON_DOLLY_TOOL2,
+	ICON_DOLLY_TOOL3,
+	ICON_DOLLY_TOOL4,
+	ICON_RAILRIDER_ON_UP,
+	ICON_RAILRIDER_ON_DOWN,
+	ICON_RAILRIDER_ON_LEFT,
+	ICON_RAILRIDER_ON_RIGHT,
+	ICON_RAILRIDER_UP,
+	ICON_RAILRIDER_DOWN,
+	ICON_RAILRIDER_LEFT,
+	ICON_RAILRIDER_RIGHT,
+	ICON_SODA,
+	ICON_ARROW_4WAY,
+	ICON_DEADEYE_DOWN,
+	ICON_DEADEYE_UP,
+	ICON_DEADEYE_RIGHT,
+	ICON_DEADEYE_LEFT,
+	ICON_MEERKAT_MOUND,
+	ICON_FATFROG_DOWN,
+	ICON_FATFROG_RIGHT,
+	ICON_FATFROG_LEFT,
+	ICON_GOODFAIRY_DOWN,
+	ICON_GOODFAIRY_UP,
+	ICON_GOODFAIRY_RIGHT,
+	ICON_GOODFAIRY_LEFT,
+	ICON_BADFAIRY_DOWN,
+	ICON_BADFAIRY_UP,
+	ICON_BADFAIRY_RIGHT,
+	ICON_BADFAIRY_LEFT,
+	ICON_ACCOUNTANT_DOWN,
+	ICON_ACCOUNTANT_UP,
+	ICON_ACCOUNTANT_RIGHT,
+	ICON_ACCOUNTANT_LEFT,
+	ICON_ICEPUFF_DOWN,
+	ICON_DRAGON_DOWN,
+	ICON_BUZZFLY_DOWN,
+	ICON_BUZZFLY_UP,
+	ICON_BUZZFLY_RIGHT,
+	ICON_BUZZFLY_LEFT,
+	ICON_FROG_STATUE,
+	ICON_PIZZA_SLICER,
+	ICON_FAIRY_SRC,
+	ICON_FAIRY_SRC2,
+	ICON_FAIRY_SRC3,
+	ICON_FAIRY_SRC4,
+	ICON_FAIRY_SRC5,
+	ICON_FAIRY_DEST,
+	ICON_FAIRY_DEST2,
+	ICON_FAIRY_DEST3,
+	ICON_FAIRY_DEST4,
+	ICON_FAIRY_DEST5,
+	ICON_QUESTION_MARK,
+	ICON_DEBUG_LOGO,
+	ICON_TARGET_X,
+	ICON_WAYPOINT_SELECT1,
+	ICON_WAYPOINT_SELECT2,
+	ICON_WAYPOINT_SELECT3,
+	ICON_WAYPOINT_SELECT4,
+	ICON_WAYPOINT_1,
+	ICON_WAYPOINT_2,
+};
+
+


Commit: 4905233ef0b5394d67767b39fbafb3f963515fa2
    https://github.com/scummvm/scummvm/commit/4905233ef0b5394d67767b39fbafb3f963515fa2
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:01+02:00

Commit Message:
HDB: Add floatEntity()

Changed paths:
    engines/hdb/ai-funcs.cpp
    engines/hdb/ai.h


diff --git a/engines/hdb/ai-funcs.cpp b/engines/hdb/ai-funcs.cpp
index c65c267..28642c4 100644
--- a/engines/hdb/ai-funcs.cpp
+++ b/engines/hdb/ai-funcs.cpp
@@ -1541,6 +1541,18 @@ bool AI::checkPlayerCollision(int x, int y, int border) {
 	return (x > (_player->x - 32 + border) && x < (_player->x - 32 - border) && y >(_player->y - 32 + border) && y < (_player->y - 32 - border));
 }
 
+void AI::floatEntity(AIEntity *e, AIState state) {
+	for (Common::Array<AIEntity *>::iterator it = _ents->begin(); it != _ents->end(); it++) {
+		if (e == *it) {
+			_floats->push_back(*it);
+			_ents->erase(it);
+			break;
+		}
+	}
+	e->state = state;
+	e->level = 1;
+}
+
 bool AI::checkFloating(int x, int y) {
 	for (Common::Array<AIEntity *>::iterator it = _floats->begin(); it != _floats->end(); it++) {
 		if ((*it)->tileX == x && (*it)->tileY == y)
diff --git a/engines/hdb/ai.h b/engines/hdb/ai.h
index ec8c200..3aa7bde 100644
--- a/engines/hdb/ai.h
+++ b/engines/hdb/ai.h
@@ -709,6 +709,7 @@ public:
 	void addToPathList(int x, int y, int type, AIDir dir);
 	ArrowPath *findArrowPath(int x, int y);
 
+	void floatEntity(AIEntity *e, AIState state);
 	bool checkFloating(int x, int y);
 
 	bool getTableEnt(AIType type);


Commit: b6bfa8c03e69c7af86e537e649ddced633c5fd66
    https://github.com/scummvm/scummvm/commit/b6bfa8c03e69c7af86e537e649ddced633c5fd66
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:01+02:00

Commit Message:
HDB: Add _dummyLaser

Changed paths:
    engines/hdb/ai-init.cpp
    engines/hdb/ai.h


diff --git a/engines/hdb/ai-init.cpp b/engines/hdb/ai-init.cpp
index ade5ff4..6cfe702 100644
--- a/engines/hdb/ai-init.cpp
+++ b/engines/hdb/ai-init.cpp
@@ -773,6 +773,7 @@ bool AI::init() {
 	_kcHolderBlackOn	= g_hdb->_drawMan->getTileIndex("t32_kcholder_black_on");
 
 	_dummyPlayer.type = AI_GUY;
+	_dummyLaser.type = AI_LASERBEAM;
 	strcpy(_dummyPlayer.entityName, "Virtual Player");
 	_playerRunning = false;
 
diff --git a/engines/hdb/ai.h b/engines/hdb/ai.h
index 3aa7bde..f24dbc8 100644
--- a/engines/hdb/ai.h
+++ b/engines/hdb/ai.h
@@ -1006,7 +1006,7 @@ public:
 	Common::Array<HereT *> *_hereList;
 
 	// Virtual Player
-	AIEntity _dummyPlayer;
+	AIEntity _dummyPlayer, _dummyLaser;
 
 	// Cinematic Variables
 	Common::Array<CineCommand *> _cine;


Commit: 8aa509d9bf2bb96a6234ef49c6b14e18e18b6b82
    https://github.com/scummvm/scummvm/commit/8aa509d9bf2bb96a6234ef49c6b14e18e18b6b82
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:01+02:00

Commit Message:
HDB: Remove the stopEntity stub from animateEntity

Changed paths:
    engines/hdb/ai-funcs.cpp


diff --git a/engines/hdb/ai-funcs.cpp b/engines/hdb/ai-funcs.cpp
index 28642c4..c2a7117 100644
--- a/engines/hdb/ai-funcs.cpp
+++ b/engines/hdb/ai-funcs.cpp
@@ -715,6 +715,8 @@ void AI::animateEntity(AIEntity *e) {
 
 	int bgTileFlags, bgTileIndex;
 	int fgTileFlags, fgTileIndex;
+	bool result;
+	uint64 flags;
 
 	// Move entity if player is not dead
 	debug(3, "Before animateEntity, e->x: %d, e->y: %d", e->x, e->y);
@@ -805,7 +807,6 @@ void AI::animateEntity(AIEntity *e) {
 
 	// Reached goal?
 	// Cinematic require less accuracy for NPCs
-	int result;
 	if (_cineActive && e != _player)
 		result = (abs(e->x - (e->goalX * kTileWidth)) <= abs(e->xVel)) && (abs(e->y - (e->goalY * kTileHeight)) <= abs(e->yVel));
 	else
@@ -825,9 +826,219 @@ void AI::animateEntity(AIEntity *e) {
 			e->tileX = e->goalX;
 			e->tileY = e->goalY;
 
-			stopEntity(e);
+			uint16 buttons = g_hdb->_input->getButtons();
+
+			if (e == _player && (buttons & (kButtonUp || kButtonDown || kButtonLeft || kButtonRight))) {
+				int xva[] = {9, 0, 0, -1, 1}, yva[] = {9, -1, 1, 0, 0};
+				int nx, ny, result2;
+
+				if (e->state != STATE_PUSHRIGHT && e->state != STATE_PUSHLEFT && e->state != STATE_PUSHUP && e->state != STATE_PUSHDOWN) {
+					if (buttons & kButtonUp)
+						e->dir = DIR_UP;
+					else if (buttons & kButtonDown)
+						e->dir = DIR_DOWN;
+					else if (buttons & kButtonLeft)
+						e->dir = DIR_LEFT;
+					else if (buttons & kButtonRight)
+						e->dir = DIR_RIGHT;
+
+					nx = e->tileX + xva[e->dir];
+					ny = e->tileY + yva[e->dir];
+					AIEntity *hit = legalMove(nx, ny, e->level, &result2);
+					if (!hit && result2) {
+						switch (e->dir) {
+						case DIR_UP:	e->goalY = ny;	e->xVel = 0; e->yVel = -kPlayerMoveSpeed; e->state = STATE_MOVEUP; break;
+						case DIR_DOWN:	e->goalY = ny;  e->xVel = 0; e->yVel =  kPlayerMoveSpeed; e->state = STATE_MOVEDOWN; break;
+						case DIR_LEFT:	e->goalX = nx;  e->yVel = 0; e->xVel = -kPlayerMoveSpeed; e->state = STATE_MOVELEFT; break;
+						case DIR_RIGHT: e->goalX = nx;  e->yVel = 0; e->xVel =  kPlayerMoveSpeed; e->state = STATE_MOVERIGHT; break;
+						case DIR_NONE:	warning("animateEntity: DIR_NONE found"); break;
+						}
+						if (_playerRunning) {
+							e->xVel = e->xVel << 1;
+							e->yVel = e->yVel << 1;
+						}
+					} else
+						stopEntity(e);
+				} else
+					stopEntity(e);
+			} else
+				stopEntity(e);
+
+			// Handle lasers after entity has stopped
+			switch (e->type) {
+			case AI_GUY:
+			case AI_CRATE:
+			case AI_LIGHTBARREL:
+			case AI_HEAVYBARREL:
+			case AI_BOOMBARREL:
+			case AI_MAGIC_EGG:
+			case AI_ICE_BLOCK:
+			case AI_DIVERTER:
+				warning("STUB: animateEntity: Set _laserRescan to true");
+				break;
+			default:
+				warning("animateEntity: Unintended State");
+			}
+
+			// Checking at the Destination
+
+			// Can this entity float and it is over-water
+			if (((flags = g_hdb->_map->getMapBGTileFlags(e->tileX, e->tileY)) & kFlagWater) && (e->type == AI_CRATE || e->type == AI_LIGHTBARREL || e->type == AI_BOOMBARREL || e->type == AI_HEAVYBARREL || e->type == AI_FROGSTATUE || e->type == AI_DIVERTER)) {
+				// On a grating and level2?
+				if ((g_hdb->_map->getMapFGTileFlags(e->tileX, e->tileY) & kFlagGrating) && e->level == 2) {
+					animEntFrames(e);
+					return;
+				}
+
+				// If it fell in slime
+				// If it is a light barrel on a melting floor
+				// If it is supposed to slide across the floor
+				// If it is being pushed on a floating entity, don't float it
+				if (flags & kFlagSlime) {
+					// unless its a Heavy Barrel in which case it floats in slime
+					if ((e->type == AI_CRATE || e->type == AI_HEAVYBARREL) && !checkFloating(e->tileX, e->tileY)) {
+						addAnimateTarget(e->x, e->y, 0, 3, ANIM_NORMAL, false, false, GROUP_SLIME_SPLASH_SIT);
+						floatEntity(e, STATE_FLOATING);
+						warning("STUB: animateEntity: Play SND_SPLASH");
+					} else if (!checkFloating(e->tileX, e->tileY)) {
+						if (e->type == AI_BOOMBARREL) {
+							aiBarrelExplode(e);
+							aiBarrelBlowup(e, e->tileX, e->tileY);
+							return;
+						} else {
+							addAnimateTarget(e->x, e->y, 0, 3, ANIM_NORMAL, false, false, GROUP_STEAM_PUFF_SIT);
+							removeEntity(e);
+							warning("STUB: animateEntity: Play SND_BARREL_MELTING");
+						}
+					}
+				} else if ((flags & kFlagLightMelt) && e->type == AI_LIGHTBARREL) {
+					if (!checkFloating(e->tileX, e->tileY)) {
+						addAnimateTarget(e->x, e->y, 0, 3, ANIM_NORMAL, false, false, GROUP_STEAM_PUFF_SIT);
+						floatEntity(e, STATE_MELTED);
+						warning("STUB: animateEntity: Play SND_BARREL_MELTING");
+					}
+				} else if (flags & kFlagSlide) {
+					int xv = 0, yv = 0;
+					AIEntity *hit;
+
+					switch (e->dir) {
+					case DIR_UP:	yv = -1; break;
+					case DIR_DOWN:	yv = 1; break;
+					case DIR_LEFT:	xv = -1; break;
+					case DIR_RIGHT: xv = 1; break;
+					case DIR_NONE:	warning("animateEntity: DIR_NONE found"); break;
+					}
+
+					hit = findEntityIgnore(e->tileX + xv, e->tileY + yv, &_dummyLaser);
+					if (!hit) {
+						e->state = STATE_SLIDING;
+						if (flags & kFlagAnimFast)
+							e->moveSpeed = kPlayerMoveSpeed << 1;
+						else if (flags & kFlagAnimSlow)
+							e->moveSpeed = kPlayerMoveSpeed >> 1;
+						setEntityGoal(e, e->tileX + xv, e->tileY + yv);
+						warning("STUB: animateEntity: Play SND_LIGHT_SLIDE");
+					}
 
-			warning("STUB: animateEntity: Stop entity");
+				} else if (!checkFloating(e->tileX, e->tileY)) {
+					if (e->type == AI_BOOMBARREL || e->type == AI_HEAVYBARREL || e->type == AI_FROGSTATUE || e->type == AI_DIVERTER) {
+						// Make it disappear in the water
+						addAnimateTarget(e->x, e->y, 0, 3, ANIM_NORMAL, false, false, GROUP_WATER_SPLASH_SIT);
+						removeEntity(e);
+						warning("STUB: animateEntity: Play SND_SPLASH");
+						return;
+					} else {
+						// Make it float and splash in water
+						addAnimateTarget(e->x, e->y, 0, 3, ANIM_NORMAL, false, false, GROUP_WATER_SPLASH_SIT);
+						floatEntity(e, STATE_FLOATING);
+						warning("STUB: animateEntity: Play SND_SPLASH");
+						return;
+					}
+
+				// If it is floating downstream, keep moving it
+				if (flags & (kFlagPushRight | kFlagPushLeft | kFlagPushUp | kFlagPushDown)) {
+					int xv = 0, yv = 0;
+					AIState state;
+
+					if (flags & kFlagPushRight) {
+						e->dir = DIR_RIGHT;
+						xv = 1;
+						state = STATE_FLOATRIGHT;
+					} else if (flags & kFlagPushLeft) {
+						e->dir = DIR_LEFT;
+						xv = -1;
+						state = STATE_FLOATLEFT;
+					} else if (flags & kFlagPushUp) {
+						e->dir = DIR_UP;
+						yv = -1;
+						state = STATE_FLOATUP;
+					} else if (flags & kFlagPushDown) {
+						e->dir = DIR_DOWN;
+						yv = 1;
+						state = STATE_FLOATDOWN;
+					}
+
+					if (!checkFloating(e->tileX + xv, e->tileY + yv)) {
+						if (flags & kFlagAnimFast)
+							e->moveSpeed = kPlayerMoveSpeed << 1;
+						else if (flags & kFlagAnimMedium)
+							e->moveSpeed = kPlayerMoveSpeed;
+						else
+							e->moveSpeed = kPushMoveSpeed;
+
+						setEntityGoal(e, e->tileX + xv, e->tileY + yv);
+						e->state = state;
+					} else {
+						// Landed on a floatmove entity. Make it float really slow and then it'll speed up
+						uint32 flags2 = g_hdb->_map->getMapBGTileFlags(e->tileX + xv, e->tileY + yv);
+						if (!(flags2 & (kFlagPushRight | kFlagPushLeft | kFlagPushUp | kFlagPushDown))) {
+							floatEntity(e, STATE_FLOATING);
+							e->value1 = 0x666;	// Don't move me ever again
+							return;
+						}
+
+						if (flags & kFlagPushRight) {
+							e->dir = DIR_RIGHT;
+							xv = 1;
+							state = STATE_FLOATRIGHT;
+						} else if (flags & kFlagPushLeft) {
+							e->dir = DIR_LEFT;
+							xv = -1;
+							state = STATE_FLOATLEFT;
+						} else if (flags & kFlagPushUp) {
+							e->dir = DIR_UP;
+							yv = -1;
+							state = STATE_FLOATUP;
+						} else if (flags & kFlagPushDown) {
+							e->dir = DIR_DOWN;
+							yv = 1;
+							state = STATE_FLOATDOWN;
+						}
+
+						e->moveSpeed = kPushMoveSpeed >> 1;
+						setEntityGoal(e, e->tileX + xv, e->tileY + yv);
+						e->state = state;
+						}
+					}
+				}
+			} else if (((flags = g_hdb->_map->getMapBGTileFlags(e->tileX, e->tileY)) & kFlagWater) && (e->type == AI_MAGIC_EGG || e->type == AI_ICE_BLOCK)) {
+				// And no foreground tile is there
+				if (g_hdb->_map->getMapFGTileIndex(e->tileX, e->tileY) < 0 && !checkFloating(e->tileX, e->tileY)) {
+					if (flags & kFlagSlime) {
+						// Evaporates in Slime
+						addAnimateTarget(e->x, e->y, 0, 3, ANIM_NORMAL, false, false, GROUP_STEAM_PUFF_SIT);
+						removeEntity(e);
+						warning("STUB: animateEntity: Play SND_SPLASH");
+						return;
+					} else {
+						// Drowns in water
+						addAnimateTarget(e->x, e->y, 0, 3, ANIM_NORMAL, false, false, GROUP_WATER_SPLASH_SIT);
+						removeEntity(e);
+						warning("STUB: animateEntity: Play SND_SPLASH");
+						return;
+					}
+				}
+			}
 		} else if (onEvenTile(e->x, e->y))
 			setEntityGoal(e, _waypoints[0].x, _waypoints[0].y);
 	}


Commit: fbeb7f8c4ef472a4532926ab367e5dd5606067d9
    https://github.com/scummvm/scummvm/commit/fbeb7f8c4ef472a4532926ab367e5dd5606067d9
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:01+02:00

Commit Message:
HDB: Add _triggerList data

Changed paths:
    engines/hdb/ai-init.cpp
    engines/hdb/ai.h


diff --git a/engines/hdb/ai-init.cpp b/engines/hdb/ai-init.cpp
index 6cfe702..ab25f2d 100644
--- a/engines/hdb/ai-init.cpp
+++ b/engines/hdb/ai-init.cpp
@@ -671,6 +671,7 @@ AI::AI() {
 	_floats = new Common::Array<AIEntity *>;
 	_animTargets = new Common::Array<AnimTarget *>;
 	_arrowPaths = new Common::Array<ArrowPath *>;
+	_triggerList = new Common::Array<Trigger *>;
 	_hereList = new Common::Array<HereT *>;
 
 	// REMOVE: Remove for final. Used here due to lack of a MENU
@@ -685,6 +686,7 @@ AI::~AI() {
 	delete _floats;
 	delete _animTargets;
 	delete _arrowPaths;
+	delete _triggerList;
 	delete _hereList;
 }
 
@@ -847,6 +849,9 @@ void AI::restartSystem() {
 	// Clear ArrowPath List
 	_arrowPaths->clear();
 
+	// Clear Trigger List
+	_triggerList->clear();
+
 	// Clear Here List
 	_hereList->clear();
 
diff --git a/engines/hdb/ai.h b/engines/hdb/ai.h
index f24dbc8..7a33e42 100644
--- a/engines/hdb/ai.h
+++ b/engines/hdb/ai.h
@@ -618,6 +618,16 @@ struct HereT {
 	char entName[32];
 };
 
+struct Trigger {
+	char id[32];
+	uint16 x, y;
+	uint16 value1, value2;
+	char luaFuncInit[32];
+	char luaFuncUse[32];
+
+	Trigger() : id(""), x(0), y(0), value1(0), value2(0), luaFuncInit(""), luaFuncUse("") {}
+};
+
 struct CineCommand {
 	CineType cmdType;
 	double x, y;
@@ -1004,6 +1014,7 @@ public:
 
 	Common::Array<ArrowPath *> *_arrowPaths;
 	Common::Array<HereT *> *_hereList;
+	Common::Array<Trigger *> *_triggerList;
 
 	// Virtual Player
 	AIEntity _dummyPlayer, _dummyLaser;


Commit: 368e80c75f157da79747d2166502d97215b7b5bc
    https://github.com/scummvm/scummvm/commit/368e80c75f157da79747d2166502d97215b7b5bc
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:01+02:00

Commit Message:
HDB: Add lua_push functions and call()

Changed paths:
    engines/hdb/lua-script.cpp
    engines/hdb/lua-script.h


diff --git a/engines/hdb/lua-script.cpp b/engines/hdb/lua-script.cpp
index cbed8b5..188ab2b 100644
--- a/engines/hdb/lua-script.cpp
+++ b/engines/hdb/lua-script.cpp
@@ -814,7 +814,6 @@ void debugHook(lua_State *L, lua_Debug *ar) {
 }
 }
 
-
 bool LuaScript::initScript(Common::SeekableReadStream *stream, const char *scriptName, int32 length) {
 
 	if (_systemInit) {
@@ -940,6 +939,33 @@ bool LuaScript::initScript(Common::SeekableReadStream *stream, const char *scrip
 	return true;
 }
 
+void LuaScript::pushInt(int value) {
+	if (!_systemInit)
+		return;
+	lua_pushnumber(_state, (double)value);
+}
+
+void LuaScript::pushString(char *string) {
+	if (!_systemInit)
+		return;
+	lua_pushstring(_state, string);
+}
+
+void LuaScript::pushFunction(char *func) {
+	if (!_systemInit)
+		return;
+
+	lua_getglobal(_state, func);
+	warning("STUB: pushFunction: Open Dialog if Cheating_On");
+}
+
+void LuaScript::call(int args, int returns) {
+	if (!_systemInit)
+		return;
+
+	lua_call(_state, args, returns);
+}
+
 bool LuaScript::callFunction(const char *name, int returns) {
 	if (!_systemInit) {
 		return false;
diff --git a/engines/hdb/lua-script.h b/engines/hdb/lua-script.h
index 32eb419..a67695c 100644
--- a/engines/hdb/lua-script.h
+++ b/engines/hdb/lua-script.h
@@ -44,7 +44,13 @@ public:
 
 	bool init();
 	bool initScript(Common::SeekableReadStream *stream, const char *scriptName, int32 length);
+
+	void pushInt(int value);
+	void pushString(char *string);
+	void pushFunction(char *func);
+	void call(int args, int returns);
 	bool callFunction(const char *name, int returns);
+
 	bool executeMPC(Common::SeekableReadStream *stream, const char *name, const char *scriptName, int32 length);
 	bool executeFile(const Common::String &filename);
 	void checkParameters(const char *func, int params);


Commit: 0f313f3eda614b828574e62fbca66a1eb3b9fb71
    https://github.com/scummvm/scummvm/commit/0f313f3eda614b828574e62fbca66a1eb3b9fb71
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:02+02:00

Commit Message:
HDB: Add functions related to _triggerList

Changed paths:
    engines/hdb/ai-lists.cpp
    engines/hdb/ai.h


diff --git a/engines/hdb/ai-lists.cpp b/engines/hdb/ai-lists.cpp
index 3d1e235..207e51f 100644
--- a/engines/hdb/ai-lists.cpp
+++ b/engines/hdb/ai-lists.cpp
@@ -623,4 +623,59 @@ ArrowPath *AI::findArrowPath(int x, int y) {
 	return NULL;
 }
 
+void AI::addToTriggerList(char *luaFuncInit, char *luaFuncUse, int x, int y, int value1, int value2, char *id) {
+	Trigger *t = new Trigger;
+
+	strcpy(t->id, id);
+	t->x = x;
+	t->y = y;
+	t->value1 = value1;
+	t->value2 = value2;
+	if (luaFuncInit[0] != '*')
+		strcpy(t->luaFuncInit, luaFuncInit);
+	if (luaFuncUse[0] != '*')
+		strcpy(t->luaFuncUse, luaFuncUse);
+
+	if (!t->luaFuncUse[0])
+		warning("STUB: addToTriggerList: Open MessageBar");
+
+	if (t->luaFuncInit[0]) {
+		g_hdb->_lua->pushFunction(t->luaFuncInit);
+		g_hdb->_lua->pushInt(x);
+		g_hdb->_lua->pushInt(y);
+		g_hdb->_lua->pushInt(value1);
+		g_hdb->_lua->pushInt(value2);
+		g_hdb->_lua->call(4, 0);
+	}
+}
+
+bool AI::checkTriggerList(char *entName, int x, int y) {
+	Trigger *t;
+
+	for (Common::Array<Trigger *>::iterator it = _triggerList->begin(); it != _triggerList->end(); it++) {
+		if (t->x == x && t->y == y) {
+			if (!t->luaFuncUse[0])
+				return false;
+
+			g_hdb->_lua->pushFunction(t->luaFuncUse);
+			g_hdb->_lua->pushString(entName);
+			g_hdb->_lua->pushInt(t->x);
+			g_hdb->_lua->pushInt(t->y);
+			g_hdb->_lua->pushInt(t->value1);
+			g_hdb->_lua->pushInt(t->value2);
+			g_hdb->_lua->call(5, 0);
+			return true;
+		}
+	}
+
+	return false;
+}
+
+void AI::killTrigger(char *id) {
+	for (Common::Array<Trigger *>::iterator it = _triggerList->begin(); it != _triggerList->end(); it++) {
+		if (!scumm_stricmp(id, (*it)->id))
+			_triggerList->erase(it);
+	}
+}
+
 } // End of Namespace
diff --git a/engines/hdb/ai.h b/engines/hdb/ai.h
index 7a33e42..bf0a9bc 100644
--- a/engines/hdb/ai.h
+++ b/engines/hdb/ai.h
@@ -718,6 +718,9 @@ public:
 	bool findTeleporterDest(int tileX, int tileY, SingleTele *info);
 	void addToPathList(int x, int y, int type, AIDir dir);
 	ArrowPath *findArrowPath(int x, int y);
+	void addToTriggerList(char *luaFuncInit, char *luaFuncUse, int x, int y, int value1, int value2, char *id);
+	bool checkTriggerList(char *entName, int x, int y);
+	void killTrigger(char *id);
 
 	void floatEntity(AIEntity *e, AIState state);
 	bool checkFloating(int x, int y);


Commit: 459921b04612bf64c2b09e7eeb2d32e919833240
    https://github.com/scummvm/scummvm/commit/459921b04612bf64c2b09e7eeb2d32e919833240
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:02+02:00

Commit Message:
HDB: Remove error message stub

Changed paths:
    engines/hdb/lua-script.cpp


diff --git a/engines/hdb/lua-script.cpp b/engines/hdb/lua-script.cpp
index 188ab2b..3eb2fe5 100644
--- a/engines/hdb/lua-script.cpp
+++ b/engines/hdb/lua-script.cpp
@@ -952,11 +952,16 @@ void LuaScript::pushString(char *string) {
 }
 
 void LuaScript::pushFunction(char *func) {
+	int type;
+
 	if (!_systemInit)
 		return;
 
 	lua_getglobal(_state, func);
-	warning("STUB: pushFunction: Open Dialog if Cheating_On");
+	type = lua_type(_state, 1);
+	if (type != LUA_TFUNCTION && type != LUA_TNUMBER) {
+		warning("pushFunction: Function '%s' doesn't exists", func);
+	}
 }
 
 void LuaScript::call(int args, int returns) {


Commit: 00e6ce26809a7e37e0bb64b9614c1bc289be1631
    https://github.com/scummvm/scummvm/commit/00e6ce26809a7e37e0bb64b9614c1bc289be1631
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:02+02:00

Commit Message:
HDB: Add invokeLuaFunction()

Changed paths:
    engines/hdb/lua-script.cpp
    engines/hdb/lua-script.h


diff --git a/engines/hdb/lua-script.cpp b/engines/hdb/lua-script.cpp
index 3eb2fe5..ac8d4cd 100644
--- a/engines/hdb/lua-script.cpp
+++ b/engines/hdb/lua-script.cpp
@@ -988,6 +988,25 @@ bool LuaScript::callFunction(const char *name, int returns) {
 	return true;
 }
 
+void LuaScript::invokeLuaFunction(char *luaFunc, int x, int y, int value1, int value2) {
+	int type;
+
+	if (!_systemInit)
+		return;
+
+	lua_getglobal(_state, luaFunc);
+	type = lua_type(_state, 1);
+	if (type != LUA_TFUNCTION) {
+		warning("Function '%s' doesn't exist", luaFunc);
+	} else {
+		lua_pushnumber(_state, x);
+		lua_pushnumber(_state, y);
+		lua_pushnumber(_state, value1);
+		lua_pushnumber(_state, value2);
+		lua_call(_state, 4, 0);
+	}
+}
+
 bool LuaScript::executeMPC(Common::SeekableReadStream *stream, const char *name, const char *scriptName, int32 length) {
 
 	if (!_systemInit) {
diff --git a/engines/hdb/lua-script.h b/engines/hdb/lua-script.h
index a67695c..5cab8cb 100644
--- a/engines/hdb/lua-script.h
+++ b/engines/hdb/lua-script.h
@@ -50,6 +50,7 @@ public:
 	void pushFunction(char *func);
 	void call(int args, int returns);
 	bool callFunction(const char *name, int returns);
+	void invokeLuaFunction(char *luaFunc, int x, int y, int value1, int value2);
 
 	bool executeMPC(Common::SeekableReadStream *stream, const char *name, const char *scriptName, int32 length);
 	bool executeFile(const Common::String &filename);


Commit: c0db320111fc666076239efa4bff48babef1511b
    https://github.com/scummvm/scummvm/commit/c0db320111fc666076239efa4bff48babef1511b
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:02+02:00

Commit Message:
HDB: Add spawnBlocking()

Changed paths:
    engines/hdb/ai.h


diff --git a/engines/hdb/ai.h b/engines/hdb/ai.h
index bf0a9bc..3fb7945 100644
--- a/engines/hdb/ai.h
+++ b/engines/hdb/ai.h
@@ -656,8 +656,9 @@ struct CineBlit {
 	CineBlit() : x(0), y(0), pic(NULL), name(""), id(""), masked(false) {}
 };
 
-#define onEvenTile(x, y)	( !(x & 31) && !(y & 31) )
-#define hitPlayer(x, y)		( e->onScreen && g_hdb->_ai->checkPlayerCollision( x, y, 4 ) && !g_hdb->_ai->playerDead() )
+#define onEvenTile(x, y)		( !(x & 31) && !(y & 31) )
+#define hitPlayer(x, y)			( e->onScreen && g_hdb->_ai->checkPlayerCollision( x, y, 4 ) && !g_hdb->_ai->playerDead() )
+#define spawnBlocking(x, y, level)	g_hdb->_ai->spawn(AI_NONE, DIR_NONE, x, y, NULL, NULL, NULL, DIR_NONE, level, 0, 0, 0)
 
 class AI {
 public:


Commit: 86f7991eba8787a4e65758edd389982efbc749b0
    https://github.com/scummvm/scummvm/commit/86f7991eba8787a4e65758edd389982efbc749b0
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:02+02:00

Commit Message:
HDB: Add _luaList data

Changed paths:
    engines/hdb/ai-init.cpp
    engines/hdb/ai.h


diff --git a/engines/hdb/ai-init.cpp b/engines/hdb/ai-init.cpp
index ab25f2d..989454c 100644
--- a/engines/hdb/ai-init.cpp
+++ b/engines/hdb/ai-init.cpp
@@ -843,6 +843,13 @@ void AI::restartSystem() {
 	// Clear the Entity List
 	_ents->clear();
 
+	// Clear the Floats List
+	_floats->clear();
+
+	// Clear the Lua List
+	memset(_luaList, 0, sizeof(_luaList));
+	_numLuaList = 0;
+
 	// Clear Anim Targets List
 	_animTargets->clear();
 
diff --git a/engines/hdb/ai.h b/engines/hdb/ai.h
index 3fb7945..c76b6d6 100644
--- a/engines/hdb/ai.h
+++ b/engines/hdb/ai.h
@@ -38,6 +38,7 @@ enum {
 	kMaxActions = 20,
 	kMaxTeleporters = 20,
 	kMaxAutoActions = 30,
+	kMaxLuaEnts = 50,
 	kPlayerMoveSpeed = 4,
 	kEnemyMoveSpeed = 2,
 	kPushMoveSpeed = (kPlayerMoveSpeed >> 1),
@@ -564,6 +565,16 @@ struct Waypoint {
 	Waypoint() : x(0), y(0), level(0) {}
 };
 
+struct LuaT {
+	uint16 x, y;
+	uint16 value1, value2;
+	char luaFuncInit[32];
+	char luaFuncAction[32];
+	char luaFuncUse[32];
+
+	LuaT() : x(0), y(0), value1(0), value2(0), luaFuncInit(""), luaFuncAction(""), luaFuncUse("") {}
+};
+
 struct ActionInfo {
 	uint16 x1, y1;
 	uint16 x2, y2;
@@ -1009,6 +1020,9 @@ public:
 	Tile *_waypointGfx[4]; // Animating waypoint gfx
 	Tile *_debugQMark;
 
+	LuaT _luaList[kMaxLuaEnts];
+	int _numLuaList;
+
 	ActionInfo _actions[kMaxActions];
 
 	TeleInfo _teleporters[kMaxTeleporters];


Commit: 0f4e637e2a1710b20bb535a6dca63e125695e624
    https://github.com/scummvm/scummvm/commit/0f4e637e2a1710b20bb535a6dca63e125695e624
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:02+02:00

Commit Message:
HDB: Add _luaList functions

Changed paths:
    engines/hdb/ai-lists.cpp
    engines/hdb/ai.h


diff --git a/engines/hdb/ai-lists.cpp b/engines/hdb/ai-lists.cpp
index 207e51f..cb66ca2 100644
--- a/engines/hdb/ai-lists.cpp
+++ b/engines/hdb/ai-lists.cpp
@@ -434,6 +434,62 @@ bool AI::autoActive(int x, int y) {
 	return false;
 }
 
+void AI::addToLuaList(int x, int y, int value1, int value2, char *luaFuncInit, char *luaFuncAction, char *luaFuncUse) {
+	for (int i = 0; i < kMaxLuaEnts; i++) {
+		if (!_luaList[i].luaFuncInit[0] && !_luaList[i].luaFuncAction[0] && !_luaList[i].luaFuncUse[0]) {
+			_luaList[i].x = x;
+			_luaList[i].y = y;
+			_luaList[i].value1 = value1;
+			_luaList[i].value2 = value2;
+
+			strcpy(_luaList[i].luaFuncInit, luaFuncInit);
+			if (luaFuncInit[0] == '*')
+				_luaList[i].luaFuncInit[0] = 0;
+			strcpy(_luaList[i].luaFuncAction, luaFuncAction);
+			if (luaFuncAction[0] == '*')
+				_luaList[i].luaFuncAction[0] = 0;
+			strcpy(_luaList[i].luaFuncUse, luaFuncUse);
+			if (luaFuncUse[0] == '*')
+				_luaList[i].luaFuncUse[0] = 0;
+
+			_numLuaList++;
+			if (_luaList[i].luaFuncInit[0])
+				g_hdb->_lua->invokeLuaFunction(luaFuncInit, x, y, value1, value2);
+
+			spawnBlocking(x, y, 1);
+
+			return;
+		}
+	}
+}
+
+bool AI::checkLuaList(AIEntity *e, int x, int y) {
+	for (int i = 0;i < _numLuaList; i++) {
+		if (_luaList[i].x == x && _luaList[i].y == y && _luaList[i].luaFuncUse[0]) {
+			if (e == _player) {
+				lookAtXY(x, y);
+				animGrabbing();
+			}
+
+			g_hdb->_lua->invokeLuaFunction(_luaList[i].luaFuncUse, _luaList[i].x, _luaList[i].y, _luaList[i].value1, _luaList[i].value2);
+
+			return true;
+		}
+	}
+
+	return false;
+}
+
+bool AI::luaExistAtXY(int x, int y) {
+	for (int i = 0;i < _numLuaList; i++) {
+		if (_luaList[i].x == x && _luaList[i].y == y && _luaList[i].luaFuncUse[0]) {
+			return true;
+		}
+	}
+
+	return false;
+}
+
 void AI::addToTeleportList(int teleIndex, int x, int y, int dir, int level, int anim, int usable, const char *luaFuncUse) {
 	if (!level)
 		level = 1;
diff --git a/engines/hdb/ai.h b/engines/hdb/ai.h
index c76b6d6..1bcf757 100644
--- a/engines/hdb/ai.h
+++ b/engines/hdb/ai.h
@@ -725,6 +725,9 @@ public:
 	bool activateAction(AIEntity *e, int x, int y, int targetX, int targetY);
 	bool checkAutoList(AIEntity *e, int x, int y);
 	bool autoActive(int x, int y);
+	void addToLuaList(int x, int y, int value1, int value2, char *luaFuncInit, char *luaFuncAction, char *luaFuncUse);
+	bool checkLuaList(AIEntity *e, int x, int y);
+	bool luaExistAtXY(int x, int y);
 	void addToTeleportList(int teleIndex, int x, int y, int dir, int level, int anim, int usable, const char *luaFuncUse);
 	bool checkTeleportList(AIEntity *e, int x, int y);
 	bool findTeleporterDest(int tileX, int tileY, SingleTele *info);


Commit: 36dd16e1a9ebab675a952296c5a77d58705c9a70
    https://github.com/scummvm/scummvm/commit/36dd16e1a9ebab675a952296c5a77d58705c9a70
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:02+02:00

Commit Message:
HDB: Remove checkLuaList() stub

Changed paths:
    engines/hdb/ai-bots.cpp


diff --git a/engines/hdb/ai-bots.cpp b/engines/hdb/ai-bots.cpp
index ff94cee..481b661 100644
--- a/engines/hdb/ai-bots.cpp
+++ b/engines/hdb/ai-bots.cpp
@@ -857,7 +857,11 @@ void aiMaintBotAction(AIEntity *e) {
 					break;
 				}
 				// Did the MaintBot use a LUA Tile?
-				warning("STUB: aiMaintBotAction: Check in LUA List");
+				if (g_hdb->_ai->checkLuaList(e, nx, ny)) {
+					if (e->onScreen)
+						e->value1 = 1;
+					break;
+				}
 				break;
 			// Play a sound if we used something
 			case 25:


Commit: 922e70b723ebdb4877828098b12df7111b11a09d
    https://github.com/scummvm/scummvm/commit/922e70b723ebdb4877828098b12df7111b11a09d
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:02+02:00

Commit Message:
HDB: Remove 'checkTriggerList' stub

Changed paths:
    engines/hdb/ai-funcs.cpp
    engines/hdb/ai-lists.cpp
    engines/hdb/ai.h


diff --git a/engines/hdb/ai-funcs.cpp b/engines/hdb/ai-funcs.cpp
index c2a7117..c00c925 100644
--- a/engines/hdb/ai-funcs.cpp
+++ b/engines/hdb/ai-funcs.cpp
@@ -714,7 +714,7 @@ void AI::killPlayer(Death method) {
 void AI::animateEntity(AIEntity *e) {
 
 	int bgTileFlags, bgTileIndex;
-	int fgTileFlags, fgTileIndex;
+	int fgTileFlags;
 	bool result;
 	uint64 flags;
 
@@ -732,7 +732,126 @@ void AI::animateEntity(AIEntity *e) {
 
 	// For non-players, check for trigger being hit
 	if (onEvenTile(e->x, e->y)) {
-		debug(9, "STUB: animateEntity: Check for Triggers being hit");
+		// Check if a trigger is hit
+		checkTriggerList(e->entityName, e->tileX, e->tileY);
+
+		/*
+			For Non-Players only
+			are we on a touchplate?
+			Barrels, Crates, Magic Egg & Ice Block ONLY
+			standing on a Touchplate will activate
+			something WHILE standing on it
+		*/
+		int bgtile;
+		switch (e->type) {
+		case AI_CRATE:
+		case AI_BOOMBARREL:
+		case AI_HEAVYBARREL:
+		case AI_LIGHTBARREL:
+		case AI_MAGIC_EGG:
+		case AI_ICE_BLOCK:
+		case AI_FROGSTATUE:
+			bgtile = g_hdb->_ai->checkForTouchplate(e->tileX, e->tileY);
+			if (bgtile && !e->touchpWait && e->touchpX != e->tileX && e->touchpY != e->tileY) {
+				if (g_hdb->_ai->checkActionList(e, e->tileX, e->tileY, false)) {
+					e->touchpTile = bgtile;
+					e->touchpX = e->tileX;
+					e->touchpY = e->tileY;
+					e->touchpWait = kPlayerTouchPWait;
+				}
+			}
+			warning("STUB: animateEntity: Set laser_rescan to true");
+			break;
+		default:
+			debug(9, "animateEntity: Unintended Type");
+			break;
+		}
+
+		// Are we on ice?
+		bgTileFlags = g_hdb->_map->getMapBGTileFlags(e->tileX, e->tileY);
+		fgTileFlags = g_hdb->_map->getMapFGTileFlags(e->tileX, e->tileY);
+
+		if (e->level == 1 ? (bgTileFlags & kFlagIce) : ((bgTileFlags & kFlagIce) && !(fgTileFlags & kFlagGrating))) {
+			int xva[] = {9, 0, 0, -1, 1}, yva[] = {9, -1, 1, 0, 0};
+			int nx, ny, moveOK = 0;
+			AIEntity *hit;
+
+			// Types allowed to slide on ice...
+			switch (e->type) {
+			case AI_GUY:
+			case AI_CHICKEN:
+			case AI_TURNBOT:
+			case AI_RIGHTBOT:
+			case AI_PUSHBOT:
+			case AI_CRATE:
+			case AI_LIGHTBARREL:
+			case AI_HEAVYBARREL:
+			case AI_BOOMBARREL:
+			case AI_MAGIC_EGG:
+			case AI_ICE_BLOCK:
+			case AI_DIVERTER:
+				e->moveSpeed = kPlayerMoveSpeed << 1;
+				nx = e->tileX + xva[e->dir];
+				ny = e->tileY + yva[e->dir];
+				hit = legalMove(nx, ny, e->level, &moveOK);
+				bgTileFlags = g_hdb->_map->getMapBGTileFlags(nx, ny);
+				if (hit)
+					switch (hit->type) {
+					case ITEM_GEM_WHITE:
+					case ITEM_GEM_BLUE:
+					case ITEM_GEM_GREEN:
+					case ITEM_GEM_RED:
+					case AI_GOODFAIRY:
+					case AI_BADFAIRY:
+						hit = NULL;
+						break;
+					default:
+						debug(9, "animateEntity: Unintended type");
+						break;
+					}
+				if ((!hit && moveOK) || (bgTileFlags & kFlagPlayerDie))
+					setEntityGoal(e, nx, ny);
+
+				if (e == _player) {
+					_playerOnIce = true;
+					clearWaypoints();
+				}
+				break;
+			default:
+				debug(9, "animateEntity: Unintended type");
+				break;
+			}
+		} else if (e == _player)
+			_playerOnIce = false;
+
+		/*
+			Player only
+			are we trying to walk into a solid tile?
+			first, let's make sure we're perfectly aligned on
+			a tile boundary before the check so we don't snap
+			the player back into position...
+
+			if we're on a waypoint, nevermind!
+		*/
+		if (e == _player) {
+			warning("FIXME: Ambiguous animateEntity() code");
+			result = e->x == (e->goalX * kTileWidth) && e->y == (e->goalY * kTileWidth);
+			if (!result) {
+				int xv = 0, yv = 0;
+				switch (e->dir) {
+				case DIR_UP:	yv = -1;	break;
+				case DIR_DOWN:	yv = 1;		break;
+				case DIR_LEFT:	xv = -1;	break;
+				case DIR_RIGHT: xv = 1;		break;
+				case DIR_NONE:	warning("animateEntity: DIR_NONE found"); break;
+				}
+
+				bgTileFlags = g_hdb->_map->getMapBGTileFlags(e->tileX + xv, e->tileY + yv);
+				fgTileFlags = g_hdb->_map->getMapFGTileFlags(e->tileX + xv, e->tileY + yv);
+				if ((bgTileFlags & kFlagSolid) && !(fgTileFlags & kFlagGrating))
+					stopEntity(e);
+			}
+		}
 	}
 
 	// If player, then scroll the screen with the player
@@ -877,7 +996,7 @@ void AI::animateEntity(AIEntity *e) {
 				warning("STUB: animateEntity: Set _laserRescan to true");
 				break;
 			default:
-				warning("animateEntity: Unintended State");
+				debug(9, "animateEntity: Unintended State");
 			}
 
 			// Checking at the Destination
diff --git a/engines/hdb/ai-lists.cpp b/engines/hdb/ai-lists.cpp
index cb66ca2..389b3ab 100644
--- a/engines/hdb/ai-lists.cpp
+++ b/engines/hdb/ai-lists.cpp
@@ -709,6 +709,7 @@ bool AI::checkTriggerList(char *entName, int x, int y) {
 	Trigger *t;
 
 	for (Common::Array<Trigger *>::iterator it = _triggerList->begin(); it != _triggerList->end(); it++) {
+		t = *it;
 		if (t->x == x && t->y == y) {
 			if (!t->luaFuncUse[0])
 				return false;
diff --git a/engines/hdb/ai.h b/engines/hdb/ai.h
index 1bcf757..33e107a 100644
--- a/engines/hdb/ai.h
+++ b/engines/hdb/ai.h
@@ -42,6 +42,7 @@ enum {
 	kPlayerMoveSpeed = 4,
 	kEnemyMoveSpeed = 2,
 	kPushMoveSpeed = (kPlayerMoveSpeed >> 1),
+	kPlayerTouchPWait = 16,
 	kMaxCineGfx = 10
 };
 


Commit: ef25f372589bab2dfffc3176c59aaac66ab5c952
    https://github.com/scummvm/scummvm/commit/ef25f372589bab2dfffc3176c59aaac66ab5c952
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:02+02:00

Commit Message:
HDB: Fix warning

Changed paths:
    engines/hdb/mpc.h


diff --git a/engines/hdb/mpc.h b/engines/hdb/mpc.h
index ddfa365..d8a0a4c 100644
--- a/engines/hdb/mpc.h
+++ b/engines/hdb/mpc.h
@@ -918,7 +918,7 @@ enum IconList {
 	ICON_WAYPOINT_SELECT3,
 	ICON_WAYPOINT_SELECT4,
 	ICON_WAYPOINT_1,
-	ICON_WAYPOINT_2,
+	ICON_WAYPOINT_2
 };
 
 


Commit: 72173c26d0f43614cdbfbe6aaf0d8836073646db
    https://github.com/scummvm/scummvm/commit/72173c26d0f43614cdbfbe6aaf0d8836073646db
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:02+02:00

Commit Message:
HDB: Fix warnings

Changed paths:
    engines/hdb/ai-bots.cpp


diff --git a/engines/hdb/ai-bots.cpp b/engines/hdb/ai-bots.cpp
index 481b661..7018c19 100644
--- a/engines/hdb/ai-bots.cpp
+++ b/engines/hdb/ai-bots.cpp
@@ -1053,11 +1053,12 @@ void aiDeadEyeWalkInPlace(AIEntity *e) {
 		s = state[dir];
 		e->dir = dir;
 		e->state = s;
-		if (e->onScreen)
+		if (e->onScreen) {
 			if (e->sequence == 50)
 				warning("STUB: aiDeadEyeWalkInPlace: Play SND_DEADEYE_AMB01");
 			else if (e->sequence == 10)
 				warning("STUB: aiDeadEyeWalkInPlace: Play SND_DEADEYE_AMB02");
+		}
 		break;
 	case 0:
 		e->sequence = 64;
@@ -1144,11 +1145,12 @@ void aiDeadEyeAction(AIEntity *e) {
 			e->dir = dir;
 			e->state = s;
 
-			if (e->onScreen)
+			if (e->onScreen) {
 				if (e->sequence == 50)
 					warning("STUB: aiDeadEyeAction: Play SND_DEADEYE_AMB01");
 				else if (e->sequence == 10)
 					warning("STUB: aiDeadEyeAction: Play SND_DEADEYE_AMB01");
+			}
 			break;
 		case 0:
 			// Pick a random direction and random number of tiles in that direction


Commit: 33388494587572c33f013bd7308aadaacdbc37b3
    https://github.com/scummvm/scummvm/commit/33388494587572c33f013bd7308aadaacdbc37b3
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:02+02:00

Commit Message:
JANITORIAL: Add endline to the end of file

Changed paths:
    engines/hdb/input.cpp


diff --git a/engines/hdb/input.cpp b/engines/hdb/input.cpp
index d20a203..12d415e 100644
--- a/engines/hdb/input.cpp
+++ b/engines/hdb/input.cpp
@@ -58,4 +58,5 @@ void stylusMove(int x, int y) {
 	warning("STUB: Input: stylusMove required");
 }
 
-}
\ No newline at end of file
+}
+


Commit: a98e24634760ab4132536c9a9b2160b2bf6c1c86
    https://github.com/scummvm/scummvm/commit/a98e24634760ab4132536c9a9b2160b2bf6c1c86
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:02+02:00

Commit Message:
HDB: Add remaining luaGlobalStrings\Values

Changed paths:
    engines/hdb/lua-script.cpp


diff --git a/engines/hdb/lua-script.cpp b/engines/hdb/lua-script.cpp
index ac8d4cd..6ffd092 100644
--- a/engines/hdb/lua-script.cpp
+++ b/engines/hdb/lua-script.cpp
@@ -695,6 +695,124 @@ struct VarInit {
 	const char *luaName;
 } luaGlobalStrings[] = {
 	{ "Map00",	"MAP00"},
+	{ TILE_TELEPORT1,					"TILE_TELEPORT1"	},
+	{ TILE_SKY_STARS,					"TILE_SKY_STARS"	},
+	{ TILE_HOLDER1,						"TILE_HOLDER1"		},
+	{ TILE_HOLDERFULL,					"TILE_HOLDERFULL"	},
+	{ TILE_SWITCH1,						"TILE_SWITCH1"		},
+	{ TILE_1SWITCH1,					"TILE_1SWITCH1"		},
+	{ TILE_DOOR_N,						"TILE_DOOR_N"		},
+	{ TILE_DOOR_P,						"TILE_DOOR_P"		},
+	{ TILE_DOOR_S,						"TILE_DOOR_S"		},
+	{ TILE_ASKCOMP1,					"TILE_ASKCOMP1"		},
+	{ TILE_SWITCH_ON,					"TILE_SWITCH_ON"	},
+	{ TILE_1SWITCH_ON,					"TILE_1SWITCH_ON"	},
+	{ TILE_FLOORSHOCK,					"TILE_FLOORSHOCK"	},
+	{ TILE_DOOR_NV,						"TILE_DOOR_NV"		},
+	{ TILE_DOOR_PV,						"TILE_DOOR_PV"		},
+	{ TILE_DOOR_SV,						"TILE_DOOR_SV"		},
+	{ TILE_MAILSORT,					"TILE_MAILSORT"		},
+	{ TILE_BEDR_OPEN,					"TILE_BEDR_OPEN"	},
+	{ TILE_BEDL_OPEN,					"TILE_BEDL_OPEN"	},
+	{ TILE_BEDR_CLOSED,					"TILE_BEDR_CLOSED"	},
+	{ TILE_BEDL_CLOSED,					"TILE_BEDL_CLOSED"	},
+	{ TILE_FERRET,						"TILE_FERRET"		},
+	{ TILE_CABOPEN_T,					"TILE_CABOPEN_T"	},
+	{ TILE_CABOPEN_B,					"TILE_CABOPEN_B"	},
+	{ GROUP_ENT_ENVELOPE_WHITE_SIT"01",	"TILE_ENV_WHITE"	},
+	{ GROUP_ENT_ENVELOPE_BLUE_SIT"01",	"TILE_ENV_BLUE"		},
+	{ GROUP_ENT_ENVELOPE_RED_SIT"01",	"TILE_ENV_RED" 		},
+	{ GROUP_ENT_ENVELOPE_GREEN_SIT"01",	"TILE_ENV_GREEN"	},
+	{ GROUP_ENT_TRANSCEIVER_SIT"01",	"TILE_TRANSCEIVER"	},
+	{ TILE_HEAD_SCIENTIST,				"TILE_HEAD_SCIENTIST" },
+	{ TILE_HEAD_SPACEDUDE,				"TILE_HEAD_SPACEDUDE" },
+	{ TILE_HEAD_WORKER,					"TILE_HEAD_WORKER" },
+	{ TILE_HEAD_ACCOUNTANT,				"TILE_HEAD_ACCOUNTANT" },
+	{ TILE_HEAD_DOLLY,					"TILE_HEAD_DOLLY" },
+	{ TILE_HEAD_SARGE,					"TILE_HEAD_SARGE" },
+	{ TILE_BTUNNEL_BLOCK_B,				"TILE_BTUNNEL_BLOCK_B" },
+	{ TILE_BTUNNEL_BLOCK_L,				"TILE_BTUNNEL_BLOCK_L" },
+	{ TILE_BTUNNEL_BLOCK_R,				"TILE_BTUNNEL_BLOCK_R" },
+	{ TILE_BTUNNEL_BLOCK_T,				"TILE_BTUNNEL_BLOCK_T" },
+	{ TILE_BTUNNEL_DONE_B,				"TILE_BTUNNEL_DONE_B" },
+	{ TILE_BTUNNEL_DONE_L,				"TILE_BTUNNEL_DONE_L" },
+	{ TILE_BTUNNEL_DONE_R,				"TILE_BTUNNEL_DONE_R" },
+	{ TILE_BTUNNEL_DONE_T,				"TILE_BTUNNEL_DONE_T" },
+	{ GROUP_ENT_ROUTER_SIT"01",			"TILE_ROUTER" },
+	{ GROUP_ENT_NOTE_SIT"01",			"TILE_NOTE" },
+	{ TILE_INBOX,						"TILE_INBOX" },
+	{ TILE_MEMOS,						"TILE_MEMOS" },
+	{ TILE_A,							"TILE_A" },
+	{ TILE_B,							"TILE_B" },
+	{ TILE_C,							"TILE_C" },
+	{ TILE_D,							"TILE_D" },
+	{ TILE_E,							"TILE_E" },
+	{ TILE_F,							"TILE_F" },
+	{ TILE_G,							"TILE_G" },
+	{ TILE_H,							"TILE_H" },
+	{ TILE_I,							"TILE_I" },
+	{ TILE_J,							"TILE_J" },
+	{ TILE_K,							"TILE_K" },
+	{ TILE_L,							"TILE_L" },
+	{ TILE_M,							"TILE_M" },
+	{ TILE_N,							"TILE_N" },
+	{ TILE_O,							"TILE_O" },
+	{ TILE_P,							"TILE_P" },
+	{ TILE_Q,							"TILE_Q" },
+	{ TILE_R,							"TILE_R" },
+	{ TILE_S,							"TILE_S" },
+	{ TILE_T,							"TILE_T" },
+	{ TILE_U,							"TILE_U" },
+	{ TILE_V,							"TILE_V" },
+	{ TILE_W,							"TILE_W" },
+	{ TILE_X,							"TILE_X" },
+	{ TILE_Y,							"TILE_Y" },
+	{ TILE_Z,							"TILE_Z" },
+	{ TILE_SNOWDOOR_B,					"TILE_SNOWDOOR_B" },
+	{ TILE_PACKAGE,						"TILE_PACKAGE" },
+	{ TILE_TYRANIUM,					"TILE_TYRANIUM" },
+	{ TILE_CHAIR,						"TILE_CHAIR" },
+	{ TILE_ROUTER_HOLDER,				"TILE_ROUTER_HOLDER" },
+	{ TILE_PHAR_CARPET,					"TILE_PHAR_CARPET" },
+	{ TILE_WASTEBASKET,					"TILE_WASTEBASKET" },
+	{ TILE_PIZZA,						"TILE_PIZZA" },
+	{ TILE_HEADSTATUE,					"TILE_HEADSTATUE" },
+	{ TILE_SLOT_GOOD1,					"TILE_SLOT_GOOD1" },
+	{ TILE_SLOT_GOOD2,					"TILE_SLOT_GOOD2" },
+	{ TILE_SLOT_GOOD3,					"TILE_SLOT_GOOD3" },
+	{ TILE_SLOT_GOOD4,					"TILE_SLOT_GOOD4" },
+	{ TILE_SLOT_GOOD5,					"TILE_SLOT_GOOD5" },
+	{ TILE_SLOT_GOOD6,					"TILE_SLOT_GOOD6" },
+	{ TILE_SLOT_BAD,					"TILE_SLOT_BAD" },
+	{ GEM_BLUE_GFX,						"TILE_GEM_BLUE" },
+	{ GEM_RED_GFX,						"TILE_GEM_RED" },
+	{ GEM_GREEN_GFX,					"TILE_GEM_GREEN" },
+	{ TITLE_EPISODE1,					"PIC_TITLE_EPISODE1"	},
+	{ TITLE_EPISODE2,					"PIC_TITLE_EPISODE2"	},
+	{ TITLE_EPISODE3,					"PIC_TITLE_EPISODE3"	},
+	{ PIC_FROG_STATUE,					"PIC_FROG_STATUE" },
+	{ PIC_JENKINS,						"PIC_JENKINS" },
+	{ GEM_WHITE,						"TILE_GEM_WHITE" },
+
+	{ CINE_INTROSHIP,					"PIC_CINE_INTROSHIP"	},
+	{ CINE_LITTLE_MBOT,					"PIC_CINE_LITTLE_MBOT"	},
+	{ CINE_CLOCK,						"PIC_CINE_CLOCK"		},
+	{ MONKEYLOGOSCREEN,					"PIC_MONKEYLOGOSCREEN"	},
+	{ MONKEYLOGO_OOHOOH,				"PIC_MONKEYLOGO_OOHOOH" },
+	{ MONKEYLOGO_SMILE,					"PIC_MONKEYLOGO_SMILE"	},
+	{ PIC_ENV_WHITE,					"PIC_ENV_WHITE" },
+	{ PIC_TEAM_BRIAN,					"PIC_TEAM_BRIAN" },
+	{ PIC_TEAM_STEVIE,					"PIC_TEAM_STEVIE" },
+	{ PIC_TEAM_JOSH,					"PIC_TEAM_JOSH" },
+	{ PIC_TEAM_TOM,						"PIC_TEAM_TOM" },
+	{ PIC_TEAM_JOHN,					"PIC_TEAM_JOHN" },
+	{ PIC_TEAM_LUCAS,					"PIC_TEAM_LUCAS" },
+
+	{ PIC_RANK1,						"PIC_RANK1" },
+	{ PIC_RANK2,						"PIC_RANK2" },
+	{ PIC_RANK3,						"PIC_RANK3" },
+	{ PIC_RANK4,						"PIC_RANK4" },
+	{ PIC_RANK5,						"PIC_RANK5" },
 	{NULL, NULL}
 };
 
@@ -708,6 +826,76 @@ struct NumberInit {
 	{ DIR_UP,			"DIR_UP"	},
 	{ DIR_LEFT,			"DIR_LEFT"	},
 	{ DIR_RIGHT,		"DIR_RIGHT"	},
+
+	{ STATE_NONE,			"STATE_NONE"			},
+	{ STATE_STANDDOWN,		"STATE_STANDDOWN"		},
+	{ STATE_STANDUP,		"STATE_STANDUP"			},
+	{ STATE_STANDLEFT,		"STATE_STANDLEFT"		},
+	{ STATE_STANDRIGHT,		"STATE_STANDRIGHT"		},
+	{ STATE_BLINK,			"STATE_BLINK"			},
+	{ STATE_MOVEUP,			"STATE_MOVEUP"			},
+	{ STATE_MOVEDOWN,		"STATE_MOVEDOWN"		},
+	{ STATE_MOVELEFT,		"STATE_MOVELEFT"		},
+	{ STATE_MOVERIGHT,		"STATE_MOVERIGHT"		},
+	{ STATE_DYING,			"STATE_DYING"			},
+	{ STATE_DEAD,			"STATE_DEAD"			},
+	{ STATE_GOODJOB,		"STATE_GOODJOB"			},
+	{ STATE_HORRIBLE1,		"STATE_HORRIBLE1"		},
+	{ STATE_HORRIBLE2,		"STATE_HORRIBLE2"		},
+	{ STATE_HORRIBLE3,		"STATE_HORRIBLE3"		},
+	{ STATE_HORRIBLE4,		"STATE_HORRIBLE4"		},
+	{ STATE_PUSHUP,			"STATE_PUSHUP"			},
+	{ STATE_PUSHDOWN,		"STATE_PUSHDOWN"		},
+	{ STATE_PUSHLEFT,		"STATE_PUSHLEFT"		},
+	{ STATE_PUSHRIGHT,		"STATE_PUSHRIGHT"		},
+	{ STATE_GRABUP,			"STATE_GRABUP"			},
+	{ STATE_GRABDOWN,		"STATE_GRABDOWN"		},
+	{ STATE_GRABLEFT,		"STATE_GRABLEFT"		},
+	{ STATE_GRABRIGHT,		"STATE_GRABRIGHT"		},
+	{ STATE_ATK_CLUB_UP,	"STATE_ATK_CLUB_UP"		},
+	{ STATE_ATK_CLUB_DOWN,	"STATE_ATK_CLUB_DOWN"	},
+	{ STATE_ATK_CLUB_LEFT,	"STATE_ATK_CLUB_LEFT"	},
+	{ STATE_ATK_CLUB_RIGHT,	"STATE_ATK_CLUB_RIGHT"	},
+	{ STATE_ATK_STUN_DOWN,	"STATE_ATK_STUN_DOWN"	},
+	{ STATE_ATK_STUN_UP,	"STATE_ATK_STUN_UP"		},
+	{ STATE_ATK_STUN_LEFT,	"STATE_ATK_STUN_LEFT"	},
+	{ STATE_ATK_STUN_RIGHT,	"STATE_ATK_STUN_RIGHT"	},
+	{ STATE_ATK_SLUG_DOWN,	"STATE_ATK_SLUG_DOWN"	},
+	{ STATE_ATK_SLUG_UP,	"STATE_ATK_SLUG_UP"		},
+	{ STATE_ATK_SLUG_LEFT,	"STATE_ATK_SLUG_LEFT"	},
+	{ STATE_ATK_SLUG_RIGHT,	"STATE_ATK_SLUG_RIGHT"	},
+	{ STATE_FLOATING,		"STATE_FLOATING"		},
+	{ STATE_FLOATDOWN,		"STATE_FLOATDOWN"		},
+	{ STATE_FLOATUP,		"STATE_FLOATUP"			},
+	{ STATE_FLOATLEFT,		"STATE_FLOATLEFT"		},
+	{ STATE_FLOATRIGHT,		"STATE_FLOATRIGHT"		},
+	{ STATE_MELTED,			"STATE_MELTED"			},
+	{ STATE_SLIDING,		"STATE_SLIDING"			},
+	{ STATE_SHOCKING,		"STATE_SHOCKING"		},
+	{ STATE_EXPLODING,		"STATE_EXPLODING"		},
+	{ STATE_USEDOWN,		"STATE_USEDOWN"			},
+	{ STATE_USEUP,			"STATE_USEUP"			},
+	{ STATE_USELEFT,		"STATE_USELEFT"			},
+	{ STATE_USERIGHT,		"STATE_USERIGHT"		},
+	{ STATE_MEER_MOVE,		"STATE_MEER_MOVE"		},
+	{ STATE_MEER_APPEAR,	"STATE_MEER_APPEAR"		},
+	{ STATE_MEER_BITE,		"STATE_MEER_BITE"		},
+	{ STATE_MEER_DISAPPEAR,	"STATE_MEER_DISAPPEAR"	},
+	{ STATE_MEER_LOOK,		"STATE_MEER_LOOK"		},
+	{ STATE_ICEP_PEEK,		"STATE_ICEP_PEEK"		},
+	{ STATE_ICEP_APPEAR,	"STATE_ICEP_APPEAR"		},
+	{ STATE_ICEP_THROWDOWN,	"STATE_ICEP_THROWDOWN"	},
+	{ STATE_ICEP_THROWRIGHT,"STATE_ICEP_THROWRIGHT"	},
+	{ STATE_ICEP_THROWLEFT,	"STATE_ICEP_THROWLEFT"	},
+	{ STATE_ICEP_DISAPPEAR,	"STATE_ICEP_DISAPPEAR"	},
+	{ STATE_ANGRY,			"STATE_ANGRY"			},
+	{ STATE_PANIC,			"STATE_PANIC"			},
+	{ STATE_LAUGH,			"STATE_LAUGH"			},
+	{ STATE_KISSLEFT,		"STATE_KISSLEFT"		},
+	{ STATE_KISSRIGHT,		"STATE_KISSRIGHT"		},
+	{ STATE_DOLLYUSERIGHT,	"STATE_DOLLYUSERIGHT"	},
+	{ STATE_YELL,			"STATE_YELL"			},
+
 	{ NULL, NULL }
 };
 


Commit: 678de0f73f4f48348895efdaccb656a4ae583a48
    https://github.com/scummvm/scummvm/commit/678de0f73f4f48348895efdaccb656a4ae583a48
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:02+02:00

Commit Message:
HDB: Add _callbacks data

Changed paths:
    engines/hdb/ai-init.cpp
    engines/hdb/ai.h


diff --git a/engines/hdb/ai-init.cpp b/engines/hdb/ai-init.cpp
index 989454c..5bb8c89 100644
--- a/engines/hdb/ai-init.cpp
+++ b/engines/hdb/ai-init.cpp
@@ -840,6 +840,9 @@ void AI::restartSystem() {
 	// Clear the Auto-Action list
 	memset(_autoActions, 0, sizeof(_autoActions));
 
+	// Clear the Callback List
+	memset(_callbacks, 0, sizeof(_callbacks));
+
 	// Clear the Entity List
 	_ents->clear();
 
diff --git a/engines/hdb/ai.h b/engines/hdb/ai.h
index 33e107a..6f5653a 100644
--- a/engines/hdb/ai.h
+++ b/engines/hdb/ai.h
@@ -39,6 +39,7 @@ enum {
 	kMaxTeleporters = 20,
 	kMaxAutoActions = 30,
 	kMaxLuaEnts = 50,
+	kMaxCallbacks = 20,
 	kPlayerMoveSpeed = 4,
 	kEnemyMoveSpeed = 2,
 	kPushMoveSpeed = (kPlayerMoveSpeed >> 1),
@@ -354,6 +355,15 @@ enum CineType {
 	C_ENDLIST
 };
 
+enum CallbackType {
+	NO_FUNCTION,
+	AI_BARREL_EXPLOSION_END,
+	CALLBACK_DOOR_OPEN_CLOSE,
+	CALLBACK_AUTODOOR_OPEN_CLOSE,
+
+	CALLBACK_END
+};
+
 struct AIStateDef {
 	AIState state;
 	const char name[64];
@@ -640,6 +650,22 @@ struct Trigger {
 	Trigger() : id(""), x(0), y(0), value1(0), value2(0), luaFuncInit(""), luaFuncUse("") {}
 };
 
+struct CallbackDef {
+	CallbackType type;
+	void(*function)(int x, int y);
+
+	CallbackDef() : type(NO_FUNCTION), function(NULL) {}
+	CallbackDef(CallbackType type, void(*function)(int, int)) : type(type), function(function) {}
+};
+
+struct Callback {
+	CallbackType type;
+	uint16 x, y;
+	uint16 delay;
+
+	Callback() : type(NO_FUNCTION), x(0), y(0), delay(0) {}
+};
+
 struct CineCommand {
 	CineType cmdType;
 	double x, y;
@@ -1034,6 +1060,8 @@ public:
 
 	AutoAction _autoActions[kMaxAutoActions];
 
+	Callback _callbacks[kMaxCallbacks];
+
 	Common::Array<ArrowPath *> *_arrowPaths;
 	Common::Array<HereT *> *_hereList;
 	Common::Array<Trigger *> *_triggerList;


Commit: dbfddba4cfbcfee8e588e68cd2ce92c7e1d898de
    https://github.com/scummvm/scummvm/commit/dbfddba4cfbcfee8e588e68cd2ce92c7e1d898de
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:02+02:00

Commit Message:
HDB: Add stubbed aiBarrelExplosionEnd(int, int)

Changed paths:
    engines/hdb/ai-player.cpp
    engines/hdb/ai-player.h


diff --git a/engines/hdb/ai-player.cpp b/engines/hdb/ai-player.cpp
index 05e8035..e399749 100644
--- a/engines/hdb/ai-player.cpp
+++ b/engines/hdb/ai-player.cpp
@@ -304,6 +304,10 @@ void aiBarrelExplodeSpread(AIEntity *e) {
 	warning("STUB: AI: aiBarrelExplodeSpread required");
 }
 
+void aiBarrelExplosionEnd(int x, int y) {
+	warning("STUB: AI: aiBarrelExplosionEnd(int, int) required");
+}
+
 void aiBarrelBlowup(AIEntity *e, int x, int y) {
 	warning("STUB: AI: aiBarrelBlowup required");
 }
diff --git a/engines/hdb/ai-player.h b/engines/hdb/ai-player.h
index b78d03c..0ab9c16 100644
--- a/engines/hdb/ai-player.h
+++ b/engines/hdb/ai-player.h
@@ -62,6 +62,7 @@ void aiBarrelExplodeInit(AIEntity *e);
 void aiBarrelExplodeInit2(AIEntity *e);
 void aiBarrelExplodeAction(AIEntity *e);
 void aiBarrelExplodeSpread(AIEntity *e);
+void aiBarrelExplosionEnd(int x, int y);
 void aiBarrelBlowup(AIEntity *e, int x, int y);
 
 void aiMaintBotInit(AIEntity *e);


Commit: 761c90e62a1c7f01d38420834119a4fa697a3950
    https://github.com/scummvm/scummvm/commit/761c90e62a1c7f01d38420834119a4fa697a3950
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:02+02:00

Commit Message:
HDB: Add functions related to _callbacks

Changed paths:
    engines/hdb/ai-lists.cpp
    engines/hdb/ai.h


diff --git a/engines/hdb/ai-lists.cpp b/engines/hdb/ai-lists.cpp
index 389b3ab..a859886 100644
--- a/engines/hdb/ai-lists.cpp
+++ b/engines/hdb/ai-lists.cpp
@@ -434,6 +434,35 @@ bool AI::autoActive(int x, int y) {
 	return false;
 }
 
+CallbackDef allCallbacks[] = {
+	{NO_FUNCTION,	NULL},
+	{AI_BARREL_EXPLOSION_END,		aiBarrelExplosionEnd},
+	{CALLBACK_DOOR_OPEN_CLOSE,		callbackDoorOpenClose},
+	{CALLBACK_AUTODOOR_OPEN_CLOSE,	callbackAutoDoorOpenClose},
+	{CALLBACK_END,					NULL}
+};
+
+void AI::addCallback(CallbackType type, int x, int y, int delay) {
+	for(int i= kMaxCallbacks; i >= 0; i--)
+		if (_callbacks[i].type == NO_FUNCTION) {
+			_callbacks[i].type = type;
+			_callbacks[i].x = x;
+			_callbacks[i].y = y;
+			_callbacks[i].delay = delay;
+			return;
+		}
+}
+
+void AI::processCallbackList() {
+	for (int i = 0; i < kMaxCallbacks; i++)
+		if (_callbacks[i].type != NO_FUNCTION) {
+			allCallbacks[_callbacks[i].type].function(_callbacks[i].x, _callbacks[i].y);
+			_callbacks[i].type = NO_FUNCTION;
+			_callbacks[i].x = _callbacks[i].y = 0;
+			return;
+		}
+}
+
 void AI::addToLuaList(int x, int y, int value1, int value2, char *luaFuncInit, char *luaFuncAction, char *luaFuncUse) {
 	for (int i = 0; i < kMaxLuaEnts; i++) {
 		if (!_luaList[i].luaFuncInit[0] && !_luaList[i].luaFuncAction[0] && !_luaList[i].luaFuncUse[0]) {
diff --git a/engines/hdb/ai.h b/engines/hdb/ai.h
index 6f5653a..690e868 100644
--- a/engines/hdb/ai.h
+++ b/engines/hdb/ai.h
@@ -752,6 +752,8 @@ public:
 	bool activateAction(AIEntity *e, int x, int y, int targetX, int targetY);
 	bool checkAutoList(AIEntity *e, int x, int y);
 	bool autoActive(int x, int y);
+	void addCallback(CallbackType type, int x, int y, int delay);
+	void processCallbackList();
 	void addToLuaList(int x, int y, int value1, int value2, char *luaFuncInit, char *luaFuncAction, char *luaFuncUse);
 	bool checkLuaList(AIEntity *e, int x, int y);
 	bool luaExistAtXY(int x, int y);


Commit: 235040fb8a331d0cd5bccd6877966ffb1f3ed928
    https://github.com/scummvm/scummvm/commit/235040fb8a331d0cd5bccd6877966ffb1f3ed928
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:02+02:00

Commit Message:
HDB: Modify constants for simpler access

Changed paths:
    engines/hdb/ai.h
    engines/hdb/draw-manager.h
    engines/hdb/hdb.h


diff --git a/engines/hdb/ai.h b/engines/hdb/ai.h
index 690e868..8241d0d 100644
--- a/engines/hdb/ai.h
+++ b/engines/hdb/ai.h
@@ -40,6 +40,7 @@ enum {
 	kMaxAutoActions = 30,
 	kMaxLuaEnts = 50,
 	kMaxCallbacks = 20,
+	kDelay5Seconds = 5 * kGameFPS,
 	kPlayerMoveSpeed = 4,
 	kEnemyMoveSpeed = 2,
 	kPushMoveSpeed = (kPlayerMoveSpeed >> 1),
diff --git a/engines/hdb/draw-manager.h b/engines/hdb/draw-manager.h
index 05d6245..d1f1e81 100644
--- a/engines/hdb/draw-manager.h
+++ b/engines/hdb/draw-manager.h
@@ -35,7 +35,12 @@ enum {
 	kMaxSkies = 10,
 	kNum3DStars = 300,
 	kFontSpace = 5,
-	kFontIncrement = 1
+	kFontIncrement = 1,
+	kGameFPS = 60,
+	kAnimFrameDelay = kGameFPS / 30,
+	kAnimSlowFrames = kAnimFrameDelay * 10,
+	kAnimMediumFrames = kAnimFrameDelay * 6,
+	kAnimFastFrames = kAnimFrameDelay * 2
 };
 
 class Tile;
diff --git a/engines/hdb/hdb.h b/engines/hdb/hdb.h
index 11ab000..8fb2c7a 100644
--- a/engines/hdb/hdb.h
+++ b/engines/hdb/hdb.h
@@ -113,11 +113,6 @@ enum Flag {
 enum {
 	kScreenWidth = 640,
 	kScreenHeight = 480,
-	kGameFPS = 60,
-	kAnimFrameDelay = kGameFPS / 30,
-	kAnimSlowFrames = kAnimFrameDelay * 10,
-	kAnimMediumFrames = kAnimFrameDelay * 6,
-	kAnimFastFrames = kAnimFrameDelay * 2
 };
 
 class HDBGame : public Engine {


Commit: 0daae853408a8a1e7a35bef52dee88a79fac4541
    https://github.com/scummvm/scummvm/commit/0daae853408a8a1e7a35bef52dee88a79fac4541
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:02+02:00

Commit Message:
HDB: Add and call useAutoDoorOpenClose()

Changed paths:
    engines/hdb/ai-player.cpp
    engines/hdb/ai-use.cpp
    engines/hdb/hdb.cpp


diff --git a/engines/hdb/ai-player.cpp b/engines/hdb/ai-player.cpp
index e399749..7cfcb24 100644
--- a/engines/hdb/ai-player.cpp
+++ b/engines/hdb/ai-player.cpp
@@ -952,10 +952,6 @@ void callbackDoorOpenClose(int x, int y) {
 	warning("STUB: AI: callbackDoorOpenClose required");
 }
 
-void callbackAutoDoorOpenClose(int x, int y) {
-	warning("STUB: AI: callbackAutoDoorOpenClose required");
-}
-
 // Utility Functions
 void aiAnimateStanddown(AIEntity *e, int speed) {
 	warning("STUB: AI: aiAnimateStanddown required");
diff --git a/engines/hdb/ai-use.cpp b/engines/hdb/ai-use.cpp
index 4abb102..83a294d 100644
--- a/engines/hdb/ai-use.cpp
+++ b/engines/hdb/ai-use.cpp
@@ -72,8 +72,32 @@ bool AI::useDoorOpenClose(AIEntity *e, int x, int y) {
 	warning("STUB: Define useDoorOpenClose");
 	return false;
 }
+
+void callbackAutoDoorOpenClose(int x, int y) {
+	int tileIndex = g_hdb->_map->getMapBGTileIndex(x, y);
+
+	// Is the door going to close on something?
+	if (g_hdb->_ai->findEntity(x, y)) {
+		g_hdb->_ai->addCallback(CALLBACK_AUTODOOR_OPEN_CLOSE, x, y, kDelay5Seconds);
+		return;
+	}
+
+	g_hdb->_ai->addAnimateTarget(x, y, tileIndex, tileIndex + 3, ANIM_SLOW, true, true, NULL);
+	if (g_hdb->_map->onScreen(x, y))
+		warning("STUB: callbackAutoDoorOpenClose: Play SND_DOOR_OPEN_CLOSE");
+	return;
+}
+
 bool AI::useAutoDoorOpenClose(AIEntity *e, int x, int y) {
-	warning("STUB: Define useAutoDoorOpenClose");
+	int tileIndex = g_hdb->_map->getMapBGTileIndex(x, y);
+
+	if (autoActive(x, y))
+		return false;
+
+	addAnimateTarget(x, y, tileIndex, tileIndex - 3, ANIM_SLOW, false, true, NULL);
+	addCallback(CALLBACK_AUTODOOR_OPEN_CLOSE, x, y, kDelay5Seconds);
+	if (g_hdb->_map->onScreen(x, y))
+		warning("useAutoDoorOpenClose: Play SND_DOOR_OPEN_CLOSE");
 	return false;
 }
 
diff --git a/engines/hdb/hdb.cpp b/engines/hdb/hdb.cpp
index 238033c..78774e1 100644
--- a/engines/hdb/hdb.cpp
+++ b/engines/hdb/hdb.cpp
@@ -300,7 +300,10 @@ Common::Error HDBGame::run() {
 
 		_drawMan->drawSky();
 
+		warning("STUB: HDBGame::run: Add check for pause flag");
+
 		_ai->moveEnts();
+		_ai->processCallbackList();
 
 		_map->draw();
 		_ai->processCines();


Commit: dfa9a6bb3b1a8518f79f4d6d445b9d96959aeb79
    https://github.com/scummvm/scummvm/commit/dfa9a6bb3b1a8518f79f4d6d445b9d96959aeb79
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:02+02:00

Commit Message:
HDB: Add FIXME for out-of-bounds access

Changed paths:
    engines/hdb/ai-lists.cpp
    engines/hdb/hdb.cpp


diff --git a/engines/hdb/ai-lists.cpp b/engines/hdb/ai-lists.cpp
index a859886..a8c69f1 100644
--- a/engines/hdb/ai-lists.cpp
+++ b/engines/hdb/ai-lists.cpp
@@ -90,12 +90,13 @@ void AI::animateTargets() {
 	int layer;
 
 	g_hdb->_map->getMapXY(&mx, &my);
+	debug("animateTargets: Size of _animTargets: %d", _animTargets->size());
 
 	for (Common::Array<AnimTarget *>::iterator it = _animTargets->begin(); it != _animTargets->end(); it++) {
-
 		at = *it;
 		// Draw Non-Map stuff every frame
 		if (!at->inMap)
+			// FIXME: Out of bounds reference to gfxList
 			at->gfxList[at->start]->drawMasked(at->x - mx, at->y - my);
 
 		// Frame Timer
diff --git a/engines/hdb/hdb.cpp b/engines/hdb/hdb.cpp
index 78774e1..7fb4551 100644
--- a/engines/hdb/hdb.cpp
+++ b/engines/hdb/hdb.cpp
@@ -300,7 +300,7 @@ Common::Error HDBGame::run() {
 
 		_drawMan->drawSky();
 
-		warning("STUB: HDBGame::run: Add check for pause flag");
+		debug(9, "STUB: HDBGame::run: Add check for pause flag");
 
 		_ai->moveEnts();
 		_ai->processCallbackList();


Commit: 091437533e34dae70247106a870f4dd7934221c5
    https://github.com/scummvm/scummvm/commit/091437533e34dae70247106a870f4dd7934221c5
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:02+02:00

Commit Message:
HDB: Add debug output

Changed paths:
    engines/hdb/ai-lists.cpp


diff --git a/engines/hdb/ai-lists.cpp b/engines/hdb/ai-lists.cpp
index a8c69f1..df779d5 100644
--- a/engines/hdb/ai-lists.cpp
+++ b/engines/hdb/ai-lists.cpp
@@ -91,10 +91,14 @@ void AI::animateTargets() {
 
 	g_hdb->_map->getMapXY(&mx, &my);
 	debug("animateTargets: Size of _animTargets: %d", _animTargets->size());
+	debug("_animTargets:");
 
 	for (Common::Array<AnimTarget *>::iterator it = _animTargets->begin(); it != _animTargets->end(); it++) {
 		at = *it;
+		debug("it - _animTargets->begin(): %d", it - _animTargets->begin());
+		debug("at: at->x: %d, at->y: %d, at->start: %d, at->end: %d, at->vel: %d", at->x, at->y, at->start, at->end, at->vel);
 		// Draw Non-Map stuff every frame
+
 		if (!at->inMap)
 			// FIXME: Out of bounds reference to gfxList
 			at->gfxList[at->start]->drawMasked(at->x - mx, at->y - my);


Commit: 576a2605da1b68f2285851c78dfc38126aa06f76
    https://github.com/scummvm/scummvm/commit/576a2605da1b68f2285851c78dfc38126aa06f76
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:02+02:00

Commit Message:
HDB: Track and assign new pointer after erasing

Changed paths:
    engines/hdb/ai-lists.cpp


diff --git a/engines/hdb/ai-lists.cpp b/engines/hdb/ai-lists.cpp
index df779d5..a652a8c 100644
--- a/engines/hdb/ai-lists.cpp
+++ b/engines/hdb/ai-lists.cpp
@@ -133,7 +133,9 @@ void AI::animateTargets() {
 				if (at->killAuto)
 					autoDeactivate(at->x, at->y);
 
+				AnimTarget **jt = it;
 				_animTargets->erase(it);
+				it = jt-1;
 				continue;
 			}
 		}


Commit: 1acba7e5bb3e48d13135b437d12d8ba6e4aca168
    https://github.com/scummvm/scummvm/commit/1acba7e5bb3e48d13135b437d12d8ba6e4aca168
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:02+02:00

Commit Message:
HDB: Update debug output

Changed paths:
    engines/hdb/ai-lists.cpp


diff --git a/engines/hdb/ai-lists.cpp b/engines/hdb/ai-lists.cpp
index a652a8c..0e4f01e 100644
--- a/engines/hdb/ai-lists.cpp
+++ b/engines/hdb/ai-lists.cpp
@@ -90,13 +90,13 @@ void AI::animateTargets() {
 	int layer;
 
 	g_hdb->_map->getMapXY(&mx, &my);
-	debug("animateTargets: Size of _animTargets: %d", _animTargets->size());
-	debug("_animTargets:");
+	debug(9, "animateTargets: Size of _animTargets: %d", _animTargets->size());
+	debug(9, "_animTargets:");
 
 	for (Common::Array<AnimTarget *>::iterator it = _animTargets->begin(); it != _animTargets->end(); it++) {
 		at = *it;
-		debug("it - _animTargets->begin(): %d", it - _animTargets->begin());
-		debug("at: at->x: %d, at->y: %d, at->start: %d, at->end: %d, at->vel: %d", at->x, at->y, at->start, at->end, at->vel);
+		debug(9, "it - _animTargets->begin(): %d", it - _animTargets->begin());
+		debug(9, "at: at->x: %d, at->y: %d, at->start: %d, at->end: %d, at->vel: %d", at->x, at->y, at->start, at->end, at->vel);
 		// Draw Non-Map stuff every frame
 
 		if (!at->inMap)


Commit: f8b436cab79b7a365dff441d040ed6628ca4024a
    https://github.com/scummvm/scummvm/commit/f8b436cab79b7a365dff441d040ed6628ca4024a
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:02+02:00

Commit Message:
HDB: Fix gem counter position

Changed paths:
    engines/hdb/window.cpp
    engines/hdb/window.h


diff --git a/engines/hdb/window.cpp b/engines/hdb/window.cpp
index 5130769..09d8866 100644
--- a/engines/hdb/window.cpp
+++ b/engines/hdb/window.cpp
@@ -74,6 +74,11 @@ bool Window::init() {
 
 	_infobarDimmed = 0;
 
+	_invWinInfo.width = kInvItemSpaceX * 3;
+	_invWinInfo.height = kInvItemSpaceY * 4;
+	_invWinInfo.x = kScreenWidth - _gfxInfobar->_width + 16;
+	_invWinInfo.y = 40;
+
 	restartSystem();
 
 	return true;
diff --git a/engines/hdb/window.h b/engines/hdb/window.h
index 32a41ae..3059ab0 100644
--- a/engines/hdb/window.h
+++ b/engines/hdb/window.h
@@ -57,6 +57,8 @@ struct InvWinInfo {
 	int width, height;
 	int selection;
 	bool active;
+
+	InvWinInfo() : x(0), y(0), width(0), height(0), selection(0), active(false) {}
 };
 
 class Window {


Commit: a3e12b07089f52d91b0a2c61c40440acb6bed9a2
    https://github.com/scummvm/scummvm/commit/a3e12b07089f52d91b0a2c61c40440acb6bed9a2
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:02+02:00

Commit Message:
HDB: Fix compiler-error thrown by constructor

Changed paths:
    engines/hdb/ai.h


diff --git a/engines/hdb/ai.h b/engines/hdb/ai.h
index 8241d0d..654eec9 100644
--- a/engines/hdb/ai.h
+++ b/engines/hdb/ai.h
@@ -654,9 +654,6 @@ struct Trigger {
 struct CallbackDef {
 	CallbackType type;
 	void(*function)(int x, int y);
-
-	CallbackDef() : type(NO_FUNCTION), function(NULL) {}
-	CallbackDef(CallbackType type, void(*function)(int, int)) : type(type), function(function) {}
 };
 
 struct Callback {


Commit: 4461c1b7efa24384c51ad62fe796a06decac041c
    https://github.com/scummvm/scummvm/commit/4461c1b7efa24384c51ad62fe796a06decac041c
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:03+02:00

Commit Message:
HDB: Fix warnings

Changed paths:
    engines/hdb/ai-bots.cpp
    engines/hdb/ai-funcs.cpp
    engines/hdb/ai-lists.cpp
    engines/hdb/hdb.h


diff --git a/engines/hdb/ai-bots.cpp b/engines/hdb/ai-bots.cpp
index 7018c19..2d451b6 100644
--- a/engines/hdb/ai-bots.cpp
+++ b/engines/hdb/ai-bots.cpp
@@ -755,6 +755,7 @@ void aiRailRiderOnAction(AIEntity *e) {
 		case DIR_DOWN:	e->draw = e->movedownGfx[0]; break;
 		case DIR_LEFT:	e->draw = e->moveleftGfx[0]; break;
 		case DIR_RIGHT: e->draw = e->moverightGfx[0]; break;
+		default: break; // DIR_NONE
 		}
 		g_hdb->_map->centerMapXY(e->x + 16, e->y + 16);
 
diff --git a/engines/hdb/ai-funcs.cpp b/engines/hdb/ai-funcs.cpp
index c00c925..81419fa 100644
--- a/engines/hdb/ai-funcs.cpp
+++ b/engines/hdb/ai-funcs.cpp
@@ -947,7 +947,7 @@ void AI::animateEntity(AIEntity *e) {
 
 			uint16 buttons = g_hdb->_input->getButtons();
 
-			if (e == _player && (buttons & (kButtonUp || kButtonDown || kButtonLeft || kButtonRight))) {
+			if (e == _player && (buttons & (kButtonUp | kButtonDown | kButtonLeft | kButtonRight))) {
 				int xva[] = {9, 0, 0, -1, 1}, yva[] = {9, -1, 1, 0, 0};
 				int nx, ny, result2;
 
diff --git a/engines/hdb/ai-lists.cpp b/engines/hdb/ai-lists.cpp
index 0e4f01e..bd3fcbf 100644
--- a/engines/hdb/ai-lists.cpp
+++ b/engines/hdb/ai-lists.cpp
@@ -95,7 +95,7 @@ void AI::animateTargets() {
 
 	for (Common::Array<AnimTarget *>::iterator it = _animTargets->begin(); it != _animTargets->end(); it++) {
 		at = *it;
-		debug(9, "it - _animTargets->begin(): %d", it - _animTargets->begin());
+		debug(9, "it - _animTargets->begin(): %ld", it - _animTargets->begin());
 		debug(9, "at: at->x: %d, at->y: %d, at->start: %d, at->end: %d, at->vel: %d", at->x, at->y, at->start, at->end, at->vel);
 		// Draw Non-Map stuff every frame
 
diff --git a/engines/hdb/hdb.h b/engines/hdb/hdb.h
index 8fb2c7a..0e2ec3d 100644
--- a/engines/hdb/hdb.h
+++ b/engines/hdb/hdb.h
@@ -112,7 +112,7 @@ enum Flag {
 
 enum {
 	kScreenWidth = 640,
-	kScreenHeight = 480,
+	kScreenHeight = 480
 };
 
 class HDBGame : public Engine {


Commit: e18effcce4ba7a998b0b83491c2b7363ba55ac64
    https://github.com/scummvm/scummvm/commit/e18effcce4ba7a998b0b83491c2b7363ba55ac64
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:03+02:00

Commit Message:
HDB: Rewrite _animTargets as a struct array

Changed paths:
    engines/hdb/ai-init.cpp
    engines/hdb/ai-lists.cpp
    engines/hdb/ai.h


diff --git a/engines/hdb/ai-init.cpp b/engines/hdb/ai-init.cpp
index 5bb8c89..56ecad2 100644
--- a/engines/hdb/ai-init.cpp
+++ b/engines/hdb/ai-init.cpp
@@ -669,7 +669,6 @@ AIEntTypeInfo aiEntList[] = {
 AI::AI() {
 	_ents = new Common::Array<AIEntity *>;
 	_floats = new Common::Array<AIEntity *>;
-	_animTargets = new Common::Array<AnimTarget *>;
 	_arrowPaths = new Common::Array<ArrowPath *>;
 	_triggerList = new Common::Array<Trigger *>;
 	_hereList = new Common::Array<HereT *>;
@@ -684,7 +683,6 @@ AI::AI() {
 AI::~AI() {
 	delete _ents;
 	delete _floats;
-	delete _animTargets;
 	delete _arrowPaths;
 	delete _triggerList;
 	delete _hereList;
@@ -854,7 +852,7 @@ void AI::restartSystem() {
 	_numLuaList = 0;
 
 	// Clear Anim Targets List
-	_animTargets->clear();
+	_animTargets.clear();
 
 	// Clear ArrowPath List
 	_arrowPaths->clear();
diff --git a/engines/hdb/ai-lists.cpp b/engines/hdb/ai-lists.cpp
index bd3fcbf..95bfe04 100644
--- a/engines/hdb/ai-lists.cpp
+++ b/engines/hdb/ai-lists.cpp
@@ -77,7 +77,7 @@ void AI::addAnimateTarget(int x, int y, int start, int end, AnimSpeed speed, boo
 	}
 
 	// Insert in the beginning
-	_animTargets->insert_at(0, at);
+	_animTargets.insert_at(0, at);
 }
 
 /*
@@ -90,15 +90,15 @@ void AI::animateTargets() {
 	int layer;
 
 	g_hdb->_map->getMapXY(&mx, &my);
-	debug(9, "animateTargets: Size of _animTargets: %d", _animTargets->size());
+	debug(9, "animateTargets: Size of _animTargets: %d", _animTargets.size());
 	debug(9, "_animTargets:");
 
-	for (Common::Array<AnimTarget *>::iterator it = _animTargets->begin(); it != _animTargets->end(); it++) {
-		at = *it;
-		debug(9, "it - _animTargets->begin(): %ld", it - _animTargets->begin());
+	for (uint i = 0; i < _animTargets.size(); i++) {
+		at = _animTargets[i];
+		debug(9, "i: %d", i);
 		debug(9, "at: at->x: %d, at->y: %d, at->start: %d, at->end: %d, at->vel: %d", at->x, at->y, at->start, at->end, at->vel);
-		// Draw Non-Map stuff every frame
 
+		// Draw Non-map stuff every frame
 		if (!at->inMap)
 			// FIXME: Out of bounds reference to gfxList
 			at->gfxList[at->start]->drawMasked(at->x - mx, at->y - my);
@@ -133,9 +133,8 @@ void AI::animateTargets() {
 				if (at->killAuto)
 					autoDeactivate(at->x, at->y);
 
-				AnimTarget **jt = it;
-				_animTargets->erase(it);
-				it = jt-1;
+				_animTargets.remove_at(i);
+				i--;
 				continue;
 			}
 		}
diff --git a/engines/hdb/ai.h b/engines/hdb/ai.h
index 654eec9..ab0abe6 100644
--- a/engines/hdb/ai.h
+++ b/engines/hdb/ai.h
@@ -1110,7 +1110,7 @@ private:
 
 	Common::Array<AIEntity *> *_ents;
 	Common::Array<AIEntity *> *_floats;
-	Common::Array<AnimTarget *> *_animTargets;
+	Common::Array<AnimTarget *> _animTargets;
 	AIEntity *_player;
 
 	// Cinematics Variables


Commit: 3c44d05daaf22886c932aa053f915316e7d6f9dd
    https://github.com/scummvm/scummvm/commit/3c44d05daaf22886c932aa053f915316e7d6f9dd
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:03+02:00

Commit Message:
HDB: Fix initialization error

Changed paths:
    engines/hdb/ai-lists.cpp


diff --git a/engines/hdb/ai-lists.cpp b/engines/hdb/ai-lists.cpp
index 95bfe04..ab445fd 100644
--- a/engines/hdb/ai-lists.cpp
+++ b/engines/hdb/ai-lists.cpp
@@ -449,7 +449,7 @@ CallbackDef allCallbacks[] = {
 };
 
 void AI::addCallback(CallbackType type, int x, int y, int delay) {
-	for(int i= kMaxCallbacks; i >= 0; i--)
+	for (int i = kMaxCallbacks - 1; i >= 0; i--)
 		if (_callbacks[i].type == NO_FUNCTION) {
 			_callbacks[i].type = type;
 			_callbacks[i].x = x;


Commit: 55c78f1f53a3e5517dfa80c4aadd95e05e7ba751
    https://github.com/scummvm/scummvm/commit/55c78f1f53a3e5517dfa80c4aadd95e05e7ba751
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:03+02:00

Commit Message:
HDB: Fix formatting

Changed paths:
    engines/hdb/ai-lists.cpp
    engines/hdb/map-loader.cpp


diff --git a/engines/hdb/ai-lists.cpp b/engines/hdb/ai-lists.cpp
index ab445fd..d76fa9e 100644
--- a/engines/hdb/ai-lists.cpp
+++ b/engines/hdb/ai-lists.cpp
@@ -441,11 +441,11 @@ bool AI::autoActive(int x, int y) {
 }
 
 CallbackDef allCallbacks[] = {
-	{NO_FUNCTION,	NULL},
-	{AI_BARREL_EXPLOSION_END,		aiBarrelExplosionEnd},
-	{CALLBACK_DOOR_OPEN_CLOSE,		callbackDoorOpenClose},
-	{CALLBACK_AUTODOOR_OPEN_CLOSE,	callbackAutoDoorOpenClose},
-	{CALLBACK_END,					NULL}
+	{NO_FUNCTION, NULL},
+	{AI_BARREL_EXPLOSION_END, aiBarrelExplosionEnd},
+	{CALLBACK_DOOR_OPEN_CLOSE, callbackDoorOpenClose},
+	{CALLBACK_AUTODOOR_OPEN_CLOSE, callbackAutoDoorOpenClose},
+	{CALLBACK_END, NULL}
 };
 
 void AI::addCallback(CallbackType type, int x, int y, int delay) {
@@ -499,7 +499,7 @@ void AI::addToLuaList(int x, int y, int value1, int value2, char *luaFuncInit, c
 }
 
 bool AI::checkLuaList(AIEntity *e, int x, int y) {
-	for (int i = 0;i < _numLuaList; i++) {
+	for (int i = 0; i < _numLuaList; i++) {
 		if (_luaList[i].x == x && _luaList[i].y == y && _luaList[i].luaFuncUse[0]) {
 			if (e == _player) {
 				lookAtXY(x, y);
@@ -516,7 +516,7 @@ bool AI::checkLuaList(AIEntity *e, int x, int y) {
 }
 
 bool AI::luaExistAtXY(int x, int y) {
-	for (int i = 0;i < _numLuaList; i++) {
+	for (int i = 0; i < _numLuaList; i++) {
 		if (_luaList[i].x == x && _luaList[i].y == y && _luaList[i].luaFuncUse[0]) {
 			return true;
 		}
@@ -560,7 +560,7 @@ void AI::addToTeleportList(int teleIndex, int x, int y, int dir, int level, int
 }
 
 bool AI::findTeleporterDest(int tileX, int tileY, SingleTele *info) {
-	for (int i = 0;i < _numTeleporters; i++) {
+	for (int i = 0; i < _numTeleporters; i++) {
 		if ((_teleporters[i].x1 == tileX) && (_teleporters[i].x1 == tileY)) {
 			info->anim = _teleporters[i].anim2;
 			info->x = _teleporters[i].x2;
diff --git a/engines/hdb/map-loader.cpp b/engines/hdb/map-loader.cpp
index 49a7c89..c861936 100644
--- a/engines/hdb/map-loader.cpp
+++ b/engines/hdb/map-loader.cpp
@@ -808,7 +808,7 @@ void Map::removeBGTileAnimation(int x, int y) {
 	uint32 flags = tile->_flags;
 
 	if (flags & kFlagAnimFast) {
-		for(Common::Array<uint32>::iterator it = _listBGAnimFast.begin(); it!=_listBGAnimFast.end(); it++)
+		for (Common::Array<uint32>::iterator it = _listBGAnimFast.begin(); it!=_listBGAnimFast.end(); it++)
 			if ((uint)i == (*it)) {
 				_listBGAnimFast.erase(it);
 				break;
@@ -837,7 +837,7 @@ void Map::removeFGTileAnimation(int x, int y) {
 	uint32 flags = tile->_flags;
 
 	if (flags & kFlagAnimFast) {
-		for(Common::Array<uint32>::iterator it = _listFGAnimFast.begin(); it!=_listFGAnimFast.end(); it++)
+		for (Common::Array<uint32>::iterator it = _listFGAnimFast.begin(); it!=_listFGAnimFast.end(); it++)
 			if ((uint)i == (*it)) {
 				_listFGAnimFast.erase(it);
 				break;


Commit: 9182fef47dd0ec2a12bbe125bb1b682d0aea3968
    https://github.com/scummvm/scummvm/commit/9182fef47dd0ec2a12bbe125bb1b682d0aea3968
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:03+02:00

Commit Message:
HDB: Add stunEnemy()

Changed paths:
    engines/hdb/ai-funcs.cpp
    engines/hdb/ai.h


diff --git a/engines/hdb/ai-funcs.cpp b/engines/hdb/ai-funcs.cpp
index 81419fa..1180150 100644
--- a/engines/hdb/ai-funcs.cpp
+++ b/engines/hdb/ai-funcs.cpp
@@ -705,6 +705,57 @@ void AI::killPlayer(Death method) {
 	warning("STUB: killPlayer: Stop Music");
 }
 
+void AI::stunEnemy(AIEntity *e, int time) {
+	int ns = 0;
+
+	if (e->stunnedWait)
+		ns = 1;
+
+	e->stunnedWait = g_hdb->getTimeSlice() + 1000 * time;
+
+	// Already stunned? If not, play sound
+	if (!ns)
+		switch (e->type) {
+		case AI_BUZZFLY:
+			warning("STUB: stunEnemy: Play sound");
+			break;
+		case AI_PUSHBOT:
+			warning("STUB: stunEnemy: Play sound");
+			break;
+		case AI_MEERKAT:
+			warning("STUB: stunEnemy: Play sound");
+			break;
+		case AI_FATFROG:
+			warning("STUB: stunEnemy: Play sound");
+			break;
+		case AI_OMNIBOT:
+		case AI_SHOCKBOT:
+		case AI_LISTENBOT:
+			warning("STUB: stunEnemy: Play sound");
+			break;
+		case AI_GOODFAIRY:
+			warning("STUB: stunEnemy: Play sound");
+			break;
+		case AI_BADFAIRY:
+			warning("STUB: stunEnemy: Play sound");
+			break;
+		case AI_ICEPUFF:
+			warning("STUB: stunEnemy: Play sound");
+			break;
+		case AI_RIGHTBOT:
+			warning("STUB: stunEnemy: Play sound");
+			break;
+		case AI_BOOMBARREL:
+			warning("STUB: stunEnemy: Play sound");
+			break;
+		case AI_CHICKEN:	// Fall through
+			warning("STUB: stunEnemy: Play sound");
+		default:
+			warning("STUB: stunEnemy: Play sound");
+			break;
+		}
+}
+
 /*
 	Note from original:
 	Moves the entity along toward its goal, sets current frame to draw
diff --git a/engines/hdb/ai.h b/engines/hdb/ai.h
index ab0abe6..a2f59e9 100644
--- a/engines/hdb/ai.h
+++ b/engines/hdb/ai.h
@@ -718,6 +718,7 @@ public:
 	void setEntityGoal(AIEntity *e, int x, int y);
 	void initAllEnts();
 	void killPlayer(Death method);
+	void stunEnemy(AIEntity *e, int time);
 
 	void animateEntity(AIEntity *e);
 	void animEntFrames(AIEntity *e);


Commit: 8057837ba7de62a28444b8102a5df0c10bd00a8b
    https://github.com/scummvm/scummvm/commit/8057837ba7de62a28444b8102a5df0c10bd00a8b
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:03+02:00

Commit Message:
HDB: Add cycleFrames()

Changed paths:
    engines/hdb/ai.h


diff --git a/engines/hdb/ai.h b/engines/hdb/ai.h
index a2f59e9..d8a831c 100644
--- a/engines/hdb/ai.h
+++ b/engines/hdb/ai.h
@@ -694,6 +694,16 @@ struct CineBlit {
 
 #define onEvenTile(x, y)		( !(x & 31) && !(y & 31) )
 #define hitPlayer(x, y)			( e->onScreen && g_hdb->_ai->checkPlayerCollision( x, y, 4 ) && !g_hdb->_ai->playerDead() )
+#define cycleFrames( e, max ) \
+	{ \
+		if ( e->animDelay-- < 1 ) \
+		{ \
+			e->animDelay = e->animCycle; \
+			e->animFrame++; \
+			if ( e->animFrame >= max ) \
+				e->animFrame = 0; \
+		} \
+	}
 #define spawnBlocking(x, y, level)	g_hdb->_ai->spawn(AI_NONE, DIR_NONE, x, y, NULL, NULL, NULL, DIR_NONE, level, 0, 0, 0)
 
 class AI {


Commit: 85a16cba27d20ba51dd0bb52e61d40b608739f2f
    https://github.com/scummvm/scummvm/commit/85a16cba27d20ba51dd0bb52e61d40b608739f2f
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:03+02:00

Commit Message:
HDB: Unstub aiPlayerAction()

Changed paths:
    engines/hdb/ai-player.cpp


diff --git a/engines/hdb/ai-player.cpp b/engines/hdb/ai-player.cpp
index 7cfcb24..097a5f6 100644
--- a/engines/hdb/ai-player.cpp
+++ b/engines/hdb/ai-player.cpp
@@ -128,7 +128,312 @@ void aiPlayerInit2(AIEntity *e) {
 }
 
 void aiPlayerAction(AIEntity *e) {
-	debug(9, "STUB: AI: aiPlayerAction required");
+	AIState stand[5] = {STATE_NONE, STATE_STANDUP, STATE_STANDDOWN, STATE_STANDLEFT, STATE_STANDRIGHT};
+	int xvAhead[5] = {9, 0, 0, -1, 1}, yvAhead[5] = {9, -1, 1, 0, 0};
+	AIEntity *hit;
+
+	// Draw the STUN lightning if it exists
+	if (e->sequence) {
+		e->aiDraw = aiPlayerDraw;
+		warning("STUB: Play SND_STUNNER_FIRE");
+		hit = g_hdb->_ai->findEntity(e->tileX + xvAhead[e->dir], e->tileY + yvAhead[e->dir]);
+		if (hit)
+			switch (hit->type) {
+			case AI_MEERKAT:
+				if (hit->sequence > 2)
+					g_hdb->_ai->stunEnemy(hit, 8);
+				break;
+			case AI_ICEPUFF:
+				if (hit->state == STATE_ICEP_APPEAR || hit->state == STATE_ICEP_THROWDOWN || hit->state == STATE_ICEP_THROWLEFT || hit->state == STATE_ICEP_THROWRIGHT) {
+					g_hdb->_ai->addAnimateTarget(hit->x, hit->y, 0, 3, ANIM_NORMAL, false, false, GROUP_STEAM_PUFF_SIT);
+					g_hdb->_ai->stunEnemy(hit, 8);
+				}
+				break;
+			case AI_BADFAIRY:
+			case AI_GOODFAIRY:
+			case AI_CHICKEN:
+			case AI_OMNIBOT:
+			case AI_TURNBOT:
+			case AI_PUSHBOT:
+			case AI_DEADEYE:
+			case AI_FATFROG:
+			case AI_BUZZFLY:
+			case AI_MAINTBOT:
+			case AI_RIGHTBOT:
+			case AI_GATEPUDDLE:
+				g_hdb->_ai->stunEnemy(hit, 8);
+				break;
+			default:
+				warning("aiPlayerAction: Unintended State");
+				break;
+			}
+
+		hit = g_hdb->_ai->findEntity(e->tileX + (xvAhead[e->dir] << 1), e->tileY + (yvAhead[e->dir] << 1));
+		if (hit)
+			switch (hit->type) {
+			case AI_MEERKAT:
+				if (hit->sequence > 2)
+					g_hdb->_ai->stunEnemy(hit, 8);
+				break;
+			case AI_ICEPUFF:
+				if (hit->state == STATE_ICEP_APPEAR || hit->state == STATE_ICEP_THROWDOWN || hit->state == STATE_ICEP_THROWLEFT || hit->state == STATE_ICEP_THROWRIGHT) {
+					g_hdb->_ai->addAnimateTarget(hit->x, hit->y, 0, 3, ANIM_NORMAL, false, false, GROUP_STEAM_PUFF_SIT);
+					g_hdb->_ai->stunEnemy(hit, 8);
+				}
+				break;
+			case AI_BADFAIRY:
+			case AI_GOODFAIRY:
+			case AI_CHICKEN:
+			case AI_OMNIBOT:
+			case AI_TURNBOT:
+			case AI_PUSHBOT:
+			case AI_DEADEYE:
+			case AI_FATFROG:
+			case AI_BUZZFLY:
+			case AI_MAINTBOT:
+			case AI_RIGHTBOT:
+			case AI_GATEPUDDLE:
+				g_hdb->_ai->stunEnemy(hit, 8);
+				break;
+			default:
+				warning("aiPlayerAction: Unintended State");
+				break;
+			}
+	}
+
+	int xOff[] = {0, 0, -8,-16};
+	int yOff[] = {-8,-24,-16,-16};
+	// If the player is supposed to animate for abit, check for it here
+	switch (e->state) {
+	case STATE_GRABUP:
+	case STATE_GRABDOWN:
+	case STATE_GRABLEFT:
+	case STATE_GRABRIGHT:
+		if (!e->animFrame--) {
+			// Done with the Grabbing Animation, switch to standing
+			switch (e->state) {
+			case STATE_GRABUP:		e->draw = e->standupGfx[0];	e->state = STATE_STANDUP; break;
+			case STATE_GRABDOWN:	e->draw = e->standdownGfx[0];	e->state = STATE_STANDDOWN; break;
+			case STATE_GRABLEFT:	e->draw = e->standleftGfx[0];	e->state = STATE_STANDLEFT; break;
+			case STATE_GRABRIGHT:	e->draw = e->standrightGfx[0];	e->state = STATE_STANDRIGHT; break;
+			default:
+				warning("aiPlayerAction: Unintended State");
+				break;
+			}
+			e->animDelay = 1;
+			e->animCycle = 1;
+		}
+		break;
+	case STATE_ATK_CLUB_UP:
+	case STATE_ATK_CLUB_DOWN:
+	case STATE_ATK_CLUB_LEFT:
+	case STATE_ATK_CLUB_RIGHT:
+		g_hdb->_ai->setPlayerInvisible(true);
+		e->aiDraw = aiPlayerDraw;
+		e->drawXOff = xOff[e->state - STATE_ATK_CLUB_UP];
+		e->drawYOff = yOff[e->state - STATE_ATK_CLUB_UP];
+		switch (e->state) {
+		case STATE_ATK_CLUB_UP:		cycleFrames(e, g_hdb->_ai->_clubUpFrames); break;
+		case STATE_ATK_CLUB_DOWN:	cycleFrames(e, g_hdb->_ai->_clubDownFrames); break;
+		case STATE_ATK_CLUB_LEFT:	cycleFrames(e, g_hdb->_ai->_clubLeftFrames); break;
+		case STATE_ATK_CLUB_RIGHT:	cycleFrames(e, g_hdb->_ai->_clubRightFrames); break;
+		default:
+			warning("aiPlayerAction: Unintended State");
+			break;
+		}
+		// Whack!
+		if ((e->animFrame >= 1) && (e->animDelay == e->animCycle)) {
+			switch (e->dir) {
+			case DIR_UP:	hit = g_hdb->_ai->playerCollision(32, 0, 16, 16); break;
+			case DIR_DOWN:	hit = g_hdb->_ai->playerCollision(0, 32, 16, 16); break;
+			case DIR_LEFT:	hit = g_hdb->_ai->playerCollision(16, 16, 32, 0); break;
+			case DIR_RIGHT:	hit = g_hdb->_ai->playerCollision(16, 16, 0, 32); break;
+			default:
+				warning("aiPlayerAction: DIR_NONE found");
+				break;
+			}
+
+			if (hit && hit->level == e->level && !hit->stunnedWait) {
+				switch (hit->type) {
+				case AI_MEERKAT:
+					if (hit->sequence > 2)		// out of the ground?
+						g_hdb->_ai->stunEnemy(hit, 2);
+					break;
+				case AI_ICEPUFF:
+					if (hit->state == STATE_ICEP_APPEAR ||
+						hit->state == STATE_ICEP_THROWDOWN ||
+						hit->state == STATE_ICEP_THROWLEFT ||
+						hit->state == STATE_ICEP_THROWRIGHT)
+						g_hdb->_ai->stunEnemy(hit, 2);
+					break;
+				case AI_CHICKEN:
+					g_hdb->_ai->addAnimateTarget(hit->x, hit->y, 0, 3, ANIM_NORMAL, false, false, GROUP_STEAM_PUFF_SIT);
+					g_hdb->_ai->removeEntity(hit);
+					break;
+				case AI_BADFAIRY:
+				case AI_GOODFAIRY:
+				case AI_OMNIBOT:
+				case AI_TURNBOT:
+				case AI_PUSHBOT:
+				case AI_DEADEYE:
+				case AI_FATFROG:
+				case AI_BUZZFLY:
+				case AI_MAINTBOT:
+				case AI_RIGHTBOT:
+				case AI_SHOCKBOT:
+				case AI_GATEPUDDLE:
+					g_hdb->_ai->stunEnemy(hit, 2);
+					warning("STUB: Play MetalorFlesh SND");
+					break;
+				default:
+					warning("aiPlayerAction: DIR_NONE found");
+					break;
+				}
+			}
+		}
+		if ((!e->animFrame) && (e->animDelay == e->animCycle)) {
+			e->state = stand[e->dir];
+			e->aiDraw = NULL;
+			switch (e->state) {
+			case STATE_ATK_CLUB_UP:		e->draw = e->standupGfx[0]; break;
+			case STATE_ATK_CLUB_DOWN:	e->draw = e->standdownGfx[0]; break;
+			case STATE_ATK_CLUB_LEFT:	e->draw = e->standleftGfx[0]; break;
+			case STATE_ATK_CLUB_RIGHT:	e->draw = e->standrightGfx[0]; break;
+			default:
+				warning("aiPlayerAction: Unintended State");
+				break;
+			}
+			g_hdb->_ai->setPlayerInvisible(false);
+			e->drawXOff = e->drawYOff = 0;
+		}
+		return;
+	case STATE_ATK_STUN_UP:
+		e->draw = g_hdb->_ai->_stunUpGfx[e->animFrame];
+		cycleFrames(e, g_hdb->_ai->_stunUpFrames);
+		if (!e->animFrame && e->animDelay == e->animCycle) {
+			e->state = stand[e->dir];
+			e->aiDraw = NULL;
+			e->sequence = 0;
+		}
+		return;
+	case STATE_ATK_STUN_DOWN:
+		e->draw = g_hdb->_ai->_stunDownGfx[e->animFrame];
+		cycleFrames(e, g_hdb->_ai->_stunDownFrames);
+		if (!e->animFrame && e->animDelay == e->animCycle) {
+			e->state = stand[e->dir];
+			e->aiDraw = NULL;
+			e->sequence = 0;
+		}
+		return;
+	case STATE_ATK_STUN_LEFT:
+		e->draw = g_hdb->_ai->_stunLeftGfx[e->animFrame];
+		cycleFrames(e, g_hdb->_ai->_stunLeftFrames);
+		if (!e->animFrame && e->animDelay == e->animCycle) {
+			e->state = stand[e->dir];
+			e->aiDraw = NULL;
+			e->sequence = 0;
+		}
+		return;
+	case STATE_ATK_STUN_RIGHT:
+		e->draw = g_hdb->_ai->_stunRightGfx[e->animFrame];
+		cycleFrames(e, g_hdb->_ai->_stunRightFrames);
+		if (!e->animFrame && e->animDelay == e->animCycle) {
+			e->state = stand[e->dir];
+			e->aiDraw = NULL;
+			e->sequence = 0;
+		}
+		return;
+	case STATE_ATK_SLUG_UP:
+		e->draw = g_hdb->_ai->_slugUpGfx[e->animFrame];
+		cycleFrames(e, g_hdb->_ai->_slugUpFrames);
+		if (!e->animFrame && e->animDelay == e->animCycle) {
+			e->state = stand[e->dir];
+			e->sequence = 0;
+		}
+		return;
+	case STATE_ATK_SLUG_DOWN:
+		e->draw = g_hdb->_ai->_slugDownGfx[e->animFrame];
+		cycleFrames(e, g_hdb->_ai->_slugDownFrames);
+		if (!e->animFrame && e->animDelay == e->animCycle) {
+			e->state = stand[e->dir];
+			e->sequence = 0;
+		}
+		return;
+	case STATE_ATK_SLUG_LEFT:
+		e->draw = g_hdb->_ai->_slugLeftGfx[e->animFrame];
+		cycleFrames(e, g_hdb->_ai->_slugLeftFrames);
+		if (!e->animFrame && e->animDelay == e->animCycle) {
+			e->state = stand[e->dir];
+			e->sequence = 0;
+		}
+		return;
+	case STATE_ATK_SLUG_RIGHT:
+		e->draw = g_hdb->_ai->_slugRightGfx[e->animFrame];
+		cycleFrames(e, g_hdb->_ai->_slugRightFrames);
+		if (!e->animFrame && e->animDelay == e->animCycle) {
+			e->state = stand[e->dir];
+			e->sequence = 0;
+		}
+		return;
+	default:
+		warning("aiPlayerAction: Unintended State");
+		break;
+	}
+
+	// If the touchplate wait is on, keep it timing
+	if (e->touchpWait) {
+		e->touchpWait--;
+		if (!e->touchpWait)
+			e->touchpTile = -e->touchpTile;
+	} else if (e->touchpTile < 0 && (e->touchpX != e->tileX || e->touchpY != e->tileY)) {
+		g_hdb->_ai->checkActionList(e, e->touchpX, e->touchpY, false);
+		g_hdb->_map->setMapBGTileIndex(e->touchpX, e->touchpY, -e->touchpTile);
+		e->touchpX = e->touchpY = e->touchpTile = 0;
+	}
+
+	// If the player is moving somewhere, animate him
+	int bgFlags, fgFlags;
+	if (e->goalX) {
+		if (onEvenTile(e->x, e->y)) {
+			g_hdb->_ai->playerOnIce() ? warning("STUB: Play SND_STEPS_ICE") : warning("STUB: Play SND_FOOTSTEPS");
+
+			// Did we just fall down a PLUMMET?
+			bgFlags = g_hdb->_map->getMapBGTileFlags(e->tileX, e->tileY);
+			fgFlags = g_hdb->_map->getMapFGTileFlags(e->tileX, e->tileY);
+			if ((bgFlags & kFlagPlummet) && !(fgFlags & kFlagGrating) && !g_hdb->_ai->playerDead()) {
+				g_hdb->_ai->killPlayer(DEATH_PLUMMET);
+				g_hdb->_ai->animEntFrames(e);
+				return;
+			}
+		}
+		g_hdb->_ai->animateEntity(e);
+	} else {
+		// Sometimes the fading stays black
+		if (!g_hdb->_ai->cinematicsActive() && g_hdb->_drawMan->isFadeStaying())
+			g_hdb->_drawMan->turnOffFade();
+
+		// Did we just fall down a PLUMMET?
+		bgFlags = g_hdb->_map->getMapBGTileFlags(e->tileX, e->tileY);
+		fgFlags = g_hdb->_map->getMapFGTileFlags(e->tileX, e->tileY);
+		if ((bgFlags & kFlagPlummet) && !(fgFlags & kFlagGrating) && !g_hdb->_ai->playerDead()) {
+			g_hdb->_ai->killPlayer(DEATH_PLUMMET);
+			g_hdb->_ai->animEntFrames(e);
+			return;
+		}
+
+		// Standing on a TouchPlate will activate something WHILE standing on it
+		int bgTile = g_hdb->_ai->checkForTouchplate(e->tileX, e->tileY);
+		if (bgTile && !e->touchpWait && !e->touchpTile) {
+			if (g_hdb->_ai->checkActionList(e, e->tileX, e->tileY, false)) {
+				e->touchpTile = bgTile;
+				e->touchpX = e->tileX;
+				e->touchpY = e->tileY;
+				e->touchpWait = kPlayerTouchPWait;
+				g_hdb->_ai->stopEntity(e);
+			}
+		}
+		g_hdb->_ai->animEntFrames(e);
+	}
 }
 
 void aiPlayerDraw(AIEntity *e, int mx, int my) {


Commit: f50ff7aabb551c85e1d6d80fb29e909d1d2c3eb7
    https://github.com/scummvm/scummvm/commit/f50ff7aabb551c85e1d6d80fb29e909d1d2c3eb7
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:03+02:00

Commit Message:
HDB: Modify debug output

Changed paths:
    engines/hdb/ai-player.cpp


diff --git a/engines/hdb/ai-player.cpp b/engines/hdb/ai-player.cpp
index 097a5f6..63af8f4 100644
--- a/engines/hdb/ai-player.cpp
+++ b/engines/hdb/ai-player.cpp
@@ -164,7 +164,7 @@ void aiPlayerAction(AIEntity *e) {
 				g_hdb->_ai->stunEnemy(hit, 8);
 				break;
 			default:
-				warning("aiPlayerAction: Unintended State");
+				debug(9, "STUB: stunEnemy: Play sound");
 				break;
 			}
 
@@ -196,7 +196,7 @@ void aiPlayerAction(AIEntity *e) {
 				g_hdb->_ai->stunEnemy(hit, 8);
 				break;
 			default:
-				warning("aiPlayerAction: Unintended State");
+				debug(9, "STUB: stunEnemy: Play sound");
 				break;
 			}
 	}
@@ -217,7 +217,7 @@ void aiPlayerAction(AIEntity *e) {
 			case STATE_GRABLEFT:	e->draw = e->standleftGfx[0];	e->state = STATE_STANDLEFT; break;
 			case STATE_GRABRIGHT:	e->draw = e->standrightGfx[0];	e->state = STATE_STANDRIGHT; break;
 			default:
-				warning("aiPlayerAction: Unintended State");
+				debug(9, "STUB: stunEnemy: Play sound");
 				break;
 			}
 			e->animDelay = 1;
@@ -238,7 +238,7 @@ void aiPlayerAction(AIEntity *e) {
 		case STATE_ATK_CLUB_LEFT:	cycleFrames(e, g_hdb->_ai->_clubLeftFrames); break;
 		case STATE_ATK_CLUB_RIGHT:	cycleFrames(e, g_hdb->_ai->_clubRightFrames); break;
 		default:
-			warning("aiPlayerAction: Unintended State");
+			debug(9, "STUB: stunEnemy: Play sound");
 			break;
 		}
 		// Whack!
@@ -300,7 +300,7 @@ void aiPlayerAction(AIEntity *e) {
 			case STATE_ATK_CLUB_LEFT:	e->draw = e->standleftGfx[0]; break;
 			case STATE_ATK_CLUB_RIGHT:	e->draw = e->standrightGfx[0]; break;
 			default:
-				warning("aiPlayerAction: Unintended State");
+				debug(9, "STUB: stunEnemy: Play sound");
 				break;
 			}
 			g_hdb->_ai->setPlayerInvisible(false);
@@ -376,7 +376,7 @@ void aiPlayerAction(AIEntity *e) {
 		}
 		return;
 	default:
-		warning("aiPlayerAction: Unintended State");
+		debug(9, "STUB: stunEnemy: Play sound");
 		break;
 	}
 


Commit: f74437e503e1e1ff6ad8dc1fdbe2a3c5d18d6a22
    https://github.com/scummvm/scummvm/commit/f74437e503e1e1ff6ad8dc1fdbe2a3c5d18d6a22
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:03+02:00

Commit Message:
HDB: Unstub checkTeleportList()

Changed paths:
    engines/hdb/ai-funcs.cpp


diff --git a/engines/hdb/ai-funcs.cpp b/engines/hdb/ai-funcs.cpp
index 1180150..313506f 100644
--- a/engines/hdb/ai-funcs.cpp
+++ b/engines/hdb/ai-funcs.cpp
@@ -911,7 +911,7 @@ void AI::animateEntity(AIEntity *e) {
 			g_hdb->_map->centerMapXY(e->x + 16, e->y + 16);
 
 		// Check if player walked into teleporter
-		warning("STUB: animateEntity: Check Teleporter List");
+		checkTeleportList(e, e->tileX, e->tileY);
 
 		// Check for bad tiles (DEATH)
 		int cx = (e->x + 16) / kTileWidth;


Commit: 763cc24c4c896880899994beb9f5d7f1392ccdce
    https://github.com/scummvm/scummvm/commit/763cc24c4c896880899994beb9f5d7f1392ccdce
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:03+02:00

Commit Message:
HDB: Fix warnings

Changed paths:
    engines/hdb/ai-player.cpp


diff --git a/engines/hdb/ai-player.cpp b/engines/hdb/ai-player.cpp
index 63af8f4..8078f71 100644
--- a/engines/hdb/ai-player.cpp
+++ b/engines/hdb/ai-player.cpp
@@ -130,7 +130,7 @@ void aiPlayerInit2(AIEntity *e) {
 void aiPlayerAction(AIEntity *e) {
 	AIState stand[5] = {STATE_NONE, STATE_STANDUP, STATE_STANDDOWN, STATE_STANDLEFT, STATE_STANDRIGHT};
 	int xvAhead[5] = {9, 0, 0, -1, 1}, yvAhead[5] = {9, -1, 1, 0, 0};
-	AIEntity *hit;
+	AIEntity *hit = NULL;
 
 	// Draw the STUN lightning if it exists
 	if (e->sequence) {


Commit: 003f8dc2a435f3ea466c9284ed22dadb166f1dc2
    https://github.com/scummvm/scummvm/commit/003f8dc2a435f3ea466c9284ed22dadb166f1dc2
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:03+02:00

Commit Message:
HDB: Move constants to draw-manager

Changed paths:
    engines/hdb/draw-manager.h
    engines/hdb/hdb.h


diff --git a/engines/hdb/draw-manager.h b/engines/hdb/draw-manager.h
index d1f1e81..7f16f07 100644
--- a/engines/hdb/draw-manager.h
+++ b/engines/hdb/draw-manager.h
@@ -30,6 +30,8 @@
 namespace HDB {
 
 enum {
+	kScreenWidth = 640,
+	kScreenHeight = 480,
 	kTileWidth = 32,
 	kTileHeight = 32,
 	kMaxSkies = 10,
diff --git a/engines/hdb/hdb.h b/engines/hdb/hdb.h
index 0e2ec3d..8948c0c 100644
--- a/engines/hdb/hdb.h
+++ b/engines/hdb/hdb.h
@@ -110,11 +110,6 @@ enum Flag {
 	kFlagPlummet		= 0x8000000
 };
 
-enum {
-	kScreenWidth = 640,
-	kScreenHeight = 480
-};
-
 class HDBGame : public Engine {
 public:
 	HDBGame(OSystem *syst, const ADGameDescription *gameDesc);


Commit: 48428a75b7d0061f183733cd5a386ef5b5718cee
    https://github.com/scummvm/scummvm/commit/48428a75b7d0061f183733cd5a386ef5b5718cee
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:03+02:00

Commit Message:
HDB: Add _textOutList data

Changed paths:
    engines/hdb/window.h


diff --git a/engines/hdb/window.h b/engines/hdb/window.h
index 3059ab0..b803370 100644
--- a/engines/hdb/window.h
+++ b/engines/hdb/window.h
@@ -32,7 +32,8 @@ enum {
 	kWeaponY = 2,
 	kInvItemSpaceX = 48,
 	kInvItemSpaceY = 40,
-	kInvItemPerLine = 3
+	kInvItemPerLine = 3,
+	kTextOutCenterX = ((kScreenWidth - kTileWidth * 5) / 2)
 };
 
 struct DialogInfo {
@@ -61,6 +62,14 @@ struct InvWinInfo {
 	InvWinInfo() : x(0), y(0), width(0), height(0), selection(0), active(false) {}
 };
 
+struct TOut {
+	char text[128];
+	int x, y;
+	uint32 timer;
+
+	TOut() : text(""), x(0), y(0), timer(0) {}
+};
+
 class Window {
 public:
 
@@ -98,6 +107,7 @@ private:
 	uint32 _dialogDelay;	// Used for Cinematics
 
 	InvWinInfo _invWinInfo;
+	Common::Array<TOut *> _textOutList;
 
 	// Windows GFX
 	Picture *_gfxTL, *_gfxTM, *_gfxTR;


Commit: 178bb473c1b891403972aef976901e0ddd252fba
    https://github.com/scummvm/scummvm/commit/178bb473c1b891403972aef976901e0ddd252fba
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:03+02:00

Commit Message:
HDB: Add _textOutList functions

Changed paths:
    engines/hdb/window.cpp
    engines/hdb/window.h


diff --git a/engines/hdb/window.cpp b/engines/hdb/window.cpp
index 09d8866..aa10fde 100644
--- a/engines/hdb/window.cpp
+++ b/engines/hdb/window.cpp
@@ -384,4 +384,55 @@ void Window::drawInventory() {
 	}
 }
 
+void Window::textOut(const char *text, int x, int y, int timer) {
+	TOut *t = new TOut;
+
+	t->x = x;
+	t->y = y;
+	strcpy(t->text, text);
+	t->timer = g_system->getMillis() + (uint32)(timer << 4);
+
+	if (x < 0) {
+		int pw, lines;
+		g_hdb->_drawMan->getDimensions(t->text, &pw, &lines);
+		t->x = kTextOutCenterX - pw / 2;
+	}
+}
+
+void Window::centerTextOut(const char *text, int y, int timer) {
+	int width, lines;
+	g_hdb->_drawMan->getDimensions(text, &width, &lines);
+	textOut(text, kTextOutCenterX - ((width - 8) >> 1), y, timer);
+}
+
+void Window::drawTextOut() {
+	int e1, e2, e3, e4;
+	uint32 time;
+	TOut *t;
+
+	if (_textOutList.empty())
+		return;
+
+	g_hdb->_drawMan->getTextEdges(&e1, &e2, &e3, &e4);
+	g_hdb->_drawMan->setTextEdges(0, 480, 0, kScreenHeight);
+
+	time = g_system->getMillis();
+	
+	for (uint i = 0; i < _textOutList.size(); i++) {
+		t = _textOutList[i];
+		g_hdb->_drawMan->setCursor(t->x, t->y);
+		g_hdb->_drawMan->drawText(t->text);
+
+		if (t->timer < time) {
+			_textOutList.remove_at(i);
+			i--;
+		}
+	}
+
+	g_hdb->_drawMan->setTextEdges(e1, e2, e3, e4);
+}
+
+void Window::closeTextOut() {
+	_textOutList.clear();
+}
 } // End of Namespace
diff --git a/engines/hdb/window.h b/engines/hdb/window.h
index b803370..b2d2a3e 100644
--- a/engines/hdb/window.h
+++ b/engines/hdb/window.h
@@ -101,6 +101,14 @@ public:
 		return _invWinInfo.selection;
 	}
 
+	// TextOut functions
+	void textOut(const char *text, int x, int y, int timer);
+	void centerTextOut(const char *text, int y, int timer);
+	void drawTextOut();
+	int textOutActive() {
+		return (_textOutList.size());
+	}
+	void closeTextOut();
 private:
 
 	DialogInfo _dialogInfo;


Commit: 6d7329836236f624aa0fe838d344bb84b159e4d1
    https://github.com/scummvm/scummvm/commit/6d7329836236f624aa0fe838d344bb84b159e4d1
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:03+02:00

Commit Message:
HDB: Call drawTextOut()

Changed paths:
    engines/hdb/hdb.cpp


diff --git a/engines/hdb/hdb.cpp b/engines/hdb/hdb.cpp
index 7fb4551..a00d89e 100644
--- a/engines/hdb/hdb.cpp
+++ b/engines/hdb/hdb.cpp
@@ -327,6 +327,7 @@ Common::Error HDBGame::run() {
 
 		_window->drawDialog();
 		_window->drawInventory();
+		_window->drawTextOut();
 
 		// Update Timer that's NOT used for in-game Timing
 		_prevTimeSlice = _timeSlice;


Commit: ba002d8616fbb3dbfe02dab63a03c5ac8de1ffc8
    https://github.com/scummvm/scummvm/commit/ba002d8616fbb3dbfe02dab63a03c5ac8de1ffc8
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:03+02:00

Commit Message:
HDB: Add cineTextOut() and cineCenterTextOut()

Changed paths:
    engines/hdb/ai-cinematic.cpp
    engines/hdb/ai.h


diff --git a/engines/hdb/ai-cinematic.cpp b/engines/hdb/ai-cinematic.cpp
index 39a203b..e92c85b 100644
--- a/engines/hdb/ai-cinematic.cpp
+++ b/engines/hdb/ai-cinematic.cpp
@@ -569,6 +569,27 @@ void AI::cineDialog(const char *title, const char *string, int seconds) {
 	_cine.push_back(cmd);
 }
 
+void AI::cineTextOut(const char *text, int x, int y, int timer) {
+	CineCommand *cmd = new CineCommand;
+	cmd->title = text;
+	cmd->x = x;
+	cmd->y = y;
+	cmd->end = timer;
+	cmd->start = 0;
+	cmd->cmdType = C_TEXTOUT;
+	_cine.push_back(cmd);
+}
+
+void AI::cineCenterTextOut(const char *text, int y, int timer) {
+	CineCommand *cmd = new CineCommand;
+	cmd->title = text;
+	cmd->y = y;
+	cmd->end = timer;
+	cmd->start = 0;
+	cmd->cmdType = C_CENTERTEXTOUT;
+	_cine.push_back(cmd);
+}
+
 void AI::cineMoveMaskedPic(const char *id, const char *pic, int x1, int y1, int x2, int y2, int speed) {
 	if (!pic || !id) {
 		warning("cineMoveMaskedPic: Missing ID or PIC");
diff --git a/engines/hdb/ai.h b/engines/hdb/ai.h
index d8a831c..0d3de9c 100644
--- a/engines/hdb/ai.h
+++ b/engines/hdb/ai.h
@@ -868,6 +868,8 @@ public:
 	void cineSetAnimFrame(const char *entName, AIState state, int frame);
 	void cineEntityFace(const char *luaName, double dir);
 	void cineDialog(const char *title, const char *string, int seconds);
+	void cineTextOut(const char *text, int x, int y, int timer);
+	void cineCenterTextOut(const char *text, int y, int timer);
 	void cineMoveMaskedPic(const char *id, const char *pic, int x1, int y1, int x2, int y2, int speed);
 	void cineUse(const char *entName);
 	void cineFadeIn(bool isBlack, int steps);


Commit: a406218c2e92cdc192ac627e00e8428e3cba4be9
    https://github.com/scummvm/scummvm/commit/a406218c2e92cdc192ac627e00e8428e3cba4be9
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:03+02:00

Commit Message:
HDB: Process cineTextOut() and cineCenterTextOut()

Changed paths:
    engines/hdb/ai-cinematic.cpp


diff --git a/engines/hdb/ai-cinematic.cpp b/engines/hdb/ai-cinematic.cpp
index e92c85b..5f651a3 100644
--- a/engines/hdb/ai-cinematic.cpp
+++ b/engines/hdb/ai-cinematic.cpp
@@ -275,6 +275,24 @@ void AI::processCines() {
 					complete = true;
 			}
 			break;
+		case C_TEXTOUT:
+			if (!_cine[i]->start) {
+				g_hdb->_window->textOut(_cine[i]->title, _cine[i]->x, _cine[i]->y, _cine[i]->end);
+				_cine[i]->start = 1;
+			} else {
+				if (!g_hdb->_window->textOutActive())
+					complete = true;
+			}
+			break;
+		case C_CENTERTEXTOUT:
+			if (!_cine[i]->start) {
+				g_hdb->_window->centerTextOut(_cine[i]->title, _cine[i]->y, _cine[i]->end);
+				_cine[i]->start = 1;
+			} else {
+				if (!g_hdb->_window->textOutActive())
+					complete = true;
+			}
+			break;
 		case C_MOVEMASKEDPIC:
 			if (!_cine[i]->start) {
 				Picture *pic = cineFindInBlitList(_cine[i]->id);


Commit: 9bd1d58b8233f0f34c921bb2b17c9af145d25433
    https://github.com/scummvm/scummvm/commit/9bd1d58b8233f0f34c921bb2b17c9af145d25433
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:03+02:00

Commit Message:
HDB: Add Lua cineTextOut() and cineCenterTextOut()

Changed paths:
    engines/hdb/lua-script.cpp


diff --git a/engines/hdb/lua-script.cpp b/engines/hdb/lua-script.cpp
index 6ffd092..464b581 100644
--- a/engines/hdb/lua-script.cpp
+++ b/engines/hdb/lua-script.cpp
@@ -392,12 +392,32 @@ static int cineEntityFace(lua_State *L) {
 }
 
 static int cineTextOut(lua_State *L) {
-	warning("STUB: CINE TEXT OUT");
+	const char *string = lua_tostring(L, 1);
+	double x = lua_tonumber(L, 2);
+	double y = lua_tonumber(L, 3);
+	double timer = lua_tonumber(L, 4);
+
+	g_hdb->_lua->checkParameters("cineTextOut", 4);
+
+	x += kCameraXOff;
+	y += kCameraYOff;
+
+	lua_pop(L, 4);
+	g_hdb->_ai->cineTextOut(string, (int)x, (int)y, (int)timer);
 	return 0;
 }
 
 static int cineCenterTextOut(lua_State *L) {
-	warning("STUB: CINE CENTER TEXT OUT");
+	const char *string = lua_tostring(L, 1);
+	double y = lua_tonumber(L, 2);
+	double timer = lua_tonumber(L, 3);
+
+	g_hdb->_lua->checkParameters("cineCenterTextOut", 3);
+
+	y += kCameraYOff;
+
+	lua_pop(L, 3);
+	g_hdb->_ai->cineCenterTextOut(string, (int)y, (int)timer);
 	return 0;
 }
 


Commit: 2d7ab33be2f820ce0c7c8215cabbb8e1237a449b
    https://github.com/scummvm/scummvm/commit/2d7ab33be2f820ce0c7c8215cabbb8e1237a449b
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:03+02:00

Commit Message:
HDB: Add _textOutList.push_back() call

Changed paths:
    engines/hdb/window.cpp


diff --git a/engines/hdb/window.cpp b/engines/hdb/window.cpp
index aa10fde..041bceb 100644
--- a/engines/hdb/window.cpp
+++ b/engines/hdb/window.cpp
@@ -397,6 +397,8 @@ void Window::textOut(const char *text, int x, int y, int timer) {
 		g_hdb->_drawMan->getDimensions(t->text, &pw, &lines);
 		t->x = kTextOutCenterX - pw / 2;
 	}
+
+	_textOutList.push_back(t);
 }
 
 void Window::centerTextOut(const char *text, int y, int timer) {


Commit: 4c5cb8bafea28df61afd54d568a5b2b60961723d
    https://github.com/scummvm/scummvm/commit/4c5cb8bafea28df61afd54d568a5b2b60961723d
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:03+02:00

Commit Message:
HDB: Add _gameState check

Changed paths:
    engines/hdb/hdb.cpp


diff --git a/engines/hdb/hdb.cpp b/engines/hdb/hdb.cpp
index a00d89e..9e41924 100644
--- a/engines/hdb/hdb.cpp
+++ b/engines/hdb/hdb.cpp
@@ -99,6 +99,7 @@ bool HDBGame::init() {
 	// Defaults the game into Action Mode
 	setActionMode(1);
 
+	start();
 	_gameShutdown = false;
 	_systemInit = true;
 
@@ -106,7 +107,8 @@ bool HDBGame::init() {
 }
 
 void HDBGame::start() {
-	_gameState = GAME_TITLE;
+	warning("REMOVE: _gameState initialized to GAME_PLAY");
+	_gameState = GAME_PLAY;
 }
 
 /*
@@ -237,7 +239,7 @@ Common::Error HDBGame::run() {
 	initGraphics(kScreenWidth, kScreenHeight, &_format);
 	_console = new Console();
 
-
+#if 0
 	Common::SeekableReadStream *titleStream = _fileMan->findFirstData("monkeylogoscreen", TYPE_PIC);
 	if (titleStream == NULL) {
 		debug("The TitleScreen MPC entry can't be found.");
@@ -255,6 +257,7 @@ Common::Error HDBGame::run() {
 
 	Tile *tile = new Tile;
 	tile->load(tileStream);
+#endif
 
 	Common::SeekableReadStream *luaStream = _fileMan->findFirstData("MAP00_LUA", TYPE_BINARY);
 	int32 luaLength = _fileMan->getLength("MAP00_LUA", TYPE_BINARY);
@@ -298,36 +301,38 @@ Common::Error HDBGame::run() {
 			}
 		}
 
-		_drawMan->drawSky();
+		if (_gameState == GAME_PLAY) {
+			_drawMan->drawSky();
 
-		debug(9, "STUB: HDBGame::run: Add check for pause flag");
+			debug(9, "STUB: HDBGame::run: Add check for pause flag");
 
-		_ai->moveEnts();
-		_ai->processCallbackList();
+			_ai->moveEnts();
+			_ai->processCallbackList();
 
-		_map->draw();
-		_ai->processCines();
-		//_window->drawDialog();
+			_map->draw();
+			_ai->processCines();
+			//_window->drawDialog();
 
-		AIEntity *e = _ai->getPlayer();
+			AIEntity *e = _ai->getPlayer();
 
-		if (e && e->level < 2)
-			_ai->drawWayPoints();
+			if (e && e->level < 2)
+				_ai->drawWayPoints();
 
-		_map->drawEnts();
-		_map->drawGratings();
+			_map->drawEnts();
+			_map->drawGratings();
 
-		if (e && e->level == 2)
-			_ai->drawWayPoints();
+			if (e && e->level == 2)
+				_ai->drawWayPoints();
 
-		_ai->drawLevel2Ents();
+			_ai->drawLevel2Ents();
 
-		_map->drawForegrounds();
-		_ai->animateTargets();
+			_map->drawForegrounds();
+			_ai->animateTargets();
 
-		_window->drawDialog();
-		_window->drawInventory();
-		_window->drawTextOut();
+			_window->drawDialog();
+			_window->drawInventory();
+			_window->drawTextOut();
+		}
 
 		// Update Timer that's NOT used for in-game Timing
 		_prevTimeSlice = _timeSlice;


Commit: 105abf54295f44ff346f6b1d33bafa873b1d5417
    https://github.com/scummvm/scummvm/commit/105abf54295f44ff346f6b1d33bafa873b1d5417
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:03+02:00

Commit Message:
HDB: Add Pointer/Cursor data

Changed paths:
    engines/hdb/draw-manager.cpp
    engines/hdb/draw-manager.h


diff --git a/engines/hdb/draw-manager.cpp b/engines/hdb/draw-manager.cpp
index fabadac..57585ca 100644
--- a/engines/hdb/draw-manager.cpp
+++ b/engines/hdb/draw-manager.cpp
@@ -28,6 +28,7 @@ DrawMan::DrawMan() {
 	_tLookupArray = NULL;
 	_gfxCache = new Common::Array<GfxCache *>;
 	_globalSurface.create(kScreenWidth, kScreenHeight, g_hdb->_format);
+	_pointerDisplayable = 1;
 	_systemInit = false;
 }
 
@@ -110,11 +111,18 @@ bool DrawMan::init() {
 		TODO: Setup Gamma Table
 	*/
 
-	/*
-		TODO: Load Mouse Pointer and Display Cursor
-	*/
-
-	//Load all 4 levels of star colors
+	// Load Mouse Pointer and Display Cursor
+	_mousePointer[0] = loadPic(PIC_MOUSE_CURSOR1);
+	_mousePointer[1] = loadPic(PIC_MOUSE_CURSOR2);
+	_mousePointer[2] = loadPic(PIC_MOUSE_CURSOR3);
+	_mousePointer[3] = loadPic(PIC_MOUSE_CURSOR4);
+	_mousePointer[4] = loadPic(PIC_MOUSE_CURSOR5);
+	_mousePointer[5] = loadPic(PIC_MOUSE_CURSOR6);
+	_mousePointer[6] = loadPic(PIC_MOUSE_CURSOR7);
+	_mousePointer[7] = loadPic(PIC_MOUSE_CURSOR8);
+	_showCursor = true;
+
+	// Load all 4 levels of star colors
 	_starField[0] = getPicture("pic_star64");
 	_starField[1] = getPicture("pic_star128");
 	_starField[2] = getPicture("pic_star192");
diff --git a/engines/hdb/draw-manager.h b/engines/hdb/draw-manager.h
index 7f16f07..9f05b31 100644
--- a/engines/hdb/draw-manager.h
+++ b/engines/hdb/draw-manager.h
@@ -172,6 +172,9 @@ private:
 
 	// Cursor
 	int _cursorX, _cursorY;
+	Picture *_mousePointer[8];	// Gfx for screen pointer (4 Animations)
+	int _pointerDisplayable;
+	bool _showCursor;
 
 	// Font Data
 


Commit: 40b23d122d699b9f3bf683ac76bd850af4bf024e
    https://github.com/scummvm/scummvm/commit/40b23d122d699b9f3bf683ac76bd850af4bf024e
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:03+02:00

Commit Message:
HDB: Add Pointer functions

Changed paths:
    engines/hdb/draw-manager.cpp
    engines/hdb/draw-manager.h


diff --git a/engines/hdb/draw-manager.cpp b/engines/hdb/draw-manager.cpp
index 57585ca..1b53a5e 100644
--- a/engines/hdb/draw-manager.cpp
+++ b/engines/hdb/draw-manager.cpp
@@ -146,6 +146,28 @@ void DrawMan::updateVideo() {
 	debug(9, "STUB: DrawMan::updateVideo incomplete");
 }
 
+void DrawMan::drawPointer() {
+	static int anim = 0;
+	static uint32 animTime = 0;
+
+	if (animTime < g_system->getMillis()) {
+		animTime = g_system->getMillis() + 50;
+		anim = (anim + 1) & 7;
+	}
+
+	// If pointer is not displayable and we are in game, exit
+	if (!_pointerDisplayable && g_hdb->getGameState() == GAME_PLAY)
+		return;
+
+	// If we are in game and the cursor should be displayed, draw it
+	if (_showCursor || g_hdb->getGameState() != GAME_PLAY)
+		_mousePointer[anim]->drawMasked(g_hdb->_input->getMouseX() - 16, g_hdb->_input->getMouseY() - 16);
+}
+
+void DrawMan::setPointerState(int value) {
+	_pointerDisplayable = value;
+}
+
 void DrawMan::setFade(bool fadeIn, bool black, int steps) {
 	_fadeInfo.isFadeIn = fadeIn;
 	_fadeInfo.isBlack = black;
diff --git a/engines/hdb/draw-manager.h b/engines/hdb/draw-manager.h
index 9f05b31..1ace112 100644
--- a/engines/hdb/draw-manager.h
+++ b/engines/hdb/draw-manager.h
@@ -93,6 +93,14 @@ public:
 	bool init();
 	void fillScreen(uint32 color);
 	void updateVideo();
+	void setPointerState(int value);
+	void drawPointer();
+	void showPointer(bool status) {
+		_showCursor = status;
+	}
+	bool getPointer() {
+		return _showCursor;
+	}
 
 	void setFade(bool fadeIn, bool black, int steps);
 	void updateFade();


Commit: ea40074d845486985bd3e992aa0229bb7235713c
    https://github.com/scummvm/scummvm/commit/ea40074d845486985bd3e992aa0229bb7235713c
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:03+02:00

Commit Message:
HDB: Add getMouseX() and getMouseY()

Changed paths:
    engines/hdb/input.h


diff --git a/engines/hdb/input.h b/engines/hdb/input.h
index 57e145b..0b6a3db 100644
--- a/engines/hdb/input.h
+++ b/engines/hdb/input.h
@@ -53,6 +53,13 @@ public:
 	void stylusUp(int x, int y);
 	void stylusMove(int x, int y);
 
+	int getMouseX() {
+		return _mouseX;
+	}
+	int getMouseY() {
+		return _mouseY;
+	}
+
 private:
 
 	uint16 _buttons;	// Flags for buttons


Commit: 1370cf8b9db640c04d607ca33d9e5419baf1ccf0
    https://github.com/scummvm/scummvm/commit/1370cf8b9db640c04d607ca33d9e5419baf1ccf0
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:03+02:00

Commit Message:
HDB: Call DrawMan::drawPointer()

Changed paths:
    engines/hdb/hdb.cpp


diff --git a/engines/hdb/hdb.cpp b/engines/hdb/hdb.cpp
index 9e41924..005060a 100644
--- a/engines/hdb/hdb.cpp
+++ b/engines/hdb/hdb.cpp
@@ -146,7 +146,7 @@ void HDBGame::paint() {
 		warning("STUB: MENU::DrawMenu required");
 		break;
 	case GAME_PLAY:
-		warning("STUB: DrawMan::DrawPointer required");
+		_drawMan->drawPointer();
 		break;
 	case GAME_LOADING:
 		warning("STUB: DrawMan::DrawLoadingScreen required");


Commit: 437b9a86a1a5f75c8fa71902c78bcc2e46e6361c
    https://github.com/scummvm/scummvm/commit/437b9a86a1a5f75c8fa71902c78bcc2e46e6361c
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:03+02:00

Commit Message:
HDB: Add getter-setter for _gameState

Changed paths:
    engines/hdb/hdb.h


diff --git a/engines/hdb/hdb.h b/engines/hdb/hdb.h
index 8948c0c..0cfa08f 100644
--- a/engines/hdb/hdb.h
+++ b/engines/hdb/hdb.h
@@ -145,6 +145,12 @@ public:
 	bool init();
 
 	void start();
+	void setGameState(GameState gs) {
+		_gameState = gs;
+	}
+	GameState getGameState() {
+		return _gameState;
+	}
 	void changeGameState();
 	void paint();
 


Commit: 14d83c9667b3a05b57d8738f0d3eee413ed71797
    https://github.com/scummvm/scummvm/commit/14d83c9667b3a05b57d8738f0d3eee413ed71797
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:03+02:00

Commit Message:
HDB: Unstub animGrabbing() call

Changed paths:
    engines/hdb/hdb.cpp


diff --git a/engines/hdb/hdb.cpp b/engines/hdb/hdb.cpp
index 005060a..8029866 100644
--- a/engines/hdb/hdb.cpp
+++ b/engines/hdb/hdb.cpp
@@ -219,7 +219,7 @@ void HDBGame::useEntity(AIEntity *e) {
 
 	// Grab animation
 	if (added) {
-		warning("STUB: HDBGame::useEntity show Grab Animation");
+		_ai->animGrabbing();
 	}
 
 	// Can't push it - make a sound


Commit: 6a6f0e99d8810975b2a539589564a1ec5ea6fdd0
    https://github.com/scummvm/scummvm/commit/6a6f0e99d8810975b2a539589564a1ec5ea6fdd0
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:04+02:00

Commit Message:
HDB: Add tileDistance() and waypointsLeft()

Changed paths:
    engines/hdb/ai.h


diff --git a/engines/hdb/ai.h b/engines/hdb/ai.h
index 0d3de9c..b164161 100644
--- a/engines/hdb/ai.h
+++ b/engines/hdb/ai.h
@@ -45,7 +45,8 @@ enum {
 	kEnemyMoveSpeed = 2,
 	kPushMoveSpeed = (kPlayerMoveSpeed >> 1),
 	kPlayerTouchPWait = 16,
-	kMaxCineGfx = 10
+	kMaxCineGfx = 10,
+	kRunToggleDelay = 2
 };
 
 enum AIType {
@@ -729,6 +730,9 @@ public:
 	void initAllEnts();
 	void killPlayer(Death method);
 	void stunEnemy(AIEntity *e, int time);
+	int tileDistance(AIEntity *e1, AIEntity *e2) {
+		return abs(e1->tileX - e2->tileX) + abs(e1->tileY - e2->tileY);
+	}
 
 	void animateEntity(AIEntity *e);
 	void animEntFrames(AIEntity *e);
@@ -885,6 +889,9 @@ public:
 	void clearWaypoints();
 	Tile *getStandFrameDir(AIEntity *e);
 	void drawWayPoints();
+	int waypointsLeft() {
+		return _numWaypoints;
+	}
 
 	// Inventory Functions
 	bool addToInventory(AIEntity *e);


Commit: fe914ffd416279779bf40e8158d78db06b1e5fe7
    https://github.com/scummvm/scummvm/commit/fe914ffd416279779bf40e8158d78db06b1e5fe7
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:04+02:00

Commit Message:
HDB: Add setTargetXY()

Changed paths:
    engines/hdb/hdb.cpp
    engines/hdb/hdb.h


diff --git a/engines/hdb/hdb.cpp b/engines/hdb/hdb.cpp
index 8029866..d73228d 100644
--- a/engines/hdb/hdb.cpp
+++ b/engines/hdb/hdb.cpp
@@ -156,6 +156,164 @@ void HDBGame::paint() {
 	_drawMan->updateVideo();
 }
 
+// builds a waypoint list if an entity is not next to player,
+//	or gives info on an entity, or actually uses an entity
+void HDBGame::setTargetXY(int x, int y) {
+	AIEntity *e, *p;
+	int px, py;
+	bool oneTileAway;
+
+	// if ANY button is pressed
+	if (_input->getButtons() || _ai->_playerEmerging)
+		return;
+
+	// Check if an entity is next to us
+	x /= kTileWidth;
+	y /= kTileHeight;
+
+	// Don't ever allow going to X-coord 0
+	if (!x)
+		return;
+
+	e = _ai->findEntity(x, y);
+	p = _ai->getPlayer();
+
+	if (!p)
+		return;
+
+	px = p->x / kTileWidth;
+	py = p->y / kTileHeight;
+
+	// Are we on a touchplate and trying to move within the waiting period?
+	if (p->touchpWait)
+		return;
+
+	// If we're attacking...don't do anything else
+	AIState stateList[] = {
+		STATE_ATK_CLUB_UP,	STATE_ATK_CLUB_DOWN, STATE_ATK_CLUB_LEFT, STATE_ATK_CLUB_RIGHT,
+		STATE_ATK_STUN_UP,	STATE_ATK_STUN_DOWN, STATE_ATK_STUN_LEFT, STATE_ATK_STUN_RIGHT,
+		STATE_ATK_SLUG_UP,	STATE_ATK_SLUG_DOWN, STATE_ATK_SLUG_LEFT, STATE_ATK_SLUG_RIGHT,
+		STATE_PUSHUP,		STATE_PUSHDOWN,		 STATE_PUSHLEFT,	  STATE_PUSHRIGHT};
+
+	for (int i = 0; i < 16; i++) {
+		if (p->state == stateList[i])
+			return;
+	}
+
+	oneTileAway = (abs(px - x) + abs(py - y) < 2);
+
+	// If any entity has been targeted
+	if (e && !_ai->waypointsLeft()) {
+		// Clicking on a gettable item?
+		// First check if an iterm is on top of a BLOCKER entity.
+		// If so, try to find another entity there
+		if (e->type == AI_NONE) {
+			AIEntity *temp = g_hdb->_ai->findEntityIgnore(x, y, e);
+			if (temp)
+				e = temp;
+		}
+
+		if ((p->level == e->level) && _ai->getTableEnt(e->type)) {
+			if (g_hdb->_ai->tileDistance(e, p) < 2) {
+				useEntity(e);
+				return;
+			}
+		}
+
+		// Clicking on a Walkthrough Item?
+		if ((p->level == e->level) && _ai->walkThroughEnt(e->type)) {
+			_ai->addWaypoint(px, py, x, y, p->level);
+			return;
+		}
+
+		// Is this an invisible blocker? If so, it probably has a LUA entity under it
+		if (e->type == AI_NONE && _ai->luaExistAtXY(x, y)) {
+			// Did player click on a LUA tile?
+			if (oneTileAway && _ai->checkLuaList(_ai->getPlayer(), x, y))
+				return;
+		}
+
+		// On the same Level? (Allow pushing on stairs, down only)
+		if ((p->level != e->level && !(_map->getMapBGTileFlags(e->tileX, e->tileY) & kFlagStairBot)) || (p->level == e->level && _ai->walkThroughEnt(e->type))) {
+			_ai->addWaypoint(px, py, x, y, p->level);
+			return;
+		}
+
+		int chx = abs(px - x);
+		int chy = abs(py - y);
+
+		// And its a unit away and the Player's GOALS are done...
+		if (chx <= 1 && chy <= 1 && !p->goalX) {
+			// At a horizontal or vertical direction?
+			if (chx + chy > 1) {
+				AIEntity *e1, *e2;
+				uint32 flag1, flag2;
+
+				e1 = _ai->findEntity(px, y);
+				e2 = _ai->findEntity(x, py);
+				flag1 = _map->getMapBGTileFlags(px, y) & kFlagSolid;
+				flag2 = _map->getMapBGTileFlags(x, py) & kFlagSolid;
+				if ((e1 || flag1) && (e2 || flag2))
+					return;
+			}
+
+			// Check for items that should NOT be picked up or talked to
+			switch (e->type) {
+				// USEing a floating crate or barrel?  Just go there.
+				// Unless it's not floating, in which case you wanna push it.
+			case AI_CRATE:
+			case AI_LIGHTBARREL:
+				// USEing a heavy barrel ONLY means walking on it if it's floating
+				// *** cannot push a heavy barrel
+			case AI_HEAVYBARREL:
+				if (e->state == STATE_FLOATING || e->state == STATE_MELTED)
+					_ai->addWaypoint(px, py, x, y, p->level);
+				else
+					useEntity(e);
+				return;
+			default:
+				useEntity(e);
+				return;
+			}
+		} else {
+			_ai->addWaypoint(px, py, x, y, p->level);
+			return;
+		}
+	}
+
+	// Are we trying to "activate" a touchplate?
+	// Set a waypoint on it
+	if (_ai->checkForTouchplate(x, y)) {
+		_ai->addWaypoint(px, py, x, y, p->level);
+		return;
+	}
+
+	// Did the player click on an action tile?
+	if (oneTileAway && _ai->checkActionList(_ai->getPlayer(), x, y, true))
+		return;
+
+	// Did the player click on an auto-action tile?
+	if (oneTileAway && _ai->checkAutoList(_ai->getPlayer(), x, y))
+		return;
+
+	// we need to add this point to the waypoint list!
+	// the list is tile coord-based
+	//
+	// if the player is not PUSHING anything and has no GOALS,
+	// it's ok to set up a waypoint
+	switch (p->state) {
+	case STATE_PUSHDOWN:
+	case STATE_PUSHUP:
+	case STATE_PUSHLEFT:
+	case STATE_PUSHRIGHT:
+	case STATE_NONE:
+		break;
+	default:
+		_ai->addWaypoint(px, py, x, y, p->level);
+		break;
+	}
+}
+
 // PLAYER is trying to use this entity
 void HDBGame::useEntity(AIEntity *e) {
 	warning("STUB: HDBGame::useEntity incomplete");
diff --git a/engines/hdb/hdb.h b/engines/hdb/hdb.h
index 0cfa08f..56be985 100644
--- a/engines/hdb/hdb.h
+++ b/engines/hdb/hdb.h
@@ -154,6 +154,7 @@ public:
 	void changeGameState();
 	void paint();
 
+	void setTargetXY(int x, int y);
 	void useEntity(AIEntity *e);
 
 	int getActionMode() {


Commit: 0b87875a3ab088eed2ed33f4897aeddaf79b4147
    https://github.com/scummvm/scummvm/commit/0b87875a3ab088eed2ed33f4897aeddaf79b4147
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:04+02:00

Commit Message:
HDB: Unstub stylusDown()

Changed paths:
    engines/hdb/input.cpp


diff --git a/engines/hdb/input.cpp b/engines/hdb/input.cpp
index 12d415e..34dadc1 100644
--- a/engines/hdb/input.cpp
+++ b/engines/hdb/input.cpp
@@ -47,7 +47,87 @@ uint16 Input::getButtons() {
 }
 
 void Input::stylusDown(int x, int y) {
-	warning("STUB: Input: stylusDown required");
+	int worldX, worldY;
+	GameState gs;
+	static uint32 delay = 0, time;
+
+	// Don't let the screen get clicked too fast
+	time = g_system->getMillis();
+	if (time - delay < 100)
+		return;
+	time = delay;
+
+	_stylusDown = true;
+	_stylusDownX = x;
+	_stylusDownY = y;
+	gs = g_hdb->getGameState();
+
+	switch (gs) {
+	case GAME_TITLE:
+		warning("STUB: Menu: changeToMenu required");
+		g_hdb->changeGameState();
+		break;
+	case GAME_MENU:
+		warning("STUB: Menu: processInput required");
+		break;
+	case GAME_PLAY:
+		// Is Player Dead? Click on TRY AGAIN
+		if (g_hdb->_ai->playerDead()) {
+			warning("STUB: TRY AGAIN is onscreen");
+			return;
+		}
+
+		// Is Dialog Active?
+		if (g_hdb->_window->dialogActive()) {
+			g_hdb->_window->closeDialog();
+			if (!g_hdb->_ai->cinematicsActive())
+				return;
+		}
+
+		// Is a Choice Dialog Active?
+		warning("STUB: stylusDown: Check Choice Dialog Active");
+
+		// Is MessageBar active?
+		warning("STUB: stylusDown: Check Message Bar Active");
+
+		// In a cinematic?
+		if (g_hdb->_ai->playerLocked())
+			return;
+
+		// Check for map dragging in debug Mode and place player there
+		warning("STUB: stylusDown: Check for Map dragging in Debug Mode");
+
+		// Clicked in the world
+		g_hdb->_map->getMapXY(&worldX, &worldY);
+		worldX = ((worldX + x) / kTileWidth) * kTileWidth;
+		worldY = ((worldY + y) / kTileHeight) * kTileHeight;
+
+		// Don't allow a click into INV/DELIVERIES area to go into the world
+		if (x >= (kScreenWidth - 32 * 5))
+			return;
+
+		// Toggle Walk Speed if we clicked Player
+		int nx, ny;
+		static uint32 lastRunning = g_system->getMillis();
+		g_hdb->_ai->getPlayerXY(&nx, &ny);
+		if (nx == worldX && ny == worldY) {
+			if (lastRunning > g_system->getMillis())
+				return;
+			lastRunning = g_system->getMillis() + 1000 * kRunToggleDelay;
+			g_hdb->_ai->togglePlayerRunning();
+			if (g_hdb->_ai->playerRunning())
+				g_hdb->_window->centerTextOut("Running Speed", kScreenHeight - 32, kRunToggleDelay * kGameFPS);
+			else
+				g_hdb->_window->centerTextOut("Walking Speed", kScreenHeight - 32, kRunToggleDelay * kGameFPS);
+			warning("STUB: Play SND_SWITCH_USE");
+		}
+
+		g_hdb->setTargetXY(worldX, worldY);
+		break;
+	case GAME_LOADING:
+		debug(9, "stylusDown: GAME_LOADING found");
+		break;
+	}
 }
 
 void stylusUp(int x, int y) {
@@ -58,5 +138,4 @@ void stylusMove(int x, int y) {
 	warning("STUB: Input: stylusMove required");
 }
 
-}
-
+} // End of Namespace


Commit: 037400ed1bae31704ea7421420ed0686a9af180d
    https://github.com/scummvm/scummvm/commit/037400ed1bae31704ea7421420ed0686a9af180d
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:04+02:00

Commit Message:
HDB: Unstub stylusMove() and stylusUp()

Changed paths:
    engines/hdb/input.cpp


diff --git a/engines/hdb/input.cpp b/engines/hdb/input.cpp
index 34dadc1..c421b12 100644
--- a/engines/hdb/input.cpp
+++ b/engines/hdb/input.cpp
@@ -130,12 +130,26 @@ void Input::stylusDown(int x, int y) {
 	}
 }
 
-void stylusUp(int x, int y) {
-	warning("STUB: Input: stylusUp required");
+void Input::stylusUp(int x, int y) {
+	_stylusDown = false;
 }
 
-void stylusMove(int x, int y) {
-	warning("STUB: Input: stylusMove required");
+void Input::stylusMove(int x, int y) {
+	// In a cinematic?
+	if (g_hdb->_ai->playerLocked() || g_hdb->_ai->playerDead())
+		return;
+
+	switch (g_hdb->getGameState()) {
+	case GAME_PLAY:
+		warning("STUB: stylusMove: Add GetDebug() check");
+		break;
+	case GAME_MENU:
+		warning("STUB: stylusMove: Menu::processInput() required");
+		break;
+	default:
+		debug(9, "stylusMove: Unintended GameState");
+		break;
+	}
 }
 
 } // End of Namespace


Commit: f41e1999fb6397a8feeb7c105a40d77072ce1123
    https://github.com/scummvm/scummvm/commit/f41e1999fb6397a8feeb7c105a40d77072ce1123
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:04+02:00

Commit Message:
HDB: Add updateMouse() and call it in game loop

Changed paths:
    engines/hdb/hdb.cpp
    engines/hdb/input.cpp
    engines/hdb/input.h


diff --git a/engines/hdb/hdb.cpp b/engines/hdb/hdb.cpp
index d73228d..d0c65b5 100644
--- a/engines/hdb/hdb.cpp
+++ b/engines/hdb/hdb.cpp
@@ -451,6 +451,9 @@ Common::Error HDBGame::run() {
 			case Common::EVENT_QUIT:
 			case Common::EVENT_RTL:
 				break;
+			case Common::EVENT_MOUSEMOVE:
+				_input->updateMouse(event.mouse.x, event.mouse.y);
+				break;
 			case Common::EVENT_KEYDOWN:
 				debug("Key was pressed.");
 				break;
diff --git a/engines/hdb/input.cpp b/engines/hdb/input.cpp
index c421b12..41dbc9d 100644
--- a/engines/hdb/input.cpp
+++ b/engines/hdb/input.cpp
@@ -152,4 +152,28 @@ void Input::stylusMove(int x, int y) {
 	}
 }
 
+void Input::updateMouse(int newX, int newY) {
+	_lastMouseX = _mouseX;
+	_lastMouseY = _mouseY;
+	_mouseX = newX;
+	_mouseY = newY;
+
+	if (_mouseX < 0)
+		_mouseX = 0;
+	else if (_mouseX >= kScreenWidth)
+		_mouseX = kScreenWidth - 1;
+
+	if (_mouseY < 0)
+		_mouseY = 0;
+	else if (_mouseY >= kScreenHeight)
+		_mouseY = kScreenHeight - 1;
+
+	// Turn Cursor back on?
+	if ((_lastMouseX != _mouseX || _lastMouseY != _mouseY) && !g_hdb->_drawMan->getPointer()) {
+		g_hdb->_drawMan->showPointer(true);
+	}
+
+	warning("STUB: updateMouse: Update Mouse buttons");
+}
+
 } // End of Namespace
diff --git a/engines/hdb/input.h b/engines/hdb/input.h
index 0b6a3db..211d9d4 100644
--- a/engines/hdb/input.h
+++ b/engines/hdb/input.h
@@ -53,6 +53,8 @@ public:
 	void stylusUp(int x, int y);
 	void stylusMove(int x, int y);
 
+	void updateMouse(int newX, int newY);
+
 	int getMouseX() {
 		return _mouseX;
 	}


Commit: 4a8ce49968e3a316bcdacfab0925622292fb7e24
    https://github.com/scummvm/scummvm/commit/4a8ce49968e3a316bcdacfab0925622292fb7e24
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:04+02:00

Commit Message:
HDB: Remove _lastMouseX and _lastMouseY

Changed paths:
    engines/hdb/input.cpp
    engines/hdb/input.h


diff --git a/engines/hdb/input.cpp b/engines/hdb/input.cpp
index 41dbc9d..0819410 100644
--- a/engines/hdb/input.cpp
+++ b/engines/hdb/input.cpp
@@ -31,8 +31,6 @@ bool Input::init() {
 
 	_mouseX = kScreenWidth / 2;
 	_mouseY = kScreenHeight / 2;
-	_lastMouseX = _mouseX;
-	_lastMouseY = _mouseY;
 
 	return true;
 }
@@ -153,8 +151,6 @@ void Input::stylusMove(int x, int y) {
 }
 
 void Input::updateMouse(int newX, int newY) {
-	_lastMouseX = _mouseX;
-	_lastMouseY = _mouseY;
 	_mouseX = newX;
 	_mouseY = newY;
 
@@ -169,7 +165,7 @@ void Input::updateMouse(int newX, int newY) {
 		_mouseY = kScreenHeight - 1;
 
 	// Turn Cursor back on?
-	if ((_lastMouseX != _mouseX || _lastMouseY != _mouseY) && !g_hdb->_drawMan->getPointer()) {
+	if (!g_hdb->_drawMan->getPointer()) {
 		g_hdb->_drawMan->showPointer(true);
 	}
 
diff --git a/engines/hdb/input.h b/engines/hdb/input.h
index 211d9d4..e585d0a 100644
--- a/engines/hdb/input.h
+++ b/engines/hdb/input.h
@@ -68,7 +68,6 @@ private:
 	bool _stylusDown;
 	int _stylusDownX, _stylusDownY;
 	int _mouseX, _mouseY;
-	int _lastMouseX, _lastMouseY;
 
 	// Definable Keys
 	int _keyUp, _keyDown, _keyLeft, _keyRight;


Commit: 6d75390e8418f1969aae8c4643021432562f0329
    https://github.com/scummvm/scummvm/commit/6d75390e8418f1969aae8c4643021432562f0329
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:04+02:00

Commit Message:
HDB: Add checkInvSelect()

Changed paths:
    engines/hdb/window.cpp
    engines/hdb/window.h


diff --git a/engines/hdb/window.cpp b/engines/hdb/window.cpp
index 041bceb..ba7575c 100644
--- a/engines/hdb/window.cpp
+++ b/engines/hdb/window.cpp
@@ -384,6 +384,22 @@ void Window::drawInventory() {
 	}
 }
 
+void Window::checkInvSelect(int x, int y) {
+	if (x >= _invWinInfo.x && x < _invWinInfo.x + _invWinInfo.width && y >= _invWinInfo.y && y < _invWinInfo.y + _invWinInfo.height) {
+		int xc = (x - _invWinInfo.x) / kInvItemSpaceX;
+		int yc = (y - _invWinInfo.y) / kInvItemSpaceY;
+		if (yc * kInvItemPerLine + xc > g_hdb->_ai->getInvAmount())
+			return;
+
+		_invWinInfo.selection = yc * kInvItemPerLine + xc;
+
+		// If this is a weapon, choose it
+		warning("STUB: checkInvSelect: ChooseWeapon() required");
+
+		warning("STUB: checkInvSelect: Play SND_POP");
+	}
+}
+
 void Window::textOut(const char *text, int x, int y, int timer) {
 	TOut *t = new TOut;
 
diff --git a/engines/hdb/window.h b/engines/hdb/window.h
index b2d2a3e..27e3742 100644
--- a/engines/hdb/window.h
+++ b/engines/hdb/window.h
@@ -100,6 +100,7 @@ public:
 	int getInvSelect() {
 		return _invWinInfo.selection;
 	}
+	void checkInvSelect(int x, int y);
 
 	// TextOut functions
 	void textOut(const char *text, int x, int y, int timer);


Commit: 5e0e12531b51fc3f904ec11849f62aa73a928c22
    https://github.com/scummvm/scummvm/commit/5e0e12531b51fc3f904ec11849f62aa73a928c22
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:04+02:00

Commit Message:
HDB: Update Mouse data for buttons

Changed paths:
    engines/hdb/input.cpp
    engines/hdb/input.h


diff --git a/engines/hdb/input.cpp b/engines/hdb/input.cpp
index 0819410..462c65c 100644
--- a/engines/hdb/input.cpp
+++ b/engines/hdb/input.cpp
@@ -32,6 +32,8 @@ bool Input::init() {
 	_mouseX = kScreenWidth / 2;
 	_mouseY = kScreenHeight / 2;
 
+	_mouseLButton = _mouseMButton = _mouseRButton = 0;
+
 	return true;
 }
 
diff --git a/engines/hdb/input.h b/engines/hdb/input.h
index e585d0a..d649c21 100644
--- a/engines/hdb/input.h
+++ b/engines/hdb/input.h
@@ -36,10 +36,7 @@ enum Button {
 	kButtonB		= 2 << 5,
 	kButtonC		= 2 << 6,
 	kButtonD		= 2 << 7,
-	kButtonMouseL	= 2 << 8,
-	kButtonMouseM	= 2 << 9,
-	kButtonMouseR	= 2 << 10,
-	kButtonExit		= 2 << 11
+	kButtonExit		= 2 << 8
 };
 
 class Input {
@@ -68,6 +65,7 @@ private:
 	bool _stylusDown;
 	int _stylusDownX, _stylusDownY;
 	int _mouseX, _mouseY;
+	int _mouseLButton, _mouseMButton, _mouseRButton;
 
 	// Definable Keys
 	int _keyUp, _keyDown, _keyLeft, _keyRight;


Commit: ff25a0f4dd69ebe38867366b60a60f4b49633af8
    https://github.com/scummvm/scummvm/commit/ff25a0f4dd69ebe38867366b60a60f4b49633af8
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:04+02:00

Commit Message:
HDB: Add updateMouseButtons and update updateMouse

Changed paths:
    engines/hdb/hdb.cpp
    engines/hdb/input.cpp
    engines/hdb/input.h


diff --git a/engines/hdb/hdb.cpp b/engines/hdb/hdb.cpp
index d0c65b5..0edad42 100644
--- a/engines/hdb/hdb.cpp
+++ b/engines/hdb/hdb.cpp
@@ -454,6 +454,24 @@ Common::Error HDBGame::run() {
 			case Common::EVENT_MOUSEMOVE:
 				_input->updateMouse(event.mouse.x, event.mouse.y);
 				break;
+			case Common::EVENT_LBUTTONDOWN:
+				_input->updateMouseButtons(1, 0, 0);
+				break;
+			case Common::EVENT_LBUTTONUP:
+				_input->updateMouseButtons(-1, 0, 0);
+				break;
+			case Common::EVENT_MBUTTONDOWN:
+				_input->updateMouseButtons(0, 1, 0);
+				break;
+			case Common::EVENT_MBUTTONUP:
+				_input->updateMouseButtons(0, -1, 0);
+				break;
+			case Common::EVENT_RBUTTONDOWN:
+				_input->updateMouseButtons(0, 0, 1);
+				break;
+			case Common::EVENT_RBUTTONUP:
+				_input->updateMouseButtons(0, 0, -1);
+				break;
 			case Common::EVENT_KEYDOWN:
 				debug("Key was pressed.");
 				break;
diff --git a/engines/hdb/input.cpp b/engines/hdb/input.cpp
index 462c65c..e19b5ee 100644
--- a/engines/hdb/input.cpp
+++ b/engines/hdb/input.cpp
@@ -171,7 +171,45 @@ void Input::updateMouse(int newX, int newY) {
 		g_hdb->_drawMan->showPointer(true);
 	}
 
-	warning("STUB: updateMouse: Update Mouse buttons");
+	// Check if LButton is being dragged
+	if (_mouseLButton) {
+		stylusMove(_mouseX, _mouseY);
+	}
+}
+
+void Input::updateMouseButtons(int l, int m, int r) {
+	_mouseLButton += l;
+	_mouseMButton += m;
+	_mouseRButton += r;
+
+	// Check if LButton has been pressed
+	// Check if LButton has been lifted
+	if (_mouseLButton) {
+		if (_mouseX > (kScreenWidth - 32 * 5) && _mouseY < 240) {
+			g_hdb->_window->checkInvSelect(_mouseX, _mouseY);
+		} else if (_mouseX > (kScreenWidth - 32 * 5) && _mouseY >= 240) {
+			warning("STUB: updateMouseButtons: checkDeliveriesSelect() required");
+		} else {
+			warning("STUB: updateMouseButtons: Add pause check");
+			stylusDown(_mouseX, _mouseY);
+		}
+	} else if (!_mouseLButton) {
+		stylusUp(_mouseX, _mouseY);
+	}
+
+	// Check if MButton has been pressed
+	if (_mouseMButton) {
+		warning("STUB: updateMouseButtons: Add pause check");
+		g_hdb->_ai->clearWaypoints();
+		warning("STUB: Play SND_POP");
+	}
+
+	// Check if RButton has been pressed
+	if (_mouseRButton) {
+		warning("STUB: updateMouseButtons: Add pause check");
+		uint16 buttons = getButtons() | kButtonB;
+		setButtons(buttons);
+	}
 }
 
 } // End of Namespace
diff --git a/engines/hdb/input.h b/engines/hdb/input.h
index d649c21..a296bba 100644
--- a/engines/hdb/input.h
+++ b/engines/hdb/input.h
@@ -51,6 +51,7 @@ public:
 	void stylusMove(int x, int y);
 
 	void updateMouse(int newX, int newY);
+	void updateMouseButtons(int l, int m, int r);
 
 	int getMouseX() {
 		return _mouseX;


Commit: 5b327fb519ef2b8c203d74d33e2666971170c537
    https://github.com/scummvm/scummvm/commit/5b327fb519ef2b8c203d74d33e2666971170c537
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:04+02:00

Commit Message:
HDB: Fix bug when drawing gratings

Changed paths:
    engines/hdb/map-loader.cpp


diff --git a/engines/hdb/map-loader.cpp b/engines/hdb/map-loader.cpp
index c861936..0958654 100644
--- a/engines/hdb/map-loader.cpp
+++ b/engines/hdb/map-loader.cpp
@@ -698,7 +698,7 @@ void Map::drawEnts() {
 }
 
 void Map::drawGratings() {
-	for (int i = 0; i < kMaxGratings; i++) {
+	for (int i = 0; i < _numGratings; i++) {
 		g_hdb->_drawMan->getTile(_gratings[i]->tile)->drawMasked(_gratings[i]->x, _gratings[i]->y);
 	}
 
@@ -706,7 +706,7 @@ void Map::drawGratings() {
 }
 
 void Map::drawForegrounds() {
-	for (int i = 0; i < kMaxForegrounds; i++) {
+	for (int i = 0; i < _numForegrounds; i++) {
 		g_hdb->_drawMan->getTile(_foregrounds[i]->tile)->drawMasked(_foregrounds[i]->x, _foregrounds[i]->y);
 	}
 


Commit: b42109d368622408ca9a61f8157ba2a01a493005
    https://github.com/scummvm/scummvm/commit/b42109d368622408ca9a61f8157ba2a01a493005
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:04+02:00

Commit Message:
HDB: Add _pauseFlag data

Changed paths:
    engines/hdb/hdb.cpp
    engines/hdb/hdb.h


diff --git a/engines/hdb/hdb.cpp b/engines/hdb/hdb.cpp
index 0edad42..9e84a36 100644
--- a/engines/hdb/hdb.cpp
+++ b/engines/hdb/hdb.cpp
@@ -101,6 +101,7 @@ bool HDBGame::init() {
 
 	start();
 	_gameShutdown = false;
+	_pauseFlag = 0;
 	_systemInit = true;
 
 	return true;
diff --git a/engines/hdb/hdb.h b/engines/hdb/hdb.h
index 56be985..c33742a 100644
--- a/engines/hdb/hdb.h
+++ b/engines/hdb/hdb.h
@@ -196,6 +196,7 @@ private:
 	bool _systemInit;
 	GameState _gameState;
 	int _actionMode; // 0 or 1
+	int _pauseFlag;
 
 };
 


Commit: a607dd1bcd7859e2da599414be0d2d97e642cd87
    https://github.com/scummvm/scummvm/commit/a607dd1bcd7859e2da599414be0d2d97e642cd87
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:04+02:00

Commit Message:
HDB: Add functions related to _pauseFlag

Changed paths:
    engines/hdb/hdb.h


diff --git a/engines/hdb/hdb.h b/engines/hdb/hdb.h
index c33742a..e9f0548 100644
--- a/engines/hdb/hdb.h
+++ b/engines/hdb/hdb.h
@@ -164,6 +164,13 @@ public:
 		_actionMode = status;
 	}
 
+	void togglePause() {
+		_pauseFlag ^= 1;
+	}
+	int getPause() {
+		return _pauseFlag;
+	}
+
 	void resetTimer() {
 		_timePlayed = _timeSeconds = 0;
 	}


Commit: 568ec34994873779eecd5f36e7e09e6a7d6c7878
    https://github.com/scummvm/scummvm/commit/568ec34994873779eecd5f36e7e09e6a7d6c7878
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:04+02:00

Commit Message:
HDB: Add drawPause() and checkPause()

Changed paths:
    engines/hdb/window.cpp
    engines/hdb/window.h


diff --git a/engines/hdb/window.cpp b/engines/hdb/window.cpp
index ba7575c..5532ccd 100644
--- a/engines/hdb/window.cpp
+++ b/engines/hdb/window.cpp
@@ -96,6 +96,18 @@ void Window::setInfobarDark(int value) {
 	_infobarDimmed = value;
 }
 
+void Window::drawPause() {
+	if (g_hdb->getPause())
+		_gfxPausePlaque->drawMasked(480 / 2 - _gfxPausePlaque->_width / 2, kPauseY);
+}
+
+void Window::checkPause(uint x, uint y) {
+	if (x >= 480 / 2 - _gfxPausePlaque->_width / 2 && 480 / 2 + _gfxPausePlaque->_width / 2 > x && y >= kPauseY && y < kPauseY + _gfxPausePlaque->_height) {
+		g_hdb->togglePause();
+		warning("STUB: checkPause: Play SND_POP");
+	}
+}
+
 void Window::openDialog(const char *title, int tileIndex, const char *string, int more, const char *luaMore) {
 	if (_dialogInfo.active)
 		return;
diff --git a/engines/hdb/window.h b/engines/hdb/window.h
index 27e3742..b017c4c 100644
--- a/engines/hdb/window.h
+++ b/engines/hdb/window.h
@@ -33,7 +33,8 @@ enum {
 	kInvItemSpaceX = 48,
 	kInvItemSpaceY = 40,
 	kInvItemPerLine = 3,
-	kTextOutCenterX = ((kScreenWidth - kTileWidth * 5) / 2)
+	kTextOutCenterX = ((kScreenWidth - kTileWidth * 5) / 2),
+	kPauseY = (kScreenHeight / 2 - 64)
 };
 
 struct DialogInfo {
@@ -77,6 +78,10 @@ public:
 	void restartSystem();
 	void setInfobarDark(int value);
 
+	// Pause Functions
+	void drawPause();
+	void checkPause(uint x, uint y);
+
 	// Dialog Functions
 
 	void openDialog(const char *title, int tileIndex, const char *string, int more, const char *luaMore);


Commit: 0ede3a249c65bf555f6be9650f63d40c23440581
    https://github.com/scummvm/scummvm/commit/0ede3a249c65bf555f6be9650f63d40c23440581
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:04+02:00

Commit Message:
HDB: Remove 'Check Pause Flag' stubs

Changed paths:
    engines/hdb/ai-cinematic.cpp
    engines/hdb/input.cpp


diff --git a/engines/hdb/ai-cinematic.cpp b/engines/hdb/ai-cinematic.cpp
index 5f651a3..1226470 100644
--- a/engines/hdb/ai-cinematic.cpp
+++ b/engines/hdb/ai-cinematic.cpp
@@ -84,7 +84,9 @@ void AI::processCines() {
 			_cineBlitList[i]->pic->drawMasked(_cine[i]->x, _cine[i]->y);
 	}
 
-	// TODO: Check for Game Pause
+	// Check for Game Pause
+	if (g_hdb->getPause())
+		return;
 
 	for (uint i = 0; i < _cine.size(); i++) {
 		debug(3, "processCines: [%d] %s now: %d  start: %d delay: %d", i, cineTypeStr[_cine[i]->cmdType],
diff --git a/engines/hdb/input.cpp b/engines/hdb/input.cpp
index e19b5ee..d9e0cbe 100644
--- a/engines/hdb/input.cpp
+++ b/engines/hdb/input.cpp
@@ -190,7 +190,10 @@ void Input::updateMouseButtons(int l, int m, int r) {
 		} else if (_mouseX > (kScreenWidth - 32 * 5) && _mouseY >= 240) {
 			warning("STUB: updateMouseButtons: checkDeliveriesSelect() required");
 		} else {
-			warning("STUB: updateMouseButtons: Add pause check");
+			if (g_hdb->getPause() && g_hdb->getGameState() == GAME_PLAY) {
+				g_hdb->_window->checkPause(_mouseX, _mouseY);
+				return;
+			}
 			stylusDown(_mouseX, _mouseY);
 		}
 	} else if (!_mouseLButton) {
@@ -199,14 +202,18 @@ void Input::updateMouseButtons(int l, int m, int r) {
 
 	// Check if MButton has been pressed
 	if (_mouseMButton) {
-		warning("STUB: updateMouseButtons: Add pause check");
+		if (g_hdb->getPause() && g_hdb->getGameState() == GAME_PLAY)
+			return;
+
 		g_hdb->_ai->clearWaypoints();
 		warning("STUB: Play SND_POP");
 	}
 
 	// Check if RButton has been pressed
 	if (_mouseRButton) {
-		warning("STUB: updateMouseButtons: Add pause check");
+		if (g_hdb->getPause() && g_hdb->getGameState() == GAME_PLAY)
+			return;
+
 		uint16 buttons = getButtons() | kButtonB;
 		setButtons(buttons);
 	}


Commit: ad2fa4185a8088d2a3eeb24c0138bd259a1b1e4b
    https://github.com/scummvm/scummvm/commit/ad2fa4185a8088d2a3eeb24c0138bd259a1b1e4b
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:04+02:00

Commit Message:
HDB: Add pause checks to the Main loop

Changed paths:
    engines/hdb/hdb.cpp


diff --git a/engines/hdb/hdb.cpp b/engines/hdb/hdb.cpp
index 9e84a36..76f4956 100644
--- a/engines/hdb/hdb.cpp
+++ b/engines/hdb/hdb.cpp
@@ -484,10 +484,10 @@ Common::Error HDBGame::run() {
 		if (_gameState == GAME_PLAY) {
 			_drawMan->drawSky();
 
-			debug(9, "STUB: HDBGame::run: Add check for pause flag");
-
-			_ai->moveEnts();
-			_ai->processCallbackList();
+			if (!_pauseFlag) {
+				_ai->moveEnts();
+				_ai->processCallbackList();
+			}
 
 			_map->draw();
 			_ai->processCines();
@@ -512,6 +512,7 @@ Common::Error HDBGame::run() {
 			_window->drawDialog();
 			_window->drawInventory();
 			_window->drawTextOut();
+			_window->drawPause();
 		}
 
 		// Update Timer that's NOT used for in-game Timing


Commit: 8a63a2169d53e43388a513f251e7b9defa3e632b
    https://github.com/scummvm/scummvm/commit/8a63a2169d53e43388a513f251e7b9defa3e632b
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:04+02:00

Commit Message:
HDB: Add updateKeys()

Changed paths:
    engines/hdb/input.cpp
    engines/hdb/input.h


diff --git a/engines/hdb/input.cpp b/engines/hdb/input.cpp
index d9e0cbe..3ea214e 100644
--- a/engines/hdb/input.cpp
+++ b/engines/hdb/input.cpp
@@ -27,7 +27,15 @@ namespace HDB {
 bool Input::init() {
 	_stylusDown = false;
 
-	warning("STUB: Input::init: Set the default key values");
+	_keyUp = Common::KEYCODE_UP;
+	_keyDown = Common::KEYCODE_DOWN;
+	_keyLeft = Common::KEYCODE_LEFT;
+	_keyRight = Common::KEYCODE_RIGHT;
+	_keyMenu = Common::KEYCODE_ESCAPE;
+	_keyUse = Common::KEYCODE_RETURN;
+	_keyInv = Common::KEYCODE_SPACE;
+	_keyDebug = Common::KEYCODE_F1;
+	_keyQuit = Common::KEYCODE_F10;
 
 	_mouseX = kScreenWidth / 2;
 	_mouseY = kScreenHeight / 2;
@@ -219,4 +227,73 @@ void Input::updateMouseButtons(int l, int m, int r) {
 	}
 }
 
+void Input::updateKeys(Common::Event event, bool keyDown) {
+
+	warning("STUB: updateKeys: Check for Quit key");
+	warning("STUB: updateKeys: Check for Pause key");
+
+	uint16 buttons = getButtons();
+
+	if (!g_hdb->getPause()) {
+		if (event.kbd.keycode == _keyUp) {
+			if (keyDown) {
+				buttons |= kButtonUp;
+				if (g_hdb->_drawMan->getPointer())
+					g_hdb->_drawMan->showPointer(false);
+			} else {
+				buttons &= ~kButtonUp;
+			}
+		} else if (event.kbd.keycode == _keyDown) {
+			if (keyDown) {
+				buttons |= kButtonDown;
+				if (g_hdb->_drawMan->getPointer())
+					g_hdb->_drawMan->showPointer(false);
+			} else {
+				buttons &= ~kButtonDown;
+			}
+		} else if (event.kbd.keycode == _keyLeft) {
+			if (keyDown) {
+				buttons |= kButtonLeft;
+				if (g_hdb->_drawMan->getPointer())
+					g_hdb->_drawMan->showPointer(false);
+			} else {
+				buttons &= ~kButtonLeft;
+			}
+		} else if (event.kbd.keycode == _keyRight) {
+			if (keyDown) {
+				buttons |= kButtonRight;
+				if (g_hdb->_drawMan->getPointer())
+					g_hdb->_drawMan->showPointer(false);
+			} else {
+				buttons &= ~kButtonRight;
+			}
+		} else if (event.kbd.keycode == _keyUse) {
+			if (keyDown) {
+				buttons |= kButtonB;
+				if (g_hdb->_drawMan->getPointer())
+					g_hdb->_drawMan->showPointer(false);
+			} else {
+				buttons &= ~kButtonB;
+			}
+		}
+	}
+
+	if (event.kbd.keycode == _keyMenu) {
+		if (keyDown) {
+			buttons |= kButtonA;
+			g_hdb->_drawMan->showPointer(true);
+		} else {
+			buttons &= ~kButtonA;
+		}
+	} else if (event.kbd.keycode == _keyDebug) {
+		if (keyDown) {
+			buttons |= kButtonExit;
+		} else {
+			buttons &= ~kButtonExit;
+		}
+	}
+
+	setButtons(buttons);
+}
+
 } // End of Namespace
diff --git a/engines/hdb/input.h b/engines/hdb/input.h
index a296bba..d12f333 100644
--- a/engines/hdb/input.h
+++ b/engines/hdb/input.h
@@ -52,6 +52,7 @@ public:
 
 	void updateMouse(int newX, int newY);
 	void updateMouseButtons(int l, int m, int r);
+	void updateKeys(Common::Event event, bool keyDown);
 
 	int getMouseX() {
 		return _mouseX;
@@ -69,9 +70,9 @@ private:
 	int _mouseLButton, _mouseMButton, _mouseRButton;
 
 	// Definable Keys
-	int _keyUp, _keyDown, _keyLeft, _keyRight;
-	int _keyInv, _keyUse, _keyMenu, _keyDebug;
-	int _keyQuit;
+	Common::KeyCode _keyUp, _keyDown, _keyLeft, _keyRight;
+	Common::KeyCode _keyInv, _keyUse, _keyMenu, _keyDebug;
+	Common::KeyCode _keyQuit;
 };
 
 } // End of Namespace


Commit: 08771f2aebd671f710a862a1111e8cae26f43635
    https://github.com/scummvm/scummvm/commit/08771f2aebd671f710a862a1111e8cae26f43635
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:04+02:00

Commit Message:
HDB: Add getter-setter for _buttons

Changed paths:
    engines/hdb/input.cpp


diff --git a/engines/hdb/input.cpp b/engines/hdb/input.cpp
index 3ea214e..5c18b75 100644
--- a/engines/hdb/input.cpp
+++ b/engines/hdb/input.cpp
@@ -46,12 +46,11 @@ bool Input::init() {
 }
 
 void Input::setButtons(uint16 b) {
-	warning("STUB: Input: setButtons required");
+	_buttons = b;
 }
 
 uint16 Input::getButtons() {
-	warning("STUB: Input: getButtons required");
-	return 0;
+	return _buttons;
 }
 
 void Input::stylusDown(int x, int y) {


Commit: 3d979e14ff234744f534cdcfc651331ac4fd622d
    https://github.com/scummvm/scummvm/commit/3d979e14ff234744f534cdcfc651331ac4fd622d
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:04+02:00

Commit Message:
HDB: Call updateKeys() from game loop

Changed paths:
    engines/hdb/hdb.cpp


diff --git a/engines/hdb/hdb.cpp b/engines/hdb/hdb.cpp
index 76f4956..32d65d6 100644
--- a/engines/hdb/hdb.cpp
+++ b/engines/hdb/hdb.cpp
@@ -474,7 +474,10 @@ Common::Error HDBGame::run() {
 				_input->updateMouseButtons(0, 0, -1);
 				break;
 			case Common::EVENT_KEYDOWN:
-				debug("Key was pressed.");
+				_input->updateKeys(event, true);
+				break;
+			case Common::EVENT_KEYUP:
+				_input->updateKeys(event, false);
 				break;
 			default:
 				break;


Commit: 81ea30aa18541a5cf870099ff93bb6bbe78fa790
    https://github.com/scummvm/scummvm/commit/81ea30aa18541a5cf870099ff93bb6bbe78fa790
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:04+02:00

Commit Message:
HDB: Add movePlayer() and playerUse()

Changed paths:
    engines/hdb/ai-funcs.cpp
    engines/hdb/ai.h


diff --git a/engines/hdb/ai-funcs.cpp b/engines/hdb/ai-funcs.cpp
index 313506f..358c37d 100644
--- a/engines/hdb/ai-funcs.cpp
+++ b/engines/hdb/ai-funcs.cpp
@@ -2066,4 +2066,193 @@ void AI::lookAtXY(int x, int y) {
 		warning("AI-FUNCS: lookAtXY: DIR_NONE");
 	}
 }
+
+void AI::movePlayer(uint16 buttons) {
+	AIState stateList[] = {STATE_ATK_CLUB_UP,	STATE_ATK_CLUB_DOWN, STATE_ATK_CLUB_LEFT, STATE_ATK_CLUB_RIGHT,
+							STATE_ATK_STUN_UP,	STATE_ATK_STUN_DOWN, STATE_ATK_STUN_LEFT, STATE_ATK_STUN_RIGHT,
+							STATE_ATK_SLUG_UP,	STATE_ATK_SLUG_DOWN, STATE_ATK_SLUG_LEFT, STATE_ATK_SLUG_RIGHT,
+							STATE_PUSHUP,		STATE_PUSHDOWN,		 STATE_PUSHLEFT,	  STATE_PUSHRIGHT,
+							STATE_GRABUP,		STATE_GRABDOWN,		 STATE_GRABLEFT,	  STATE_GRABRIGHT};
+	int	xva[5] = {9, 0, 0,-1, 1};
+	int	yva[5] = {9,-1, 1, 0, 0};
+	AIEntity *hit;
+	int	xv = 0, yv = 0, nx, ny;
+	int	attackable;
+
+	if (!_player)
+		return;
+
+	// If we're already attacking, don't do anything else
+	for (int i = 0; i < 20; i++) {
+		if (_player->state == stateList[i])
+			return;
+	}
+
+	// Just trying to put away a dialog?
+	if (buttons & kButtonB) {
+		if (g_hdb->_window->dialogActive()) {
+			g_hdb->_window->closeDialog();
+			return;
+		}
+		warning("STUB: movePlayer: Add DialogChoice Check");
+		warning("STUB: movePlayer: Add MessageBar Check");
+
+		if (cinematicsActive() || _playerLock)
+			return;
+
+		// Are we trying to use something? An ACTION, AUTO, LUA?
+		nx = _player->tileX + xva[_player->dir];
+		ny = _player->tileY + yva[_player->dir];
+		hit = findEntity(nx, ny);
+
+		// the reason to check for no entity or an AI_NONE is because
+		// there's a possibility that an actual entity and a LUA entity
+		// can share the same spot, so we need to be able to deal with
+		// the real entity first, then the LUA entity.
+		if (!hit || (hit && hit->type == AI_NONE)) {
+			switch (_player->state) {
+			case STATE_STANDUP:
+			case STATE_STANDDOWN:
+			case STATE_STANDLEFT:
+			case STATE_STANDRIGHT:
+				if (checkForTouchplate(nx, ny))
+					break;
+				if (checkActionList(_player, nx, ny, true))
+					return;
+				if (checkAutoList(_player, nx, ny))
+					return;
+				if (checkLuaList(_player, nx, ny))
+					return;
+			default:
+				break;
+			}
+		}
+
+		// Attackable Entity? (we're right up on it)
+		int amt = getGemAmount();
+		attackable = 0;
+		if (hit)
+			switch (hit->type) {
+			case AI_OMNIBOT:
+			case AI_TURNBOT:
+			case AI_SHOCKBOT:
+			case AI_RIGHTBOT:
+			case AI_PUSHBOT:
+			case AI_LISTENBOT:
+			case AI_MAINTBOT:
+			case AI_DEADEYE:
+			case AI_MEERKAT:
+			case AI_FATFROG:
+			case AI_GOODFAIRY:
+			case AI_BADFAIRY:
+			case AI_ICEPUFF:
+			case AI_BUZZFLY:
+			case AI_DRAGON:
+			case AI_NONE:
+				attackable = 1;
+				break;
+			default:
+				break;
+			}
+
+		if (g_hdb->getActionMode() && ((hit && attackable) || !hit)) {
+			// Attack
+			warning("STUB: movePlayer: Attack!");
+			return;
+		}
+
+		// Puzzle Mode - throw a gem
+		// If this is the last gem, throw it and signal that it should come back
+
+		if (amt && (attackable || !hit)) {
+			xv = xva[_player->dir];
+			yv = yva[_player->dir];
+			nx = _player->tileX + xv;
+			ny = _player->tileY + yv;
+
+			spawn(AI_GEM_ATTACK, _player->dir, nx, ny, NULL, NULL, NULL, DIR_NONE, _player->level, amt == 1, 0, 1);
+			setGemAmount(amt - 1);
+			animGrabbing();
+			return;
+		}
+
+		// Are we trying to use this entity?
+		if (hit) {
+			g_hdb->useEntity(hit);
+			return;
+		}
+	}	// if kButtonB
+
+	if (!onEvenTile(_player->x, _player->y))
+		return;
+
+	// Is the player dead or move-locked?
+	if (_player->state == STATE_DEAD || _playerLock || _playerEmerging)
+		return;
+
+	// Are we on a touchplate and trying to move within the waiting period
+	if (_player->touchpWait > kPlayerTouchPWait / 4)
+		return;
+
+	// Is a dialog active?
+	if (g_hdb->_window->dialogActive())
+		if (!cinematicsActive())
+			return;
+
+	warning("STUB: movePlayer: Add Choice Dialog");
+
+	// In a cinematic?
+	if (_playerLock || _numWaypoints)
+		return;
+
+	if (buttons & kButtonUp)
+		yv = -1;
+	else if (buttons & kButtonDown)
+		yv = 1;
+	else if (buttons & kButtonLeft)
+		xv = -1;
+	else if (buttons & kButtonUp)
+		xv = 1;
+	else if (buttons & kButtonB) {
+		playerUse();
+		return;
+	}
+
+	// Check if we can move there
+	nx = _player->tileX + xv;
+	if (!nx)	// Don't allow moving to X-cooridinate 0
+		return;
+	ny = _player->tileY + yv;
+
+	int moveOK;
+	hit = legalMove(nx, ny, _player->level, &moveOK);
+	if (hit && walkThroughEnt(hit->type))
+		hit = NULL;
+
+	if (hit || !moveOK) {
+		lookAtXY(nx, ny);
+		stopEntity(_player);
+		return;
+	}
+
+	// Walk into Lua Entity?
+	if (checkLuaList(_player, nx, ny))
+		return;
+
+	if (buttons & (kButtonUp | kButtonDown | kButtonLeft | kButtonRight)) {
+		int temp = _player->animFrame;
+		if (_player->state != STATE_MOVELEFT && _player->state != STATE_MOVERIGHT && _player->state != STATE_MOVEUP && _player->state != STATE_MOVEDOWN)
+			temp = 0;
+		setEntityGoal(_player, nx, ny);
+		_player->animFrame = temp;
+	} else
+		setEntityGoal(_player, nx, ny);
+}
+
+void AI::playerUse() {
+	int	xv[5] = {9, 0, 0,-1, 1};
+	int	yv[5] = {9,-1, 1, 0, 0};
+
+	g_hdb->setTargetXY(kTileWidth * (_player->tileX + xv[_player->dir]), kTileWidth * (_player->tileY + yv[_player->dir]));
+}
 } // End of Namespace
diff --git a/engines/hdb/ai.h b/engines/hdb/ai.h
index b164161..f053d20 100644
--- a/engines/hdb/ai.h
+++ b/engines/hdb/ai.h
@@ -788,6 +788,10 @@ public:
 	void lookAtEntity(AIEntity *e);
 
 	// Player Functions
+
+	void movePlayer(uint16 buttons);
+	void playerUse();
+
 	AIEntity *getPlayer() {
 		if (!_player)
 			return &_dummyPlayer;


Commit: 806e9fedaceb77f0a69212e02eb515a041647ad1
    https://github.com/scummvm/scummvm/commit/806e9fedaceb77f0a69212e02eb515a041647ad1
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:04+02:00

Commit Message:
HDB: Use case-insensitive string comparison

Changed paths:
    engines/hdb/ai-cinematic.cpp


diff --git a/engines/hdb/ai-cinematic.cpp b/engines/hdb/ai-cinematic.cpp
index 1226470..a295086 100644
--- a/engines/hdb/ai-cinematic.cpp
+++ b/engines/hdb/ai-cinematic.cpp
@@ -316,18 +316,18 @@ void AI::processCines() {
 			break;
 		case C_USEENTITY:
 			for (Common::Array<AIEntity *>::iterator it = _ents->begin(); it != _ents->end(); it++) {
-				if ((*it)->entityName && Common::matchString((*it)->entityName, _cine[i]->string)) {
+				if ((*it)->entityName && Common::matchString((*it)->entityName, _cine[i]->string, true)) {
 					g_hdb->useEntity((*it));
 				}
 			}
 			for (int k = 0; k < kMaxActions; k++) {
-				if (_actions[k].entityName && Common::matchString(_actions[k].entityName, _cine[i]->string)) {
+				if (_actions[k].entityName && Common::matchString(_actions[k].entityName, _cine[i]->string, true)) {
 					checkActionList(&_dummyPlayer, _actions[k].x1, _actions[k].y1, false);
 					checkActionList(&_dummyPlayer, _actions[k].x2, _actions[k].y2, false);
 				}
 			}
 			for (int j = 0; j < kMaxAutoActions; j++) {
-				if (_autoActions[j].entityName && Common::matchString(_autoActions[j].entityName, _cine[i]->string) && !_autoActions[j].activated)
+				if (_autoActions[j].entityName && Common::matchString(_autoActions[j].entityName, _cine[i]->string, true) && !_autoActions[j].activated)
 					checkAutoList(&_dummyPlayer, _autoActions[j].x, _autoActions[j].y);
 			}
 			complete = true;
@@ -424,7 +424,7 @@ void AI::cineAddToBlitList(const char *id, Picture *pic, int x, int y, bool mask
 
 Picture *AI::cineFindInBlitList(const char *name) {
 	for (int i = 0; i < _numCineBlitList; i++) {
-		if (Common::matchString(_cineBlitList[i]->id, name))
+		if (Common::matchString(_cineBlitList[i]->id, name, true))
 			return _cineBlitList[i]->pic;
 	}
 	return NULL;
@@ -432,7 +432,7 @@ Picture *AI::cineFindInBlitList(const char *name) {
 
 void AI::cineRemoveFromBlitList(const char *name) {
 	for (int i = 0; i < _numCineBlitList; i++) {
-		if (Common::matchString(_cineBlitList[i]->id, name))
+		if (Common::matchString(_cineBlitList[i]->id, name, true))
 			delete _cineBlitList[i];
 			for (; i < _numCineBlitList - 1; i++)
 				_cineBlitList[i] = _cineBlitList[i + 1];


Commit: 5b22ced438727f34682de55f3f49c70c50375fa7
    https://github.com/scummvm/scummvm/commit/5b22ced438727f34682de55f3f49c70c50375fa7
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:04+02:00

Commit Message:
HDB: Fix drawing Cine Pics. This affects drawing thorwn clock

Changed paths:
    engines/hdb/ai-cinematic.cpp


diff --git a/engines/hdb/ai-cinematic.cpp b/engines/hdb/ai-cinematic.cpp
index a295086..a8b9eaf 100644
--- a/engines/hdb/ai-cinematic.cpp
+++ b/engines/hdb/ai-cinematic.cpp
@@ -79,9 +79,9 @@ void AI::processCines() {
 	// Make sure Cine Pics are drawing
 	for (int i = 0; i < _numCineBlitList; i++) {
 		if (_cineBlitList[i]->masked == false)
-			_cineBlitList[i]->pic->draw(_cine[i]->x, _cine[i]->y);
+			_cineBlitList[i]->pic->draw(_cineBlitList[i]->x, _cineBlitList[i]->y);
 		else
-			_cineBlitList[i]->pic->drawMasked(_cine[i]->x, _cine[i]->y);
+			_cineBlitList[i]->pic->drawMasked(_cineBlitList[i]->x, _cineBlitList[i]->y);
 	}
 
 	// Check for Game Pause


Commit: 6891f478a6c03449d02461da455f05d7963b851e
    https://github.com/scummvm/scummvm/commit/6891f478a6c03449d02461da455f05d7963b851e
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:04+02:00

Commit Message:
HDB: Add cineAbortable()

Changed paths:
    engines/hdb/ai.h


diff --git a/engines/hdb/ai.h b/engines/hdb/ai.h
index f053d20..ba1461d 100644
--- a/engines/hdb/ai.h
+++ b/engines/hdb/ai.h
@@ -853,6 +853,9 @@ public:
 	bool cinematicsActive() {
 		return _cineActive;
 	}
+	bool cineAbortable() {
+		return _cineAbortable;
+	}
 	void processCines();
 	void cineCleanup();
 	void cineAbort();


Commit: f0ab92faa14d45bea2f0c6e1c8d5ac6e4c6e5c5c
    https://github.com/scummvm/scummvm/commit/f0ab92faa14d45bea2f0c6e1c8d5ac6e4c6e5c5c
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:04+02:00

Commit Message:
HDB: Update setButtons()

Changed paths:
    engines/hdb/input.cpp


diff --git a/engines/hdb/input.cpp b/engines/hdb/input.cpp
index 5c18b75..0fb4e30 100644
--- a/engines/hdb/input.cpp
+++ b/engines/hdb/input.cpp
@@ -46,7 +46,45 @@ bool Input::init() {
 }
 
 void Input::setButtons(uint16 b) {
+	static int changeState = 0;
+	static int drawDlg = 0;
+	static int quit = 0;
+	static int debugOn = 0;
+
 	_buttons = b;
+	if (!b)
+		return;
+
+	// Change Game State
+	if ((_buttons & kButtonA) && !changeState && (g_hdb->getGameState() != GAME_MENU)) {
+		if (g_hdb->_ai->cinematicsActive() && g_hdb->_ai->cineAbortable()) {
+			g_hdb->_ai->cineAbort();
+			warning("STUB: setButtons: Play SND_POP");
+			return;
+		}
+
+		if (g_hdb->getGameState() == GAME_TITLE)
+			warning("STUB: setButtons: changeToMenu() required");
+		warning("STUB: setButtons: Play SND_MENU_BACKOUT");
+		g_hdb->changeGameState();
+	}
+
+	// Debug Mode Cycling
+	warning("STUB: setButtons: Check and set Debug Mode");
+
+	if (g_hdb->getGameState() == GAME_PLAY) {
+		// Is Player Dead? Click on TRY AGAIN
+		if (g_hdb->_ai->playerDead()) {
+			warning("STUB: TRY AGAIN is onscreen");
+			return;
+		}
+
+		warning("STUB: setButtons: Choose from DialogChoice");
+
+		// Try to move the player
+		if (!g_hdb->_ai->playerDead())
+			g_hdb->_ai->movePlayer(_buttons);
+	}
 }
 
 uint16 Input::getButtons() {


Commit: 1f920a201edc97a06f90d9a60d8b626f437d8faa
    https://github.com/scummvm/scummvm/commit/1f920a201edc97a06f90d9a60d8b626f437d8faa
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:05+02:00

Commit Message:
HDB: Solve ambigious code

Changed paths:
    engines/hdb/ai-lists.cpp


diff --git a/engines/hdb/ai-lists.cpp b/engines/hdb/ai-lists.cpp
index d76fa9e..1a7b794 100644
--- a/engines/hdb/ai-lists.cpp
+++ b/engines/hdb/ai-lists.cpp
@@ -90,8 +90,6 @@ void AI::animateTargets() {
 	int layer;
 
 	g_hdb->_map->getMapXY(&mx, &my);
-	debug(9, "animateTargets: Size of _animTargets: %d", _animTargets.size());
-	debug(9, "_animTargets:");
 
 	for (uint i = 0; i < _animTargets.size(); i++) {
 		at = _animTargets[i];
@@ -110,8 +108,7 @@ void AI::animateTargets() {
 			if (at->inMap) {
 				// Animate Map Tiles
 				layer = 0; // BG layer
-				warning("FIXME: Ambigious animateTargets() code.");
-				if (!at->start == g_hdb->_map->getMapBGTileIndex(at->x, at->y))
+				if (!(at->start == g_hdb->_map->getMapBGTileIndex(at->x, at->y)))
 					layer = 1;
 
 				// Change Tile Anim


Commit: 9182e0df177eb4c2c8ceb819c0f7fbca1064146d
    https://github.com/scummvm/scummvm/commit/9182e0df177eb4c2c8ceb819c0f7fbca1064146d
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:05+02:00

Commit Message:
HDB: Made debug output more compact

Changed paths:
    engines/hdb/ai-lists.cpp


diff --git a/engines/hdb/ai-lists.cpp b/engines/hdb/ai-lists.cpp
index 1a7b794..0e91db4 100644
--- a/engines/hdb/ai-lists.cpp
+++ b/engines/hdb/ai-lists.cpp
@@ -70,7 +70,6 @@ void AI::addAnimateTarget(int x, int y, int start, int end, AnimSpeed speed, boo
 				snprintf(name, 32, "%s0%d", tileName, i + 1);
 			else
 				snprintf(name, 32, "%s%d", tileName, i + 1);
-			debug("AddAnimateTarget: %s", name);
 			size = g_hdb->_fileMan->getLength(name, TYPE_TILE32);
 			at->gfxList[i] = g_hdb->_drawMan->getTileGfx(name, size);
 		}
@@ -93,8 +92,7 @@ void AI::animateTargets() {
 
 	for (uint i = 0; i < _animTargets.size(); i++) {
 		at = _animTargets[i];
-		debug(9, "i: %d", i);
-		debug(9, "at: at->x: %d, at->y: %d, at->start: %d, at->end: %d, at->vel: %d", at->x, at->y, at->start, at->end, at->vel);
+		debug(9, "AnimTarget #%i: at: at->x: %d, at->y: %d, at->start: %d, at->end: %d, at->vel: %d", i, at->x, at->y, at->start, at->end, at->vel);
 
 		// Draw Non-map stuff every frame
 		if (!at->inMap)


Commit: 42ea7a97b0e562961a6c54140d5ac412fde38974
    https://github.com/scummvm/scummvm/commit/42ea7a97b0e562961a6c54140d5ac412fde38974
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:05+02:00

Commit Message:
HDB: Fire callbacks only when thier timeout is triggered

Changed paths:
    engines/hdb/ai-lists.cpp


diff --git a/engines/hdb/ai-lists.cpp b/engines/hdb/ai-lists.cpp
index 0e91db4..967d8ac 100644
--- a/engines/hdb/ai-lists.cpp
+++ b/engines/hdb/ai-lists.cpp
@@ -457,6 +457,10 @@ void AI::addCallback(CallbackType type, int x, int y, int delay) {
 void AI::processCallbackList() {
 	for (int i = 0; i < kMaxCallbacks; i++)
 		if (_callbacks[i].type != NO_FUNCTION) {
+			if (_callbacks[i].delay) {
+				_callbacks[i].delay--;
+				return;
+			}
 			allCallbacks[_callbacks[i].type].function(_callbacks[i].x, _callbacks[i].y);
 			_callbacks[i].type = NO_FUNCTION;
 			_callbacks[i].x = _callbacks[i].y = 0;


Commit: c702968984f95ab27f4bd2546282b6586c108308
    https://github.com/scummvm/scummvm/commit/c702968984f95ab27f4bd2546282b6586c108308
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:05+02:00

Commit Message:
HDB: Initialize _buttons

Fixes the BUG where Guy is randomly moving about
the screen

Changed paths:
    engines/hdb/input.cpp


diff --git a/engines/hdb/input.cpp b/engines/hdb/input.cpp
index 0fb4e30..8de0cc1 100644
--- a/engines/hdb/input.cpp
+++ b/engines/hdb/input.cpp
@@ -26,6 +26,7 @@ namespace HDB {
 
 bool Input::init() {
 	_stylusDown = false;
+	_buttons = 0;
 
 	_keyUp = Common::KEYCODE_UP;
 	_keyDown = Common::KEYCODE_DOWN;


Commit: 8c3bad65203edac5c5ebef60e993cdab1df9b093
    https://github.com/scummvm/scummvm/commit/8c3bad65203edac5c5ebef60e993cdab1df9b093
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:05+02:00

Commit Message:
HDB: Fix copy-paste error

Changed paths:
    engines/hdb/ai-funcs.cpp


diff --git a/engines/hdb/ai-funcs.cpp b/engines/hdb/ai-funcs.cpp
index 358c37d..8dfbf0d 100644
--- a/engines/hdb/ai-funcs.cpp
+++ b/engines/hdb/ai-funcs.cpp
@@ -624,7 +624,7 @@ void AI::initAllEnts() {
 		AIEntity *temp = _inventory[i].ent;
 
 		// Clear out all ptrs in entity before writing
-		for (int j = 0; i < kMaxAnimFrames; i++) {
+		for (int j = 0; j < kMaxAnimFrames; j++) {
 			temp->blinkGfx[j] = NULL;
 			temp->movedownGfx[j] = NULL;
 			temp->moveupGfx[j] = NULL;


Commit: ea2e29317319d7166f9764ea085308395f8d31d6
    https://github.com/scummvm/scummvm/commit/ea2e29317319d7166f9764ea085308395f8d31d6
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:05+02:00

Commit Message:
HDB: Fix Header Guard and add Namespace

Changed paths:
    engines/hdb/mpc.h


diff --git a/engines/hdb/mpc.h b/engines/hdb/mpc.h
index d8a0a4c..6b8f19d 100644
--- a/engines/hdb/mpc.h
+++ b/engines/hdb/mpc.h
@@ -23,7 +23,7 @@
 #ifndef HDB_MPC_H
 #define HDB_MPC_H
 
-#endif // !HDB_MPC_H
+namespace HDB {
 
 #define		TILE_TELEPORT1					"anim_t32_teleporter1"
 #define		TILE_TOUCHPLATE_OFF				"t32_touchplateoff"
@@ -921,4 +921,6 @@ enum IconList {
 	ICON_WAYPOINT_2
 };
 
+} // End of Namespace
 
+#endif // !HDB_MPC_H


Commit: 8cf8a9663961c22a72c34fcc8e67b9228b50a387
    https://github.com/scummvm/scummvm/commit/8cf8a9663961c22a72c34fcc8e67b9228b50a387
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:05+02:00

Commit Message:
HDB: Add _deliveries data

Changed paths:
    engines/hdb/ai-init.cpp
    engines/hdb/ai.h


diff --git a/engines/hdb/ai-init.cpp b/engines/hdb/ai-init.cpp
index 56ecad2..feeac65 100644
--- a/engines/hdb/ai-init.cpp
+++ b/engines/hdb/ai-init.cpp
@@ -673,8 +673,8 @@ AI::AI() {
 	_triggerList = new Common::Array<Trigger *>;
 	_hereList = new Common::Array<HereT *>;
 
-	// REMOVE: Remove for final. Used here due to lack of a MENU
-	_numGems = _numGooCups = _numMonkeystones = _numInventory = 0;
+	warning("REMOVE: Remove for final. Used here due to lack of a MENU");
+	_numGems = _numGooCups = _numMonkeystones = _numInventory = _numDeliveries = 0;
 
 	_stunAnim = 0;
 	_stunTimer = g_system->getMillis();
diff --git a/engines/hdb/ai.h b/engines/hdb/ai.h
index ba1461d..4133708 100644
--- a/engines/hdb/ai.h
+++ b/engines/hdb/ai.h
@@ -572,6 +572,20 @@ struct InvEnt {
 	InvEnt() : keep(0), ent(NULL) {}
 };
 
+struct DlvEnt {
+	char itemTextName[32];
+	char itemGfxName[32];
+	Tile *itemGfx;
+
+	char destTextName[32];
+	char destGfxName[32];
+	Tile *destGfx;
+
+	char id[32];
+
+	DlvEnt() : itemTextName(""), itemGfxName(""), itemGfx(NULL), destTextName(""), destGfxName(""), destGfx(NULL) {}
+};
+
 struct Waypoint {
 	int x, y, level;
 
@@ -1072,6 +1086,9 @@ public:
 	InvEnt _inventory[kMaxInventory];
 	int _numInventory;
 
+	DlvEnt _deliveries[kMaxDeliveries];
+	int _numDeliveries;
+
 	Waypoint _waypoints[kMaxWaypoints];
 	int _numWaypoints;
 	Tile *_waypointGfx[4]; // Animating waypoint gfx


Commit: b58b5b7ff538ce820e9fca4d26547674e481c241
    https://github.com/scummvm/scummvm/commit/b58b5b7ff538ce820e9fca4d26547674e481c241
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:05+02:00

Commit Message:
HDB: Add _deliveries functions

Changed paths:
    engines/hdb/ai-inventory.cpp
    engines/hdb/ai.h


diff --git a/engines/hdb/ai-inventory.cpp b/engines/hdb/ai-inventory.cpp
index 09fee3b..cfa45e3 100644
--- a/engines/hdb/ai-inventory.cpp
+++ b/engines/hdb/ai-inventory.cpp
@@ -104,4 +104,41 @@ AIEntity *AI::getInvItem(int which) {
 		return NULL;
 	return _inventory[which].ent;
 }
+
+void AI::newDelivery(const char *itemTextName, const char *itemGfxName, const char *destTextName, const char *destGfxName, const char *id) {
+	int i = _numDeliveries;
+
+	if (i == kMaxDeliveries) {
+		g_hdb->_window->openMessageBar("You have too many deliveries already!", 3);
+		return;
+	}
+
+	if (itemTextName)
+		strcpy(_deliveries[i].itemTextName, itemTextName);
+	if (itemGfxName)
+		strcpy(_deliveries[i].itemGfxName, itemGfxName);
+	if (destTextName)
+		strcpy(_deliveries[i].destTextName, destTextName);
+	if (destGfxName)
+		strcpy(_deliveries[i].destGfxName, destGfxName);
+
+	strcpy(_deliveries[i].id, id);
+
+	_numDeliveries++;
+
+	g_hdb->_window->openDeliveries(true);
+}
+
+bool AI::completeDelivery(const char *id) {
+	for (int i = 0; i < _numDeliveries; i++)
+		if (!scumm_stricmp(_deliveries[i].id, id)) {
+			for (; i < _numDeliveries; i++)
+				memcpy(&_deliveries[i], &_deliveries[i + 1], sizeof(_deliveries[0]));
+			_numDeliveries--;
+			warning("STUB: Play Voice: GUY_COMPLETED");
+			return true;
+		}
+	return false;
+}
+
 } // End of Namespace
diff --git a/engines/hdb/ai.h b/engines/hdb/ai.h
index 4133708..40be5af 100644
--- a/engines/hdb/ai.h
+++ b/engines/hdb/ai.h
@@ -935,6 +935,16 @@ public:
 
 	AIEntity *getInvItem(int which);
 
+	// Delivery Functions
+	void newDelivery(const char *itemTextName, const char *itemGfxName, const char *destTextName, const char *destGfxName, const char *id);
+	int getDeliveriesAmount() {
+		return _numDeliveries;
+	}
+	DlvEnt *getDeliveryItem(int which) {
+		return &_deliveries[which];
+	}
+	bool completeDelivery(const char *id);
+
 	// Player Variables
 	bool _playerDead;
 	bool _playerInvisible;	// While on RailRider for example


Commit: a5c9e053ab8f84037290127757e52f809c475a23
    https://github.com/scummvm/scummvm/commit/a5c9e053ab8f84037290127757e52f809c475a23
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:05+02:00

Commit Message:
HDB: Add stubbed openMessageBar function

Changed paths:
    engines/hdb/window.cpp
    engines/hdb/window.h


diff --git a/engines/hdb/window.cpp b/engines/hdb/window.cpp
index 5532ccd..a8ed992 100644
--- a/engines/hdb/window.cpp
+++ b/engines/hdb/window.cpp
@@ -318,6 +318,10 @@ void Window::setDialogDelay(int delay) {
 	_dialogDelay = g_system->getMillis() + 1000 * delay;
 }
 
+void Window::openMessageBar(const char *msg, int count) {
+	warning("STUB: Add openMessageBar()");
+}
+
 void Window::drawInventory() {
 	int baseX, drawX, drawY;
 	static uint32 timer = g_hdb->getTimeSlice() + 300;
diff --git a/engines/hdb/window.h b/engines/hdb/window.h
index b017c4c..b030c86 100644
--- a/engines/hdb/window.h
+++ b/engines/hdb/window.h
@@ -97,6 +97,9 @@ public:
 		return _dialogInfo.active;
 	}
 
+	// MessageBar Functions
+	void openMessageBar(const char *msg, int count);
+
 	// Inventory Functions
 	void drawInventory();
 	void setInvSelect(int status) {


Commit: 56deb8604913c64e935ecffc947e1d0cf8a17608
    https://github.com/scummvm/scummvm/commit/56deb8604913c64e935ecffc947e1d0cf8a17608
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:05+02:00

Commit Message:
HDB: Add _dlvsInfo data for the Deliveries Window

Changed paths:
    engines/hdb/window.cpp
    engines/hdb/window.h


diff --git a/engines/hdb/window.cpp b/engines/hdb/window.cpp
index a8ed992..ff0f2c0 100644
--- a/engines/hdb/window.cpp
+++ b/engines/hdb/window.cpp
@@ -79,6 +79,11 @@ bool Window::init() {
 	_invWinInfo.x = kScreenWidth - _gfxInfobar->_width + 16;
 	_invWinInfo.y = 40;
 
+	_dlvsInfo.width = kInvItemSpaceX * 3;
+	_dlvsInfo.height = kInvItemSpaceY * 4;
+	_dlvsInfo.x = (kScreenWidth - _gfxInfobar->_width) + 16;
+	_dlvsInfo.y = 272;
+
 	restartSystem();
 
 	return true;
diff --git a/engines/hdb/window.h b/engines/hdb/window.h
index b030c86..6ee9596 100644
--- a/engines/hdb/window.h
+++ b/engines/hdb/window.h
@@ -33,6 +33,11 @@ enum {
 	kInvItemSpaceX = 48,
 	kInvItemSpaceY = 40,
 	kInvItemPerLine = 3,
+	kDlvItemSpaceX = 48,
+	kDlvItemSpaceY = (kTileHeight * 2 + 16),
+	kDlvItemPerLine = 3,
+	kDlvItemTextY = (kScreenHeight - 30),
+	kNumCrazy = 37,
 	kTextOutCenterX = ((kScreenWidth - kTileWidth * 5) / 2),
 	kPauseY = (kScreenHeight / 2 - 64)
 };
@@ -63,6 +68,18 @@ struct InvWinInfo {
 	InvWinInfo() : x(0), y(0), width(0), height(0), selection(0), active(false) {}
 };
 
+struct DlvsInfo {
+	int x, y;
+	int width, height;
+	bool active;
+	int selected;
+	bool animate;
+	uint32 delay1, delay2, delay3;
+	bool go1, go2, go3;
+
+	DlvsInfo() : x(0), y(0), width(0), height(0), active(false), selected(0), animate(false), delay1(0), delay2(0), delay3(0), go1(false), go2(false), go3(false) {}
+};
+
 struct TOut {
 	char text[128];
 	int x, y;
@@ -125,6 +142,7 @@ private:
 
 	InvWinInfo _invWinInfo;
 	Common::Array<TOut *> _textOutList;
+	DlvsInfo _dlvsInfo;
 
 	// Windows GFX
 	Picture *_gfxTL, *_gfxTM, *_gfxTR;


Commit: bbfab922cd877db94d9b0bbfdd131744ac1e297b
    https://github.com/scummvm/scummvm/commit/bbfab922cd877db94d9b0bbfdd131744ac1e297b
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:05+02:00

Commit Message:
HDB: Add Deliveries functions in window.h

Changed paths:
    engines/hdb/window.cpp
    engines/hdb/window.h


diff --git a/engines/hdb/window.cpp b/engines/hdb/window.cpp
index ff0f2c0..d71e16b 100644
--- a/engines/hdb/window.cpp
+++ b/engines/hdb/window.cpp
@@ -421,6 +421,168 @@ void Window::checkInvSelect(int x, int y) {
 	}
 }
 
+void Window::openDeliveries(bool animate) {
+	DlvEnt *d;
+
+	// Load Gfx
+	for (int i = 0; i < g_hdb->_ai->getDeliveriesAmount(); i++) {
+		d = g_hdb->_ai->getDeliveryItem(i);
+		if (d->itemGfxName[0])
+			d->itemGfx = g_hdb->_drawMan->loadTile(d->itemGfxName);
+		if (d->destGfxName[0])
+			d->destGfx = g_hdb->_drawMan->loadTile(d->destGfxName);
+	}
+
+	warning("STUB: Play SND_POP");
+	_dlvsInfo.animate = animate;
+	_dlvsInfo.delay1 = g_hdb->getTimeSlice() + 500;
+	_dlvsInfo.go1 = _dlvsInfo.go2 = _dlvsInfo.go3 = false;
+
+	if (animate) {
+		_dlvsInfo.go1 = true;
+		_dlvsInfo.selected = g_hdb->_ai->getDeliveriesAmount() - 1;
+	}
+
+	// Make sure cursor isn't on an empty delivery
+	if (_dlvsInfo.selected >= g_hdb->_ai->getDeliveriesAmount())
+		_dlvsInfo.selected = g_hdb->_ai->getDeliveriesAmount() - 1;
+}
+
+void Window::drawDeliveries() {
+	int baseX, drawX, drawY;
+	DlvEnt *d;
+	static uint32 timer = g_hdb->getTimeSlice() + 300;
+
+	debug(9, "STUB: Add Crazy Sounds");
+
+	if (_infobarDimmed > 1)
+		return;
+
+	baseX = drawX = _dlvsInfo.x;
+	drawY = _dlvsInfo.y;
+
+	if (_dlvsInfo.selected >= g_hdb->_ai->getDeliveriesAmount())
+		_dlvsInfo.selected = g_hdb->_ai->getDeliveriesAmount() - 1;
+
+	// Draw Delivery Items
+	int inv;
+	for (inv = 0; inv < g_hdb->_ai->getDeliveriesAmount(); inv++) {
+		int centerX = baseX + (kScreenWidth - baseX) / 2;
+		d = g_hdb->_ai->getDeliveryItem(inv);
+		if (_dlvsInfo.animate && inv == g_hdb->_ai->getDeliveriesAmount() - 1) {
+			if (_dlvsInfo.go1) {
+				if (_dlvsInfo.delay1 < g_hdb->getTimeSlice()) {
+					// Draw Item
+					_gfxIndent->draw(drawX, drawY);
+					d->itemGfx->drawMasked(drawX, drawY);
+
+					g_hdb->_drawMan->setCursor(centerX - g_hdb->_drawMan->stringLength(d->itemTextName) / 2, kDlvItemTextY);
+					g_hdb->_drawMan->drawText(d->itemTextName);
+					if (!_dlvsInfo.go2) {
+						_dlvsInfo.go2 = true;
+						_dlvsInfo.delay2 = g_hdb->getTimeSlice() + 500;
+						warning("STUB: Play crazy sound");
+					}
+				}
+			}
+			if (_dlvsInfo.go2) {
+				if (_dlvsInfo.delay2 < g_hdb->getTimeSlice()) {
+					// Draw TO
+					_gfxArrowTo->drawMasked(_dlvsInfo.x + kDlvItemSpaceX * _dlvsInfo.selected + 8, drawY + kTileHeight);
+
+					g_hdb->_drawMan->setCursor(centerX - g_hdb->_drawMan->stringLength("to") / 2, kDlvItemTextY + 12);
+					g_hdb->_drawMan->drawText("to");
+					if (!_dlvsInfo.go3) {
+						_dlvsInfo.go3 = true;
+						_dlvsInfo.delay3 = g_hdb->getTimeSlice() + 500;
+						warning("STUB: Play crazy sound");
+					}
+				}
+			}
+			if (_dlvsInfo.go3) {
+				if (_dlvsInfo.delay3 < g_hdb->getTimeSlice()) {
+					// Draw Delivery
+					_gfxIndent->draw(drawX, drawY + kTileHeight + 16);
+					d->destGfx->drawMasked(drawX, drawY + kTileHeight + 16);
+
+					g_hdb->_drawMan->setCursor(centerX - (g_hdb->_drawMan->stringLength(d->destTextName) + g_hdb->_drawMan->stringLength("to")) / 2, kDlvItemTextY + 12);
+					g_hdb->_drawMan->drawText("to ");
+					g_hdb->_drawMan->drawText(d->destTextName);
+
+					warning("STUB: Play crazy sound");
+					_dlvsInfo.animate = false;
+				}
+			}
+
+		} else {
+			// Draw Item
+			_gfxIndent->draw(drawX, drawY);
+			d->itemGfx->drawMasked(drawX, drawY);
+			// Draw Delivery
+			_gfxIndent->draw(drawX, drawY + kTileHeight + 16);
+			d->destGfx->drawMasked(drawX, drawY + kTileHeight + 16);
+
+			if (!_dlvsInfo.animate && inv == _dlvsInfo.selected) {
+				g_hdb->_drawMan->setCursor(centerX - g_hdb->_drawMan->stringLength(d->itemTextName)/2, kDlvItemTextY);
+				g_hdb->_drawMan->drawText(d->itemTextName);
+				g_hdb->_drawMan->setCursor(centerX - (g_hdb->_drawMan->stringLength(d->destTextName) + g_hdb->_drawMan->stringLength("to ")) / 2, kDlvItemTextY + 12);
+				g_hdb->_drawMan->drawText("to ");
+				g_hdb->_drawMan->drawText(d->destTextName);
+			}
+
+			drawX += kDlvItemSpaceX;
+			if (drawX >= kScreenWidth) {
+				drawX = baseX;
+				drawY += kDlvItemSpaceY + 8;
+			}
+		}
+	}
+
+	// Draw "No Deliveries" or the arrow that points to the currently selected one
+	if (!inv) {
+		g_hdb->_drawMan->setCursor(baseX + 16, _dlvsInfo.y);
+		g_hdb->_drawMan->drawText("No Deliveries");
+	} else if (!_dlvsInfo.animate) {
+		int dx, dy, rowtwo;
+
+		rowtwo = _dlvsInfo.selected > 2;
+		dx = 8 + _dlvsInfo.x + kDlvItemSpaceX * (_dlvsInfo.selected % 3);
+		dy = _dlvsInfo.y + kTileHeight + (kDlvItemSpaceY + 8) * rowtwo;
+		_gfxArrowTo->drawMasked(dx, dy);
+	}
+
+	// If the infobar is dimmed out, this where we dim the whole thing
+	if (_infobarDimmed) {
+		for (int j = 0; j < kScreenHeight; j += kTileHeight) {
+			for (int i = (kScreenWidth - _gfxInfobar->_width); i < kScreenWidth; i += kTileWidth)
+				_gfxDarken->drawMasked(i, j);
+		}
+	}
+}
+
+void Window::setSelectedDelivery(int which) {
+	_dlvsInfo.selected = which;
+	warning("STUB: Play SND_MENU_SLIDER");
+}
+
+void Window::checkDlvSelect(int x, int y) {
+	int xc, yc;
+
+	if (_dlvsInfo.animate)
+		return;
+
+	int amt = g_hdb->_ai->getDeliveriesAmount();
+
+	// Click on a Delivery to select it for inspection?
+	if (x >= _dlvsInfo.x && x < _dlvsInfo.x + _dlvsInfo.width && y >= _dlvsInfo.y && y < _dlvsInfo.y + _dlvsInfo.height) {
+		xc = (x - _dlvsInfo.x) / kDlvItemSpaceX;
+		yc = (y - _dlvsInfo.y) / kDlvItemSpaceY;
+		int value = yc * kDlvItemPerLine + xc;
+		if (value < amt)
+			setSelectedDelivery(value);
+	}
+}
+
 void Window::textOut(const char *text, int x, int y, int timer) {
 	TOut *t = new TOut;
 
diff --git a/engines/hdb/window.h b/engines/hdb/window.h
index 6ee9596..9a248e7 100644
--- a/engines/hdb/window.h
+++ b/engines/hdb/window.h
@@ -127,6 +127,18 @@ public:
 	}
 	void checkInvSelect(int x, int y);
 
+	// Deliveries Functions
+	void openDeliveries(bool animate);
+	void drawDeliveries();
+	void setSelectedDelivery(int which);
+	int getSelectedDelivery() {
+		return _dlvsInfo.selected;
+	}
+	bool animatingDelivery() {
+		return _dlvsInfo.animate;
+	}
+	void checkDlvSelect(int x, int y);
+
 	// TextOut functions
 	void textOut(const char *text, int x, int y, int timer);
 	void centerTextOut(const char *text, int y, int timer);


Commit: 842377456201c42d4f6d269b046cde7ede3f2c5c
    https://github.com/scummvm/scummvm/commit/842377456201c42d4f6d269b046cde7ede3f2c5c
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:05+02:00

Commit Message:
HDB: Call drawDeliveries()

Changed paths:
    engines/hdb/hdb.cpp


diff --git a/engines/hdb/hdb.cpp b/engines/hdb/hdb.cpp
index 32d65d6..a2b77cc 100644
--- a/engines/hdb/hdb.cpp
+++ b/engines/hdb/hdb.cpp
@@ -514,6 +514,7 @@ Common::Error HDBGame::run() {
 
 			_window->drawDialog();
 			_window->drawInventory();
+			_window->drawDeliveries();
 			_window->drawTextOut();
 			_window->drawPause();
 		}


Commit: 7529d3e2b73e7183fcc5964de5b059f82b87ea62
    https://github.com/scummvm/scummvm/commit/7529d3e2b73e7183fcc5964de5b059f82b87ea62
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:05+02:00

Commit Message:
HDB: Fix crash when skipping cinematic

Changed paths:
    engines/hdb/ai-cinematic.cpp


diff --git a/engines/hdb/ai-cinematic.cpp b/engines/hdb/ai-cinematic.cpp
index a8b9eaf..915605b 100644
--- a/engines/hdb/ai-cinematic.cpp
+++ b/engines/hdb/ai-cinematic.cpp
@@ -400,11 +400,9 @@ void AI::cineCleanup() {
 }
 
 void AI::cineAbort() {
-	for (Common::Array<CineCommand *>::iterator it = _cine.begin(); it != _cine.end(); it++) {
-		if ((*it)->cmdType == C_STARTMAP || (*it)->cmdType == C_STOPCINE)
-			_cine[0] = *it;
-		if (it != _cine.begin())
-			_cine.erase(it);
+	for (uint i = 0; i < _cine.size(); i++) {
+		if (_cine[i]->cmdType == C_STARTMAP || _cine[i]->cmdType == C_STOPCINE)
+			_cine[0] = _cine[i];
 	}
 	warning("STUB: Window: closeAll() required");
 	if (_player)


Commit: 9bc1d5fb6e486ddeeb4d160d1d8f472c902d3990
    https://github.com/scummvm/scummvm/commit/9bc1d5fb6e486ddeeb4d160d1d8f472c902d3990
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:05+02:00

Commit Message:
HDB: Fix directional key logic

Changed paths:
    engines/hdb/ai-funcs.cpp


diff --git a/engines/hdb/ai-funcs.cpp b/engines/hdb/ai-funcs.cpp
index 8dfbf0d..36e663f 100644
--- a/engines/hdb/ai-funcs.cpp
+++ b/engines/hdb/ai-funcs.cpp
@@ -2211,7 +2211,7 @@ void AI::movePlayer(uint16 buttons) {
 		yv = 1;
 	else if (buttons & kButtonLeft)
 		xv = -1;
-	else if (buttons & kButtonUp)
+	else if (buttons & kButtonRight)
 		xv = 1;
 	else if (buttons & kButtonB) {
 		playerUse();


Commit: 709f5751906b5eaec85b911dd76ade78a2b07074
    https://github.com/scummvm/scummvm/commit/709f5751906b5eaec85b911dd76ade78a2b07074
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:05+02:00

Commit Message:
HDB: Fix getMapBGTileFlags()

Changed paths:
    engines/hdb/map-loader.cpp


diff --git a/engines/hdb/map-loader.cpp b/engines/hdb/map-loader.cpp
index 0958654..7c86e4b 100644
--- a/engines/hdb/map-loader.cpp
+++ b/engines/hdb/map-loader.cpp
@@ -717,7 +717,7 @@ uint32 Map::getMapBGTileFlags(int x, int y) {
 	if (x < 0 || x >= _width || y < 0 || y >= _height) {
 		return 0;
 	}
-	Tile* tile = g_hdb->_drawMan->getTile(_foreground[y * _width + x]);
+	Tile *tile = g_hdb->_drawMan->getTile(_background[y * _width + x]);
 	if (tile)
 		return tile->_flags;
 	return 0;
@@ -727,7 +727,7 @@ uint32 Map::getMapFGTileFlags(int x, int y) {
 	if (x < 0 || x >= _width || y < 0 || y >= _height) {
 		return 0;
 	}
-	Tile* tile = g_hdb->_drawMan->getTile(_foreground[y * _width + x]);
+	Tile *tile = g_hdb->_drawMan->getTile(_foreground[y * _width + x]);
 	if (tile)
 		return tile->_flags;
 	return 0;


Commit: ba6ca58d3ba91626a9350adca7af60158334ad39
    https://github.com/scummvm/scummvm/commit/ba6ca58d3ba91626a9350adca7af60158334ad39
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:05+02:00

Commit Message:
HDB: Fix legalMove() check

Changed paths:
    engines/hdb/ai-funcs.cpp


diff --git a/engines/hdb/ai-funcs.cpp b/engines/hdb/ai-funcs.cpp
index 36e663f..4671b1e 100644
--- a/engines/hdb/ai-funcs.cpp
+++ b/engines/hdb/ai-funcs.cpp
@@ -1858,7 +1858,7 @@ AIEntity *AI::legalMove(int tileX, int tileY, int level, int *result) {
 		} else if (fgFlags & kFlagGrating) {
 			*result = 1;
 			return hit;
-		} else if (fgFlags & kFlagSolid) {
+		} else if (bgFlags & kFlagSolid) {
 			*result = 0;
 			return hit;
 		}


Commit: d848428f56608e7530e6bf4ced002a0ab838e531
    https://github.com/scummvm/scummvm/commit/d848428f56608e7530e6bf4ced002a0ab838e531
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:05+02:00

Commit Message:
HDB: Unstub addToList stubs

Changed paths:
    engines/hdb/map-loader.cpp


diff --git a/engines/hdb/map-loader.cpp b/engines/hdb/map-loader.cpp
index 7c86e4b..c45102d 100644
--- a/engines/hdb/map-loader.cpp
+++ b/engines/hdb/map-loader.cpp
@@ -526,7 +526,16 @@ bool Map::load(Common::SeekableReadStream *stream) {
 		case INFO_TELEPORTER18:
 		case INFO_TELEPORTER19:
 		case INFO_TELEPORTER20:
-			warning("STUB: Map::load: AddToTeleporterList required");
+			g_hdb->_ai->addToTeleportList(
+				aiInfo[_iconList[i].icon].type - INFO_TELEPORTER1,
+				_iconList[i].x,
+				_iconList[i].y,
+				_iconList[i].dir,
+				_iconList[i].level,
+				_iconList[i].value1,
+				_iconList[i].value2,
+				_iconList[i].funcUse
+			);
 			break;
 
 		case INFO_SET_MUSIC:
@@ -535,13 +544,33 @@ bool Map::load(Common::SeekableReadStream *stream) {
 			break;
 
 		case INFO_LUA:
-			warning("STUB: Map::load: AddToLUAList required");
+			g_hdb->_ai->addToLuaList(
+				_iconList[i].x,
+				_iconList[i].y,
+				_iconList[i].value1,
+				_iconList[i].value2,
+				_iconList[i].funcInit,
+				_iconList[i].funcAction,
+				_iconList[i].funcUse
+			);
 			break;
 		case INFO_HERE:
-			warning("STUB: Map::load: AddToHereList required");
+			g_hdb->_ai->addToHereList(
+				_iconList[i].funcInit,
+				_iconList[i].x,
+				_iconList[i].y
+			);
 			break;
 		case INFO_TRIGGER:
-			warning("STUB: Map::load: AddToTriggerList required");
+			g_hdb->_ai->addToTriggerList(
+				_iconList[i].funcInit,
+				_iconList[i].funcUse,
+				_iconList[i].x,
+				_iconList[i].y,
+				_iconList[i].value1,
+				_iconList[i].value2,
+				_iconList[i].funcAction
+			);
 			break;
 
 		case INFO_FAIRY_SRC:


Commit: 2f67167c272bb25891334de9ee0376dbd37b2763
    https://github.com/scummvm/scummvm/commit/2f67167c272bb25891334de9ee0376dbd37b2763
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:05+02:00

Commit Message:
HDB: Add NPC functions

Changed paths:
    engines/hdb/ai-player.cpp


diff --git a/engines/hdb/ai-player.cpp b/engines/hdb/ai-player.cpp
index 8078f71..8ff503c 100644
--- a/engines/hdb/ai-player.cpp
+++ b/engines/hdb/ai-player.cpp
@@ -512,11 +512,12 @@ void aiChickenInit2(AIEntity *e) {
 }
 
 void aiDollyInit(AIEntity *e) {
-	warning("STUB: AI: aiDollyInit required");
+	e->moveSpeed = kPlayerMoveSpeed >> 1;
+	e->aiAction = aiGenericAction;
 }
 
 void aiDollyInit2(AIEntity *e) {
-	warning("STUB: AI: aiDollyInit2 required");
+	e->draw = e->movedownGfx[0];
 }
 
 void aiSergeantInit(AIEntity *e) {
@@ -538,11 +539,21 @@ void aiSergeantAction(AIEntity *e) {
 }
 
 void aiSpacedudeInit(AIEntity *e) {
-	warning("STUB: AI: aiSpacedudeInit required");
+	e->moveSpeed = kPlayerMoveSpeed >> 1;
+	if (e->value1)
+		e->aiAction = aiGenericAction;
 }
 
 void aiSpacedudeInit2(AIEntity *e) {
-	warning("STUB: AI: aiSpacedudeInit2 required");
+	e->standdownFrames = 1;
+	e->standdownGfx[0] = e->movedownGfx[0];
+	e->standupFrames = 1;
+	e->standupGfx[0] = e->moveupGfx[0];
+	e->standleftFrames = 1;
+	e->standleftGfx[0] = e->moveleftGfx[0];
+	e->standrightFrames = 1;
+	e->standrightGfx[0] = e->moverightGfx[0];
+	e->draw = g_hdb->_ai->getStandFrameDir(e);
 }
 
 void aiCrateAction(AIEntity *e) {
@@ -618,11 +629,15 @@ void aiBarrelBlowup(AIEntity *e, int x, int y) {
 }
 
 void aiScientistInit(AIEntity *e) {
-	warning("STUB: AI: aiScientistInit required");
+	e->moveSpeed = kPlayerMoveSpeed >> 1;
+	if (g_hdb->_ai->findPath(e))
+		e->aiAction = aiGenericAction;
+	else if (e->value1)
+		e->aiAction = aiGenericAction;
 }
 
 void aiScientistInit2(AIEntity *e) {
-	warning("STUB: AI: aiScientistInit2 required");
+	e->draw = g_hdb->_ai->getStandFrameDir(e);
 }
 
 void aiSlugAttackAction(AIEntity *e) {
@@ -642,27 +657,27 @@ void aiSlugAttackInit2(AIEntity *e) {
 }
 
 void aiDeadWorkerInit(AIEntity *e) {
-	warning("STUB: AI: aiDeadWorkerInit required");
 }
 
 void aiDeadWorkerInit2(AIEntity *e) {
-	warning("STUB: AI: aiDeadWorkerInit2 required");
+	e->draw = e->standdownGfx[0];
 }
 
 void aiWorkerInit(AIEntity *e) {
-	warning("STUB: AI: aiWorkerInit required");
+	if (e->value1)
+		e->aiAction = aiGenericAction;
+	e->moveSpeed = kPlayerMoveSpeed >> 1;
 }
 
 void aiWorkerInit2(AIEntity *e) {
-	warning("STUB: AI: aiWorkerInit2 required");
+	e->draw = g_hdb->_ai->getStandFrameDir(e);
 }
 
 void aiAccountantInit(AIEntity *e) {
-	warning("STUB: AI: aiAccountantInit required");
 }
 
 void aiAccountantInit2(AIEntity *e) {
-	warning("STUB: AI: aiAccountantInit2 required");
+	e->draw = g_hdb->_ai->getStandFrameDir(e);
 }
 
 void aiFrogStatueInit(AIEntity *e) {


Commit: bebb2e39567f24d35a12e875ad7a935e894bfca5
    https://github.com/scummvm/scummvm/commit/bebb2e39567f24d35a12e875ad7a935e894bfca5
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:05+02:00

Commit Message:
HDB: Add utility functions

aiAnimateStanddown, aiGenericAction, aiGetItemAction

Changed paths:
    engines/hdb/ai-player.cpp


diff --git a/engines/hdb/ai-player.cpp b/engines/hdb/ai-player.cpp
index 8ff503c..100f186 100644
--- a/engines/hdb/ai-player.cpp
+++ b/engines/hdb/ai-player.cpp
@@ -1274,15 +1274,40 @@ void callbackDoorOpenClose(int x, int y) {
 
 // Utility Functions
 void aiAnimateStanddown(AIEntity *e, int speed) {
-	warning("STUB: AI: aiAnimateStanddown required");
+	if (e->value2-- > 0)
+		return;
+	e->value2 = speed;
+
+	if (e->type == AI_GUY && e->animFrame > 0)
+		e->value2 = 0;
+	e->draw = e->standdownGfx[e->animFrame];
+	e->animFrame++;
+	if (e->animFrame >= e->standdownFrames)
+		e->animFrame = 0;
 }
 
 void aiGenericAction(AIEntity *e) {
-	warning("STUB: AI: aiGenericAction required");
+	if (!e->goalX)
+		g_hdb->_ai->findPath(e);
+	else if (onEvenTile(e->x, e->y))
+		debug(9, "STUB: Play SND_FOOTSTEPS");
+	g_hdb->_ai->animateEntity(e);
 }
 
 void aiGetItemAction(AIEntity *e) {
-	warning("STUB: AI: aiGetItemAction required");
+	if (!e->onScreen)
+		return;
+
+	AIEntity *p = g_hdb->_ai->getPlayer();
+	if (abs(p->x - e->x) < 16 && abs(p->y - e->y) < 16 && e->level == p->level) {
+		if (e->aiUse)
+			e->aiUse(e);
+		if (e->luaFuncUse[0])
+			g_hdb->_lua->callFunction(e->luaFuncUse, 0);
+
+		g_hdb->_ai->getItemSound(e->type);
+		g_hdb->_ai->addToInventory(e);
+	}
 }
 
 } // End of Namespace


Commit: a4eb195ab8e08f034c6a0b4ca9e98fafc64275cb
    https://github.com/scummvm/scummvm/commit/a4eb195ab8e08f034c6a0b4ca9e98fafc64275cb
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:05+02:00

Commit Message:
HDB: Remove warning

Changed paths:
    engines/hdb/ai-funcs.cpp


diff --git a/engines/hdb/ai-funcs.cpp b/engines/hdb/ai-funcs.cpp
index 4671b1e..2b74dd2 100644
--- a/engines/hdb/ai-funcs.cpp
+++ b/engines/hdb/ai-funcs.cpp
@@ -885,7 +885,6 @@ void AI::animateEntity(AIEntity *e) {
 			if we're on a waypoint, nevermind!
 		*/
 		if (e == _player) {
-			warning("FIXME: Ambiguous animateEntity() code");
 			result = e->x == (e->goalX * kTileWidth) && e->y == (e->goalY * kTileWidth);
 			if (!result) {
 				int xv = 0, yv = 0;


Commit: 216ec886ac9ddd8edb6961fbfb48a47e4069eac7
    https://github.com/scummvm/scummvm/commit/216ec886ac9ddd8edb6961fbfb48a47e4069eac7
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:05+02:00

Commit Message:
JANITORIAL: Fix code formatting

Changed paths:
    engines/hdb/ai-funcs.cpp


diff --git a/engines/hdb/ai-funcs.cpp b/engines/hdb/ai-funcs.cpp
index 2b74dd2..1d22805 100644
--- a/engines/hdb/ai-funcs.cpp
+++ b/engines/hdb/ai-funcs.cpp
@@ -953,7 +953,9 @@ void AI::animateEntity(AIEntity *e) {
 				warning("AI-FUNCS: animateEntity: DIR_NONE found");
 				break;
 			}
-			if ((e->tileX+xOff == _waypoints[_numWaypoints-1].x && e->tileY + yOff == _waypoints[_numWaypoints - 1].y) && e->level == _waypoints[_numWaypoints - 1].level) {
+			if ((e->tileX + xOff == _waypoints[_numWaypoints - 1].x &&
+				 e->tileY + yOff == _waypoints[_numWaypoints - 1].y) &&
+				 e->level == _waypoints[_numWaypoints - 1].level) {
 				memset(&_waypoints[0], 0, sizeof(_waypoints));
 				_numWaypoints = 1;
 				_waypoints[0].x = e->tileX + xOff;


Commit: e5cf4308b9c5537f4bf25c6067b989284537541e
    https://github.com/scummvm/scummvm/commit/e5cf4308b9c5537f4bf25c6067b989284537541e
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:05+02:00

Commit Message:
JANITORIAL: Fix code formatting

Changed paths:
    engines/hdb/ai-funcs.cpp


diff --git a/engines/hdb/ai-funcs.cpp b/engines/hdb/ai-funcs.cpp
index 1d22805..42562e5 100644
--- a/engines/hdb/ai-funcs.cpp
+++ b/engines/hdb/ai-funcs.cpp
@@ -1307,8 +1307,8 @@ void AI::animEntFrames(AIEntity *e) {
 			warning("STUB: Play SND_SHOCKBOT_SHOCK");
 			click = 0;
 		}
+		break;
 	}
-	break;
 	case STATE_HORRIBLE3:
 	{
 		static int		click = 0;
@@ -1319,8 +1319,8 @@ void AI::animEntFrames(AIEntity *e) {
 			warning("STUB: Play SND_GUY_GRABBED");
 			click = 0;
 		}
+		break;
 	}
-	break;
 	case STATE_HORRIBLE4:
 		e->draw = _horrible4Gfx[e->animFrame];
 		max = _horrible4Frames;


Commit: 224658a1ba97499c61ef92f74444f4abde7ce994
    https://github.com/scummvm/scummvm/commit/224658a1ba97499c61ef92f74444f4abde7ce994
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:05+02:00

Commit Message:
HDB: Fix Maintenance bot path finding. Still it runs too fast

Changed paths:
    engines/hdb/ai-lists.cpp


diff --git a/engines/hdb/ai-lists.cpp b/engines/hdb/ai-lists.cpp
index 967d8ac..ff0ecfb 100644
--- a/engines/hdb/ai-lists.cpp
+++ b/engines/hdb/ai-lists.cpp
@@ -699,7 +699,7 @@ void AI::addToPathList(int x, int y, int type, AIDir dir) {
 
 	arrowPath->type = type;
 	arrowPath->tileX = x;
-	arrowPath->tileX = y;
+	arrowPath->tileY = y;
 	arrowPath->dir = dir;
 
 	_arrowPaths->push_back(arrowPath);


Commit: b697371154c4648e9523222c39c6639337fc2dd8
    https://github.com/scummvm/scummvm/commit/b697371154c4648e9523222c39c6639337fc2dd8
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:05+02:00

Commit Message:
HDB: Make animations follow the requested framerate

Changed paths:
    engines/hdb/ai-funcs.cpp


diff --git a/engines/hdb/ai-funcs.cpp b/engines/hdb/ai-funcs.cpp
index 42562e5..6c0feec 100644
--- a/engines/hdb/ai-funcs.cpp
+++ b/engines/hdb/ai-funcs.cpp
@@ -1724,6 +1724,8 @@ void AI::moveEnts() {
 	if (frameDelay-- > 0)
 		return;
 
+	frameDelay = kAnimFrameDelay;
+
 	// Call aiAction for Floating Entities
 	for (Common::Array<AIEntity *>::iterator it = _floats->begin(); it != _floats->end(); it++) {
 		if ((*it)->aiAction)


Commit: 810dc15f97eb0c7be03cf2004f577fb7849d942a
    https://github.com/scummvm/scummvm/commit/810dc15f97eb0c7be03cf2004f577fb7849d942a
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:05+02:00

Commit Message:
HDB: Made main loop running 60fps

Changed paths:
    engines/hdb/hdb.cpp


diff --git a/engines/hdb/hdb.cpp b/engines/hdb/hdb.cpp
index a2b77cc..4e93737 100644
--- a/engines/hdb/hdb.cpp
+++ b/engines/hdb/hdb.cpp
@@ -526,7 +526,7 @@ Common::Error HDBGame::run() {
 		paint();
 
 		g_system->updateScreen();
-		g_system->delayMillis(10);
+		g_system->delayMillis(1000/60);
 	}
 
 	return Common::kNoError;


Commit: 2a9c34f95b954d9ac64d7c08a71fb79ca2b7afa2
    https://github.com/scummvm/scummvm/commit/2a9c34f95b954d9ac64d7c08a71fb79ca2b7afa2
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:06+02:00

Commit Message:
HDB: Add getEntityXY()

Changed paths:
    engines/hdb/ai-funcs.cpp
    engines/hdb/ai.h


diff --git a/engines/hdb/ai-funcs.cpp b/engines/hdb/ai-funcs.cpp
index 6c0feec..f3686ef 100644
--- a/engines/hdb/ai-funcs.cpp
+++ b/engines/hdb/ai-funcs.cpp
@@ -564,6 +564,38 @@ AIEntity *AI::findEntityType(AIType type, int x, int y) {
 	return NULL;
 }
 
+void AI::getEntityXY(const char *entName, int *x, int *y) {
+	AIEntity *e;
+	HereT *h;
+
+	for (Common::Array<AIEntity *>::iterator it = _ents->begin(); it != _ents->end(); it++) {
+		e = *it;
+		if (e->entityName && !scumm_stricmp(entName, e->entityName)) {
+			*x = e->tileX;
+			*y = e->tileY;
+			return;
+		}
+	}
+
+	for (Common::Array<AIEntity *>::iterator jt = _floats->begin(); jt != _floats->end(); jt++) {
+		e = *jt;
+		if (e->entityName && !scumm_stricmp(entName, e->entityName)) {
+			*x = e->tileX;
+			*y = e->tileY;
+			return;
+		}
+	}
+
+	for (Common::Array<HereT *>::iterator kt = _hereList->begin(); kt != _hereList->end(); kt++) {
+		h = *kt;
+		if (!scumm_stricmp(entName, h->entName)) {
+			*x = h->x;
+			*y = h->y;
+			return;
+		}
+	}
+}
+
 void AI::removeEntity(AIEntity *e) {
 	_ents->erase(&e);
 }
diff --git a/engines/hdb/ai.h b/engines/hdb/ai.h
index 40be5af..31a6766 100644
--- a/engines/hdb/ai.h
+++ b/engines/hdb/ai.h
@@ -739,6 +739,7 @@ public:
 	AIEntity *findEntity(int x, int y);
 	AIEntity *findEntityIgnore(int x, int y, AIEntity *ignore);
 	AIEntity *findEntityType(AIType type, int x, int y);
+	void getEntityXY(const char *entName, int *x, int *y);
 	void removeEntity(AIEntity *e);
 	void setEntityGoal(AIEntity *e, int x, int y);
 	void initAllEnts();


Commit: 428af6c972725a980f0a9fe4a15bb724ed46af18
    https://github.com/scummvm/scummvm/commit/428af6c972725a980f0a9fe4a15bb724ed46af18
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:06+02:00

Commit Message:
HDB: Add patches for deprecated Lua 4.0 calls

Changed paths:
    engines/hdb/lua-script.cpp


diff --git a/engines/hdb/lua-script.cpp b/engines/hdb/lua-script.cpp
index 464b581..aeb629b 100644
--- a/engines/hdb/lua-script.cpp
+++ b/engines/hdb/lua-script.cpp
@@ -37,7 +37,13 @@ struct ScriptPatch {
 	{"GLOBAL_LUA", "for i,npc in npcs do", "for i,npc in pairs(npcs) do"},
 	{"GLOBAL_LUA", "setglobal( npcdef.codename..\"_init\", function() return NPC_Init( %npcdef ) end )", "_G[npcdef.codename .. \"_init\"] = function() return NPC_Init( npcdef ) end"},
 	{"GLOBAL_LUA", "setglobal( npcdef.codename..\"_use\", function(x, y, v1, v2) return NPC_Use( %npcdef, x, y, v1, v2 ) end )", "_G[npcdef.codename .. \"_use\"] = function(x, y, v1, v2) return NPC_Use( npcdef, x, y, v1, v2 ) end"},
+	{"GLOBAL_LUA", "if( dtable.counter < getn(dtable) ) then", "if( dtable.counter < #dtable ) then"},
+	{"GLOBAL_LUA", "if( getglobal( \"map\"..tostring(v1)..\"_complete\" ) ) then", "if( _G[\"map\"..tostring(v1)..\"_complete\"] ) then"},
+	{"GLOBAL_LUA", "closefunc = getglobal( npcdef.codename..\"_use\" )", "closefunc = _G[npcdef.codename..\"_use\"]"},
 	{"MAP00_LUA", "tempfunc = function() emptybed_use( %x, %y, %v1, %v2 ) end", "tempfunc = function() emptybed_use(x, y, v1, v2) end"},
+	{"MAP00_LUA", "if( getn( beds ) == 0 ) then", "if( #beds == 0 ) then"},
+	{"MAP01_LUA", "if( covert_index < getn(covert_dialog) ) then", "if( covert_index < #covert_dialog ) then"},
+	{"MAP01_LUA", "if( chiste_index < getn( chiste_dialog ) )then", "if( covert_index < #covert_dialog ) then"},
 	{NULL, NULL, NULL},
 };
 


Commit: 6b5fd8a95ff3713a0e199f2757ddde8d1ad8a9c8
    https://github.com/scummvm/scummvm/commit/6b5fd8a95ff3713a0e199f2757ddde8d1ad8a9c8
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:06+02:00

Commit Message:
HDB: Add lua functions for dialog and getEntityXY

Changed paths:
    engines/hdb/lua-script.cpp


diff --git a/engines/hdb/lua-script.cpp b/engines/hdb/lua-script.cpp
index aeb629b..2a3b032 100644
--- a/engines/hdb/lua-script.cpp
+++ b/engines/hdb/lua-script.cpp
@@ -443,8 +443,18 @@ static int deliveriesLeft(lua_State *L) {
 }
 
 static int getEntityXY(lua_State *L) {
-	warning("STUB: GET ENTITYXY");
-	return 0;
+	int x, y;
+	const char *initName = lua_tostring(L, 1);
+
+	g_hdb->_lua->checkParameters("getEntityXY", 1);
+
+	lua_pop(L, 1);
+
+	g_hdb->_ai->getEntityXY(initName, &x, &y);
+
+	lua_pushnumber(L, x);
+	lua_pushnumber(L, y);
+	return 2;
 }
 
 static int setEntity(lua_State *L) {
@@ -546,7 +556,22 @@ static int setBackground(lua_State *L) {
 }
 
 static int dialog(lua_State *L) {
-	warning("STUB: DIALOG");
+	const char *title, *string, *more;
+	double tileIndex;
+
+	title = lua_tostring(L, 1);
+	tileIndex = lua_tonumber(L, 2);
+	string = lua_tostring(L, 3);
+	more = lua_tostring(L, 4);
+
+	if (!more || more[0] == '0')
+		more = NULL;
+
+	g_hdb->_lua->checkParameters("dialog", 4);
+
+	lua_pop(L, 4);
+	if (string)
+		g_hdb->_window->openDialog(title, (int)tileIndex, string, (int)more, more);
 	return 0;
 }
 


Commit: c3be6f7f2b025886489e08d74c8248f883c609bf
    https://github.com/scummvm/scummvm/commit/c3be6f7f2b025886489e08d74c8248f883c609bf
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:06+02:00

Commit Message:
HDB: Add Inventory functions

Changed paths:
    engines/hdb/ai-inventory.cpp
    engines/hdb/ai.h


diff --git a/engines/hdb/ai-inventory.cpp b/engines/hdb/ai-inventory.cpp
index cfa45e3..0325d3b 100644
--- a/engines/hdb/ai-inventory.cpp
+++ b/engines/hdb/ai-inventory.cpp
@@ -79,6 +79,11 @@ bool AI::addToInventory(AIEntity *e) {
 	return true;
 }
 
+void AI::purgeInventory() {
+	memset(&_inventory, 0, sizeof(InvEnt) * kMaxInventory);
+	_numInventory = 0;
+}
+
 // Clear out the Player inventory except Gems,
 // Monkeystones and Goo Cups unless its marked
 void AI::clearInventory() {
@@ -105,6 +110,167 @@ AIEntity *AI::getInvItem(int which) {
 	return _inventory[which].ent;
 }
 
+int AI::queryInventory(const char *string) {
+	int		i, count;
+
+	if (!scumm_stricmp(string, "monkeystone"))
+		return getMonkeystoneAmount();
+	if (!scumm_stricmp(string, "goo"))
+		return getGooCupAmount();
+	if (!scumm_stricmp(string, "gem"))
+		return getGemAmount();
+
+	if (!_numInventory)
+		return 0;
+
+	count = 0;
+	for (i = _numInventory - 1; i >= 0; i--)
+		if (_inventory[i].ent->entityName && strstr(_inventory[i].ent->entityName, string))
+			count++;
+
+	return count;
+}
+
+bool AI::removeInvItem(const char *string, int amount) {
+	int		i, j;
+	int		found;
+
+	// Check specially for Gems, Monkeystones and Goo Cups
+	if (!scumm_stricmp(string, "gem")) {
+		_numGems -= amount;
+		return true;
+	} else if (!scumm_stricmp(string, "monkeystone")) {
+		_numMonkeystones -= amount;
+		return true;
+	} else if (!scumm_stricmp(string, "goo")) {
+		_numGooCups -= amount;
+		return true;
+	}
+
+	if (!_numInventory)
+		return false;
+
+	do {
+		found = 0;
+
+		for (i = _numInventory - 1; i >= 0; i--)
+			if (_inventory[i].ent->entityName && strstr(_inventory[i].ent->entityName, string)) {
+				j = i;
+				memset(&_inventory[j], 0, sizeof(InvEnt));
+				while (j < _numInventory - 1) {
+					memcpy(&_inventory[j], &_inventory[j + 1], sizeof(InvEnt));
+					memset(&_inventory[j + 1], 0, sizeof(InvEnt));
+					j++;
+				}
+				_numInventory--;
+				amount--;
+				found = 1;
+				if (!amount)
+					break;
+			}
+	} while (found && amount);
+
+	// if we haven't removed them all, return false
+	if (amount)
+		return false;
+
+	return true;
+}
+
+int AI::queryInventoryType(AIType which) {
+	int		i, count;
+
+	if (which == ITEM_MONKEYSTONE)
+		return getMonkeystoneAmount();
+	if (which == ITEM_GOO_CUP)
+		return getGooCupAmount();
+	if (which == ITEM_GEM_WHITE)
+		return getGemAmount();
+
+	if (!_numInventory)
+		return 0;
+
+	count = 0;
+	for (i = 0; i < _numInventory; i++)
+		if (_inventory[i].ent->type == which)
+			count++;
+
+	return count;
+}
+
+bool AI::removeInvItemType(AIType which, int amount) {
+	int		i, j, found;
+
+	// Check specially for Gems, Monkeystones and Goo Cups
+	if (which == ITEM_GEM_WHITE) {
+		_numGems -= amount;
+		return true;
+	} else if (which == ITEM_MONKEYSTONE) {
+		_numMonkeystones -= amount;
+		return true;
+	} else if (which == ITEM_GOO_CUP) {
+		_numGooCups -= amount;
+		return true;
+	}
+
+	if (!_numInventory)
+		return false;
+
+	do {
+		found = 0;
+
+		for (i = 0; i < _numInventory; i++)
+			if (_inventory[i].ent->type == which) {
+				j = i;
+				memset(&_inventory[j], 0, sizeof(InvEnt));
+				while (j < _numInventory - 1) {
+					memcpy(&_inventory[j], &_inventory[j + 1], sizeof(InvEnt));
+					memset(&_inventory[j + 1], 0, sizeof(InvEnt));
+					j++;
+				}
+				_numInventory--;
+				amount--;
+				found = 1;
+				if (!amount)
+					break;
+			}
+	} while (found && amount);
+
+	// if we haven't removed them all, return false
+	if (amount)
+		return false;
+
+	return true;
+}
+
+bool AI::addItemToInventory(AIType type, int amount, char *funcInit, char *funcAction, char *funcUse) {
+	int		i;
+	AIEntity *e;
+	for (i = 0; i < amount; i++) {
+		spawn(type, DIR_UP, 0, 0, funcInit, funcAction, funcUse, DIR_UP, 1, 0, 0, 1);
+		e = findEntity(0, 0);
+		if (!e)
+			return false;
+		if (!addToInventory(e))
+			return false;
+	}
+	return true;
+}
+
+void AI::keepInvItem(AIType type) {
+	for (int i = 0; i < _numInventory; i++)
+		if (_inventory[i].ent->type == type)
+			_inventory[i].keep = 1;
+}
+
+void AI::printYouGotMsg(const char *name) {
+	if (!name || !name[0])
+		return;
+
+	sprintf(_youGotBuffer, "Got %s", name);
+	g_hdb->_window->textOut(_youGotBuffer, kYouGotX, kYouGotY, 120);
+}
+
 void AI::newDelivery(const char *itemTextName, const char *itemGfxName, const char *destTextName, const char *destGfxName, const char *id) {
 	int i = _numDeliveries;
 
diff --git a/engines/hdb/ai.h b/engines/hdb/ai.h
index 31a6766..27fcddf 100644
--- a/engines/hdb/ai.h
+++ b/engines/hdb/ai.h
@@ -46,7 +46,9 @@ enum {
 	kPushMoveSpeed = (kPlayerMoveSpeed >> 1),
 	kPlayerTouchPWait = 16,
 	kMaxCineGfx = 10,
-	kRunToggleDelay = 2
+	kRunToggleDelay = 2,
+	kYouGotX = -1,
+	kYouGotY = (kScreenHeight - 16)
 };
 
 enum AIType {
@@ -917,6 +919,7 @@ public:
 
 	// Inventory Functions
 	bool addToInventory(AIEntity *e);
+	void purgeInventory();
 	void clearInventory();
 	int getInvAmount() {
 		return _numInventory;
@@ -933,8 +936,24 @@ public:
 	void setGemAmount(int amt) {
 		_numGems = amt;
 	}
+	int getInvMax() {
+		return _numInventory;
+	}
+	AIType getInvItemType(int which) {
+		return _inventory[which].ent->type;
+	}
+	Tile *getInvItemGfx(int which) {
+		return _inventory[which].ent->standdownGfx[0];
+	}
 
 	AIEntity *getInvItem(int which);
+	int queryInventory(const char *string);
+	bool removeInvItem(const char *string, int amount);
+	int queryInventoryType(AIType which);
+	bool removeInvItemType(AIType which, int amount);
+	bool addItemToInventory(AIType type, int amount, char *funcInit, char *funcAction, char *funcUse);
+	void keepInvItem(AIType type);
+	void printYouGotMsg(const char *name);
 
 	// Delivery Functions
 	void newDelivery(const char *itemTextName, const char *itemGfxName, const char *destTextName, const char *destGfxName, const char *id);
@@ -1124,6 +1143,8 @@ public:
 	// Virtual Player
 	AIEntity _dummyPlayer, _dummyLaser;
 
+	char _youGotBuffer[32];	// For printing the text of entities that are removed
+
 	// Cinematic Variables
 	Common::Array<CineCommand *> _cine;
 


Commit: f2150cd89a07e0607976a2fe580ffec8367bfd45
    https://github.com/scummvm/scummvm/commit/f2150cd89a07e0607976a2fe580ffec8367bfd45
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:06+02:00

Commit Message:
HDB: Add functions for Lua Entities

Changed paths:
    engines/hdb/ai-funcs.cpp
    engines/hdb/ai.h


diff --git a/engines/hdb/ai-funcs.cpp b/engines/hdb/ai-funcs.cpp
index f3686ef..ff336bc 100644
--- a/engines/hdb/ai-funcs.cpp
+++ b/engines/hdb/ai-funcs.cpp
@@ -596,6 +596,71 @@ void AI::getEntityXY(const char *entName, int *x, int *y) {
 	}
 }
 
+bool AI::useLuaEntity(const char *initName) {
+	AIEntity *e;
+
+	for (Common::Array<AIEntity *>::iterator it = _ents->begin(); it != _ents->end(); it++) {
+		e = *it;
+		if (e->entityName && !scumm_stricmp(initName, e->entityName)) {
+			e->aiUse(e);
+			checkActionList(e, e->tileX, e->tileY, true);
+			if (e->luaFuncUse)
+				g_hdb->_lua->callFunction(e->luaFuncUse, 0);
+			return true;
+		}
+	}
+
+	// Check _actions list for activation as well
+	for (int i = 0; i < kMaxActions; i++) {
+		if (_actions[i].entityName && !scumm_stricmp(initName, _actions[i].entityName)) {
+			checkActionList(&_dummyPlayer, _actions[i].x1, _actions[i].y1, false);
+			checkActionList(&_dummyPlayer, _actions[i].x2, _actions[i].y2, false);
+		}
+	}
+
+	return false;
+}
+
+void AI::removeLuaEntity(const char *initName) {
+	AIEntity *e;
+
+	for (uint i = 0; i < _ents->size(); i++) {
+		e = *(_ents->begin() + i);
+		if (e->entityName && !scumm_stricmp(initName, e->entityName)) {
+			removeEntity(*(_ents->begin() + i));
+			i--;
+		}
+	}
+}
+
+void AI::animLuaEntity(const char *initName, AIState st) {
+	AIEntity *e;
+
+	for (Common::Array<AIEntity *>::iterator it = _ents->begin(); it != _ents->end(); it++) {
+		e = *it;
+		if (e->entityName && !scumm_stricmp(initName, e->entityName)) {
+			e->state = st;
+			e->animFrame = 0;
+			e->animDelay = e->animCycle;
+		}
+	}
+}
+
+void AI::setLuaAnimFrame(const char *initName, AIState st, int frame) {
+	AIEntity *e;
+
+	for (Common::Array<AIEntity *>::iterator it = _ents->begin(); it != _ents->end(); it++) {
+		e = *it;
+		if (e->entityName && !scumm_stricmp(initName, e->entityName)) {
+			e->state = st;
+			e->animFrame = frame;
+			e->animDelay = e->animCycle;
+			animEntFrames(e);
+			e->state = STATE_NONE;
+		}
+	}
+}
+
 void AI::removeEntity(AIEntity *e) {
 	_ents->erase(&e);
 }
diff --git a/engines/hdb/ai.h b/engines/hdb/ai.h
index 27fcddf..ccd9aed 100644
--- a/engines/hdb/ai.h
+++ b/engines/hdb/ai.h
@@ -742,6 +742,10 @@ public:
 	AIEntity *findEntityIgnore(int x, int y, AIEntity *ignore);
 	AIEntity *findEntityType(AIType type, int x, int y);
 	void getEntityXY(const char *entName, int *x, int *y);
+	bool useLuaEntity(const char *initName);
+	void removeLuaEntity(const char *initName);
+	void animLuaEntity(const char *initName, AIState st);
+	void setLuaAnimFrame(const char *initName, AIState st, int frame);
 	void removeEntity(AIEntity *e);
 	void setEntityGoal(AIEntity *e, int x, int y);
 	void initAllEnts();
@@ -753,7 +757,6 @@ public:
 
 	void animateEntity(AIEntity *e);
 	void animEntFrames(AIEntity *e);
-	void animLuaEntity(const char *initName, AIState st);
 	void drawEnts(int x, int y, int w, int h);
 	void drawLevel2Ents();
 	void animGrabbing();


Commit: 016e0baca8bbdb6e172c3731da0b88beef3b934c
    https://github.com/scummvm/scummvm/commit/016e0baca8bbdb6e172c3731da0b88beef3b934c
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:06+02:00

Commit Message:
HDB: Add entityFace()

Changed paths:
    engines/hdb/ai-funcs.cpp
    engines/hdb/ai.h


diff --git a/engines/hdb/ai-funcs.cpp b/engines/hdb/ai-funcs.cpp
index ff336bc..a59e468 100644
--- a/engines/hdb/ai-funcs.cpp
+++ b/engines/hdb/ai-funcs.cpp
@@ -1619,16 +1619,6 @@ void AI::animEntFrames(AIEntity *e) {
 	}
 }
 
-void AI::animLuaEntity(const char *initName, AIState st) {
-	for (Common::Array<AIEntity *>::iterator it = _ents->begin(); it != _ents->end(); it++) {
-		if (Common::matchString((*it)->entityName, initName)) {
-			(*it)->state = st;
-			(*it)->animFrame = 0;
-			(*it)->animDelay = (*it)->animCycle;
-		}
-	}
-}
-
 void AI::drawEnts(int x, int y, int w, int h) {
 
 	static int stunAnim = 0;
@@ -1814,6 +1804,19 @@ void AI::animGrabbing() {
 	_player->animFrame = 5;
 }
 
+void AI::entityFace(const char *luaName, int dir) {
+	AIEntity *e = locateEntity(luaName);
+	e->dir = (AIDir)dir;
+
+	switch (e->dir) {
+	case DIR_UP: e->state = STATE_STANDUP; break;
+	case DIR_DOWN: e->state = STATE_STANDDOWN; break;
+	case DIR_LEFT: e->state = STATE_STANDLEFT; break;
+	case DIR_RIGHT: e->state = STATE_STANDRIGHT; break;
+	case DIR_NONE: break;
+	}
+}
+
 void AI::moveEnts() {
 	static int frameDelay = kAnimFrameDelay;
 	AIEntity *e;
diff --git a/engines/hdb/ai.h b/engines/hdb/ai.h
index ccd9aed..4e42487 100644
--- a/engines/hdb/ai.h
+++ b/engines/hdb/ai.h
@@ -760,6 +760,7 @@ public:
 	void drawEnts(int x, int y, int w, int h);
 	void drawLevel2Ents();
 	void animGrabbing();
+	void entityFace(const char *luaName, int dir);
 
 	void moveEnts();
 


Commit: c4dbb0967515852d87987baba2af5f7273e70aaa
    https://github.com/scummvm/scummvm/commit/c4dbb0967515852d87987baba2af5f7273e70aaa
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:06+02:00

Commit Message:
HDB: Add Lua functions for Deliveries

Changed paths:
    engines/hdb/lua-script.cpp


diff --git a/engines/hdb/lua-script.cpp b/engines/hdb/lua-script.cpp
index 2a3b032..031ce55 100644
--- a/engines/hdb/lua-script.cpp
+++ b/engines/hdb/lua-script.cpp
@@ -428,18 +428,39 @@ static int cineCenterTextOut(lua_State *L) {
 }
 
 static int newDelivery(lua_State *L) {
-	warning("STUB: NEW DELIVERY");
+	const char *itemTextName, *itemGfxName;
+	const char *destTextName, *destGfxName, *id;
+
+	itemTextName = lua_tostring(L, 1);
+	itemGfxName = lua_tostring(L, 2);
+	destTextName = lua_tostring(L, 3);
+	destGfxName = lua_tostring(L, 4);
+	id = lua_tostring(L, 5);
+
+	g_hdb->_lua->checkParameters("newDelivery", 5);
+
+	lua_pop(L, 5);
+
+	g_hdb->_ai->newDelivery(itemTextName, itemGfxName, destTextName, destGfxName, id);
+
 	return 0;
 }
 
 static int completeDelivery(lua_State *L) {
-	warning("STUB: COMPLETE DELIVERY");
-	return 0;
+	const char *id = lua_tostring(L, 1);
+	double rtn = g_hdb->_ai->completeDelivery(id);
+
+	g_hdb->_lua->checkParameters("completeDelivery", 1);
+
+	lua_pop(L, 1);
+	lua_pushnumber(L, rtn);
+	return 1;
 }
 
 static int deliveriesLeft(lua_State *L) {
-	warning("STUB: DELIVERIES LEFT");
-	return 0;
+	double	value = (double)g_hdb->_ai->getDeliveriesAmount();
+	lua_pushnumber(L, value);
+	return 1;
 }
 
 static int getEntityXY(lua_State *L) {


Commit: e895a0929bd3acfccf8b3dd5a8eea617d629e04f
    https://github.com/scummvm/scummvm/commit/e895a0929bd3acfccf8b3dd5a8eea617d629e04f
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:06+02:00

Commit Message:
HDB: Add Lua function for setEntDir()

Changed paths:
    engines/hdb/lua-script.cpp


diff --git a/engines/hdb/lua-script.cpp b/engines/hdb/lua-script.cpp
index 031ce55..e8abd34 100644
--- a/engines/hdb/lua-script.cpp
+++ b/engines/hdb/lua-script.cpp
@@ -505,7 +505,25 @@ static int setEntity(lua_State *L) {
 }
 
 static int setEntDir(lua_State *L) {
-	warning("STUB: SET ENTITY DIR");
+	AIEntity *e;
+	char buff[64];
+
+	const char *entName = lua_tostring(L, 1);
+	double d = lua_tonumber(L, 2);
+
+	g_hdb->_lua->checkParameters("setEntDir", 2);
+
+	lua_pop(L, 2);
+	e = g_hdb->_ai->locateEntity(entName);
+
+	if (e) {
+		int	dd = (int)d;
+		e->dir = (AIDir)dd;
+	} else {
+		sprintf(buff, "Could not SetEntDir on '%s'", entName);
+		g_hdb->_window->openMessageBar(buff, 10);
+	}
+
 	return 0;
 }
 


Commit: a07cbc0dd1c9ca5518389376e0ec4711af403336
    https://github.com/scummvm/scummvm/commit/a07cbc0dd1c9ca5518389376e0ec4711af403336
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:06+02:00

Commit Message:
HDB: Add Lua functions for Entities + entityFace()

Changed paths:
    engines/hdb/lua-script.cpp


diff --git a/engines/hdb/lua-script.cpp b/engines/hdb/lua-script.cpp
index e8abd34..348f749 100644
--- a/engines/hdb/lua-script.cpp
+++ b/engines/hdb/lua-script.cpp
@@ -528,7 +528,14 @@ static int setEntDir(lua_State *L) {
 }
 
 static int removeEntity(lua_State *L) {
-	warning("STUB: REMOVE ENTITY");
+	const char *entName = lua_tostring(L, 1);
+
+	g_hdb->_lua->checkParameters("removeEntity", 1);
+
+	lua_pop(L, 1);
+
+	g_hdb->_ai->removeLuaEntity(entName);
+
 	return 0;
 }
 
@@ -545,17 +552,42 @@ static int animEntity(lua_State *L) {
 }
 
 static int setAnimFrame(lua_State *L) {
-	warning("STUB: SET ANIM FRAME");
+	const char *entName = lua_tostring(L, 1);
+	double	state = lua_tonumber(L, 2);
+	double	frame = lua_tonumber(L, 3);
+
+	g_hdb->_lua->checkParameters("setAnimFrame", 3);
+
+	lua_pop(L, 3);
+
+	int	s = (int)state;
+	g_hdb->_ai->setLuaAnimFrame(entName, (AIState)s, (int)frame);
+
 	return 0;
 }
 
 static int useEntity(lua_State *L) {
-	warning("STUB: USE ENTITY");
+	const char *initName = lua_tostring(L, 1);
+
+	g_hdb->_lua->checkParameters("useEntity", 1);
+
+	lua_pop(L, 1);
+
+	g_hdb->_ai->useLuaEntity(initName);
+
 	return 0;
 }
 
 static int entityFace(lua_State *L) {
-	warning("STUB: ENTITY FACE");
+	const char *initName = lua_tostring(L, 1);
+	double dir = lua_tonumber(L, 2);
+
+	g_hdb->_lua->checkParameters("entityFace", 2);
+
+	lua_pop(L, 2);
+
+	g_hdb->_ai->entityFace(initName, (int)dir);
+
 	return 0;
 }
 


Commit: a5ba855dd2718f971ef71402588fe11441564e44
    https://github.com/scummvm/scummvm/commit/a5ba855dd2718f971ef71402588fe11441564e44
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:06+02:00

Commit Message:
HDB: Add lua function for clearForeground()

Changed paths:
    engines/hdb/lua-script.cpp


diff --git a/engines/hdb/lua-script.cpp b/engines/hdb/lua-script.cpp
index 348f749..ea77a04 100644
--- a/engines/hdb/lua-script.cpp
+++ b/engines/hdb/lua-script.cpp
@@ -592,7 +592,16 @@ static int entityFace(lua_State *L) {
 }
 
 static int clearForeground(lua_State *L) {
-	warning("STUB: CLEAR FOREGROUND");
+	double x = lua_tonumber(L, 1);
+	double y = lua_tonumber(L, 2);
+
+	g_hdb->_lua->checkParameters("clearForegnd", 2);
+
+	lua_pop(L, 2);
+
+	g_hdb->_map->setMapFGTileIndex((int)x, (int)y, -1);
+	g_hdb->_map->removeFGTileAnimation((int)x, (int)y);
+
 	return 0;
 }
 


Commit: 50d297637f5b887a96d52543de73349bdaae3cf1
    https://github.com/scummvm/scummvm/commit/50d297637f5b887a96d52543de73349bdaae3cf1
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:06+02:00

Commit Message:
HDB: Add Lua function for animation()

Changed paths:
    engines/hdb/lua-script.cpp


diff --git a/engines/hdb/lua-script.cpp b/engines/hdb/lua-script.cpp
index ea77a04..a9256d4 100644
--- a/engines/hdb/lua-script.cpp
+++ b/engines/hdb/lua-script.cpp
@@ -666,7 +666,50 @@ static int message(lua_State *L) {
 }
 
 static int animation(lua_State *L) {
-	warning("STUB: ANIMATION");
+	double	x = lua_tonumber(L, 1);
+	double	y = lua_tonumber(L, 2);
+	double	which = lua_tonumber(L, 3);
+	double	playsnd = lua_tonumber(L, 4);
+
+	g_hdb->_lua->checkParameters("animation", 4);
+
+	x *= kTileWidth;
+	y *= kTileHeight;
+
+	switch ((int)which) {
+	case 0:
+		g_hdb->_ai->addAnimateTarget((int)x, (int)y, 0, 3, ANIM_NORMAL, false, false, GROUP_WATER_SPLASH_SIT);
+		if (playsnd)
+			warning("STUB: Play SND_SPLASH");
+		break;
+	case 1:
+		g_hdb->_ai->addAnimateTarget((int)x, (int)y, 0, 3, ANIM_NORMAL, false, false, GROUP_EXPLOSION_BOOM_SIT);
+		if (playsnd)
+			warning("STUB: Play SND_BARREL_EXPLODE");
+		break;
+	case 2:
+		g_hdb->_ai->addAnimateTarget((int)x, (int)y, 0, 3, ANIM_FAST, false, false, GROUP_STEAM_PUFF_SIT);
+		if (playsnd)
+			warning("STUB: Play SND_BARREL_MELTING");
+		break;
+	case 3:
+		g_hdb->_ai->addAnimateTarget((int)x, (int)y, 0, 7, ANIM_NORMAL, false, false, TELEPORT_FLASH);
+		if (playsnd)
+			warning("STUB: Play SND_TELEPORT");
+		break;
+	case 4:
+		g_hdb->_ai->addAnimateTarget((int)x, (int)y, 0, 3, ANIM_NORMAL, false, false, GEM_FLASH);
+		if (playsnd)
+			warning("STUB: Play SND_GET_GEM");
+		break;
+	case 5:
+		g_hdb->_ai->addAnimateTarget((int)x, (int)y, 0, 2, ANIM_NORMAL, false, false, GROUP_ENT_CHICKEN_DIE);
+		if (playsnd)
+			warning("STUB: Play SND_CHICKEN_DEATH");
+		break;
+	}
+
+	lua_pop(L, 3);
 	return 0;
 }
 


Commit: e441680fbf46feb7cded0b3bd213b4d53d650644
    https://github.com/scummvm/scummvm/commit/e441680fbf46feb7cded0b3bd213b4d53d650644
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:06+02:00

Commit Message:
HDB: Add Lua function for spawn()

Changed paths:
    engines/hdb/lua-script.cpp


diff --git a/engines/hdb/lua-script.cpp b/engines/hdb/lua-script.cpp
index a9256d4..6c6fbf9 100644
--- a/engines/hdb/lua-script.cpp
+++ b/engines/hdb/lua-script.cpp
@@ -714,7 +714,27 @@ static int animation(lua_State *L) {
 }
 
 static int spawnEntity(lua_State *L) {
-	warning("STUB: SPAWN ENTITY");
+	double type = lua_tonumber(L, 1);
+	double	dir = lua_tonumber(L, 2);
+	double	x = lua_tonumber(L, 3);
+	double	y = lua_tonumber(L, 4);
+	char *funcInit = (char *)lua_tostring(L, 5);
+	char *funcAction = (char *)lua_tostring(L, 6);
+	char *funcUse = (char *)lua_tostring(L, 7);
+	double	dir2 = lua_tonumber(L, 8);
+	double	level = lua_tonumber(L, 9);
+	double	value1 = lua_tonumber(L, 10);
+	double	value2 = lua_tonumber(L, 11);
+
+	int t = (int)type;
+	int d = (int)dir;
+	int d2 = (int)dir2;
+
+	g_hdb->_lua->checkParameters("spawnEntity", 11);
+
+	lua_pop(L, 11);
+
+	g_hdb->_ai->spawn((AIType)t, (AIDir)d, (int)x, (int)y, funcInit, funcAction, funcUse, (AIDir)d2, (int)level, (int)value1, (int)value2, 1);
 	return 0;
 }
 


Commit: 1ee37266b19b9ddcebfdfd2032bb06ace647be64
    https://github.com/scummvm/scummvm/commit/1ee37266b19b9ddcebfdfd2032bb06ace647be64
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:06+02:00

Commit Message:
HDB: Add Lua functions for Inventory

Changed paths:
    engines/hdb/lua-script.cpp


diff --git a/engines/hdb/lua-script.cpp b/engines/hdb/lua-script.cpp
index 6c6fbf9..b0adc96 100644
--- a/engines/hdb/lua-script.cpp
+++ b/engines/hdb/lua-script.cpp
@@ -739,38 +739,102 @@ static int spawnEntity(lua_State *L) {
 }
 
 static int addInvItem(lua_State *L) {
-	warning("STUB: ADD INVENTORY ITEM");
-	return 0;
+	double	type = lua_tonumber(L, 1);
+	double	amount = lua_tonumber(L, 2);
+	char *funcInit = (char *)lua_tostring(L, 3);
+	char *funcAction = (char *)lua_tostring(L, 4);
+	char *funcUse = (char *)lua_tostring(L, 5);
+
+	int t = (int)type;
+
+	g_hdb->_lua->checkParameters("addInvItem", 5);
+
+	lua_pop(L, 5);
+
+	bool rtn = g_hdb->_ai->addItemToInventory((AIType)t, (int)amount, funcInit, funcAction, funcUse);
+
+	lua_pushnumber(L, rtn);
+	return 1;
 }
 
 static int keepInvItem(lua_State *L) {
-	warning("STUB: KEEP INVENTORY ITEM");
+	double type = lua_tonumber(L, 1);
+	int t = (int)type;
+
+	g_hdb->_lua->checkParameters("keepInvItem", 1);
+
+	lua_pop(L, 1);
+
+	g_hdb->_ai->keepInvItem((AIType)t);
 	return 0;
 }
 
 static int queryInv(lua_State *L) {
-	warning("STUB: QUERY INVENTORY");
-	return 0;
+	const char *search;
+	int	result;
+
+	search = lua_tostring(L, 1);		// get the passed-in search string
+
+	g_hdb->_lua->checkParameters("queryInv", 1);
+
+	lua_pop(L, 1);
+
+	result = g_hdb->_ai->queryInventory(search);			// call the function & get return value
+	lua_pushnumber(L, result);					// send the return value back to Lua
+	return 1;
 }
 
 static int purgeInv(lua_State *L) {
-	warning("STUB: PURGE INVENTORY");
+	g_hdb->_ai->purgeInventory();
 	return 0;
 }
 
 static int queryInvItem(lua_State *L) {
-	warning("STUB: QUERY INVENTORY ITEM");
-	return 0;
+	double	search;
+	int	result, s1;
+
+	search = lua_tonumber(L, 1);					// get the passed-in search string
+	s1 = (int)search;
+
+	g_hdb->_lua->checkParameters("queryInvItem", 1);
+
+	lua_pop(L, 1);
+
+	result = g_hdb->_ai->queryInventoryType((AIType)s1);	// call the function & get return value
+	lua_pushnumber(L, result);					// send the return value back to Lua
+	return 1;
 }
 
 static int removeInv(lua_State *L) {
-	warning("STUB: REMOVE INVENTORY");
-	return 0;
+	const char *search;
+	int	result;
+
+	search = lua_tostring(L, 1);		// get the passed-in search string
+	double number = lua_tonumber(L, 2);
+
+	g_hdb->_lua->checkParameters("removeInv", 2);
+
+	lua_pop(L, 2);
+
+	result = (int)g_hdb->_ai->removeInvItem(search, (int)number);	// call the function & get return value
+	lua_pushnumber(L, result);					// send the return value back to Lua
+	return 1;
 }
 
 static int removeInvItem(lua_State *L) {
-	warning("STUB: REMOVE INVENTORY ITEM");
-	return 0;
+	int	result;
+
+	double	search = lua_tonumber(L, 1);		// get the passed-in type value
+	double	number = lua_tonumber(L, 2);
+
+	g_hdb->_lua->checkParameters("removeInvItem", 2);
+
+	lua_pop(L, 2);
+
+	int	s = (int)search;
+	result = (int)g_hdb->_ai->removeInvItemType((AIType)s, (int)number);	// call the function & get return value
+	lua_pushnumber(L, result);					// send the return value back to Lua
+	return 1;
 }
 
 static int killTrigger(lua_State *L) {


Commit: aadc58ca474d2e99a9246f3e0fc581a2fa034812
    https://github.com/scummvm/scummvm/commit/aadc58ca474d2e99a9246f3e0fc581a2fa034812
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:06+02:00

Commit Message:
HDB: Add Lua function for killTrigger()

Changed paths:
    engines/hdb/lua-script.cpp


diff --git a/engines/hdb/lua-script.cpp b/engines/hdb/lua-script.cpp
index b0adc96..f9d0aa7 100644
--- a/engines/hdb/lua-script.cpp
+++ b/engines/hdb/lua-script.cpp
@@ -838,7 +838,12 @@ static int removeInvItem(lua_State *L) {
 }
 
 static int killTrigger(lua_State *L) {
-	warning("STUB: KILL TRIGGER");
+	char *id = (char *)lua_tostring(L, 1);
+
+	g_hdb->_lua->checkParameters("killTrigger", 1);
+
+	lua_pop(L, 1);
+	g_hdb->_ai->killTrigger(id);
 	return 0;
 }
 


Commit: 84216491421b6c98451c5f7884c509e836b32530
    https://github.com/scummvm/scummvm/commit/84216491421b6c98451c5f7884c509e836b32530
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:06+02:00

Commit Message:
HDB: Add Lua functions for textOut

Changed paths:
    engines/hdb/lua-script.cpp


diff --git a/engines/hdb/lua-script.cpp b/engines/hdb/lua-script.cpp
index f9d0aa7..69e43fa 100644
--- a/engines/hdb/lua-script.cpp
+++ b/engines/hdb/lua-script.cpp
@@ -903,12 +903,27 @@ static int purgeGlobals(lua_State *L) {
 }
 
 static int textOut(lua_State *L) {
-	warning("STUB: TEXT OUT");
+	const char *string = lua_tostring(L, 1);
+	double	x = lua_tonumber(L, 2);
+	double	y = lua_tonumber(L, 3);
+	double	timer = lua_tonumber(L, 4);
+
+	g_hdb->_lua->checkParameters("textOut", 4);
+
+	lua_pop(L, 4);
+	g_hdb->_window->textOut(string, (int)x, (int)y, (int)timer);
 	return 0;
 }
 
 static int centerTextOut(lua_State *L) {
-	warning("STUB: CENTER TEXT OUT");
+	const char *string = lua_tostring(L, 1);
+	double	y = lua_tonumber(L, 2);
+	double	timer = lua_tonumber(L, 3);
+
+	g_hdb->_lua->checkParameters("centerTextOut", 3);
+
+	lua_pop(L, 3);
+	g_hdb->_window->centerTextOut(string, (int)y, (int)timer);
 	return 0;
 }
 


Commit: 2cd3bbe2304117a8c0a4cb27f365814c2c9f6f58
    https://github.com/scummvm/scummvm/commit/2cd3bbe2304117a8c0a4cb27f365814c2c9f6f58
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:06+02:00

Commit Message:
HDB: Add Lua function for setPointerState()

Changed paths:
    engines/hdb/lua-script.cpp


diff --git a/engines/hdb/lua-script.cpp b/engines/hdb/lua-script.cpp
index 69e43fa..40582a5 100644
--- a/engines/hdb/lua-script.cpp
+++ b/engines/hdb/lua-script.cpp
@@ -955,7 +955,13 @@ static int setInfobarDark(lua_State *L) {
 }
 
 static int setPointerState(lua_State *L) {
-	warning("STUB: SET POINTER STATE");
+	double	value = lua_tonumber(L, 1);
+
+	g_hdb->_lua->checkParameters("setPointerState", 1);
+
+	lua_pop(L, 1);
+
+	g_hdb->_drawMan->setPointerState((int)value);
 	return 0;
 }
 


Commit: f9c560fd9a5630e25280150dbeca049a9ffaec24
    https://github.com/scummvm/scummvm/commit/f9c560fd9a5630e25280150dbeca049a9ffaec24
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:06+02:00

Commit Message:
HDB: Fix warnings, const'ness

Changed paths:
    engines/hdb/ai-funcs.cpp
    engines/hdb/ai-inventory.cpp
    engines/hdb/ai-lists.cpp
    engines/hdb/ai.h
    engines/hdb/lua-script.cpp


diff --git a/engines/hdb/ai-funcs.cpp b/engines/hdb/ai-funcs.cpp
index a59e468..da4efc0 100644
--- a/engines/hdb/ai-funcs.cpp
+++ b/engines/hdb/ai-funcs.cpp
@@ -24,7 +24,7 @@
 
 namespace HDB {
 
-AIEntity *AI::spawn(AIType type, AIDir dir, int x, int y, char *funcInit, char *funcAction, char *funcUse, AIDir dir2, int level, int value1, int value2, int callInit) {
+AIEntity *AI::spawn(AIType type, AIDir dir, int x, int y, const char *funcInit, const char *funcAction, const char *funcUse, AIDir dir2, int level, int value1, int value2, int callInit) {
 	AIEntity *e = new AIEntity;
 
 	e->type = type;
diff --git a/engines/hdb/ai-inventory.cpp b/engines/hdb/ai-inventory.cpp
index 0325d3b..48ce48f 100644
--- a/engines/hdb/ai-inventory.cpp
+++ b/engines/hdb/ai-inventory.cpp
@@ -243,7 +243,7 @@ bool AI::removeInvItemType(AIType which, int amount) {
 	return true;
 }
 
-bool AI::addItemToInventory(AIType type, int amount, char *funcInit, char *funcAction, char *funcUse) {
+bool AI::addItemToInventory(AIType type, int amount, const char *funcInit, const char *funcAction, const char *funcUse) {
 	int		i;
 	AIEntity *e;
 	for (i = 0; i < amount; i++) {
diff --git a/engines/hdb/ai-lists.cpp b/engines/hdb/ai-lists.cpp
index ff0ecfb..b60013a 100644
--- a/engines/hdb/ai-lists.cpp
+++ b/engines/hdb/ai-lists.cpp
@@ -762,7 +762,7 @@ bool AI::checkTriggerList(char *entName, int x, int y) {
 	return false;
 }
 
-void AI::killTrigger(char *id) {
+void AI::killTrigger(const char *id) {
 	for (Common::Array<Trigger *>::iterator it = _triggerList->begin(); it != _triggerList->end(); it++) {
 		if (!scumm_stricmp(id, (*it)->id))
 			_triggerList->erase(it);
diff --git a/engines/hdb/ai.h b/engines/hdb/ai.h
index 4e42487..bf6503f 100644
--- a/engines/hdb/ai.h
+++ b/engines/hdb/ai.h
@@ -734,7 +734,7 @@ public:
 	void initAnimInfo();
 
 	// Entity Functions
-	AIEntity *spawn(AIType type, AIDir dir, int x, int y, char *funcInit, char *funcAction, char *funcUse, AIDir dir2, int level, int value1, int value2, int callInit);
+	AIEntity *spawn(AIType type, AIDir dir, int x, int y, const char *funcInit, const char *funcAction, const char *funcUse, AIDir dir2, int level, int value1, int value2, int callInit);
 	bool cacheEntGfx(AIEntity *e, bool init);
 	void stopEntity(AIEntity *e);
 	AIEntity *locateEntity(const char *luaName);
@@ -798,7 +798,7 @@ public:
 	ArrowPath *findArrowPath(int x, int y);
 	void addToTriggerList(char *luaFuncInit, char *luaFuncUse, int x, int y, int value1, int value2, char *id);
 	bool checkTriggerList(char *entName, int x, int y);
-	void killTrigger(char *id);
+	void killTrigger(const char *id);
 
 	void floatEntity(AIEntity *e, AIState state);
 	bool checkFloating(int x, int y);
@@ -955,7 +955,7 @@ public:
 	bool removeInvItem(const char *string, int amount);
 	int queryInventoryType(AIType which);
 	bool removeInvItemType(AIType which, int amount);
-	bool addItemToInventory(AIType type, int amount, char *funcInit, char *funcAction, char *funcUse);
+	bool addItemToInventory(AIType type, int amount, const char *funcInit, const char *funcAction, const char *funcUse);
 	void keepInvItem(AIType type);
 	void printYouGotMsg(const char *name);
 
diff --git a/engines/hdb/lua-script.cpp b/engines/hdb/lua-script.cpp
index 40582a5..72214b0 100644
--- a/engines/hdb/lua-script.cpp
+++ b/engines/hdb/lua-script.cpp
@@ -651,7 +651,7 @@ static int dialog(lua_State *L) {
 
 	lua_pop(L, 4);
 	if (string)
-		g_hdb->_window->openDialog(title, (int)tileIndex, string, (int)more, more);
+		g_hdb->_window->openDialog(title, (int)tileIndex, string, more ? 1 : 0, more);
 	return 0;
 }
 
@@ -718,9 +718,9 @@ static int spawnEntity(lua_State *L) {
 	double	dir = lua_tonumber(L, 2);
 	double	x = lua_tonumber(L, 3);
 	double	y = lua_tonumber(L, 4);
-	char *funcInit = (char *)lua_tostring(L, 5);
-	char *funcAction = (char *)lua_tostring(L, 6);
-	char *funcUse = (char *)lua_tostring(L, 7);
+	const char *funcInit = lua_tostring(L, 5);
+	const char *funcAction = lua_tostring(L, 6);
+	const char *funcUse = lua_tostring(L, 7);
 	double	dir2 = lua_tonumber(L, 8);
 	double	level = lua_tonumber(L, 9);
 	double	value1 = lua_tonumber(L, 10);
@@ -741,9 +741,9 @@ static int spawnEntity(lua_State *L) {
 static int addInvItem(lua_State *L) {
 	double	type = lua_tonumber(L, 1);
 	double	amount = lua_tonumber(L, 2);
-	char *funcInit = (char *)lua_tostring(L, 3);
-	char *funcAction = (char *)lua_tostring(L, 4);
-	char *funcUse = (char *)lua_tostring(L, 5);
+	const char *funcInit = lua_tostring(L, 3);
+	const char *funcAction = lua_tostring(L, 4);
+	const char *funcUse = lua_tostring(L, 5);
 
 	int t = (int)type;
 
@@ -838,7 +838,7 @@ static int removeInvItem(lua_State *L) {
 }
 
 static int killTrigger(lua_State *L) {
-	char *id = (char *)lua_tostring(L, 1);
+	const char *id = lua_tostring(L, 1);
 
 	g_hdb->_lua->checkParameters("killTrigger", 1);
 


Commit: d93e0a2d615f233e5a004723f3195ce86e0345ad
    https://github.com/scummvm/scummvm/commit/d93e0a2d615f233e5a004723f3195ce86e0345ad
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:06+02:00

Commit Message:
HDB: Clip to screen when rendering text. This prevents crash when aborting the cinematics

Changed paths:
    engines/hdb/draw-manager.cpp


diff --git a/engines/hdb/draw-manager.cpp b/engines/hdb/draw-manager.cpp
index 1b53a5e..852718f 100644
--- a/engines/hdb/draw-manager.cpp
+++ b/engines/hdb/draw-manager.cpp
@@ -572,7 +572,13 @@ void DrawMan::drawText(const char *string) {
 
 		// Blit the character
 		g_hdb->_drawMan->_globalSurface.transBlitFrom(_fontSurfaces[c], Common::Point(_cursorX, _cursorY), 0xf81f);
-		g_system->copyRectToScreen(g_hdb->_drawMan->_globalSurface.getBasePtr(_cursorX, _cursorY), g_hdb->_drawMan->_globalSurface.pitch, _cursorX, _cursorY, width, _fontHeader.height);
+
+		Common::Rect clip(0, 0, width, _fontHeader.height);
+		clip.moveTo(_cursorX, _cursorY);
+		clip.clip(_globalSurface.getBounds());
+		if (!clip.isEmpty()) {
+			g_system->copyRectToScreen(g_hdb->_drawMan->_globalSurface.getBasePtr(clip.left, clip.top), g_hdb->_drawMan->_globalSurface.pitch, clip.left, clip.top, clip.width(), clip.height());
+		}
 
 		// Advance the cursor
 		_cursorX += width + _fontHeader.kerning + kFontIncrement;


Commit: 988ac1f25bf40e53ab2a606a548b1f8aab5271ca
    https://github.com/scummvm/scummvm/commit/988ac1f25bf40e53ab2a606a548b1f8aab5271ca
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:06+02:00

Commit Message:
HDB: Add _dialogChoiceInfo

Changed paths:
    engines/hdb/window.cpp
    engines/hdb/window.h


diff --git a/engines/hdb/window.cpp b/engines/hdb/window.cpp
index d71e16b..d353c8f 100644
--- a/engines/hdb/window.cpp
+++ b/engines/hdb/window.cpp
@@ -91,6 +91,7 @@ bool Window::init() {
 
 void Window::restartSystem() {
 	_dialogInfo.active = false;
+	_dialogChoiceInfo.active = false;
 	_invWinInfo.active = false;
 	_dialogDelay = _invWinInfo.selection = 0;
 	_gemGfx = g_hdb->_drawMan->loadTile("ent_gem_white_sit01");
diff --git a/engines/hdb/window.h b/engines/hdb/window.h
index 9a248e7..542f26d 100644
--- a/engines/hdb/window.h
+++ b/engines/hdb/window.h
@@ -28,6 +28,8 @@ namespace HDB {
 enum {
 	kDialogTextLeft = 64,
 	kDialogTextRight = (kDialogTextLeft + kTileWidth * 9),
+	kOpenDialogTextLeft = kDialogTextLeft,
+	kOpenDialogTextRight = (kDialogTextRight + kTileWidth * 2),
 	kWeaponX = (480 - 34),
 	kWeaponY = 2,
 	kInvItemSpaceX = 48,
@@ -56,7 +58,34 @@ struct DialogInfo {
 	int			el, er, et, eb;			// saves the text edges
 	char		luaMore[64];			// the name of the function to call after clicking the MORE button
 
-	DialogInfo() : title(""), tileIndex(0), string(""), active(false), x(0), y(0), width(0), height(0), titleWidth(0), gfx(NULL), more(0), el(0), er(0), et(0), eb(0), luaMore("") {}
+	DialogInfo() : title(""), tileIndex(0), string(""), active(false), x(0), y(0),
+		width(0), height(0), titleWidth(0), gfx(NULL), more(0), el(0), er(0), et(0),
+		eb(0), luaMore("") {}
+};
+
+struct DialogChoiceInfo {
+	char		title[64];				// TITLE string
+	char		text[160];				// actual text in the dialog
+	char		func[64];				// function to call with result
+
+	bool		active;					// is it drawing or not?
+	int			x, y;					// where to draw dialog
+	int			width, height;			// size of the dialog itself
+	int			textHeight;				// height of everything above choices
+	int			titleWidth;
+	int			el, er, et, eb;			// saves the text edges
+	uint32		timeout;				// timeout value!
+
+	int			selection;				// which choice we've made
+	int			numChoices;			// how many choices possible
+	char		choices[10][64];		// ptrs to choice text
+
+	DialogChoiceInfo() : title(""), text(""), func(""), active(false), x(0), y(0),
+		width(0), height(0), textHeight(0), titleWidth(0), el(0), er(0), et(0),
+		eb(0), timeout(0), selection(0), numChoices(0) {
+		for (int i = 0; i < 10; i++)
+			strcpy(choices[i], "");
+	}
 };
 
 struct InvWinInfo {
@@ -152,6 +181,8 @@ private:
 	DialogInfo _dialogInfo;
 	uint32 _dialogDelay;	// Used for Cinematics
 
+	DialogChoiceInfo _dialogChoiceInfo;
+
 	InvWinInfo _invWinInfo;
 	Common::Array<TOut *> _textOutList;
 	DlvsInfo _dlvsInfo;


Commit: 13102d05b02881f0037c29980d0dd5dd471256eb
    https://github.com/scummvm/scummvm/commit/13102d05b02881f0037c29980d0dd5dd471256eb
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:06+02:00

Commit Message:
HDB: Add _msgInfo

Changed paths:
    engines/hdb/window.cpp
    engines/hdb/window.h


diff --git a/engines/hdb/window.cpp b/engines/hdb/window.cpp
index d353c8f..6adc2ba 100644
--- a/engines/hdb/window.cpp
+++ b/engines/hdb/window.cpp
@@ -90,6 +90,8 @@ bool Window::init() {
 }
 
 void Window::restartSystem() {
+	_numMsgQueue = 0;
+	_msgInfo.active = false;
 	_dialogInfo.active = false;
 	_dialogChoiceInfo.active = false;
 	_invWinInfo.active = false;
diff --git a/engines/hdb/window.h b/engines/hdb/window.h
index 542f26d..b7a3c5f 100644
--- a/engines/hdb/window.h
+++ b/engines/hdb/window.h
@@ -30,6 +30,7 @@ enum {
 	kDialogTextRight = (kDialogTextLeft + kTileWidth * 9),
 	kOpenDialogTextLeft = kDialogTextLeft,
 	kOpenDialogTextRight = (kDialogTextRight + kTileWidth * 2),
+	kMaxMsgQueue = 10,
 	kWeaponX = (480 - 34),
 	kWeaponY = 2,
 	kInvItemSpaceX = 48,
@@ -88,6 +89,16 @@ struct DialogChoiceInfo {
 	}
 };
 
+struct MessageInfo {
+	bool		active;
+	char		title[128];
+	int			timer;
+	int			x, y;
+	int			width, height;
+
+	MessageInfo() : active(false), title(""), timer(0), x(0), y(0), width(0), height(0) {}
+};
+
 struct InvWinInfo {
 	int x, y;
 	int width, height;
@@ -183,10 +194,16 @@ private:
 
 	DialogChoiceInfo _dialogChoiceInfo;
 
+	MessageInfo _msgInfo;
+
 	InvWinInfo _invWinInfo;
 	Common::Array<TOut *> _textOutList;
 	DlvsInfo _dlvsInfo;
 
+	char _msgQueueStr[kMaxMsgQueue][128];
+	int _msgQueueWait[kMaxMsgQueue];
+	int _numMsgQueue;
+
 	// Windows GFX
 	Picture *_gfxTL, *_gfxTM, *_gfxTR;
 	Picture *_gfxL, *_gfxM, *_gfxR;


Commit: e3020ee4d5f038d0826d406609c263493934d5e4
    https://github.com/scummvm/scummvm/commit/e3020ee4d5f038d0826d406609c263493934d5e4
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:06+02:00

Commit Message:
HDB: Add DialogChoice and MessageBar functions

Changed paths:
    engines/hdb/window.cpp
    engines/hdb/window.h


diff --git a/engines/hdb/window.cpp b/engines/hdb/window.cpp
index 6adc2ba..120191c 100644
--- a/engines/hdb/window.cpp
+++ b/engines/hdb/window.cpp
@@ -326,8 +326,257 @@ void Window::setDialogDelay(int delay) {
 	_dialogDelay = g_system->getMillis() + 1000 * delay;
 }
 
-void Window::openMessageBar(const char *msg, int count) {
-	warning("STUB: Add openMessageBar()");
+void Window::openDialogChoice(const char *title, const char *text, const char *func, int numChoices, const char *choices[10]) {
+	int		width, height, titleWidth, titleHeight;
+	int		e1, e2, e3, e4, i;
+
+	if (true == _dialogInfo.active)
+		return;
+
+	memset(&_dialogChoiceInfo, 0, sizeof(_dialogChoiceInfo));
+	strcpy(_dialogChoiceInfo.title, title);
+	strcpy(_dialogChoiceInfo.text, text);
+	strcpy(_dialogChoiceInfo.func, func);
+	_dialogChoiceInfo.numChoices = numChoices;
+
+	for (i = 0; i < numChoices; i++)
+		strcpy(_dialogChoiceInfo.choices[i], choices[i]);
+	_dialogChoiceInfo.active = true;
+
+	g_hdb->_drawMan->getTextEdges(&e1, &e2, &e3, &e4);
+	g_hdb->_drawMan->setTextEdges(kOpenDialogTextLeft, kOpenDialogTextRight, 0, 480);
+	g_hdb->_drawMan->getDimensions(text, &width, &height);
+	g_hdb->_drawMan->getDimensions(title, &titleWidth, &titleHeight);
+
+	for (i = 0; i < 10; i++)
+		if (choices[i]) {
+			int	w, h;
+			g_hdb->_drawMan->getDimensions(choices[i], &w, &h);
+			if (w > width)
+				width = w;
+		}
+
+	g_hdb->_drawMan->setTextEdges(e1, e2, e3, e4);
+	_dialogChoiceInfo.textHeight = (height + 1) * 16;
+	_dialogChoiceInfo.height = (height + 2 + numChoices) * 16;
+	_dialogChoiceInfo.width = width + 48;
+	_dialogChoiceInfo.titleWidth = titleWidth;
+
+	_dialogChoiceInfo.x = (480 >> 1) - (_dialogChoiceInfo.width >> 1);
+	_dialogChoiceInfo.y = (kScreenHeight >> 1) - ((_dialogChoiceInfo.height >> 1) + 32);
+	if (_dialogChoiceInfo.y < 0)
+		_dialogChoiceInfo.y = 0;
+
+	_dialogChoiceInfo.selection = 0;
+	_dialogChoiceInfo.timeout = 0;
+	warning("STUB: Play SND_MOVE_SELECTION");
+}
+
+void Window::drawDialogChoice() {
+	int		e1, e2, e3, e4, blocks, i, w;
+
+	if (!_dialogChoiceInfo.active)
+		return;
+
+	// time out?
+	if (_dialogChoiceInfo.timeout && _dialogChoiceInfo.timeout < g_hdb->getTimeSlice()) {
+		closeDialogChoice();
+		return;
+	}
+
+	bool guyTalking = !scumm_stricmp(_dialogChoiceInfo.title, "guy");
+
+	w = _dialogChoiceInfo.width;
+	if (_dialogChoiceInfo.titleWidth > w)
+		w = _dialogChoiceInfo.titleWidth;
+
+	drawBorder(_dialogChoiceInfo.x, _dialogChoiceInfo.y, w, _dialogChoiceInfo.height, guyTalking);
+
+	if (!guyTalking) {
+		_gfxTitleL->drawMasked(_dialogChoiceInfo.x, _dialogChoiceInfo.y - 10);
+		blocks = _dialogChoiceInfo.titleWidth / 16;
+		for (i = 0; i < blocks; i++)
+			_gfxTitleM->drawMasked(_dialogChoiceInfo.x + 16 * (i + 1), _dialogChoiceInfo.y - 10);
+		_gfxTitleR->drawMasked(_dialogChoiceInfo.x + (blocks + 1) * 16, _dialogChoiceInfo.y - 10);
+	} else {
+		_gGfxTitleL->drawMasked(_dialogChoiceInfo.x, _dialogChoiceInfo.y - 10);
+		blocks = _dialogChoiceInfo.titleWidth / 16;
+		for (i = 0; i < blocks; i++)
+			_gGfxTitleM->drawMasked(_dialogChoiceInfo.x + 16 * (i + 1), _dialogChoiceInfo.y - 10);
+		_gGfxTitleR->drawMasked(_dialogChoiceInfo.x + (blocks + 1) * 16, _dialogChoiceInfo.y - 10);
+	}
+
+	g_hdb->_drawMan->getTextEdges(&e1, &e2, &e3, &e4);
+	g_hdb->_drawMan->setTextEdges(_dialogChoiceInfo.x + 10, kOpenDialogTextRight, 0, 480);
+	g_hdb->_drawMan->setCursor(0, _dialogChoiceInfo.y - 7);
+	if (_dialogChoiceInfo.title)
+		g_hdb->_drawMan->drawText(_dialogChoiceInfo.title);
+	g_hdb->_drawMan->setTextEdges(_dialogChoiceInfo.x + 16, kOpenDialogTextRight, 0, 480);
+	g_hdb->_drawMan->setCursor(0, _dialogChoiceInfo.y + 16);
+	if (_dialogChoiceInfo.text)
+		g_hdb->_drawMan->drawText(_dialogChoiceInfo.text);
+
+	for (i = 0; i < _dialogChoiceInfo.numChoices; i++) {
+		g_hdb->_drawMan->setCursor(_dialogChoiceInfo.x + 48, _dialogChoiceInfo.y + _dialogChoiceInfo.textHeight + 16 * i);
+		g_hdb->_drawMan->drawText(_dialogChoiceInfo.choices[i]);
+	}
+	g_hdb->_drawMan->setTextEdges(e1, e2, e3, e4);
+
+	_gfxHandright->drawMasked(_dialogChoiceInfo.x + 10, 4 + _dialogChoiceInfo.y + _dialogChoiceInfo.textHeight + 16 * _dialogChoiceInfo.selection);
+}
+
+void Window::closeDialogChoice() {
+	if (_dialogChoiceInfo.active) {
+		_dialogChoiceInfo.active = false;
+		g_hdb->_lua->pushFunction(_dialogChoiceInfo.func);
+		g_hdb->_lua->pushInt(_dialogChoiceInfo.selection);
+		g_hdb->_lua->call(1, 0);
+		warning("STUB: Play SND_SWITCH_USE");
+	}
+}
+
+bool Window::checkDialogChoiceClose(int x, int y) {
+	if (!_dialogChoiceInfo.active || _dialogChoiceInfo.timeout)
+		return false;
+
+	if (x >= _dialogChoiceInfo.x && x < _dialogChoiceInfo.x + _dialogChoiceInfo.width &&
+		y >= _dialogChoiceInfo.y + _dialogChoiceInfo.textHeight && y < _dialogChoiceInfo.y + _dialogChoiceInfo.textHeight + _dialogChoiceInfo.numChoices * 16) {
+		warning("STUB: Play SND_SWITCH_USE");
+		_dialogChoiceInfo.selection = (y - (_dialogChoiceInfo.y + _dialogChoiceInfo.textHeight)) >> 4;
+		_dialogChoiceInfo.timeout = g_hdb->getTimeSlice() + 500;
+		return true;
+	}
+
+	return false;
+}
+
+void Window::dialogChoiceMoveup() {
+	_dialogChoiceInfo.selection--;
+	if (_dialogChoiceInfo.selection < 0)
+		_dialogChoiceInfo.selection = _dialogChoiceInfo.numChoices - 1;
+	warning("STUB: Play SND_MOVE_SELECTION");
+}
+
+void Window::dialogChoiceMovedown() {
+	_dialogChoiceInfo.selection++;
+	if (_dialogChoiceInfo.selection >= _dialogChoiceInfo.numChoices)
+		_dialogChoiceInfo.selection = 0;
+	warning("STUB: Play SND_MOVE_SELECTION");
+}
+
+void Window::openMessageBar(const char *title, int time) {
+	int	width, height;
+	int	e1, e2, e3, e4;
+
+	// is the messagebar already up?  if so, add this msg to the queue
+	if (_msgInfo.active) {
+		if (_numMsgQueue < kMaxMsgQueue) {
+			int		i;
+			if (!scumm_stricmp(_msgInfo.title, title))
+				return;
+
+			for (i = 0; i < _numMsgQueue; i++)
+				if (!_stricmp(_msgQueueStr[i], title))
+					return;
+			strcpy(_msgQueueStr[_numMsgQueue], title);
+			_msgQueueWait[_numMsgQueue] = time;
+			_numMsgQueue++;
+		}
+		return;
+	}
+
+	memset(&_msgInfo, 0, sizeof(_msgInfo));
+
+	_msgInfo.timer = (time * kGameFPS);
+	strcpy(_msgInfo.title, title);
+
+	g_hdb->_drawMan->getTextEdges(&e1, &e2, &e3, &e4);
+	g_hdb->_drawMan->setTextEdges(kDialogTextLeft, kDialogTextRight, 0, 480);
+	g_hdb->_drawMan->getDimensions(title, &width, &height);
+	g_hdb->_drawMan->setTextEdges(e1, e2, e3, e4);
+
+	_msgInfo.height = (height + 2) * 16;
+	_msgInfo.width = width + 32;
+
+	_msgInfo.x = (480 >> 1) - (_msgInfo.width >> 1);
+	_msgInfo.active = true;
+}
+
+void Window::drawMessageBar() {
+	int	xx, py, my;
+	int	e1, e2, e3, e4;
+
+	// if msgbar's not up OR inventory is up, exit
+	if (!_msgInfo.active || _invWinInfo.active || _dialogInfo.active)
+		return;
+
+	g_hdb->_ai->getPlayerXY(&xx, &py);	// don't care about the x
+	g_hdb->_map->getMapXY(&xx, &my);
+	_msgInfo.y = (py - my) - _msgInfo.height - 64;	// put msgbar directly above player
+	if (_msgInfo.y < _msgInfo.height)
+		_msgInfo.y = (py - my) + 40;					// if at top, but it directly below
+
+	drawBorder(_msgInfo.x, _msgInfo.y, _msgInfo.width, _msgInfo.height, false);
+
+	g_hdb->_drawMan->getTextEdges(&e1, &e2, &e3, &e4);
+	g_hdb->_drawMan->setTextEdges(_msgInfo.x + 16, _msgInfo.x + _msgInfo.width - 16, 0, 320);
+	g_hdb->_drawMan->setCursor(_msgInfo.x + 16, _msgInfo.y + 16);
+	g_hdb->_drawMan->drawText(_msgInfo.title);
+	g_hdb->_drawMan->setTextEdges(e1, e2, e3, e4);
+
+	//
+	// time to go away?  see if we have any more msgs in the queue...
+	//
+	if (_msgInfo.timer-- < 1)
+		nextMsgQueued();
+}
+
+bool Window::checkMsgClose(int x, int y) {
+	if (x >= _msgInfo.x && x < _msgInfo.x + _msgInfo.width &&
+		y >= _msgInfo.y && y < _msgInfo.y + _msgInfo.height) {
+		closeMsg();
+		return true;
+	}
+
+	return false;
+}
+
+void Window::nextMsgQueued() {
+	int		xx;				// frameskip COULD be 0!
+	int		width, height;
+	int		e1, e2, e3, e4;
+
+	if (!_numMsgQueue) {
+		_msgInfo.active = false;
+		return;
+	}
+
+	strcpy(_msgInfo.title, _msgQueueStr[0]);
+	_msgInfo.timer = (_msgQueueWait[0] * kGameFPS);
+
+	g_hdb->_drawMan->getTextEdges(&e1, &e2, &e3, &e4);
+	g_hdb->_drawMan->setTextEdges(kDialogTextLeft, kDialogTextRight, 0, 480);
+	g_hdb->_drawMan->getDimensions(_msgInfo.title, &width, &height);
+	g_hdb->_drawMan->setTextEdges(e1, e2, e3, e4);
+
+	_msgInfo.height = (height + 2) * 16;
+
+	_msgInfo.width = width + 32;
+	_msgInfo.x = (480 >> 1) - (_msgInfo.width >> 1);
+	_msgInfo.y = (kScreenHeight >> 2) - (_msgInfo.height >> 1);
+
+	for (xx = 0; xx < _numMsgQueue - 1; xx++)
+	{
+		strcpy(_msgQueueStr[xx], _msgQueueStr[xx + 1]);
+		_msgQueueWait[xx] = _msgQueueWait[xx + 1];
+	}
+	_numMsgQueue--;
+	_msgInfo.active = true;
+}
+
+void Window::closeMsg() {
+	nextMsgQueued();
+	warning("STUB: Play SND_DIALOG_CLOSE");
 }
 
 void Window::drawInventory() {
diff --git a/engines/hdb/window.h b/engines/hdb/window.h
index b7a3c5f..08f957c 100644
--- a/engines/hdb/window.h
+++ b/engines/hdb/window.h
@@ -154,8 +154,27 @@ public:
 		return _dialogInfo.active;
 	}
 
+	// Dialog Choice Functions
+
+	void openDialogChoice(const char *title, const char *text, const char *func, int numChoices, const char *choices[10]);
+	void drawDialogChoice();
+	void closeDialogChoice();
+	bool checkDialogChoiceClose(int x, int y);
+	void dialogChoiceMoveup();
+	void dialogChoiceMovedown();
+	bool dialogChoiceActive() {
+		return _dialogChoiceInfo.active;
+	}
+
 	// MessageBar Functions
-	void openMessageBar(const char *msg, int count);
+	void openMessageBar(const char *title, int time);
+	void drawMessageBar();
+	bool checkMsgClose(int x, int y);
+	void nextMsgQueued();
+	void closeMsg();
+	bool msgBarActive() {
+		return _msgInfo.active;
+	}
 
 	// Inventory Functions
 	void drawInventory();


Commit: 0aacd2d29adfe63f70399592e7f44f3654b53577
    https://github.com/scummvm/scummvm/commit/0aacd2d29adfe63f70399592e7f44f3654b53577
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:06+02:00

Commit Message:
HDB: Add inventoryActive() function

Changed paths:
    engines/hdb/window.h


diff --git a/engines/hdb/window.h b/engines/hdb/window.h
index 08f957c..e03e26f 100644
--- a/engines/hdb/window.h
+++ b/engines/hdb/window.h
@@ -185,6 +185,9 @@ public:
 		return _invWinInfo.selection;
 	}
 	void checkInvSelect(int x, int y);
+	bool inventoryActive() {
+		return _invWinInfo.active;
+	}
 
 	// Deliveries Functions
 	void openDeliveries(bool animate);


Commit: 8d7446406516f29ee7ebfcf463bdbfeaf65b2958
    https://github.com/scummvm/scummvm/commit/8d7446406516f29ee7ebfcf463bdbfeaf65b2958
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:07+02:00

Commit Message:
HDB: Add Lua functions for message() and dialog()

Changed paths:
    engines/hdb/lua-script.cpp


diff --git a/engines/hdb/lua-script.cpp b/engines/hdb/lua-script.cpp
index 72214b0..94fcf9e 100644
--- a/engines/hdb/lua-script.cpp
+++ b/engines/hdb/lua-script.cpp
@@ -656,12 +656,37 @@ static int dialog(lua_State *L) {
 }
 
 static int dialogChoice(lua_State *L) {
-	warning("STUB: DIALOG CHOICE");
+	const char *title = lua_tostring(L, 1);
+	const char *text = lua_tostring(L, 2);
+	const char *func = lua_tostring(L, 3);
+	const char *choice[10] = {0,0,0,0,0,0,0,0,0,0};
+
+	int	i, amount = lua_gettop(L) - 3;
+	if (amount > 9)
+		amount = 9;
+
+	for (i = 0; i < amount; i++)
+		choice[i] = lua_tostring(L, 4 + i);
+
+	lua_pop(L, amount + 3);
+
+	g_hdb->_window->openDialogChoice(title, text, func, amount, &choice[0]);
 	return 0;
 }
 
 static int message(lua_State *L) {
-	warning("STUB: MESSAGE");
+	const char *title;
+	double	delay;
+
+	title = lua_tostring(L, 1);
+	delay = lua_tonumber(L, 2);
+
+
+	g_hdb->_lua->checkParameters("message", 2);
+
+	lua_pop(L, 2);
+
+	g_hdb->_window->openMessageBar(title, (int)delay);
 	return 0;
 }
 


Commit: ad0ce9a43f280f01cda0ec1290270fb119fcb76f
    https://github.com/scummvm/scummvm/commit/ad0ce9a43f280f01cda0ec1290270fb119fcb76f
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:07+02:00

Commit Message:
HDB: Call drawDialogChoice() and drawMessageBar()

Changed paths:
    engines/hdb/hdb.cpp


diff --git a/engines/hdb/hdb.cpp b/engines/hdb/hdb.cpp
index 4e93737..3da7197 100644
--- a/engines/hdb/hdb.cpp
+++ b/engines/hdb/hdb.cpp
@@ -512,7 +512,9 @@ Common::Error HDBGame::run() {
 			_map->drawForegrounds();
 			_ai->animateTargets();
 
+			_window->drawDialogChoice();
 			_window->drawDialog();
+			_window->drawMessageBar();
 			_window->drawInventory();
 			_window->drawDeliveries();
 			_window->drawTextOut();


Commit: b9fbfa163914701016f6f396668ba3efcbd8b2d1
    https://github.com/scummvm/scummvm/commit/b9fbfa163914701016f6f396668ba3efcbd8b2d1
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:07+02:00

Commit Message:
HDB: Unstub DialogChoice and MessageBar checks

Changed paths:
    engines/hdb/ai-funcs.cpp
    engines/hdb/input.cpp


diff --git a/engines/hdb/ai-funcs.cpp b/engines/hdb/ai-funcs.cpp
index da4efc0..721fcbd 100644
--- a/engines/hdb/ai-funcs.cpp
+++ b/engines/hdb/ai-funcs.cpp
@@ -2196,9 +2196,13 @@ void AI::movePlayer(uint16 buttons) {
 		if (g_hdb->_window->dialogActive()) {
 			g_hdb->_window->closeDialog();
 			return;
+		} else if (g_hdb->_window->dialogChoiceActive()) {
+			g_hdb->_window->closeDialogChoice();
+			return;
+		} else if (g_hdb->_window->msgBarActive()) {
+			g_hdb->_window->closeMsg();
+			return;
 		}
-		warning("STUB: movePlayer: Add DialogChoice Check");
-		warning("STUB: movePlayer: Add MessageBar Check");
 
 		if (cinematicsActive() || _playerLock)
 			return;
@@ -2302,7 +2306,11 @@ void AI::movePlayer(uint16 buttons) {
 		if (!cinematicsActive())
 			return;
 
-	warning("STUB: movePlayer: Add Choice Dialog");
+	// is a choice dialog active?
+	if (g_hdb->_window->dialogChoiceActive()) {
+		if (!cinematicsActive())
+			return;
+	}
 
 	// In a cinematic?
 	if (_playerLock || _numWaypoints)
diff --git a/engines/hdb/input.cpp b/engines/hdb/input.cpp
index 8de0cc1..755ad5d 100644
--- a/engines/hdb/input.cpp
+++ b/engines/hdb/input.cpp
@@ -80,7 +80,16 @@ void Input::setButtons(uint16 b) {
 			return;
 		}
 
-		warning("STUB: setButtons: Choose from DialogChoice");
+		// Choose from DialogChoice
+		if (g_hdb->_window->dialogChoiceActive()) {
+			if (_buttons & kButtonUp)
+				g_hdb->_window->dialogChoiceMoveup();
+			else if (_buttons & kButtonDown)
+				g_hdb->_window->dialogChoiceMovedown();
+			else if (_buttons & kButtonB)
+				g_hdb->_window->closeDialogChoice();
+			return;
+		}
 
 		// Try to move the player
 		if (!g_hdb->_ai->playerDead())
@@ -131,10 +140,17 @@ void Input::stylusDown(int x, int y) {
 		}
 
 		// Is a Choice Dialog Active?
-		warning("STUB: stylusDown: Check Choice Dialog Active");
+		if (g_hdb->_window->dialogChoiceActive()) {
+			if (!g_hdb->_window->checkDialogChoiceClose(x, y))
+				return;
+			if (!g_hdb->_ai->cinematicsActive())
+				return;
+		}
 
 		// Is MessageBar active?
-		warning("STUB: stylusDown: Check Message Bar Active");
+		if (g_hdb->_window->msgBarActive())
+			if (g_hdb->_window->checkMsgClose(x, y))
+				return;
 
 		// In a cinematic?
 		if (g_hdb->_ai->playerLocked())


Commit: cc1e3d5deed6e8717ac10e6ec527d52ce09429c4
    https://github.com/scummvm/scummvm/commit/cc1e3d5deed6e8717ac10e6ec527d52ce09429c4
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:07+02:00

Commit Message:
HDB: Fix compilation

Changed paths:
    engines/hdb/window.cpp


diff --git a/engines/hdb/window.cpp b/engines/hdb/window.cpp
index 120191c..c6372a7 100644
--- a/engines/hdb/window.cpp
+++ b/engines/hdb/window.cpp
@@ -476,7 +476,7 @@ void Window::openMessageBar(const char *title, int time) {
 				return;
 
 			for (i = 0; i < _numMsgQueue; i++)
-				if (!_stricmp(_msgQueueStr[i], title))
+				if (!scumm_stricmp(_msgQueueStr[i], title))
 					return;
 			strcpy(_msgQueueStr[_numMsgQueue], title);
 			_msgQueueWait[_numMsgQueue] = time;
@@ -870,7 +870,7 @@ void Window::drawTextOut() {
 	g_hdb->_drawMan->setTextEdges(0, 480, 0, kScreenHeight);
 
 	time = g_system->getMillis();
-	
+
 	for (uint i = 0; i < _textOutList.size(); i++) {
 		t = _textOutList[i];
 		g_hdb->_drawMan->setCursor(t->x, t->y);


Commit: 45b90776e27467afecce452573ca6c8c5fafe269
    https://github.com/scummvm/scummvm/commit/45b90776e27467afecce452573ca6c8c5fafe269
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:07+02:00

Commit Message:
HDB: Hid noisy stubs

Changed paths:
    engines/hdb/input.cpp


diff --git a/engines/hdb/input.cpp b/engines/hdb/input.cpp
index 755ad5d..2dd8e2c 100644
--- a/engines/hdb/input.cpp
+++ b/engines/hdb/input.cpp
@@ -71,7 +71,7 @@ void Input::setButtons(uint16 b) {
 	}
 
 	// Debug Mode Cycling
-	warning("STUB: setButtons: Check and set Debug Mode");
+	debug(9, "STUB: setButtons: Check and set Debug Mode");
 
 	if (g_hdb->getGameState() == GAME_PLAY) {
 		// Is Player Dead? Click on TRY AGAIN
@@ -283,8 +283,8 @@ void Input::updateMouseButtons(int l, int m, int r) {
 
 void Input::updateKeys(Common::Event event, bool keyDown) {
 
-	warning("STUB: updateKeys: Check for Quit key");
-	warning("STUB: updateKeys: Check for Pause key");
+	debug(9, "STUB: updateKeys: Check for Quit key");
+	debug(9, "STUB: updateKeys: Check for Pause key");
 
 	uint16 buttons = getButtons();
 


Commit: e31e9dbae17ab707fd50b7a29bdbdf0889fe1811
    https://github.com/scummvm/scummvm/commit/e31e9dbae17ab707fd50b7a29bdbdf0889fe1811
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:07+02:00

Commit Message:
HDB: Renamed draw-manager.* -> gfx.*

Changed paths:
  A engines/hdb/gfx.cpp
  A engines/hdb/gfx.h
  R engines/hdb/draw-manager.cpp
  R engines/hdb/draw-manager.h
    engines/hdb/hdb.h
    engines/hdb/module.mk


diff --git a/engines/hdb/draw-manager.cpp b/engines/hdb/draw-manager.cpp
deleted file mode 100644
index 852718f..0000000
--- a/engines/hdb/draw-manager.cpp
+++ /dev/null
@@ -1,793 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- */
-
-#include "hdb/hdb.h"
-
-namespace HDB {
-
-DrawMan::DrawMan() {
-	_tLookupArray = NULL;
-	_gfxCache = new Common::Array<GfxCache *>;
-	_globalSurface.create(kScreenWidth, kScreenHeight, g_hdb->_format);
-	_pointerDisplayable = 1;
-	_systemInit = false;
-}
-
-DrawMan::~DrawMan() {
-	delete _gfxCache;
-	_globalSurface.free();
-}
-
-bool DrawMan::init() {
-
-	// Set the default cursor pos & char clipping
-	setCursor(0, 0);
-
-	_eLeft = 0;
-	_eRight = kScreenWidth;
-	_eTop = 0;
-	_eBottom = kScreenHeight;
-
-	// Load Game Font
-	if (!loadFont("normalprop"))
-		return false;
-
-	// Read total number of tiles in game
-	_numTiles = g_hdb->_fileMan->getCount("t32_", TYPE_TILE32);
-	if (!_numTiles) {
-		return false;
-	}
-
-	// Setup Tile Lookup Array
-	_tLookupArray = new TileLookup[_numTiles];
-	Common::Array<const char *> tileData = *g_hdb->_fileMan->findFiles("t32_", TYPE_TILE32);
-
-	assert((uint)_numTiles == tileData.size());
-
-	int index = 0, skyIndex = 0;
-	for (; index < _numTiles; index++) {
-		_tLookupArray[index].filename = tileData[index];
-		_tLookupArray[index].tData = NULL;
-		_tLookupArray[index].skyIndex = 0;
-		_tLookupArray[index].animIndex = index;
-		// Check if the loaded Tile is a Sky Tile
-		if (((Common::String)tileData[index]).contains("sky") && (skyIndex < kMaxSkies)) {
-			_tLookupArray[index].skyIndex = skyIndex + 1;
-			_skyTiles[skyIndex] = index;
-			skyIndex++;
-		}
-	}
-
-
-	// Add Animating Tile Info
-	int found = -1;
-	char search[32];
-	strcpy(search, "anim_");
-	for (index = 0; index < _numTiles; index++) {
-		// IF we have not found a start, look for it
-		// ELSE IF we have found a start and are in the middle of an anim group
-		// ELSE IF we're in an anim group and have just reached the end
-		if (!strncmp(_tLookupArray[index].filename, search, strlen(search)) && found == -1) {
-			found = index;
-			strncpy(search, _tLookupArray[index].filename, strlen(_tLookupArray[index].filename) - 2);
-		} else if (!strncmp(_tLookupArray[index].filename, search, strlen(search)) && found >= 0)
-			_tLookupArray[index - 1].animIndex = index;
-		else if (strncmp(_tLookupArray[index].filename, search, strlen(search)) && found >= 0) {
-			_tLookupArray[index - 1].animIndex = found;
-			strcpy(search, "anim_");
-			found = -1;
-			if (!strncmp(_tLookupArray[index].filename, search, strlen(search)))
-				index--;
-		}
-	}
-
-	// Init Sky Data
-	_currentSky = 0;
-	_tileSkyStars = getTileIndex("t32_sky_stars");
-	_tileSkyStarsLeft = getTileIndex("t32_sky_stars_left_slow");
-	_tileSkyClouds = getTileIndex("t32_sky_clouds"); // Not completely sure about this filename.
-	_skyClouds = NULL;
-
-	/*
-		TODO: Setup Gamma Table
-	*/
-
-	// Load Mouse Pointer and Display Cursor
-	_mousePointer[0] = loadPic(PIC_MOUSE_CURSOR1);
-	_mousePointer[1] = loadPic(PIC_MOUSE_CURSOR2);
-	_mousePointer[2] = loadPic(PIC_MOUSE_CURSOR3);
-	_mousePointer[3] = loadPic(PIC_MOUSE_CURSOR4);
-	_mousePointer[4] = loadPic(PIC_MOUSE_CURSOR5);
-	_mousePointer[5] = loadPic(PIC_MOUSE_CURSOR6);
-	_mousePointer[6] = loadPic(PIC_MOUSE_CURSOR7);
-	_mousePointer[7] = loadPic(PIC_MOUSE_CURSOR8);
-	_showCursor = true;
-
-	// Load all 4 levels of star colors
-	_starField[0] = getPicture("pic_star64");
-	_starField[1] = getPicture("pic_star128");
-	_starField[2] = getPicture("pic_star192");
-	_starField[3] = getPicture("pic_star256");
-
-	/*
-		TODO: Load the snowflake
-	*/
-
-	_systemInit = true;
-	return true;
-}
-
-void DrawMan::fillScreen(uint32 color) {
-	_globalSurface.fillRect(Common::Rect(kScreenWidth, kScreenHeight), color);
-	g_system->fillScreen(color);
-}
-
-void DrawMan::updateVideo() {
-	updateFade();
-	debug(9, "STUB: DrawMan::updateVideo incomplete");
-}
-
-void DrawMan::drawPointer() {
-	static int anim = 0;
-	static uint32 animTime = 0;
-
-	if (animTime < g_system->getMillis()) {
-		animTime = g_system->getMillis() + 50;
-		anim = (anim + 1) & 7;
-	}
-
-	// If pointer is not displayable and we are in game, exit
-	if (!_pointerDisplayable && g_hdb->getGameState() == GAME_PLAY)
-		return;
-
-	// If we are in game and the cursor should be displayed, draw it
-	if (_showCursor || g_hdb->getGameState() != GAME_PLAY)
-		_mousePointer[anim]->drawMasked(g_hdb->_input->getMouseX() - 16, g_hdb->_input->getMouseY() - 16);
-}
-
-void DrawMan::setPointerState(int value) {
-	_pointerDisplayable = value;
-}
-
-void DrawMan::setFade(bool fadeIn, bool black, int steps) {
-	_fadeInfo.isFadeIn = fadeIn;
-	_fadeInfo.isBlack = black;
-
-	if (!steps) {
-		steps = 1;
-	}
-	_fadeInfo.speed = steps;
-
-	if (fadeIn) {
-		_fadeInfo.curStep = 0;
-	} else {
-		_fadeInfo.curStep = 255;
-	}
-
-	_fadeInfo.active = true;
-}
-
-void DrawMan::updateFade() {
-	_fadeInfo.active = false;
-	debug(9, "STUB: DrawMan::updateFade incomplete");
-}
-
-Picture *DrawMan::loadPic(const char *picName) {
-	Picture *pic = new Picture;
-	Common::SeekableReadStream *stream = g_hdb->_fileMan->findFirstData(picName, TYPE_PIC);
-	if (!stream)
-		return NULL;
-	pic->load(stream);
-	return pic;
-}
-
-Tile *DrawMan::loadTile(const char *tileName) {
-	Tile *tile = new Tile;
-	Common::SeekableReadStream *stream = g_hdb->_fileMan->findFirstData(tileName, TYPE_TILE32);
-	if (!stream)
-		return NULL;
-	tile->load(stream);
-	return tile;
-}
-
-Tile *DrawMan::getTile(int index) {
-
-	if (index < 0 || index > _numTiles) {
-		if (index != 0xFFFF)
-			debug(6, "getTile(%d): wrong index > %d", index, _numTiles);
-		return NULL;
-	}
-	if (_tLookupArray[index].skyIndex) {
-		debug(6, "getTile(%d): sky tile (%d)", index, _tLookupArray[index].skyIndex);
-		// We don't draw Sky Tiles, so return NULL
-		return NULL;
-	}
-
-	if (_tLookupArray[index].tData == NULL) {
-		Common::SeekableReadStream *stream = g_hdb->_fileMan->findFirstData(_tLookupArray[index].filename, TYPE_TILE32);
-		Tile *tile = new Tile;
-		tile->load(stream);
-		_tLookupArray[index].tData = tile;
-	}
-
-	return _tLookupArray[index].tData;
-}
-
-void DrawMan::cacheTileSequence(int tileIndex, int count) {
-	for (int i = tileIndex; i < tileIndex + count; i++)
-		getTile(i);
-}
-
-int DrawMan::getTileIndex(const char *name) {
-	if (!name) {
-		return -1;
-	}
-	for (int i = 0; i < _numTiles; i++) {
-		if (Common::matchString(_tLookupArray[i].filename, name)) {
-			return i;
-		}
-	}
-	return -1;
-}
-
-Picture *DrawMan::getPicture(const char *name) {
-	Common::SeekableReadStream *stream = g_hdb->_fileMan->findFirstData(name, TYPE_PIC);
-	Picture *picture = new Picture;
-	picture->load(stream);
-	return picture;
-}
-
-// Returns: true->Tile, false->Pic
-bool DrawMan::selectGfxType(const char *name) {
-	// Check for Pic types
-	if (Common::matchString(name, "clubup1"))
-		return false;
-	if (Common::matchString(name, "clubup2"))
-		return false;
-	if (Common::matchString(name, "clubup3"))
-		return false;
-	if (Common::matchString(name, "clubup4"))
-		return false;
-	if (Common::matchString(name, "clubdown1"))
-		return false;
-	if (Common::matchString(name, "clubdown2"))
-		return false;
-	if (Common::matchString(name, "clubdown3"))
-		return false;
-	if (Common::matchString(name, "clubdown4"))
-		return false;
-	if (Common::matchString(name, "clubleft1"))
-		return false;
-	if (Common::matchString(name, "clubleft2"))
-		return false;
-	if (Common::matchString(name, "clubleft3"))
-		return false;
-	if (Common::matchString(name, "clubleft4"))
-		return false;
-	if (Common::matchString(name, "clubright1"))
-		return false;
-	if (Common::matchString(name, "clubright2"))
-		return false;
-	if (Common::matchString(name, "clubright3"))
-		return false;
-	if (Common::matchString(name, "clubright4"))
-		return false;
-	if (Common::matchString(name, "slug_shot1"))
-		return false;
-	if (Common::matchString(name, "slug_shot2"))
-		return false;
-	if (Common::matchString(name, "slug_shot3"))
-		return false;
-	if (Common::matchString(name, "slug_shot4"))
-		return false;
-
-	return true;
-}
-
-Tile *DrawMan::getTileGfx(const char *name, uint32 size) {
-	// Try to find graphic
-	for (Common::Array<GfxCache *>::iterator it = _gfxCache->begin(); it != _gfxCache->end(); it++) {
-		if (Common::matchString((*it)->name, name)) {
-			if ((*it)->loaded == -1) {	// Marked for Deletetion?
-				(*it)->loaded = 1;		// Reactivate it
-				return (*it)->tileGfx;
-			}
-		}
-	}
-
-	GfxCache *gc = new GfxCache;
-	strcpy(gc->name, name);
-
-	Common::SeekableReadStream *stream = g_hdb->_fileMan->findFirstData(name, TYPE_TILE32);
-
-	Tile *gfxTile = new Tile;
-	gfxTile->load(stream);
-
-	gc->tileGfx = gfxTile;
-	gc->size = size;
-	gc->loaded = 1;
-
-	_gfxCache->push_back(gc);
-
-	return gc->tileGfx;
-}
-
-Picture *DrawMan::getPicGfx(const char *name, uint32 size) {
-	// Try to find graphic
-	for (Common::Array<GfxCache *>::iterator it = _gfxCache->begin(); it != _gfxCache->end(); it++) {
-		if (Common::matchString((*it)->name, name)) {
-			if ((*it)->loaded == -1) {	// Marked for Deletetion?
-				(*it)->loaded = 1;		// Reactivate it
-				return (*it)->picGfx;
-			}
-		}
-	}
-
-	GfxCache *gc = new GfxCache;
-	strcpy(gc->name, name);
-
-	Common::SeekableReadStream *stream = g_hdb->_fileMan->findFirstData(name, TYPE_TILE32);
-
-	Picture *gfxPic = new Picture;
-	gfxPic->load(stream);
-
-	gc->picGfx = gfxPic;
-	gc->size = size;
-	gc->loaded = 1;
-
-	_gfxCache->push_back(gc);
-
-	return gc->picGfx;
-}
-
-int DrawMan::isSky(int index) {
-	if (!index) {
-		return 0;
-	}
-
-	for (int i = 0; i < kMaxSkies; i++) {
-		if(_skyTiles[i] == index) {
-			return i + 1; // The skyTiles are indexed from 1. 0 => No Sky tile
-		}
-	}
-
-	return 0;
-}
-
-void DrawMan::setSky(int skyIndex) {
-	int tileIndex = _skyTiles[skyIndex - 1];
-	_currentSky = skyIndex;
-
-	// Clear memory used by last sky
-	if (tileIndex != _tileSkyClouds && _skyClouds) {
-		delete _skyClouds;
-		_skyClouds = NULL;
-	}
-
-	// Setup current sky
-	if (tileIndex == _tileSkyStars) {
-		setup3DStars();
-		return;
-	} else if (skyIndex == _tileSkyStarsLeft) {
-		setup3DStarsLeft();
-		return;
-	} else if (skyIndex == _tileSkyStars) {
-		_skyClouds = getPicture("cloudy_skies");
-		return;
-	}
-}
-
-void DrawMan::setup3DStars() {
-	for (int i = 0; i < kNum3DStars; i++) {
-		_stars3D[i].x = g_hdb->_rnd->getRandomNumber(kScreenWidth);
-		_stars3D[i].y = g_hdb->_rnd->getRandomNumber(kScreenHeight);
-		_stars3D[i].speed = g_hdb->_rnd->getRandomNumber(256);
-		_stars3D[i].speed >>= 1;
-		_stars3D[i].color = _stars3D[i].speed / 64;
-	}
-}
-
-void DrawMan::setup3DStarsLeft() {
-	for (int i = 0; i < kNum3DStars; i++) {
-		_stars3DSlow[i].x = g_hdb->_rnd->getRandomNumber(kScreenWidth);
-		_stars3DSlow[i].y = g_hdb->_rnd->getRandomNumber(kScreenHeight);
-		_stars3DSlow[i].speed = ((double) (1 + g_hdb->_rnd->getRandomNumber(5))) / 6.0;
-		_stars3DSlow[i].color = (int) (_stars3DSlow[i].speed * 4.00);
-	}
-}
-
-void DrawMan::draw3DStars() {
-	fillScreen(0);
-	for (int i = 0; i < kNum3DStars; i++) {
-		_starField[_stars3D[i].color]->drawMasked((int)_stars3D[i].x, (int)_stars3D[i].y);
-		_stars3D[i].y += (_stars3D[i].speed >> 5) + 1;
-		if (_stars3D[i].y > kScreenHeight) {
-			_stars3D[i].y = 0;
-		}
-	}
-}
-
-void DrawMan::draw3DStarsLeft() {
-	fillScreen(0);
-	for (int i = 0; i < kNum3DStars; i++) {
-		_starField[_stars3DSlow[i].color]->drawMasked((int)_stars3DSlow[i].x, (int)_stars3DSlow[i].y);
-		_stars3DSlow[i].x -= _stars3DSlow[i].speed;
-		if (_stars3DSlow[i].x < kScreenWidth) {
-			_stars3DSlow[i].x = kScreenWidth - 1;
-		}
-	}
-}
-
-void DrawMan::drawSky() {
-	int tile = _skyTiles[_currentSky - 1];
-
-	if (tile == _tileSkyStars) {
-		draw3DStars();
-	}
-	else if (tile == _tileSkyStarsLeft) {
-		draw3DStarsLeft();
-	}
-	else if (tile == _tileSkyClouds) {
-		static int offset = 0, wait = 0;
-		for (int j = -64; j < kScreenHeight; j += 64) {
-			for (int i = -64; i < kScreenWidth; i += 64) {
-				_skyClouds->draw(i + offset, j + offset);
-			}
-		}
-		wait--;
-		if (wait < 1) {
-			offset = (offset + 1) & 63;
-			wait = 5;
-		}
-	}
-}
-
-int DrawMan::animateTile(int tileIndex) {
-	return _tLookupArray[tileIndex].animIndex;
-}
-
-bool DrawMan::loadFont(const char *string) {
-	Common::SeekableReadStream *stream = g_hdb->_fileMan->findFirstData(string, TYPE_FONT);
-	if (!stream)
-		return false;
-
-	// Loading _fontHeader
-	_fontHeader.type = (int)stream->readUint32LE();
-	_fontHeader.numChars = (int)stream->readUint32LE();
-	_fontHeader.height = (int)stream->readUint32LE();
-	_fontHeader.kerning = (int)stream->readUint32LE();
-	_fontHeader.leading = (int)stream->readUint32LE();
-
-	debug(3, "Loaded _fontHeader with following data");
-	debug(3, "type: %d", _fontHeader.type);
-	debug(3, "numChars: %d", _fontHeader.numChars);
-	debug(3, "height: %d", _fontHeader.height);
-	debug(3, "kerning: %d", _fontHeader.kerning);
-	debug(3, "leading: %d", _fontHeader.leading);
-
-	// Loading _charInfoBlocks & creating character surfaces
-	CharInfo *cInfo;
-	int startPos = stream->pos();	// Position after _fontHeader
-	int curPos;						// Position after reading cInfo
-	uint16 *ptr;
-	for (int i = 0; i < _fontHeader.numChars; i++) {
-		cInfo = new CharInfo;
-		cInfo->width = (int16)stream->readUint32LE();
-		cInfo->offset = (int32)stream->readUint32LE();
-
-		debug(3, "Loaded _charInfoBlocks[%d]: width: %d, offset: %d", i, cInfo->width, cInfo->offset);
-
-		curPos = stream->pos();
-
-		_fontSurfaces[i].create(cInfo->width, _fontHeader.height, g_hdb->_format);
-
-		// Go to character location
-		stream->seek(startPos+cInfo->offset);
-
-		for (int y = 0; y < _fontHeader.height; y++) {
-			ptr = (uint16 *)_fontSurfaces[i].getBasePtr(0, y);
-			for (int x = 0; x < cInfo->width; x++) {
-				*ptr = TO_LE_16(stream->readUint16LE());
-				ptr++;
-			}
-		}
-
-		stream->seek(curPos);
-
-		_charInfoBlocks.push_back(cInfo);
-	}
-
-	// Loading _fontGfx
-	_fontGfx = stream->readUint16LE();
-
-	return true;
-}
-
-void DrawMan::drawText(const char *string) {
-	if (!_systemInit)
-		return;
-
-	if (_cursorX < _eLeft)
-		_cursorX = _eLeft;
-	if (_cursorY < _eTop)
-		_cursorY = _eTop;
-
-	// Word Wrapping
-	int width = _eLeft;
-	unsigned char c;
-	char cr[256];	// Carriage Return Array
-
-	for (int i = 0; i < (int)strlen(string); i++) {
-		c = string[i];
-		width += _charInfoBlocks[c]->width + _fontHeader.kerning + kFontIncrement;
-		if (c == ' ')
-			width += kFontSpace;
-
-		cr[i] = 0;
-		if (c == '\n') {
-			cr[i] = 1;
-			width = _eLeft;
-		} else if (width > _eRight) {
-			i--;
-			while (string[i] != ' ' && i > 0)
-				i--;
-			cr[i] = 1;
-			width = _eLeft;
-		}
-	}
-
-	// Draw the characters
-	for (int j = 0; j < (int)strlen(string); j++) {
-		c = string[j];
-		if (c == '\n' || cr[j]) {
-			_cursorX = _eLeft;
-			_cursorY += _fontHeader.height + _fontHeader.leading;
-			if (_cursorY + _fontHeader.height > _eBottom)
-				_cursorY = _eTop;
-			continue;
-		}
-
-		width = _charInfoBlocks[c]->width;
-		if (c == ' ')
-			width = kFontSpace;
-
-		// Blit the character
-		g_hdb->_drawMan->_globalSurface.transBlitFrom(_fontSurfaces[c], Common::Point(_cursorX, _cursorY), 0xf81f);
-
-		Common::Rect clip(0, 0, width, _fontHeader.height);
-		clip.moveTo(_cursorX, _cursorY);
-		clip.clip(_globalSurface.getBounds());
-		if (!clip.isEmpty()) {
-			g_system->copyRectToScreen(g_hdb->_drawMan->_globalSurface.getBasePtr(clip.left, clip.top), g_hdb->_drawMan->_globalSurface.pitch, clip.left, clip.top, clip.width(), clip.height());
-		}
-
-		// Advance the cursor
-		_cursorX += width + _fontHeader.kerning + kFontIncrement;
-		if (_cursorX > kScreenWidth) {
-			_cursorX = 0;
-			_cursorY += _fontHeader.height + _fontHeader.leading;
-			if (_cursorY + _fontHeader.height > kScreenHeight)
-				_cursorY = 0;
-		}
-	}
-}
-
-// Calculates pixel width of a string
-void DrawMan::getDimensions(const char *string, int *pixelsWide, int *lines) {
-	if (!string) {
-		*pixelsWide = kFontSpace;
-		*lines = 1;
-		return;
-	}
-
-	int width, maxWidth, height;
-	unsigned char c;
-	maxWidth = 0;
-	width = _eLeft;
-	height = 1;
-
-	for (int i = 0; i < (int)strlen(string); i++) {
-		c = string[i];
-		width += _charInfoBlocks[c]->width + _fontHeader.kerning + kFontIncrement;
-		if (c == ' ')
-			width += kFontSpace;
-
-		if (c == '\n') {
-			height++;
-			if (width > maxWidth)
-				maxWidth = width;
-			width = _eLeft;
-		} else if (width > _eRight) {
-			int oldWidth = width;
-			i--;
-			while (string[i] != ' ' && i > 0) {
-				c = string[i];
-				width -= _charInfoBlocks[c]->width + _fontHeader.kerning + kFontIncrement;
-				i--;
-			}
-			if (!i) {
-				maxWidth = oldWidth;
-				break;
-			}
-			height++;
-			if (width > maxWidth)
-				maxWidth = width;
-			width = _eLeft;
-		}
-	}
-
-	if (width > maxWidth)
-		maxWidth = width;
-
-	// If its one line, add 8 pixels
-	if (height == 1)
-		maxWidth += 8;
-
-	*pixelsWide = maxWidth - _eLeft;
-	*lines = height;
-}
-
-int DrawMan::stringLength(const char *string) {
-	int w, h;
-	getDimensions(string, &w, &h);
-	return w;
-}
-
-void DrawMan::setTextEdges(int left, int right, int top, int bottom) {
-	_eLeft = left;
-	_eRight = right;
-	_eTop = top;
-	_eBottom = bottom;
-}
-
-void DrawMan::getTextEdges(int *left, int *right, int *top, int *bottom) {
-	*left = _eLeft;
-	*right = _eRight;
-	*top = _eTop;
-	*bottom = _eBottom;
-}
-
-void DrawMan::setKernLead(int kern, int lead) {
-	_fontHeader.kerning = kern;
-	_fontHeader.leading = lead;
-}
-
-void DrawMan::getKernLead(int *kern, int *lead) {
-	*kern = _fontHeader.kerning;
-	*lead = _fontHeader.leading;
-}
-
-void DrawMan::setCursor(int x, int y) {
-	_cursorX = x;
-	_cursorY = y;
-}
-
-void DrawMan::getCursor(int *x, int *y) {
-	*x = _cursorX;
-	*y = _cursorY;
-}
-
-Picture::Picture() : _width(0), _height(0), _name("") {
-	_surface.create(_width, _height, g_hdb->_format);
-}
-
-Picture::~Picture() {
-	_surface.free();
-}
-
-Graphics::Surface Picture::load(Common::SeekableReadStream *stream) {
-	_width = stream->readUint32LE();
-	_height = stream->readUint32LE();
-	stream->read(_name, 64);
-
-	debug(8, "Picture: _width: %d, _height: %d", _width, _height);
-	debug(8, "Picture: _name: %s", _name);
-
-	_surface.create(_width, _height, g_hdb->_format);
-	stream->readUint32LE(); // Skip Win32 Surface
-
-	uint16 *ptr;
-
-	for (uint y = 0; y < _height; y++) {
-		ptr = (uint16 *)_surface.getBasePtr(0, y);
-		for (uint x = 0; x < _width; x++) {
-			*ptr = TO_LE_16(stream->readUint16LE());
-			ptr++;
-		}
-	}
-
-	return _surface;
-}
-
-void Picture::draw(int x, int y) {
-	g_hdb->_drawMan->_globalSurface.blitFrom(_surface, Common::Point(x, y));
-
-	Common::Rect clip(_surface.getBounds());
-	clip.moveTo(x, y);
-	clip.clip(g_hdb->_drawMan->_globalSurface.getBounds());
-	if (!clip.isEmpty()) {
-		g_system->copyRectToScreen(g_hdb->_drawMan->_globalSurface.getBasePtr(clip.left, clip.top), g_hdb->_drawMan->_globalSurface.pitch, clip.left, clip.top, clip.width(), clip.height());
-	}
-}
-
-void Picture::drawMasked(int x, int y) {
-	g_hdb->_drawMan->_globalSurface.transBlitFrom(_surface, Common::Point(x, y), 0xf81f);
-
-	Common::Rect clip(_surface.getBounds());
-	clip.moveTo(x, y);
-	clip.clip(g_hdb->_drawMan->_globalSurface.getBounds());
-	if (!clip.isEmpty()) {
-		g_system->copyRectToScreen(g_hdb->_drawMan->_globalSurface.getBasePtr(clip.left, clip.top), g_hdb->_drawMan->_globalSurface.pitch, clip.left, clip.top, clip.width(), clip.height());
-	}
-}
-
-Tile::Tile() : _flags(0), _name("") {
-	_surface.create(32, 32, g_hdb->_format);
-}
-
-Tile::~Tile() {
-	_surface.free();
-}
-
-Graphics::Surface Tile::load(Common::SeekableReadStream *stream) {
-	_flags = stream->readUint32LE();
-	stream->read(_name, 64);
-
-	_surface.create(32, 32, g_hdb->_format);
-	stream->readUint32LE(); // Skip Win32 Surface
-
-	uint16 *ptr;
-
-	for (uint y = 0; y < 32; y++) {
-		ptr = (uint16 *)_surface.getBasePtr(0, y);
-		for (uint x = 0; x < 32; x++) {
-			*ptr = TO_LE_16(stream->readUint16LE());
-			ptr++;
-		}
-	}
-
-	return _surface;
-}
-
-void Tile::draw(int x, int y) {
-	g_hdb->_drawMan->_globalSurface.blitFrom(_surface, Common::Point(x, y));
-
-	Common::Rect clip(_surface.getBounds());
-	clip.moveTo(x, y);
-	clip.clip(g_hdb->_drawMan->_globalSurface.getBounds());
-	if (!clip.isEmpty()) {
-		g_system->copyRectToScreen(g_hdb->_drawMan->_globalSurface.getBasePtr(clip.left, clip.top), g_hdb->_drawMan->_globalSurface.pitch, clip.left, clip.top, clip.width(), clip.height());
-	}
-}
-
-void Tile::drawMasked(int x, int y) {
-	g_hdb->_drawMan->_globalSurface.transBlitFrom(_surface, Common::Point(x, y), 0xf81f);
-
-	Common::Rect clip(_surface.getBounds());
-	clip.moveTo(x, y);
-	clip.clip(g_hdb->_drawMan->_globalSurface.getBounds());
-	if (!clip.isEmpty()) {
-		g_system->copyRectToScreen(g_hdb->_drawMan->_globalSurface.getBasePtr(clip.left, clip.top), g_hdb->_drawMan->_globalSurface.pitch, clip.left, clip.top, clip.width(), clip.height());
-	}
-}
-
-}
diff --git a/engines/hdb/draw-manager.h b/engines/hdb/draw-manager.h
deleted file mode 100644
index 1ace112..0000000
--- a/engines/hdb/draw-manager.h
+++ /dev/null
@@ -1,242 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- */
-
-#ifndef HDB_DRAW_MANAGER_H
-#define HDB_DRAW_MANAGER_H
-
-#include "graphics/managed_surface.h"
-
-#include "hdb/hdb.h"
-
-namespace HDB {
-
-enum {
-	kScreenWidth = 640,
-	kScreenHeight = 480,
-	kTileWidth = 32,
-	kTileHeight = 32,
-	kMaxSkies = 10,
-	kNum3DStars = 300,
-	kFontSpace = 5,
-	kFontIncrement = 1,
-	kGameFPS = 60,
-	kAnimFrameDelay = kGameFPS / 30,
-	kAnimSlowFrames = kAnimFrameDelay * 10,
-	kAnimMediumFrames = kAnimFrameDelay * 6,
-	kAnimFastFrames = kAnimFrameDelay * 2
-};
-
-class Tile;
-class Picture;
-
-struct TileLookup {
-	const char *filename;
-	Tile *tData;
-	uint16 skyIndex;
-	uint16 animIndex;
-
-	TileLookup() : filename(NULL), tData(NULL), skyIndex(0), animIndex(0) {}
-};
-
-struct GfxCache {
-	char name[32];
-	union {
-		Tile *tileGfx;
-		Picture *picGfx;
-	};
-	uint32 size;
-	int16 loaded;
-
-	GfxCache() : name(""), tileGfx(NULL), size(0), loaded(0) {}
-};
-
-struct FontInfo {
-	int		type;		// 0 = mono, 1 = proportional
-	int		numChars;	// how many characters in font
-	int		height;		// height of entire font
-	int		kerning;	// space between chars
-	int		leading;	// space between lines
-};
-
-struct CharInfo {
-	int16 width;	// Character width in pixels
-	int32 offset;	// From the start of the font charInfo chunk
-};
-
-class DrawMan {
-public:
-
-	DrawMan();
-	~DrawMan();
-
-	Graphics::ManagedSurface _globalSurface;
-
-	bool init();
-	void fillScreen(uint32 color);
-	void updateVideo();
-	void setPointerState(int value);
-	void drawPointer();
-	void showPointer(bool status) {
-		_showCursor = status;
-	}
-	bool getPointer() {
-		return _showCursor;
-	}
-
-	void setFade(bool fadeIn, bool black, int steps);
-	void updateFade();
-	bool isFadeActive() { return _fadeInfo.active; }
-	bool isFadeStaying() { return _fadeInfo.stayFaded; }
-	void turnOffFade() { _fadeInfo.active = _fadeInfo.stayFaded = false; }
-
-	Picture *loadPic(const char *picName);
-	Tile *loadTile(const char *tileName);
-
-	Tile *getTile(int index);
-	void cacheTileSequence(int index, int count);
-	int getTileIndex(const char *name);
-	Picture *getPicture(const char *name);
-
-	// Returns: true->Tile, false->Pic
-	bool selectGfxType(const char *name);
-	Tile *getTileGfx(const char *name, uint32 size);
-	Picture *getPicGfx(const char *name, uint32 size);
-
-	int isSky(int skyIndex);
-	void setSky(int skyIndex);
-	void setup3DStars();
-	void setup3DStarsLeft();
-	void draw3DStars();
-	void draw3DStarsLeft();
-	void drawSky();
-
-	int animateTile(int tileIndex);
-
-	// Font Functions
-
-	bool loadFont(const char *string);
-	void drawText(const char *string);
-	void getDimensions(const char *string, int *pixelsWide, int *lines);
-	int stringLength(const char *string);
-	void setTextEdges(int left, int right, int top, int bottom);
-	void getTextEdges(int *left, int *right, int *top, int *bottom);
-	void setKernLead(int kern, int lead);
-	void getKernLead(int *kern, int *lead);
-	void setCursor(int x, int y);
-	void getCursor(int *x, int *y);
-
-private:
-	int _numTiles;
-	TileLookup *_tLookupArray;
-	uint16 _skyTiles[kMaxSkies];
-
-	Common::Array<GfxCache *> *_gfxCache;
-
-	int _currentSky;	// 0 if no Sky, 1+ for which Sky to use
-	struct {
-		bool active;
-		bool stayFaded;
-		bool isBlack;
-		int speed;
-		bool isFadeIn;
-
-		int curStep;
-	} _fadeInfo;
-
-	struct {
-		int x, y, speed;
-		uint16 color;
-	} _stars3D[kNum3DStars];
-
-	struct {
-		double x, y, speed;
-		uint16 color;
-	} _stars3DSlow[kNum3DStars];
-
-	int _tileSkyStars; // Index of sky_stars tile
-	int _tileSkyStarsLeft; // Left-scrolling stars, slow
-	int _tileSkyClouds; // Index of sky_stars tile
-	Picture *_starField[4];
-	Picture *_skyClouds;
-
-	// Cursor
-	int _cursorX, _cursorY;
-	Picture *_mousePointer[8];	// Gfx for screen pointer (4 Animations)
-	int _pointerDisplayable;
-	bool _showCursor;
-
-	// Font Data
-
-	FontInfo _fontHeader;
-	Common::Array<CharInfo *> _charInfoBlocks;
-	Graphics::Surface _fontSurfaces[256];
-	uint16 _fontGfx;
-	int _eLeft, _eRight, _eTop, _eBottom;
-
-	bool _systemInit;
-
-};
-
-class Picture {
-public:
-
-	Picture();
-	~Picture();
-
-	Graphics::Surface load(Common::SeekableReadStream *stream);
-	void draw(int x, int y);
-	void drawMasked(int x, int y);
-
-	uint _width, _height;
-
-	char *getName() { return _name; }
-
-private:
-
-	char _name[64];
-
-	Graphics::ManagedSurface _surface;
-
-};
-
-class Tile {
-public:
-
-	Tile();
-	~Tile();
-
-	Graphics::Surface load(Common::SeekableReadStream *stream);
-	void draw(int x, int y);
-	void drawMasked(int x, int y);
-
-	uint32 _flags;
-
-	char *getName() { return _name; }
-private:
-	char _name[64];
-
-	Graphics::ManagedSurface _surface;
-};
-
-} // End of Namespace HDB
-
-#endif // !HDB_DRAW_MANAGER_H
diff --git a/engines/hdb/gfx.cpp b/engines/hdb/gfx.cpp
new file mode 100644
index 0000000..852718f
--- /dev/null
+++ b/engines/hdb/gfx.cpp
@@ -0,0 +1,793 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "hdb/hdb.h"
+
+namespace HDB {
+
+DrawMan::DrawMan() {
+	_tLookupArray = NULL;
+	_gfxCache = new Common::Array<GfxCache *>;
+	_globalSurface.create(kScreenWidth, kScreenHeight, g_hdb->_format);
+	_pointerDisplayable = 1;
+	_systemInit = false;
+}
+
+DrawMan::~DrawMan() {
+	delete _gfxCache;
+	_globalSurface.free();
+}
+
+bool DrawMan::init() {
+
+	// Set the default cursor pos & char clipping
+	setCursor(0, 0);
+
+	_eLeft = 0;
+	_eRight = kScreenWidth;
+	_eTop = 0;
+	_eBottom = kScreenHeight;
+
+	// Load Game Font
+	if (!loadFont("normalprop"))
+		return false;
+
+	// Read total number of tiles in game
+	_numTiles = g_hdb->_fileMan->getCount("t32_", TYPE_TILE32);
+	if (!_numTiles) {
+		return false;
+	}
+
+	// Setup Tile Lookup Array
+	_tLookupArray = new TileLookup[_numTiles];
+	Common::Array<const char *> tileData = *g_hdb->_fileMan->findFiles("t32_", TYPE_TILE32);
+
+	assert((uint)_numTiles == tileData.size());
+
+	int index = 0, skyIndex = 0;
+	for (; index < _numTiles; index++) {
+		_tLookupArray[index].filename = tileData[index];
+		_tLookupArray[index].tData = NULL;
+		_tLookupArray[index].skyIndex = 0;
+		_tLookupArray[index].animIndex = index;
+		// Check if the loaded Tile is a Sky Tile
+		if (((Common::String)tileData[index]).contains("sky") && (skyIndex < kMaxSkies)) {
+			_tLookupArray[index].skyIndex = skyIndex + 1;
+			_skyTiles[skyIndex] = index;
+			skyIndex++;
+		}
+	}
+
+
+	// Add Animating Tile Info
+	int found = -1;
+	char search[32];
+	strcpy(search, "anim_");
+	for (index = 0; index < _numTiles; index++) {
+		// IF we have not found a start, look for it
+		// ELSE IF we have found a start and are in the middle of an anim group
+		// ELSE IF we're in an anim group and have just reached the end
+		if (!strncmp(_tLookupArray[index].filename, search, strlen(search)) && found == -1) {
+			found = index;
+			strncpy(search, _tLookupArray[index].filename, strlen(_tLookupArray[index].filename) - 2);
+		} else if (!strncmp(_tLookupArray[index].filename, search, strlen(search)) && found >= 0)
+			_tLookupArray[index - 1].animIndex = index;
+		else if (strncmp(_tLookupArray[index].filename, search, strlen(search)) && found >= 0) {
+			_tLookupArray[index - 1].animIndex = found;
+			strcpy(search, "anim_");
+			found = -1;
+			if (!strncmp(_tLookupArray[index].filename, search, strlen(search)))
+				index--;
+		}
+	}
+
+	// Init Sky Data
+	_currentSky = 0;
+	_tileSkyStars = getTileIndex("t32_sky_stars");
+	_tileSkyStarsLeft = getTileIndex("t32_sky_stars_left_slow");
+	_tileSkyClouds = getTileIndex("t32_sky_clouds"); // Not completely sure about this filename.
+	_skyClouds = NULL;
+
+	/*
+		TODO: Setup Gamma Table
+	*/
+
+	// Load Mouse Pointer and Display Cursor
+	_mousePointer[0] = loadPic(PIC_MOUSE_CURSOR1);
+	_mousePointer[1] = loadPic(PIC_MOUSE_CURSOR2);
+	_mousePointer[2] = loadPic(PIC_MOUSE_CURSOR3);
+	_mousePointer[3] = loadPic(PIC_MOUSE_CURSOR4);
+	_mousePointer[4] = loadPic(PIC_MOUSE_CURSOR5);
+	_mousePointer[5] = loadPic(PIC_MOUSE_CURSOR6);
+	_mousePointer[6] = loadPic(PIC_MOUSE_CURSOR7);
+	_mousePointer[7] = loadPic(PIC_MOUSE_CURSOR8);
+	_showCursor = true;
+
+	// Load all 4 levels of star colors
+	_starField[0] = getPicture("pic_star64");
+	_starField[1] = getPicture("pic_star128");
+	_starField[2] = getPicture("pic_star192");
+	_starField[3] = getPicture("pic_star256");
+
+	/*
+		TODO: Load the snowflake
+	*/
+
+	_systemInit = true;
+	return true;
+}
+
+void DrawMan::fillScreen(uint32 color) {
+	_globalSurface.fillRect(Common::Rect(kScreenWidth, kScreenHeight), color);
+	g_system->fillScreen(color);
+}
+
+void DrawMan::updateVideo() {
+	updateFade();
+	debug(9, "STUB: DrawMan::updateVideo incomplete");
+}
+
+void DrawMan::drawPointer() {
+	static int anim = 0;
+	static uint32 animTime = 0;
+
+	if (animTime < g_system->getMillis()) {
+		animTime = g_system->getMillis() + 50;
+		anim = (anim + 1) & 7;
+	}
+
+	// If pointer is not displayable and we are in game, exit
+	if (!_pointerDisplayable && g_hdb->getGameState() == GAME_PLAY)
+		return;
+
+	// If we are in game and the cursor should be displayed, draw it
+	if (_showCursor || g_hdb->getGameState() != GAME_PLAY)
+		_mousePointer[anim]->drawMasked(g_hdb->_input->getMouseX() - 16, g_hdb->_input->getMouseY() - 16);
+}
+
+void DrawMan::setPointerState(int value) {
+	_pointerDisplayable = value;
+}
+
+void DrawMan::setFade(bool fadeIn, bool black, int steps) {
+	_fadeInfo.isFadeIn = fadeIn;
+	_fadeInfo.isBlack = black;
+
+	if (!steps) {
+		steps = 1;
+	}
+	_fadeInfo.speed = steps;
+
+	if (fadeIn) {
+		_fadeInfo.curStep = 0;
+	} else {
+		_fadeInfo.curStep = 255;
+	}
+
+	_fadeInfo.active = true;
+}
+
+void DrawMan::updateFade() {
+	_fadeInfo.active = false;
+	debug(9, "STUB: DrawMan::updateFade incomplete");
+}
+
+Picture *DrawMan::loadPic(const char *picName) {
+	Picture *pic = new Picture;
+	Common::SeekableReadStream *stream = g_hdb->_fileMan->findFirstData(picName, TYPE_PIC);
+	if (!stream)
+		return NULL;
+	pic->load(stream);
+	return pic;
+}
+
+Tile *DrawMan::loadTile(const char *tileName) {
+	Tile *tile = new Tile;
+	Common::SeekableReadStream *stream = g_hdb->_fileMan->findFirstData(tileName, TYPE_TILE32);
+	if (!stream)
+		return NULL;
+	tile->load(stream);
+	return tile;
+}
+
+Tile *DrawMan::getTile(int index) {
+
+	if (index < 0 || index > _numTiles) {
+		if (index != 0xFFFF)
+			debug(6, "getTile(%d): wrong index > %d", index, _numTiles);
+		return NULL;
+	}
+	if (_tLookupArray[index].skyIndex) {
+		debug(6, "getTile(%d): sky tile (%d)", index, _tLookupArray[index].skyIndex);
+		// We don't draw Sky Tiles, so return NULL
+		return NULL;
+	}
+
+	if (_tLookupArray[index].tData == NULL) {
+		Common::SeekableReadStream *stream = g_hdb->_fileMan->findFirstData(_tLookupArray[index].filename, TYPE_TILE32);
+		Tile *tile = new Tile;
+		tile->load(stream);
+		_tLookupArray[index].tData = tile;
+	}
+
+	return _tLookupArray[index].tData;
+}
+
+void DrawMan::cacheTileSequence(int tileIndex, int count) {
+	for (int i = tileIndex; i < tileIndex + count; i++)
+		getTile(i);
+}
+
+int DrawMan::getTileIndex(const char *name) {
+	if (!name) {
+		return -1;
+	}
+	for (int i = 0; i < _numTiles; i++) {
+		if (Common::matchString(_tLookupArray[i].filename, name)) {
+			return i;
+		}
+	}
+	return -1;
+}
+
+Picture *DrawMan::getPicture(const char *name) {
+	Common::SeekableReadStream *stream = g_hdb->_fileMan->findFirstData(name, TYPE_PIC);
+	Picture *picture = new Picture;
+	picture->load(stream);
+	return picture;
+}
+
+// Returns: true->Tile, false->Pic
+bool DrawMan::selectGfxType(const char *name) {
+	// Check for Pic types
+	if (Common::matchString(name, "clubup1"))
+		return false;
+	if (Common::matchString(name, "clubup2"))
+		return false;
+	if (Common::matchString(name, "clubup3"))
+		return false;
+	if (Common::matchString(name, "clubup4"))
+		return false;
+	if (Common::matchString(name, "clubdown1"))
+		return false;
+	if (Common::matchString(name, "clubdown2"))
+		return false;
+	if (Common::matchString(name, "clubdown3"))
+		return false;
+	if (Common::matchString(name, "clubdown4"))
+		return false;
+	if (Common::matchString(name, "clubleft1"))
+		return false;
+	if (Common::matchString(name, "clubleft2"))
+		return false;
+	if (Common::matchString(name, "clubleft3"))
+		return false;
+	if (Common::matchString(name, "clubleft4"))
+		return false;
+	if (Common::matchString(name, "clubright1"))
+		return false;
+	if (Common::matchString(name, "clubright2"))
+		return false;
+	if (Common::matchString(name, "clubright3"))
+		return false;
+	if (Common::matchString(name, "clubright4"))
+		return false;
+	if (Common::matchString(name, "slug_shot1"))
+		return false;
+	if (Common::matchString(name, "slug_shot2"))
+		return false;
+	if (Common::matchString(name, "slug_shot3"))
+		return false;
+	if (Common::matchString(name, "slug_shot4"))
+		return false;
+
+	return true;
+}
+
+Tile *DrawMan::getTileGfx(const char *name, uint32 size) {
+	// Try to find graphic
+	for (Common::Array<GfxCache *>::iterator it = _gfxCache->begin(); it != _gfxCache->end(); it++) {
+		if (Common::matchString((*it)->name, name)) {
+			if ((*it)->loaded == -1) {	// Marked for Deletetion?
+				(*it)->loaded = 1;		// Reactivate it
+				return (*it)->tileGfx;
+			}
+		}
+	}
+
+	GfxCache *gc = new GfxCache;
+	strcpy(gc->name, name);
+
+	Common::SeekableReadStream *stream = g_hdb->_fileMan->findFirstData(name, TYPE_TILE32);
+
+	Tile *gfxTile = new Tile;
+	gfxTile->load(stream);
+
+	gc->tileGfx = gfxTile;
+	gc->size = size;
+	gc->loaded = 1;
+
+	_gfxCache->push_back(gc);
+
+	return gc->tileGfx;
+}
+
+Picture *DrawMan::getPicGfx(const char *name, uint32 size) {
+	// Try to find graphic
+	for (Common::Array<GfxCache *>::iterator it = _gfxCache->begin(); it != _gfxCache->end(); it++) {
+		if (Common::matchString((*it)->name, name)) {
+			if ((*it)->loaded == -1) {	// Marked for Deletetion?
+				(*it)->loaded = 1;		// Reactivate it
+				return (*it)->picGfx;
+			}
+		}
+	}
+
+	GfxCache *gc = new GfxCache;
+	strcpy(gc->name, name);
+
+	Common::SeekableReadStream *stream = g_hdb->_fileMan->findFirstData(name, TYPE_TILE32);
+
+	Picture *gfxPic = new Picture;
+	gfxPic->load(stream);
+
+	gc->picGfx = gfxPic;
+	gc->size = size;
+	gc->loaded = 1;
+
+	_gfxCache->push_back(gc);
+
+	return gc->picGfx;
+}
+
+int DrawMan::isSky(int index) {
+	if (!index) {
+		return 0;
+	}
+
+	for (int i = 0; i < kMaxSkies; i++) {
+		if(_skyTiles[i] == index) {
+			return i + 1; // The skyTiles are indexed from 1. 0 => No Sky tile
+		}
+	}
+
+	return 0;
+}
+
+void DrawMan::setSky(int skyIndex) {
+	int tileIndex = _skyTiles[skyIndex - 1];
+	_currentSky = skyIndex;
+
+	// Clear memory used by last sky
+	if (tileIndex != _tileSkyClouds && _skyClouds) {
+		delete _skyClouds;
+		_skyClouds = NULL;
+	}
+
+	// Setup current sky
+	if (tileIndex == _tileSkyStars) {
+		setup3DStars();
+		return;
+	} else if (skyIndex == _tileSkyStarsLeft) {
+		setup3DStarsLeft();
+		return;
+	} else if (skyIndex == _tileSkyStars) {
+		_skyClouds = getPicture("cloudy_skies");
+		return;
+	}
+}
+
+void DrawMan::setup3DStars() {
+	for (int i = 0; i < kNum3DStars; i++) {
+		_stars3D[i].x = g_hdb->_rnd->getRandomNumber(kScreenWidth);
+		_stars3D[i].y = g_hdb->_rnd->getRandomNumber(kScreenHeight);
+		_stars3D[i].speed = g_hdb->_rnd->getRandomNumber(256);
+		_stars3D[i].speed >>= 1;
+		_stars3D[i].color = _stars3D[i].speed / 64;
+	}
+}
+
+void DrawMan::setup3DStarsLeft() {
+	for (int i = 0; i < kNum3DStars; i++) {
+		_stars3DSlow[i].x = g_hdb->_rnd->getRandomNumber(kScreenWidth);
+		_stars3DSlow[i].y = g_hdb->_rnd->getRandomNumber(kScreenHeight);
+		_stars3DSlow[i].speed = ((double) (1 + g_hdb->_rnd->getRandomNumber(5))) / 6.0;
+		_stars3DSlow[i].color = (int) (_stars3DSlow[i].speed * 4.00);
+	}
+}
+
+void DrawMan::draw3DStars() {
+	fillScreen(0);
+	for (int i = 0; i < kNum3DStars; i++) {
+		_starField[_stars3D[i].color]->drawMasked((int)_stars3D[i].x, (int)_stars3D[i].y);
+		_stars3D[i].y += (_stars3D[i].speed >> 5) + 1;
+		if (_stars3D[i].y > kScreenHeight) {
+			_stars3D[i].y = 0;
+		}
+	}
+}
+
+void DrawMan::draw3DStarsLeft() {
+	fillScreen(0);
+	for (int i = 0; i < kNum3DStars; i++) {
+		_starField[_stars3DSlow[i].color]->drawMasked((int)_stars3DSlow[i].x, (int)_stars3DSlow[i].y);
+		_stars3DSlow[i].x -= _stars3DSlow[i].speed;
+		if (_stars3DSlow[i].x < kScreenWidth) {
+			_stars3DSlow[i].x = kScreenWidth - 1;
+		}
+	}
+}
+
+void DrawMan::drawSky() {
+	int tile = _skyTiles[_currentSky - 1];
+
+	if (tile == _tileSkyStars) {
+		draw3DStars();
+	}
+	else if (tile == _tileSkyStarsLeft) {
+		draw3DStarsLeft();
+	}
+	else if (tile == _tileSkyClouds) {
+		static int offset = 0, wait = 0;
+		for (int j = -64; j < kScreenHeight; j += 64) {
+			for (int i = -64; i < kScreenWidth; i += 64) {
+				_skyClouds->draw(i + offset, j + offset);
+			}
+		}
+		wait--;
+		if (wait < 1) {
+			offset = (offset + 1) & 63;
+			wait = 5;
+		}
+	}
+}
+
+int DrawMan::animateTile(int tileIndex) {
+	return _tLookupArray[tileIndex].animIndex;
+}
+
+bool DrawMan::loadFont(const char *string) {
+	Common::SeekableReadStream *stream = g_hdb->_fileMan->findFirstData(string, TYPE_FONT);
+	if (!stream)
+		return false;
+
+	// Loading _fontHeader
+	_fontHeader.type = (int)stream->readUint32LE();
+	_fontHeader.numChars = (int)stream->readUint32LE();
+	_fontHeader.height = (int)stream->readUint32LE();
+	_fontHeader.kerning = (int)stream->readUint32LE();
+	_fontHeader.leading = (int)stream->readUint32LE();
+
+	debug(3, "Loaded _fontHeader with following data");
+	debug(3, "type: %d", _fontHeader.type);
+	debug(3, "numChars: %d", _fontHeader.numChars);
+	debug(3, "height: %d", _fontHeader.height);
+	debug(3, "kerning: %d", _fontHeader.kerning);
+	debug(3, "leading: %d", _fontHeader.leading);
+
+	// Loading _charInfoBlocks & creating character surfaces
+	CharInfo *cInfo;
+	int startPos = stream->pos();	// Position after _fontHeader
+	int curPos;						// Position after reading cInfo
+	uint16 *ptr;
+	for (int i = 0; i < _fontHeader.numChars; i++) {
+		cInfo = new CharInfo;
+		cInfo->width = (int16)stream->readUint32LE();
+		cInfo->offset = (int32)stream->readUint32LE();
+
+		debug(3, "Loaded _charInfoBlocks[%d]: width: %d, offset: %d", i, cInfo->width, cInfo->offset);
+
+		curPos = stream->pos();
+
+		_fontSurfaces[i].create(cInfo->width, _fontHeader.height, g_hdb->_format);
+
+		// Go to character location
+		stream->seek(startPos+cInfo->offset);
+
+		for (int y = 0; y < _fontHeader.height; y++) {
+			ptr = (uint16 *)_fontSurfaces[i].getBasePtr(0, y);
+			for (int x = 0; x < cInfo->width; x++) {
+				*ptr = TO_LE_16(stream->readUint16LE());
+				ptr++;
+			}
+		}
+
+		stream->seek(curPos);
+
+		_charInfoBlocks.push_back(cInfo);
+	}
+
+	// Loading _fontGfx
+	_fontGfx = stream->readUint16LE();
+
+	return true;
+}
+
+void DrawMan::drawText(const char *string) {
+	if (!_systemInit)
+		return;
+
+	if (_cursorX < _eLeft)
+		_cursorX = _eLeft;
+	if (_cursorY < _eTop)
+		_cursorY = _eTop;
+
+	// Word Wrapping
+	int width = _eLeft;
+	unsigned char c;
+	char cr[256];	// Carriage Return Array
+
+	for (int i = 0; i < (int)strlen(string); i++) {
+		c = string[i];
+		width += _charInfoBlocks[c]->width + _fontHeader.kerning + kFontIncrement;
+		if (c == ' ')
+			width += kFontSpace;
+
+		cr[i] = 0;
+		if (c == '\n') {
+			cr[i] = 1;
+			width = _eLeft;
+		} else if (width > _eRight) {
+			i--;
+			while (string[i] != ' ' && i > 0)
+				i--;
+			cr[i] = 1;
+			width = _eLeft;
+		}
+	}
+
+	// Draw the characters
+	for (int j = 0; j < (int)strlen(string); j++) {
+		c = string[j];
+		if (c == '\n' || cr[j]) {
+			_cursorX = _eLeft;
+			_cursorY += _fontHeader.height + _fontHeader.leading;
+			if (_cursorY + _fontHeader.height > _eBottom)
+				_cursorY = _eTop;
+			continue;
+		}
+
+		width = _charInfoBlocks[c]->width;
+		if (c == ' ')
+			width = kFontSpace;
+
+		// Blit the character
+		g_hdb->_drawMan->_globalSurface.transBlitFrom(_fontSurfaces[c], Common::Point(_cursorX, _cursorY), 0xf81f);
+
+		Common::Rect clip(0, 0, width, _fontHeader.height);
+		clip.moveTo(_cursorX, _cursorY);
+		clip.clip(_globalSurface.getBounds());
+		if (!clip.isEmpty()) {
+			g_system->copyRectToScreen(g_hdb->_drawMan->_globalSurface.getBasePtr(clip.left, clip.top), g_hdb->_drawMan->_globalSurface.pitch, clip.left, clip.top, clip.width(), clip.height());
+		}
+
+		// Advance the cursor
+		_cursorX += width + _fontHeader.kerning + kFontIncrement;
+		if (_cursorX > kScreenWidth) {
+			_cursorX = 0;
+			_cursorY += _fontHeader.height + _fontHeader.leading;
+			if (_cursorY + _fontHeader.height > kScreenHeight)
+				_cursorY = 0;
+		}
+	}
+}
+
+// Calculates pixel width of a string
+void DrawMan::getDimensions(const char *string, int *pixelsWide, int *lines) {
+	if (!string) {
+		*pixelsWide = kFontSpace;
+		*lines = 1;
+		return;
+	}
+
+	int width, maxWidth, height;
+	unsigned char c;
+	maxWidth = 0;
+	width = _eLeft;
+	height = 1;
+
+	for (int i = 0; i < (int)strlen(string); i++) {
+		c = string[i];
+		width += _charInfoBlocks[c]->width + _fontHeader.kerning + kFontIncrement;
+		if (c == ' ')
+			width += kFontSpace;
+
+		if (c == '\n') {
+			height++;
+			if (width > maxWidth)
+				maxWidth = width;
+			width = _eLeft;
+		} else if (width > _eRight) {
+			int oldWidth = width;
+			i--;
+			while (string[i] != ' ' && i > 0) {
+				c = string[i];
+				width -= _charInfoBlocks[c]->width + _fontHeader.kerning + kFontIncrement;
+				i--;
+			}
+			if (!i) {
+				maxWidth = oldWidth;
+				break;
+			}
+			height++;
+			if (width > maxWidth)
+				maxWidth = width;
+			width = _eLeft;
+		}
+	}
+
+	if (width > maxWidth)
+		maxWidth = width;
+
+	// If its one line, add 8 pixels
+	if (height == 1)
+		maxWidth += 8;
+
+	*pixelsWide = maxWidth - _eLeft;
+	*lines = height;
+}
+
+int DrawMan::stringLength(const char *string) {
+	int w, h;
+	getDimensions(string, &w, &h);
+	return w;
+}
+
+void DrawMan::setTextEdges(int left, int right, int top, int bottom) {
+	_eLeft = left;
+	_eRight = right;
+	_eTop = top;
+	_eBottom = bottom;
+}
+
+void DrawMan::getTextEdges(int *left, int *right, int *top, int *bottom) {
+	*left = _eLeft;
+	*right = _eRight;
+	*top = _eTop;
+	*bottom = _eBottom;
+}
+
+void DrawMan::setKernLead(int kern, int lead) {
+	_fontHeader.kerning = kern;
+	_fontHeader.leading = lead;
+}
+
+void DrawMan::getKernLead(int *kern, int *lead) {
+	*kern = _fontHeader.kerning;
+	*lead = _fontHeader.leading;
+}
+
+void DrawMan::setCursor(int x, int y) {
+	_cursorX = x;
+	_cursorY = y;
+}
+
+void DrawMan::getCursor(int *x, int *y) {
+	*x = _cursorX;
+	*y = _cursorY;
+}
+
+Picture::Picture() : _width(0), _height(0), _name("") {
+	_surface.create(_width, _height, g_hdb->_format);
+}
+
+Picture::~Picture() {
+	_surface.free();
+}
+
+Graphics::Surface Picture::load(Common::SeekableReadStream *stream) {
+	_width = stream->readUint32LE();
+	_height = stream->readUint32LE();
+	stream->read(_name, 64);
+
+	debug(8, "Picture: _width: %d, _height: %d", _width, _height);
+	debug(8, "Picture: _name: %s", _name);
+
+	_surface.create(_width, _height, g_hdb->_format);
+	stream->readUint32LE(); // Skip Win32 Surface
+
+	uint16 *ptr;
+
+	for (uint y = 0; y < _height; y++) {
+		ptr = (uint16 *)_surface.getBasePtr(0, y);
+		for (uint x = 0; x < _width; x++) {
+			*ptr = TO_LE_16(stream->readUint16LE());
+			ptr++;
+		}
+	}
+
+	return _surface;
+}
+
+void Picture::draw(int x, int y) {
+	g_hdb->_drawMan->_globalSurface.blitFrom(_surface, Common::Point(x, y));
+
+	Common::Rect clip(_surface.getBounds());
+	clip.moveTo(x, y);
+	clip.clip(g_hdb->_drawMan->_globalSurface.getBounds());
+	if (!clip.isEmpty()) {
+		g_system->copyRectToScreen(g_hdb->_drawMan->_globalSurface.getBasePtr(clip.left, clip.top), g_hdb->_drawMan->_globalSurface.pitch, clip.left, clip.top, clip.width(), clip.height());
+	}
+}
+
+void Picture::drawMasked(int x, int y) {
+	g_hdb->_drawMan->_globalSurface.transBlitFrom(_surface, Common::Point(x, y), 0xf81f);
+
+	Common::Rect clip(_surface.getBounds());
+	clip.moveTo(x, y);
+	clip.clip(g_hdb->_drawMan->_globalSurface.getBounds());
+	if (!clip.isEmpty()) {
+		g_system->copyRectToScreen(g_hdb->_drawMan->_globalSurface.getBasePtr(clip.left, clip.top), g_hdb->_drawMan->_globalSurface.pitch, clip.left, clip.top, clip.width(), clip.height());
+	}
+}
+
+Tile::Tile() : _flags(0), _name("") {
+	_surface.create(32, 32, g_hdb->_format);
+}
+
+Tile::~Tile() {
+	_surface.free();
+}
+
+Graphics::Surface Tile::load(Common::SeekableReadStream *stream) {
+	_flags = stream->readUint32LE();
+	stream->read(_name, 64);
+
+	_surface.create(32, 32, g_hdb->_format);
+	stream->readUint32LE(); // Skip Win32 Surface
+
+	uint16 *ptr;
+
+	for (uint y = 0; y < 32; y++) {
+		ptr = (uint16 *)_surface.getBasePtr(0, y);
+		for (uint x = 0; x < 32; x++) {
+			*ptr = TO_LE_16(stream->readUint16LE());
+			ptr++;
+		}
+	}
+
+	return _surface;
+}
+
+void Tile::draw(int x, int y) {
+	g_hdb->_drawMan->_globalSurface.blitFrom(_surface, Common::Point(x, y));
+
+	Common::Rect clip(_surface.getBounds());
+	clip.moveTo(x, y);
+	clip.clip(g_hdb->_drawMan->_globalSurface.getBounds());
+	if (!clip.isEmpty()) {
+		g_system->copyRectToScreen(g_hdb->_drawMan->_globalSurface.getBasePtr(clip.left, clip.top), g_hdb->_drawMan->_globalSurface.pitch, clip.left, clip.top, clip.width(), clip.height());
+	}
+}
+
+void Tile::drawMasked(int x, int y) {
+	g_hdb->_drawMan->_globalSurface.transBlitFrom(_surface, Common::Point(x, y), 0xf81f);
+
+	Common::Rect clip(_surface.getBounds());
+	clip.moveTo(x, y);
+	clip.clip(g_hdb->_drawMan->_globalSurface.getBounds());
+	if (!clip.isEmpty()) {
+		g_system->copyRectToScreen(g_hdb->_drawMan->_globalSurface.getBasePtr(clip.left, clip.top), g_hdb->_drawMan->_globalSurface.pitch, clip.left, clip.top, clip.width(), clip.height());
+	}
+}
+
+}
diff --git a/engines/hdb/gfx.h b/engines/hdb/gfx.h
new file mode 100644
index 0000000..1ace112
--- /dev/null
+++ b/engines/hdb/gfx.h
@@ -0,0 +1,242 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef HDB_DRAW_MANAGER_H
+#define HDB_DRAW_MANAGER_H
+
+#include "graphics/managed_surface.h"
+
+#include "hdb/hdb.h"
+
+namespace HDB {
+
+enum {
+	kScreenWidth = 640,
+	kScreenHeight = 480,
+	kTileWidth = 32,
+	kTileHeight = 32,
+	kMaxSkies = 10,
+	kNum3DStars = 300,
+	kFontSpace = 5,
+	kFontIncrement = 1,
+	kGameFPS = 60,
+	kAnimFrameDelay = kGameFPS / 30,
+	kAnimSlowFrames = kAnimFrameDelay * 10,
+	kAnimMediumFrames = kAnimFrameDelay * 6,
+	kAnimFastFrames = kAnimFrameDelay * 2
+};
+
+class Tile;
+class Picture;
+
+struct TileLookup {
+	const char *filename;
+	Tile *tData;
+	uint16 skyIndex;
+	uint16 animIndex;
+
+	TileLookup() : filename(NULL), tData(NULL), skyIndex(0), animIndex(0) {}
+};
+
+struct GfxCache {
+	char name[32];
+	union {
+		Tile *tileGfx;
+		Picture *picGfx;
+	};
+	uint32 size;
+	int16 loaded;
+
+	GfxCache() : name(""), tileGfx(NULL), size(0), loaded(0) {}
+};
+
+struct FontInfo {
+	int		type;		// 0 = mono, 1 = proportional
+	int		numChars;	// how many characters in font
+	int		height;		// height of entire font
+	int		kerning;	// space between chars
+	int		leading;	// space between lines
+};
+
+struct CharInfo {
+	int16 width;	// Character width in pixels
+	int32 offset;	// From the start of the font charInfo chunk
+};
+
+class DrawMan {
+public:
+
+	DrawMan();
+	~DrawMan();
+
+	Graphics::ManagedSurface _globalSurface;
+
+	bool init();
+	void fillScreen(uint32 color);
+	void updateVideo();
+	void setPointerState(int value);
+	void drawPointer();
+	void showPointer(bool status) {
+		_showCursor = status;
+	}
+	bool getPointer() {
+		return _showCursor;
+	}
+
+	void setFade(bool fadeIn, bool black, int steps);
+	void updateFade();
+	bool isFadeActive() { return _fadeInfo.active; }
+	bool isFadeStaying() { return _fadeInfo.stayFaded; }
+	void turnOffFade() { _fadeInfo.active = _fadeInfo.stayFaded = false; }
+
+	Picture *loadPic(const char *picName);
+	Tile *loadTile(const char *tileName);
+
+	Tile *getTile(int index);
+	void cacheTileSequence(int index, int count);
+	int getTileIndex(const char *name);
+	Picture *getPicture(const char *name);
+
+	// Returns: true->Tile, false->Pic
+	bool selectGfxType(const char *name);
+	Tile *getTileGfx(const char *name, uint32 size);
+	Picture *getPicGfx(const char *name, uint32 size);
+
+	int isSky(int skyIndex);
+	void setSky(int skyIndex);
+	void setup3DStars();
+	void setup3DStarsLeft();
+	void draw3DStars();
+	void draw3DStarsLeft();
+	void drawSky();
+
+	int animateTile(int tileIndex);
+
+	// Font Functions
+
+	bool loadFont(const char *string);
+	void drawText(const char *string);
+	void getDimensions(const char *string, int *pixelsWide, int *lines);
+	int stringLength(const char *string);
+	void setTextEdges(int left, int right, int top, int bottom);
+	void getTextEdges(int *left, int *right, int *top, int *bottom);
+	void setKernLead(int kern, int lead);
+	void getKernLead(int *kern, int *lead);
+	void setCursor(int x, int y);
+	void getCursor(int *x, int *y);
+
+private:
+	int _numTiles;
+	TileLookup *_tLookupArray;
+	uint16 _skyTiles[kMaxSkies];
+
+	Common::Array<GfxCache *> *_gfxCache;
+
+	int _currentSky;	// 0 if no Sky, 1+ for which Sky to use
+	struct {
+		bool active;
+		bool stayFaded;
+		bool isBlack;
+		int speed;
+		bool isFadeIn;
+
+		int curStep;
+	} _fadeInfo;
+
+	struct {
+		int x, y, speed;
+		uint16 color;
+	} _stars3D[kNum3DStars];
+
+	struct {
+		double x, y, speed;
+		uint16 color;
+	} _stars3DSlow[kNum3DStars];
+
+	int _tileSkyStars; // Index of sky_stars tile
+	int _tileSkyStarsLeft; // Left-scrolling stars, slow
+	int _tileSkyClouds; // Index of sky_stars tile
+	Picture *_starField[4];
+	Picture *_skyClouds;
+
+	// Cursor
+	int _cursorX, _cursorY;
+	Picture *_mousePointer[8];	// Gfx for screen pointer (4 Animations)
+	int _pointerDisplayable;
+	bool _showCursor;
+
+	// Font Data
+
+	FontInfo _fontHeader;
+	Common::Array<CharInfo *> _charInfoBlocks;
+	Graphics::Surface _fontSurfaces[256];
+	uint16 _fontGfx;
+	int _eLeft, _eRight, _eTop, _eBottom;
+
+	bool _systemInit;
+
+};
+
+class Picture {
+public:
+
+	Picture();
+	~Picture();
+
+	Graphics::Surface load(Common::SeekableReadStream *stream);
+	void draw(int x, int y);
+	void drawMasked(int x, int y);
+
+	uint _width, _height;
+
+	char *getName() { return _name; }
+
+private:
+
+	char _name[64];
+
+	Graphics::ManagedSurface _surface;
+
+};
+
+class Tile {
+public:
+
+	Tile();
+	~Tile();
+
+	Graphics::Surface load(Common::SeekableReadStream *stream);
+	void draw(int x, int y);
+	void drawMasked(int x, int y);
+
+	uint32 _flags;
+
+	char *getName() { return _name; }
+private:
+	char _name[64];
+
+	Graphics::ManagedSurface _surface;
+};
+
+} // End of Namespace HDB
+
+#endif // !HDB_DRAW_MANAGER_H
diff --git a/engines/hdb/hdb.h b/engines/hdb/hdb.h
index e9f0548..3c90cdf 100644
--- a/engines/hdb/hdb.h
+++ b/engines/hdb/hdb.h
@@ -38,7 +38,7 @@
 #include "console.h"
 
 #include "hdb/mpc.h"
-#include "hdb/draw-manager.h"
+#include "hdb/gfx.h"
 #include "hdb/ai.h"
 #include "hdb/ai-player.h"
 #include "hdb/file-manager.h"
diff --git a/engines/hdb/module.mk b/engines/hdb/module.mk
index af32361..e55658f 100644
--- a/engines/hdb/module.mk
+++ b/engines/hdb/module.mk
@@ -11,9 +11,9 @@ MODULE_OBJS := \
 	ai-use.o \
 	ai-waypoint.o \
 	console.o \
-	draw-manager.o \
 	detection.o \
 	file-manager.o \
+	gfx.o \
 	hdb.o \
 	input.o \
 	lua-script.o \


Commit: 362cb060f3a70bf21218c17c148a84abbd685989
    https://github.com/scummvm/scummvm/commit/362cb060f3a70bf21218c17c148a84abbd685989
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:07+02:00

Commit Message:
HDB: Rename _drawMan -> _gfx

Changed paths:
    engines/hdb/ai-cinematic.cpp
    engines/hdb/ai-funcs.cpp
    engines/hdb/ai-init.cpp
    engines/hdb/ai-lists.cpp
    engines/hdb/ai-player.cpp
    engines/hdb/gfx.cpp
    engines/hdb/hdb.cpp
    engines/hdb/hdb.h
    engines/hdb/input.cpp
    engines/hdb/lua-script.cpp
    engines/hdb/map-loader.cpp
    engines/hdb/window.cpp


diff --git a/engines/hdb/ai-cinematic.cpp b/engines/hdb/ai-cinematic.cpp
index 915605b..bda993d 100644
--- a/engines/hdb/ai-cinematic.cpp
+++ b/engines/hdb/ai-cinematic.cpp
@@ -299,7 +299,7 @@ void AI::processCines() {
 			if (!_cine[i]->start) {
 				Picture *pic = cineFindInBlitList(_cine[i]->id);
 				if (!pic) {
-					pic = g_hdb->_drawMan->loadPic(_cine[i]->string);
+					pic = g_hdb->_gfx->loadPic(_cine[i]->string);
 					cineAddToFreeList(pic);
 				} else
 					cineRemoveFromBlitList(_cine[i]->id);
@@ -334,17 +334,17 @@ void AI::processCines() {
 			break;
 		case C_FADEIN:
 			if (!_cine[i]->start) {
-				g_hdb->_drawMan->setFade(true, (bool)_cine[i]->end, _cine[i]->speed);
+				g_hdb->_gfx->setFade(true, (bool)_cine[i]->end, _cine[i]->speed);
 				_cine[i]->start = 1;
-			} else if (!g_hdb->_drawMan->isFadeActive()) {
+			} else if (!g_hdb->_gfx->isFadeActive()) {
 				complete = true;
 			}
 			break;
 		case C_FADEOUT:
 			if (!_cine[i]->start) {
-				g_hdb->_drawMan->setFade(false, (bool)_cine[i]->end, _cine[i]->speed);
+				g_hdb->_gfx->setFade(false, (bool)_cine[i]->end, _cine[i]->speed);
 				_cine[i]->start = 1;
-			} else if (!g_hdb->_drawMan->isFadeActive()) {
+			} else if (!g_hdb->_gfx->isFadeActive()) {
 				complete = true;
 			}
 			break;
diff --git a/engines/hdb/ai-funcs.cpp b/engines/hdb/ai-funcs.cpp
index 721fcbd..c68410e 100644
--- a/engines/hdb/ai-funcs.cpp
+++ b/engines/hdb/ai-funcs.cpp
@@ -101,8 +101,8 @@ bool AI::cacheEntGfx(AIEntity *e, bool init) {
 				for (Common::Array<const char *>::iterator it = gfxFiles->begin(); it != gfxFiles->end(); it++) {
 					size = g_hdb->_fileMan->getLength((*it), TYPE_TILE32);
 
-					if (g_hdb->_drawMan->selectGfxType((*it))) {
-						Tile *gfx = g_hdb->_drawMan->getTileGfx((*it), size);
+					if (g_hdb->_gfx->selectGfxType((*it))) {
+						Tile *gfx = g_hdb->_gfx->getTileGfx((*it), size);
 
 						switch (list[j].state) {
 						case STATE_STANDDOWN:
@@ -381,7 +381,7 @@ bool AI::cacheEntGfx(AIEntity *e, bool init) {
 							break;
 						}
 					} else {
-						Picture *gfx = g_hdb->_drawMan->getPicGfx((*it), size);
+						Picture *gfx = g_hdb->_gfx->getPicGfx((*it), size);
 
 						switch (list[j].state) {
 						case STATE_ATK_CLUB_UP:
diff --git a/engines/hdb/ai-init.cpp b/engines/hdb/ai-init.cpp
index feeac65..f8fe0c2 100644
--- a/engines/hdb/ai-init.cpp
+++ b/engines/hdb/ai-init.cpp
@@ -706,71 +706,71 @@ bool AI::init() {
 	_waypointGfx[3]->load(g_hdb->_fileMan->findFirstData("icon_waypoint_select4", TYPE_ICON32));
 
 	// Setup Vars to reference SPECIAL Map Tiles
-	_useSwitchOff	= g_hdb->_drawMan->getTileIndex("anim_t32_switch_off01");
-	_useSwitchOn	= g_hdb->_drawMan->getTileIndex("t32_switch_on");
-	_useSwitch2Off	= g_hdb->_drawMan->getTileIndex("anim_t32_1switch_off01");
-	_useSwitch2On	= g_hdb->_drawMan->getTileIndex("t32_1switch_on");
-//	_useHandswitchOn	= g_hdb->_drawMan->getTileIndex("t32_ship_handswitch_on");
-//	_useHandswitchOff	= g_hdb->_drawMan->getTileIndex("anim_t32_ship_handswitch_off1");
-	_useHolderEmpty	= g_hdb->_drawMan->getTileIndex("anim_t32_holder_empty1");
-	_useHolderFull	= g_hdb->_drawMan->getTileIndex("t32_holder_full");
-	_useMailsorter	= g_hdb->_drawMan->getTileIndex("anim_t32_mailsort1");
-	_useAskcomp		= g_hdb->_drawMan->getTileIndex("anim_t32_askcomp1");
-
-	_targetDoorN	= g_hdb->_drawMan->getTileIndex("t32_door_n_1");
-	_targetDoorP	= g_hdb->_drawMan->getTileIndex("t32_door_p_1");
-	_targetDoorS	= g_hdb->_drawMan->getTileIndex("t32_door_s_1");
-	_targetDoorNv	= g_hdb->_drawMan->getTileIndex("t32_door_nv_1");
-	_targetDoorPv	= g_hdb->_drawMan->getTileIndex("t32_door_pv_1");
-	_targetDoorSv	= g_hdb->_drawMan->getTileIndex("t32_door_sv_1");
-
-	_targetDoor2N	= g_hdb->_drawMan->getTileIndex("t32_door2_n_1");
-	_targetDoor2P	= g_hdb->_drawMan->getTileIndex("t32_door2_p_1");
-	_targetDoor2S	= g_hdb->_drawMan->getTileIndex("t32_door2_s_1");
-	_targetDoor2Nv	= g_hdb->_drawMan->getTileIndex("t32_door2_nv_1");
-	_targetDoor2Pv	= g_hdb->_drawMan->getTileIndex("t32_door2_pv_1");
-	_targetDoor2Sv	= g_hdb->_drawMan->getTileIndex("t32_door2_sv_1");
-
-	_target2DoorN	= g_hdb->_drawMan->getTileIndex("t32_e2_door_n_1");
-	_target2DoorP	= g_hdb->_drawMan->getTileIndex("t32_e2_door_p_1");
-	_target2DoorS	= g_hdb->_drawMan->getTileIndex("t32_e2_door_s_1");
-	_target2DoorNv	= g_hdb->_drawMan->getTileIndex("t32_e2_door_nv_1");
-	_target2DoorPv	= g_hdb->_drawMan->getTileIndex("t32_e2_door_pv_1");
-	_target2DoorSv	= g_hdb->_drawMan->getTileIndex("t32_e2_door_sv_1");
-
-	_target3DoorN	= g_hdb->_drawMan->getTileIndex("t32_e3_door_n_1");
-	_target3DoorP	= g_hdb->_drawMan->getTileIndex("t32_e3_door_p_1");
-	_target3DoorS	= g_hdb->_drawMan->getTileIndex("t32_e3_door_s_1");
-	_target3DoorNv	= g_hdb->_drawMan->getTileIndex("t32_e3_door_nv_1");
-	_target3DoorPv	= g_hdb->_drawMan->getTileIndex("t32_e3_door_pv_1");
-	_target3DoorSv	= g_hdb->_drawMan->getTileIndex("t32_e3_door_sv_1");
-
-	_targetBridgeU	= g_hdb->_drawMan->getTileIndex("t32_bridgeup1");
-	_targetBridgeD	= g_hdb->_drawMan->getTileIndex("t32_bridgedown1");
-	_targetBridgeL	= g_hdb->_drawMan->getTileIndex("t32_bridgeleft1");
-	_targetBridgeR	= g_hdb->_drawMan->getTileIndex("t32_bridgeright1");
-	_targetBridgeMidLR	= g_hdb->_drawMan->getTileIndex("t32_mgrate_mid");
-	_targetBridgeMidUD	= g_hdb->_drawMan->getTileIndex("t32_mgrate_tbmid");
-	_touchplateOn	= g_hdb->_drawMan->getTileIndex("t32_touchplateon");
-	_touchplateOff	= g_hdb->_drawMan->getTileIndex("t32_touchplateoff");
-	_blockpole		= g_hdb->_drawMan->getTileIndex("t32_blockpole_1");
-	_useTeleporter	= g_hdb->_drawMan->getTileIndex("anim_t32_teleporter1");
-
-	_useSwitchOff	= g_hdb->_drawMan->getTileIndex("t32_temple_touchplate_on");
-	_useSwitchOff	= g_hdb->_drawMan->getTileIndex("t32_temple_touchplate_off");
-
-	_kcHolderWhiteOff	= g_hdb->_drawMan->getTileIndex("anim_t32_kcholder_white_off1");
-	_kcHolderWhiteOn	= g_hdb->_drawMan->getTileIndex("t32_kcholder_white_on");
-	_kcHolderBlueOff	= g_hdb->_drawMan->getTileIndex("anim_t32_kcholder_blue_off1");
-	_kcHolderBlueOn		= g_hdb->_drawMan->getTileIndex("t32_kcholder_blue_on");
-	_kcHolderRedOff		= g_hdb->_drawMan->getTileIndex("anim_t32_kcholder_red_off1");
-	_kcHolderRedOn		= g_hdb->_drawMan->getTileIndex("t32_kcholder_red_on");
-	_kcHolderGreenOff	= g_hdb->_drawMan->getTileIndex("anim_t32_kcholder_green_off1");
-	_kcHolderGreenOn	= g_hdb->_drawMan->getTileIndex("t32_kcholder_green_on");
-	_kcHolderPurpleOff	= g_hdb->_drawMan->getTileIndex("anim_t32_kcholder_purple_off1");
-	_kcHolderPurpleOn	= g_hdb->_drawMan->getTileIndex("t32_kcholder_purple_on");
-	_kcHolderBlackOff	= g_hdb->_drawMan->getTileIndex("anim_t32_kcholder_black_off1");
-	_kcHolderBlackOn	= g_hdb->_drawMan->getTileIndex("t32_kcholder_black_on");
+	_useSwitchOff	= g_hdb->_gfx->getTileIndex("anim_t32_switch_off01");
+	_useSwitchOn	= g_hdb->_gfx->getTileIndex("t32_switch_on");
+	_useSwitch2Off	= g_hdb->_gfx->getTileIndex("anim_t32_1switch_off01");
+	_useSwitch2On	= g_hdb->_gfx->getTileIndex("t32_1switch_on");
+//	_useHandswitchOn	= g_hdb->_gfx->getTileIndex("t32_ship_handswitch_on");
+//	_useHandswitchOff	= g_hdb->_gfx->getTileIndex("anim_t32_ship_handswitch_off1");
+	_useHolderEmpty	= g_hdb->_gfx->getTileIndex("anim_t32_holder_empty1");
+	_useHolderFull	= g_hdb->_gfx->getTileIndex("t32_holder_full");
+	_useMailsorter	= g_hdb->_gfx->getTileIndex("anim_t32_mailsort1");
+	_useAskcomp		= g_hdb->_gfx->getTileIndex("anim_t32_askcomp1");
+
+	_targetDoorN	= g_hdb->_gfx->getTileIndex("t32_door_n_1");
+	_targetDoorP	= g_hdb->_gfx->getTileIndex("t32_door_p_1");
+	_targetDoorS	= g_hdb->_gfx->getTileIndex("t32_door_s_1");
+	_targetDoorNv	= g_hdb->_gfx->getTileIndex("t32_door_nv_1");
+	_targetDoorPv	= g_hdb->_gfx->getTileIndex("t32_door_pv_1");
+	_targetDoorSv	= g_hdb->_gfx->getTileIndex("t32_door_sv_1");
+
+	_targetDoor2N	= g_hdb->_gfx->getTileIndex("t32_door2_n_1");
+	_targetDoor2P	= g_hdb->_gfx->getTileIndex("t32_door2_p_1");
+	_targetDoor2S	= g_hdb->_gfx->getTileIndex("t32_door2_s_1");
+	_targetDoor2Nv	= g_hdb->_gfx->getTileIndex("t32_door2_nv_1");
+	_targetDoor2Pv	= g_hdb->_gfx->getTileIndex("t32_door2_pv_1");
+	_targetDoor2Sv	= g_hdb->_gfx->getTileIndex("t32_door2_sv_1");
+
+	_target2DoorN	= g_hdb->_gfx->getTileIndex("t32_e2_door_n_1");
+	_target2DoorP	= g_hdb->_gfx->getTileIndex("t32_e2_door_p_1");
+	_target2DoorS	= g_hdb->_gfx->getTileIndex("t32_e2_door_s_1");
+	_target2DoorNv	= g_hdb->_gfx->getTileIndex("t32_e2_door_nv_1");
+	_target2DoorPv	= g_hdb->_gfx->getTileIndex("t32_e2_door_pv_1");
+	_target2DoorSv	= g_hdb->_gfx->getTileIndex("t32_e2_door_sv_1");
+
+	_target3DoorN	= g_hdb->_gfx->getTileIndex("t32_e3_door_n_1");
+	_target3DoorP	= g_hdb->_gfx->getTileIndex("t32_e3_door_p_1");
+	_target3DoorS	= g_hdb->_gfx->getTileIndex("t32_e3_door_s_1");
+	_target3DoorNv	= g_hdb->_gfx->getTileIndex("t32_e3_door_nv_1");
+	_target3DoorPv	= g_hdb->_gfx->getTileIndex("t32_e3_door_pv_1");
+	_target3DoorSv	= g_hdb->_gfx->getTileIndex("t32_e3_door_sv_1");
+
+	_targetBridgeU	= g_hdb->_gfx->getTileIndex("t32_bridgeup1");
+	_targetBridgeD	= g_hdb->_gfx->getTileIndex("t32_bridgedown1");
+	_targetBridgeL	= g_hdb->_gfx->getTileIndex("t32_bridgeleft1");
+	_targetBridgeR	= g_hdb->_gfx->getTileIndex("t32_bridgeright1");
+	_targetBridgeMidLR	= g_hdb->_gfx->getTileIndex("t32_mgrate_mid");
+	_targetBridgeMidUD	= g_hdb->_gfx->getTileIndex("t32_mgrate_tbmid");
+	_touchplateOn	= g_hdb->_gfx->getTileIndex("t32_touchplateon");
+	_touchplateOff	= g_hdb->_gfx->getTileIndex("t32_touchplateoff");
+	_blockpole		= g_hdb->_gfx->getTileIndex("t32_blockpole_1");
+	_useTeleporter	= g_hdb->_gfx->getTileIndex("anim_t32_teleporter1");
+
+	_useSwitchOff	= g_hdb->_gfx->getTileIndex("t32_temple_touchplate_on");
+	_useSwitchOff	= g_hdb->_gfx->getTileIndex("t32_temple_touchplate_off");
+
+	_kcHolderWhiteOff	= g_hdb->_gfx->getTileIndex("anim_t32_kcholder_white_off1");
+	_kcHolderWhiteOn	= g_hdb->_gfx->getTileIndex("t32_kcholder_white_on");
+	_kcHolderBlueOff	= g_hdb->_gfx->getTileIndex("anim_t32_kcholder_blue_off1");
+	_kcHolderBlueOn		= g_hdb->_gfx->getTileIndex("t32_kcholder_blue_on");
+	_kcHolderRedOff		= g_hdb->_gfx->getTileIndex("anim_t32_kcholder_red_off1");
+	_kcHolderRedOn		= g_hdb->_gfx->getTileIndex("t32_kcholder_red_on");
+	_kcHolderGreenOff	= g_hdb->_gfx->getTileIndex("anim_t32_kcholder_green_off1");
+	_kcHolderGreenOn	= g_hdb->_gfx->getTileIndex("t32_kcholder_green_on");
+	_kcHolderPurpleOff	= g_hdb->_gfx->getTileIndex("anim_t32_kcholder_purple_off1");
+	_kcHolderPurpleOn	= g_hdb->_gfx->getTileIndex("t32_kcholder_purple_on");
+	_kcHolderBlackOff	= g_hdb->_gfx->getTileIndex("anim_t32_kcholder_black_off1");
+	_kcHolderBlackOn	= g_hdb->_gfx->getTileIndex("t32_kcholder_black_on");
 
 	_dummyPlayer.type = AI_GUY;
 	_dummyLaser.type = AI_LASERBEAM;
@@ -873,97 +873,97 @@ void AI::restartSystem() {
 
 void AI::initAnimInfo() {
 	if (g_hdb->_map->checkOneTileExistInRange(_useSwitchOff, 2))
-		g_hdb->_drawMan->getTile(_useSwitchOn);
+		g_hdb->_gfx->getTile(_useSwitchOn);
 	if (g_hdb->_map->checkOneTileExistInRange(_useSwitch2Off, 2))
-		g_hdb->_drawMan->getTile(_useSwitch2On);
+		g_hdb->_gfx->getTile(_useSwitch2On);
 	if (g_hdb->_map->checkOneTileExistInRange(_useHolderEmpty, 2))
-		g_hdb->_drawMan->getTile(_useHolderFull);
+		g_hdb->_gfx->getTile(_useHolderFull);
 	if (g_hdb->_map->checkOneTileExistInRange(_useHandswitchOff, 2))
-		g_hdb->_drawMan->getTile(_useHandswitchOn);
+		g_hdb->_gfx->getTile(_useHandswitchOn);
 
 	if (g_hdb->_map->checkOneTileExistInRange(_targetDoorN, 4))
-		g_hdb->_drawMan->cacheTileSequence(_targetDoorN, 4);
+		g_hdb->_gfx->cacheTileSequence(_targetDoorN, 4);
 	if (g_hdb->_map->checkOneTileExistInRange(_targetDoorP, 4))
-		g_hdb->_drawMan->cacheTileSequence(_targetDoorP, 4);
+		g_hdb->_gfx->cacheTileSequence(_targetDoorP, 4);
 	if (g_hdb->_map->checkOneTileExistInRange(_targetDoorS, 4))
-		g_hdb->_drawMan->cacheTileSequence(_targetDoorS, 4);
+		g_hdb->_gfx->cacheTileSequence(_targetDoorS, 4);
 	if (g_hdb->_map->checkOneTileExistInRange(_targetDoorNv, 4))
-		g_hdb->_drawMan->cacheTileSequence(_targetDoorNv, 4);
+		g_hdb->_gfx->cacheTileSequence(_targetDoorNv, 4);
 	if (g_hdb->_map->checkOneTileExistInRange(_targetDoorPv, 4))
-		g_hdb->_drawMan->cacheTileSequence(_targetDoorPv, 4);
+		g_hdb->_gfx->cacheTileSequence(_targetDoorPv, 4);
 	if (g_hdb->_map->checkOneTileExistInRange(_targetDoorSv, 4))
-		g_hdb->_drawMan->cacheTileSequence(_targetDoorSv, 4);
+		g_hdb->_gfx->cacheTileSequence(_targetDoorSv, 4);
 
 	if (g_hdb->_map->checkOneTileExistInRange(_targetDoor2N, 4))
-		g_hdb->_drawMan->cacheTileSequence(_targetDoor2N, 4);
+		g_hdb->_gfx->cacheTileSequence(_targetDoor2N, 4);
 	if (g_hdb->_map->checkOneTileExistInRange(_targetDoor2P, 4))
-		g_hdb->_drawMan->cacheTileSequence(_targetDoor2P, 4);
+		g_hdb->_gfx->cacheTileSequence(_targetDoor2P, 4);
 	if (g_hdb->_map->checkOneTileExistInRange(_targetDoor2S, 4))
-		g_hdb->_drawMan->cacheTileSequence(_targetDoor2S, 4);
+		g_hdb->_gfx->cacheTileSequence(_targetDoor2S, 4);
 	if (g_hdb->_map->checkOneTileExistInRange(_targetDoor2Nv, 4))
-		g_hdb->_drawMan->cacheTileSequence(_targetDoor2Nv, 4);
+		g_hdb->_gfx->cacheTileSequence(_targetDoor2Nv, 4);
 	if (g_hdb->_map->checkOneTileExistInRange(_targetDoor2Pv, 4))
-		g_hdb->_drawMan->cacheTileSequence(_targetDoor2Pv, 4);
+		g_hdb->_gfx->cacheTileSequence(_targetDoor2Pv, 4);
 	if (g_hdb->_map->checkOneTileExistInRange(_targetDoor2Sv, 4))
-		g_hdb->_drawMan->cacheTileSequence(_targetDoor2Sv, 4);
+		g_hdb->_gfx->cacheTileSequence(_targetDoor2Sv, 4);
 
 	if (g_hdb->_map->checkOneTileExistInRange(_target2DoorN, 4))
-		g_hdb->_drawMan->cacheTileSequence(_target2DoorN, 4);
+		g_hdb->_gfx->cacheTileSequence(_target2DoorN, 4);
 	if (g_hdb->_map->checkOneTileExistInRange(_target2DoorP, 4))
-		g_hdb->_drawMan->cacheTileSequence(_target2DoorP, 4);
+		g_hdb->_gfx->cacheTileSequence(_target2DoorP, 4);
 	if (g_hdb->_map->checkOneTileExistInRange(_target2DoorS, 4))
-		g_hdb->_drawMan->cacheTileSequence(_target2DoorS, 4);
+		g_hdb->_gfx->cacheTileSequence(_target2DoorS, 4);
 	if (g_hdb->_map->checkOneTileExistInRange(_target2DoorNv, 4))
-		g_hdb->_drawMan->cacheTileSequence(_target2DoorNv, 4);
+		g_hdb->_gfx->cacheTileSequence(_target2DoorNv, 4);
 	if (g_hdb->_map->checkOneTileExistInRange(_target2DoorPv, 4))
-		g_hdb->_drawMan->cacheTileSequence(_target2DoorPv, 4);
+		g_hdb->_gfx->cacheTileSequence(_target2DoorPv, 4);
 	if (g_hdb->_map->checkOneTileExistInRange(_target2DoorSv, 4))
-		g_hdb->_drawMan->cacheTileSequence(_target2DoorSv, 4);
+		g_hdb->_gfx->cacheTileSequence(_target2DoorSv, 4);
 
 	if (g_hdb->_map->checkOneTileExistInRange(_target3DoorN, 4))
-		g_hdb->_drawMan->cacheTileSequence(_target3DoorN, 4);
+		g_hdb->_gfx->cacheTileSequence(_target3DoorN, 4);
 	if (g_hdb->_map->checkOneTileExistInRange(_target3DoorP, 4))
-		g_hdb->_drawMan->cacheTileSequence(_target3DoorP, 4);
+		g_hdb->_gfx->cacheTileSequence(_target3DoorP, 4);
 	if (g_hdb->_map->checkOneTileExistInRange(_target3DoorS, 4))
-		g_hdb->_drawMan->cacheTileSequence(_target3DoorS, 4);
+		g_hdb->_gfx->cacheTileSequence(_target3DoorS, 4);
 	if (g_hdb->_map->checkOneTileExistInRange(_target3DoorNv, 4))
-		g_hdb->_drawMan->cacheTileSequence(_target3DoorNv, 4);
+		g_hdb->_gfx->cacheTileSequence(_target3DoorNv, 4);
 	if (g_hdb->_map->checkOneTileExistInRange(_target3DoorPv, 4))
-		g_hdb->_drawMan->cacheTileSequence(_target3DoorPv, 4);
+		g_hdb->_gfx->cacheTileSequence(_target3DoorPv, 4);
 	if (g_hdb->_map->checkOneTileExistInRange(_target3DoorSv, 4))
-		g_hdb->_drawMan->cacheTileSequence(_target3DoorSv, 4);
+		g_hdb->_gfx->cacheTileSequence(_target3DoorSv, 4);
 
 	if (g_hdb->_map->checkOneTileExistInRange(_targetBridgeU, 3))
-		g_hdb->_drawMan->cacheTileSequence(_targetBridgeU, 3);
+		g_hdb->_gfx->cacheTileSequence(_targetBridgeU, 3);
 	if (g_hdb->_map->checkOneTileExistInRange(_targetBridgeD, 3))
-		g_hdb->_drawMan->cacheTileSequence(_targetBridgeD, 3);
+		g_hdb->_gfx->cacheTileSequence(_targetBridgeD, 3);
 	if (g_hdb->_map->checkOneTileExistInRange(_targetBridgeL, 3))
-		g_hdb->_drawMan->cacheTileSequence(_targetBridgeL, 3);
+		g_hdb->_gfx->cacheTileSequence(_targetBridgeL, 3);
 	if (g_hdb->_map->checkOneTileExistInRange(_targetBridgeR, 3))
-		g_hdb->_drawMan->cacheTileSequence(_targetBridgeR, 3);
+		g_hdb->_gfx->cacheTileSequence(_targetBridgeR, 3);
 
-	g_hdb->_drawMan->cacheTileSequence(_targetBridgeMidLR, 1);
-	g_hdb->_drawMan->cacheTileSequence(_targetBridgeMidUD, 1);
+	g_hdb->_gfx->cacheTileSequence(_targetBridgeMidLR, 1);
+	g_hdb->_gfx->cacheTileSequence(_targetBridgeMidUD, 1);
 
 	if (g_hdb->_map->checkOneTileExistInRange(_touchplateOff, 2))
-		g_hdb->_drawMan->cacheTileSequence(_touchplateOff, 2);
+		g_hdb->_gfx->cacheTileSequence(_touchplateOff, 2);
 	if (g_hdb->_map->checkOneTileExistInRange(_templeTouchpOff, 2))
-		g_hdb->_drawMan->cacheTileSequence(_templeTouchpOff, 2);
+		g_hdb->_gfx->cacheTileSequence(_templeTouchpOff, 2);
 	if (g_hdb->_map->checkOneTileExistInRange(_blockpole, 4))
-		g_hdb->_drawMan->cacheTileSequence(_blockpole, 4);
+		g_hdb->_gfx->cacheTileSequence(_blockpole, 4);
 
 	if (g_hdb->_map->checkOneTileExistInRange(_kcHolderWhiteOff, 2))
-		g_hdb->_drawMan->getTile(_kcHolderWhiteOn);
+		g_hdb->_gfx->getTile(_kcHolderWhiteOn);
 	if (g_hdb->_map->checkOneTileExistInRange(_kcHolderBlueOff, 2))
-		g_hdb->_drawMan->getTile(_kcHolderBlueOn);
+		g_hdb->_gfx->getTile(_kcHolderBlueOn);
 	if (g_hdb->_map->checkOneTileExistInRange(_kcHolderRedOff, 2))
-		g_hdb->_drawMan->getTile(_kcHolderRedOn);
+		g_hdb->_gfx->getTile(_kcHolderRedOn);
 	if (g_hdb->_map->checkOneTileExistInRange(_kcHolderGreenOff, 2))
-		g_hdb->_drawMan->getTile(_kcHolderGreenOn);
+		g_hdb->_gfx->getTile(_kcHolderGreenOn);
 	if (g_hdb->_map->checkOneTileExistInRange(_kcHolderPurpleOff, 2))
-		g_hdb->_drawMan->getTile(_kcHolderPurpleOn);
+		g_hdb->_gfx->getTile(_kcHolderPurpleOn);
 	if (g_hdb->_map->checkOneTileExistInRange(_kcHolderBlackOff, 2))
-		g_hdb->_drawMan->getTile(_kcHolderBlackOn);
+		g_hdb->_gfx->getTile(_kcHolderBlackOn);
 }
 
 const char *AITypeStr[] = {
diff --git a/engines/hdb/ai-lists.cpp b/engines/hdb/ai-lists.cpp
index b60013a..1e6dee7 100644
--- a/engines/hdb/ai-lists.cpp
+++ b/engines/hdb/ai-lists.cpp
@@ -71,7 +71,7 @@ void AI::addAnimateTarget(int x, int y, int start, int end, AnimSpeed speed, boo
 			else
 				snprintf(name, 32, "%s%d", tileName, i + 1);
 			size = g_hdb->_fileMan->getLength(name, TYPE_TILE32);
-			at->gfxList[i] = g_hdb->_drawMan->getTileGfx(name, size);
+			at->gfxList[i] = g_hdb->_gfx->getTileGfx(name, size);
 		}
 	}
 
diff --git a/engines/hdb/ai-player.cpp b/engines/hdb/ai-player.cpp
index 100f186..6c8ff00 100644
--- a/engines/hdb/ai-player.cpp
+++ b/engines/hdb/ai-player.cpp
@@ -106,22 +106,22 @@ void aiPlayerInit2(AIEntity *e) {
 		g_hdb->_ai->_slugAttackGfx[3]->load(g_hdb->_fileMan->findFirstData("slug_shot4", TYPE_PIC));
 
 		int32 size = g_hdb->_fileMan->getLength("shock_spark_sit01", TYPE_TILE32);
-		g_hdb->_ai->_stunLightningGfx[0] = g_hdb->_drawMan->getTileGfx("shock_spark_sit01", size);
+		g_hdb->_ai->_stunLightningGfx[0] = g_hdb->_gfx->getTileGfx("shock_spark_sit01", size);
 		size = g_hdb->_fileMan->getLength("shock_spark_sit02", TYPE_TILE32);
-		g_hdb->_ai->_stunLightningGfx[1] = g_hdb->_drawMan->getTileGfx("shock_spark_sit02", size);
+		g_hdb->_ai->_stunLightningGfx[1] = g_hdb->_gfx->getTileGfx("shock_spark_sit02", size);
 		size = g_hdb->_fileMan->getLength("shock_spark_sit03", TYPE_TILE32);
-		g_hdb->_ai->_stunLightningGfx[2] = g_hdb->_drawMan->getTileGfx("shock_spark_sit03", size);
+		g_hdb->_ai->_stunLightningGfx[2] = g_hdb->_gfx->getTileGfx("shock_spark_sit03", size);
 		size = g_hdb->_fileMan->getLength("shock_spark_sit04", TYPE_TILE32);
-		g_hdb->_ai->_stunLightningGfx[3] = g_hdb->_drawMan->getTileGfx("shock_spark_sit04", size);
+		g_hdb->_ai->_stunLightningGfx[3] = g_hdb->_gfx->getTileGfx("shock_spark_sit04", size);
 
 		size = g_hdb->_fileMan->getLength("starstun_sit01", TYPE_TILE32);
-		g_hdb->_ai->_stunnedGfx[0] = g_hdb->_drawMan->getTileGfx("starstun_sit01", size);
+		g_hdb->_ai->_stunnedGfx[0] = g_hdb->_gfx->getTileGfx("starstun_sit01", size);
 		size = g_hdb->_fileMan->getLength("starstun_sit02", TYPE_TILE32);
-		g_hdb->_ai->_stunnedGfx[1] = g_hdb->_drawMan->getTileGfx("starstun_sit02", size);
+		g_hdb->_ai->_stunnedGfx[1] = g_hdb->_gfx->getTileGfx("starstun_sit02", size);
 		size = g_hdb->_fileMan->getLength("starstun_sit03", TYPE_TILE32);
-		g_hdb->_ai->_stunnedGfx[2] = g_hdb->_drawMan->getTileGfx("starstun_sit03", size);
+		g_hdb->_ai->_stunnedGfx[2] = g_hdb->_gfx->getTileGfx("starstun_sit03", size);
 		size = g_hdb->_fileMan->getLength("starstun_sit04", TYPE_TILE32);
-		g_hdb->_ai->_stunnedGfx[3] = g_hdb->_drawMan->getTileGfx("starstun_sit04", size);
+		g_hdb->_ai->_stunnedGfx[3] = g_hdb->_gfx->getTileGfx("starstun_sit04", size);
 	}
 
 	e->draw = g_hdb->_ai->getStandFrameDir(e);
@@ -409,8 +409,8 @@ void aiPlayerAction(AIEntity *e) {
 		g_hdb->_ai->animateEntity(e);
 	} else {
 		// Sometimes the fading stays black
-		if (!g_hdb->_ai->cinematicsActive() && g_hdb->_drawMan->isFadeStaying())
-			g_hdb->_drawMan->turnOffFade();
+		if (!g_hdb->_ai->cinematicsActive() && g_hdb->_gfx->isFadeStaying())
+			g_hdb->_gfx->turnOffFade();
 
 		// Did we just fall down a PLUMMET?
 		bgFlags = g_hdb->_map->getMapBGTileFlags(e->tileX, e->tileY);
diff --git a/engines/hdb/gfx.cpp b/engines/hdb/gfx.cpp
index 852718f..0f6de88 100644
--- a/engines/hdb/gfx.cpp
+++ b/engines/hdb/gfx.cpp
@@ -571,13 +571,13 @@ void DrawMan::drawText(const char *string) {
 			width = kFontSpace;
 
 		// Blit the character
-		g_hdb->_drawMan->_globalSurface.transBlitFrom(_fontSurfaces[c], Common::Point(_cursorX, _cursorY), 0xf81f);
+		g_hdb->_gfx->_globalSurface.transBlitFrom(_fontSurfaces[c], Common::Point(_cursorX, _cursorY), 0xf81f);
 
 		Common::Rect clip(0, 0, width, _fontHeader.height);
 		clip.moveTo(_cursorX, _cursorY);
 		clip.clip(_globalSurface.getBounds());
 		if (!clip.isEmpty()) {
-			g_system->copyRectToScreen(g_hdb->_drawMan->_globalSurface.getBasePtr(clip.left, clip.top), g_hdb->_drawMan->_globalSurface.pitch, clip.left, clip.top, clip.width(), clip.height());
+			g_system->copyRectToScreen(g_hdb->_gfx->_globalSurface.getBasePtr(clip.left, clip.top), g_hdb->_gfx->_globalSurface.pitch, clip.left, clip.top, clip.width(), clip.height());
 		}
 
 		// Advance the cursor
@@ -719,24 +719,24 @@ Graphics::Surface Picture::load(Common::SeekableReadStream *stream) {
 }
 
 void Picture::draw(int x, int y) {
-	g_hdb->_drawMan->_globalSurface.blitFrom(_surface, Common::Point(x, y));
+	g_hdb->_gfx->_globalSurface.blitFrom(_surface, Common::Point(x, y));
 
 	Common::Rect clip(_surface.getBounds());
 	clip.moveTo(x, y);
-	clip.clip(g_hdb->_drawMan->_globalSurface.getBounds());
+	clip.clip(g_hdb->_gfx->_globalSurface.getBounds());
 	if (!clip.isEmpty()) {
-		g_system->copyRectToScreen(g_hdb->_drawMan->_globalSurface.getBasePtr(clip.left, clip.top), g_hdb->_drawMan->_globalSurface.pitch, clip.left, clip.top, clip.width(), clip.height());
+		g_system->copyRectToScreen(g_hdb->_gfx->_globalSurface.getBasePtr(clip.left, clip.top), g_hdb->_gfx->_globalSurface.pitch, clip.left, clip.top, clip.width(), clip.height());
 	}
 }
 
 void Picture::drawMasked(int x, int y) {
-	g_hdb->_drawMan->_globalSurface.transBlitFrom(_surface, Common::Point(x, y), 0xf81f);
+	g_hdb->_gfx->_globalSurface.transBlitFrom(_surface, Common::Point(x, y), 0xf81f);
 
 	Common::Rect clip(_surface.getBounds());
 	clip.moveTo(x, y);
-	clip.clip(g_hdb->_drawMan->_globalSurface.getBounds());
+	clip.clip(g_hdb->_gfx->_globalSurface.getBounds());
 	if (!clip.isEmpty()) {
-		g_system->copyRectToScreen(g_hdb->_drawMan->_globalSurface.getBasePtr(clip.left, clip.top), g_hdb->_drawMan->_globalSurface.pitch, clip.left, clip.top, clip.width(), clip.height());
+		g_system->copyRectToScreen(g_hdb->_gfx->_globalSurface.getBasePtr(clip.left, clip.top), g_hdb->_gfx->_globalSurface.pitch, clip.left, clip.top, clip.width(), clip.height());
 	}
 }
 
@@ -769,24 +769,24 @@ Graphics::Surface Tile::load(Common::SeekableReadStream *stream) {
 }
 
 void Tile::draw(int x, int y) {
-	g_hdb->_drawMan->_globalSurface.blitFrom(_surface, Common::Point(x, y));
+	g_hdb->_gfx->_globalSurface.blitFrom(_surface, Common::Point(x, y));
 
 	Common::Rect clip(_surface.getBounds());
 	clip.moveTo(x, y);
-	clip.clip(g_hdb->_drawMan->_globalSurface.getBounds());
+	clip.clip(g_hdb->_gfx->_globalSurface.getBounds());
 	if (!clip.isEmpty()) {
-		g_system->copyRectToScreen(g_hdb->_drawMan->_globalSurface.getBasePtr(clip.left, clip.top), g_hdb->_drawMan->_globalSurface.pitch, clip.left, clip.top, clip.width(), clip.height());
+		g_system->copyRectToScreen(g_hdb->_gfx->_globalSurface.getBasePtr(clip.left, clip.top), g_hdb->_gfx->_globalSurface.pitch, clip.left, clip.top, clip.width(), clip.height());
 	}
 }
 
 void Tile::drawMasked(int x, int y) {
-	g_hdb->_drawMan->_globalSurface.transBlitFrom(_surface, Common::Point(x, y), 0xf81f);
+	g_hdb->_gfx->_globalSurface.transBlitFrom(_surface, Common::Point(x, y), 0xf81f);
 
 	Common::Rect clip(_surface.getBounds());
 	clip.moveTo(x, y);
-	clip.clip(g_hdb->_drawMan->_globalSurface.getBounds());
+	clip.clip(g_hdb->_gfx->_globalSurface.getBounds());
 	if (!clip.isEmpty()) {
-		g_system->copyRectToScreen(g_hdb->_drawMan->_globalSurface.getBasePtr(clip.left, clip.top), g_hdb->_drawMan->_globalSurface.pitch, clip.left, clip.top, clip.width(), clip.height());
+		g_system->copyRectToScreen(g_hdb->_gfx->_globalSurface.getBasePtr(clip.left, clip.top), g_hdb->_gfx->_globalSurface.pitch, clip.left, clip.top, clip.width(), clip.height());
 	}
 }
 
diff --git a/engines/hdb/hdb.cpp b/engines/hdb/hdb.cpp
index 3da7197..0eb1da5 100644
--- a/engines/hdb/hdb.cpp
+++ b/engines/hdb/hdb.cpp
@@ -43,7 +43,7 @@ HDBGame::HDBGame(OSystem *syst, const ADGameDescription *gameDesc) : Engine(syst
 	_systemInit = false;
 	g_hdb = this;
 	_fileMan = new FileMan;
-	_drawMan = new DrawMan;
+	_gfx = new DrawMan;
 	_lua = new LuaScript;
 	_map = new Map;
 	_ai = new AI;
@@ -58,7 +58,7 @@ HDBGame::HDBGame(OSystem *syst, const ADGameDescription *gameDesc) : Engine(syst
 HDBGame::~HDBGame() {
 	delete _console;
 	delete _fileMan;
-	delete _drawMan;
+	delete _gfx;
 	delete _lua;
 	delete _map;
 	delete _ai;
@@ -79,7 +79,7 @@ bool HDBGame::init() {
 	if (!_fileMan->openMPC(getGameFile())) {
 		error("FileMan::openMPC: Cannot find the hyperspace.mpc data file.");
 	}
-	if (!_drawMan->init()) {
+	if (!_gfx->init()) {
 		error("DrawMan::init: Couldn't initialize DrawMan");
 	}
 	if (!_input->init()) {
@@ -147,14 +147,14 @@ void HDBGame::paint() {
 		warning("STUB: MENU::DrawMenu required");
 		break;
 	case GAME_PLAY:
-		_drawMan->drawPointer();
+		_gfx->drawPointer();
 		break;
 	case GAME_LOADING:
 		warning("STUB: DrawMan::DrawLoadingScreen required");
 		break;
 	}
 
-	_drawMan->updateVideo();
+	_gfx->updateVideo();
 }
 
 // builds a waypoint list if an entity is not next to player,
@@ -485,7 +485,7 @@ Common::Error HDBGame::run() {
 		}
 
 		if (_gameState == GAME_PLAY) {
-			_drawMan->drawSky();
+			_gfx->drawSky();
 
 			if (!_pauseFlag) {
 				_ai->moveEnts();
diff --git a/engines/hdb/hdb.h b/engines/hdb/hdb.h
index 3c90cdf..09ddede 100644
--- a/engines/hdb/hdb.h
+++ b/engines/hdb/hdb.h
@@ -130,7 +130,7 @@ public:
 	*/
 
 	FileMan *_fileMan;
-	DrawMan *_drawMan;
+	DrawMan *_gfx;
 	LuaScript *_lua;
 	Map *_map;
 	AI *_ai;
diff --git a/engines/hdb/input.cpp b/engines/hdb/input.cpp
index 2dd8e2c..c9dbd2c 100644
--- a/engines/hdb/input.cpp
+++ b/engines/hdb/input.cpp
@@ -229,8 +229,8 @@ void Input::updateMouse(int newX, int newY) {
 		_mouseY = kScreenHeight - 1;
 
 	// Turn Cursor back on?
-	if (!g_hdb->_drawMan->getPointer()) {
-		g_hdb->_drawMan->showPointer(true);
+	if (!g_hdb->_gfx->getPointer()) {
+		g_hdb->_gfx->showPointer(true);
 	}
 
 	// Check if LButton is being dragged
@@ -292,40 +292,40 @@ void Input::updateKeys(Common::Event event, bool keyDown) {
 		if (event.kbd.keycode == _keyUp) {
 			if (keyDown) {
 				buttons |= kButtonUp;
-				if (g_hdb->_drawMan->getPointer())
-					g_hdb->_drawMan->showPointer(false);
+				if (g_hdb->_gfx->getPointer())
+					g_hdb->_gfx->showPointer(false);
 			} else {
 				buttons &= ~kButtonUp;
 			}
 		} else if (event.kbd.keycode == _keyDown) {
 			if (keyDown) {
 				buttons |= kButtonDown;
-				if (g_hdb->_drawMan->getPointer())
-					g_hdb->_drawMan->showPointer(false);
+				if (g_hdb->_gfx->getPointer())
+					g_hdb->_gfx->showPointer(false);
 			} else {
 				buttons &= ~kButtonDown;
 			}
 		} else if (event.kbd.keycode == _keyLeft) {
 			if (keyDown) {
 				buttons |= kButtonLeft;
-				if (g_hdb->_drawMan->getPointer())
-					g_hdb->_drawMan->showPointer(false);
+				if (g_hdb->_gfx->getPointer())
+					g_hdb->_gfx->showPointer(false);
 			} else {
 				buttons &= ~kButtonLeft;
 			}
 		} else if (event.kbd.keycode == _keyRight) {
 			if (keyDown) {
 				buttons |= kButtonRight;
-				if (g_hdb->_drawMan->getPointer())
-					g_hdb->_drawMan->showPointer(false);
+				if (g_hdb->_gfx->getPointer())
+					g_hdb->_gfx->showPointer(false);
 			} else {
 				buttons &= ~kButtonRight;
 			}
 		} else if (event.kbd.keycode == _keyUse) {
 			if (keyDown) {
 				buttons |= kButtonB;
-				if (g_hdb->_drawMan->getPointer())
-					g_hdb->_drawMan->showPointer(false);
+				if (g_hdb->_gfx->getPointer())
+					g_hdb->_gfx->showPointer(false);
 			} else {
 				buttons &= ~kButtonB;
 			}
@@ -335,7 +335,7 @@ void Input::updateKeys(Common::Event event, bool keyDown) {
 	if (event.kbd.keycode == _keyMenu) {
 		if (keyDown) {
 			buttons |= kButtonA;
-			g_hdb->_drawMan->showPointer(true);
+			g_hdb->_gfx->showPointer(true);
 		} else {
 			buttons &= ~kButtonA;
 		}
diff --git a/engines/hdb/lua-script.cpp b/engines/hdb/lua-script.cpp
index 94fcf9e..4b10868 100644
--- a/engines/hdb/lua-script.cpp
+++ b/engines/hdb/lua-script.cpp
@@ -361,8 +361,8 @@ static int cineSetForeground(lua_State *L) {
 	g_hdb->_lua->checkParameters("cineSetForeground", 3);
 
 	lua_pop(L, 3);
-	int index = g_hdb->_drawMan->getTileIndex(tileName);
-	g_hdb->_drawMan->getTile(index);
+	int index = g_hdb->_gfx->getTileIndex(tileName);
+	g_hdb->_gfx->getTile(index);
 	g_hdb->_ai->cineSetForeground((int)x, (int)y, index);
 	return 0;
 }
@@ -375,8 +375,8 @@ static int cineSetBackground(lua_State *L) {
 	g_hdb->_lua->checkParameters("cineSetBackground", 3);
 
 	lua_pop(L, 3);
-	int index = g_hdb->_drawMan->getTileIndex(tileName);
-	g_hdb->_drawMan->getTile(index);
+	int index = g_hdb->_gfx->getTileIndex(tileName);
+	g_hdb->_gfx->getTile(index);
 	g_hdb->_ai->cineSetBackground((int)x, (int)y, index);
 	return 0;
 }
@@ -613,8 +613,8 @@ static int setForeground(lua_State *L) {
 	g_hdb->_lua->checkParameters("setForeground", 3);
 
 	lua_pop(L, 3);
-	int index = g_hdb->_drawMan->getTileIndex(tileName);
-	g_hdb->_drawMan->getTile(index);
+	int index = g_hdb->_gfx->getTileIndex(tileName);
+	g_hdb->_gfx->getTile(index);
 	g_hdb->_map->setMapFGTileIndex((int)x, (int)y, index);
 	g_hdb->_map->addFGTileAnimation((int)x, (int)y);
 	return 0;
@@ -628,8 +628,8 @@ static int setBackground(lua_State *L) {
 	g_hdb->_lua->checkParameters("setBackground", 3);
 
 	lua_pop(L, 3);
-	int index = g_hdb->_drawMan->getTileIndex(tileName);
-	g_hdb->_drawMan->getTile(index);
+	int index = g_hdb->_gfx->getTileIndex(tileName);
+	g_hdb->_gfx->getTile(index);
 	g_hdb->_map->setMapBGTileIndex((int)x, (int)y, index);
 	g_hdb->_map->addBGTileAnimation((int)x, (int)y);
 	return 0;
@@ -986,7 +986,7 @@ static int setPointerState(lua_State *L) {
 
 	lua_pop(L, 1);
 
-	g_hdb->_drawMan->setPointerState((int)value);
+	g_hdb->_gfx->setPointerState((int)value);
 	return 0;
 }
 
diff --git a/engines/hdb/map-loader.cpp b/engines/hdb/map-loader.cpp
index c45102d..e829b3d 100644
--- a/engines/hdb/map-loader.cpp
+++ b/engines/hdb/map-loader.cpp
@@ -55,11 +55,11 @@ int Map::loadTiles() {
 	for (uint j = 0; j < _height; j++) {
 		for (uint i = 0; i < _width; i++) {
 			tile = _background[j * _width + i];
-			if ((temp = g_hdb->_drawMan->isSky(tile)) && !skyIndex) {
+			if ((temp = g_hdb->_gfx->isSky(tile)) && !skyIndex) {
 				skyIndex = temp;
 			}
-			g_hdb->_drawMan->getTile(tile);
-			g_hdb->_drawMan->getTile(_foreground[j * _width + i]);
+			g_hdb->_gfx->getTile(tile);
+			g_hdb->_gfx->getTile(_foreground[j * _width + i]);
 		}
 	}
 
@@ -141,7 +141,7 @@ bool Map::load(Common::SeekableReadStream *stream) {
 	_mapLaserBeams = new byte[_width * _height];
 
 	int sky = loadTiles();
-	g_hdb->_drawMan->setSky(sky);
+	g_hdb->_gfx->setSky(sky);
 	_mapX = _mapY = 0;
 
 	// Setup animating Tile lists
@@ -646,14 +646,14 @@ void Map::draw() {
 			}
 
 			// Draw if not a sky tile
-			if (!g_hdb->_drawMan->isSky(tileIndex)) {
-				g_hdb->_drawMan->getTile(tileIndex)->draw(screenX, screenY);
+			if (!g_hdb->_gfx->isSky(tileIndex)) {
+				g_hdb->_gfx->getTile(tileIndex)->draw(screenX, screenY);
 			}
 
 			// Draw Foreground Tile
 			tileIndex = _foreground[matrixY + _mapTileX + i];
 			if (tileIndex >= 0) {
-				Tile *fTile = g_hdb->_drawMan->getTile(tileIndex);
+				Tile *fTile = g_hdb->_gfx->getTile(tileIndex);
 				if (fTile && !(fTile->_flags & kFlagInvisible)) {
 
 					if ((fTile->_flags & kFlagGrating) && (_numGratings < kMaxGratings)) {
@@ -689,33 +689,33 @@ void Map::draw() {
 	// Animate FAST Map Tiles
 	if (!(_animCycle % kAnimFastFrames)) {
 		for (Common::Array<uint32>::iterator it = _listBGAnimFast.begin(); it != _listBGAnimFast.end(); it++) {
-			_background[(*it)] = g_hdb->_drawMan->animateTile(_background[(*it)]);
+			_background[(*it)] = g_hdb->_gfx->animateTile(_background[(*it)]);
 		}
 
 		for (Common::Array<uint32>::iterator it = _listFGAnimFast.begin(); it != _listFGAnimFast.end(); it++) {
-			_foreground[(*it)] = g_hdb->_drawMan->animateTile(_foreground[(*it)]);
+			_foreground[(*it)] = g_hdb->_gfx->animateTile(_foreground[(*it)]);
 		}
 	}
 
 	// Animate MEDIUM Map Tiles
 	if (!(_animCycle % kAnimFastFrames)) {
 		for (Common::Array<uint32>::iterator it = _listBGAnimMedium.begin(); it != _listBGAnimMedium.end(); it++) {
-			_background[(*it)] = g_hdb->_drawMan->animateTile(_background[(*it)]);
+			_background[(*it)] = g_hdb->_gfx->animateTile(_background[(*it)]);
 		}
 
 		for (Common::Array<uint32>::iterator it = _listFGAnimMedium.begin(); it != _listFGAnimMedium.end(); it++) {
-			_foreground[(*it)] = g_hdb->_drawMan->animateTile(_foreground[(*it)]);
+			_foreground[(*it)] = g_hdb->_gfx->animateTile(_foreground[(*it)]);
 		}
 	}
 
 	// Animate SLOW Map Tiles
 	if (!(_animCycle % kAnimFastFrames)) {
 		for (Common::Array<uint32>::iterator it = _listBGAnimSlow.begin(); it != _listBGAnimSlow.end(); it++) {
-			_background[(*it)] = g_hdb->_drawMan->animateTile(_background[(*it)]);
+			_background[(*it)] = g_hdb->_gfx->animateTile(_background[(*it)]);
 		}
 
 		for (Common::Array<uint32>::iterator it = _listFGAnimSlow.begin(); it != _listFGAnimSlow.end(); it++) {
-			_foreground[(*it)] = g_hdb->_drawMan->animateTile(_foreground[(*it)]);
+			_foreground[(*it)] = g_hdb->_gfx->animateTile(_foreground[(*it)]);
 		}
 	}
 
@@ -728,7 +728,7 @@ void Map::drawEnts() {
 
 void Map::drawGratings() {
 	for (int i = 0; i < _numGratings; i++) {
-		g_hdb->_drawMan->getTile(_gratings[i]->tile)->drawMasked(_gratings[i]->x, _gratings[i]->y);
+		g_hdb->_gfx->getTile(_gratings[i]->tile)->drawMasked(_gratings[i]->x, _gratings[i]->y);
 	}
 
 	debug(8, "Gratings Count: %d", _numGratings);
@@ -736,7 +736,7 @@ void Map::drawGratings() {
 
 void Map::drawForegrounds() {
 	for (int i = 0; i < _numForegrounds; i++) {
-		g_hdb->_drawMan->getTile(_foregrounds[i]->tile)->drawMasked(_foregrounds[i]->x, _foregrounds[i]->y);
+		g_hdb->_gfx->getTile(_foregrounds[i]->tile)->drawMasked(_foregrounds[i]->x, _foregrounds[i]->y);
 	}
 
 	debug(8, "Foregrounds Count: %d", _numForegrounds);
@@ -746,7 +746,7 @@ uint32 Map::getMapBGTileFlags(int x, int y) {
 	if (x < 0 || x >= _width || y < 0 || y >= _height) {
 		return 0;
 	}
-	Tile *tile = g_hdb->_drawMan->getTile(_background[y * _width + x]);
+	Tile *tile = g_hdb->_gfx->getTile(_background[y * _width + x]);
 	if (tile)
 		return tile->_flags;
 	return 0;
@@ -756,7 +756,7 @@ uint32 Map::getMapFGTileFlags(int x, int y) {
 	if (x < 0 || x >= _width || y < 0 || y >= _height) {
 		return 0;
 	}
-	Tile *tile = g_hdb->_drawMan->getTile(_foreground[y * _width + x]);
+	Tile *tile = g_hdb->_gfx->getTile(_foreground[y * _width + x]);
 	if (tile)
 		return tile->_flags;
 	return 0;
@@ -794,7 +794,7 @@ void Map::addBGTileAnimation(int x, int y) {
 
 	int i = y * _width + x;
 
-	Tile *tile = g_hdb->_drawMan->getTile(_background[i]);
+	Tile *tile = g_hdb->_gfx->getTile(_background[i]);
 	if (!tile)
 		return;
 	uint32 flags = tile->_flags;
@@ -813,7 +813,7 @@ void Map::addFGTileAnimation(int x, int y) {
 
 	int i = y * _width + x;
 
-	Tile *tile = g_hdb->_drawMan->getTile(_foreground[i]);
+	Tile *tile = g_hdb->_gfx->getTile(_foreground[i]);
 	if (!tile)
 		return;
 	uint32 flags = tile->_flags;
@@ -831,7 +831,7 @@ void Map::addFGTileAnimation(int x, int y) {
 void Map::removeBGTileAnimation(int x, int y) {
 	int i = y * _width + x;
 
-	Tile *tile = g_hdb->_drawMan->getTile(_background[i]);
+	Tile *tile = g_hdb->_gfx->getTile(_background[i]);
 	if (!tile)
 		return;
 	uint32 flags = tile->_flags;
@@ -860,7 +860,7 @@ void Map::removeBGTileAnimation(int x, int y) {
 void Map::removeFGTileAnimation(int x, int y) {
 	int i = y * _width + x;
 
-	Tile *tile = g_hdb->_drawMan->getTile(_foreground[i]);
+	Tile *tile = g_hdb->_gfx->getTile(_foreground[i]);
 	if (!tile)
 		return;
 	uint32 flags = tile->_flags;
diff --git a/engines/hdb/window.cpp b/engines/hdb/window.cpp
index c6372a7..0b26a21 100644
--- a/engines/hdb/window.cpp
+++ b/engines/hdb/window.cpp
@@ -28,49 +28,49 @@ bool Window::init() {
 
 	warning("STUB: Window::init: Incomplete");
 
-	_gfxTL = g_hdb->_drawMan->loadPic("menu_back_topleft");
-	_gfxTM = g_hdb->_drawMan->loadPic("menu_back_top");
-	_gfxTR = g_hdb->_drawMan->loadPic("menu_back_topright");
+	_gfxTL = g_hdb->_gfx->loadPic("menu_back_topleft");
+	_gfxTM = g_hdb->_gfx->loadPic("menu_back_top");
+	_gfxTR = g_hdb->_gfx->loadPic("menu_back_topright");
 
-	_gfxL = g_hdb->_drawMan->loadPic("menu_back_left");
-	_gfxM = g_hdb->_drawMan->loadPic("menu_back_middle");
-	_gfxR = g_hdb->_drawMan->loadPic("menu_back_right");
+	_gfxL = g_hdb->_gfx->loadPic("menu_back_left");
+	_gfxM = g_hdb->_gfx->loadPic("menu_back_middle");
+	_gfxR = g_hdb->_gfx->loadPic("menu_back_right");
 
-	_gfxBL = g_hdb->_drawMan->loadPic("menu_back_btmleft");
-	_gfxBM = g_hdb->_drawMan->loadPic("menu_back_bottom");
-	_gfxBR = g_hdb->_drawMan->loadPic("menu_back_btmright");
+	_gfxBL = g_hdb->_gfx->loadPic("menu_back_btmleft");
+	_gfxBM = g_hdb->_gfx->loadPic("menu_back_bottom");
+	_gfxBR = g_hdb->_gfx->loadPic("menu_back_btmright");
 
-	_gfxTitleL = g_hdb->_drawMan->loadPic("menu_title_left");
-	_gfxTitleM = g_hdb->_drawMan->loadPic("menu_title_mid");
-	_gfxTitleR = g_hdb->_drawMan->loadPic("menu_title_right");
+	_gfxTitleL = g_hdb->_gfx->loadPic("menu_title_left");
+	_gfxTitleM = g_hdb->_gfx->loadPic("menu_title_mid");
+	_gfxTitleR = g_hdb->_gfx->loadPic("menu_title_right");
 
-	_gGfxTL = g_hdb->_drawMan->loadPic("g_menu_back_topleft");
-	_gGfxTM = g_hdb->_drawMan->loadPic("g_menu_back_top");
-	_gGfxTR = g_hdb->_drawMan->loadPic("g_menu_back_topright");
+	_gGfxTL = g_hdb->_gfx->loadPic("g_menu_back_topleft");
+	_gGfxTM = g_hdb->_gfx->loadPic("g_menu_back_top");
+	_gGfxTR = g_hdb->_gfx->loadPic("g_menu_back_topright");
 
-	_gGfxL = g_hdb->_drawMan->loadPic("g_menu_back_left");
-	_gGfxM = g_hdb->_drawMan->loadPic("g_menu_back_middle");
-	_gGfxR = g_hdb->_drawMan->loadPic("g_menu_back_right");
+	_gGfxL = g_hdb->_gfx->loadPic("g_menu_back_left");
+	_gGfxM = g_hdb->_gfx->loadPic("g_menu_back_middle");
+	_gGfxR = g_hdb->_gfx->loadPic("g_menu_back_right");
 
-	_gGfxBL = g_hdb->_drawMan->loadPic("g_menu_back_btmleft");
-	_gGfxBM = g_hdb->_drawMan->loadPic("g_menu_back_bottom");
-	_gGfxBR = g_hdb->_drawMan->loadPic("g_menu_back_btmright");
+	_gGfxBL = g_hdb->_gfx->loadPic("g_menu_back_btmleft");
+	_gGfxBM = g_hdb->_gfx->loadPic("g_menu_back_bottom");
+	_gGfxBR = g_hdb->_gfx->loadPic("g_menu_back_btmright");
 
-	_gGfxTitleL = g_hdb->_drawMan->loadPic("g_menu_title_left");
-	_gGfxTitleM = g_hdb->_drawMan->loadPic("g_menu_title_mid");
-	_gGfxTitleR = g_hdb->_drawMan->loadPic("g_menu_title_right");
+	_gGfxTitleL = g_hdb->_gfx->loadPic("g_menu_title_left");
+	_gGfxTitleM = g_hdb->_gfx->loadPic("g_menu_title_mid");
+	_gGfxTitleR = g_hdb->_gfx->loadPic("g_menu_title_right");
 
-	_gfxIndent = g_hdb->_drawMan->loadPic("menu_delivery_indentation");
-	_gfxArrowTo = g_hdb->_drawMan->loadPic("menu_arrow_deliverto");
+	_gfxIndent = g_hdb->_gfx->loadPic("menu_delivery_indentation");
+	_gfxArrowTo = g_hdb->_gfx->loadPic("menu_arrow_deliverto");
 
 	_gfxTry = _gfxAgain = NULL; // They will be loaded when needed
 
-	_gfxInvSelect = g_hdb->_drawMan->loadPic("inventory_normal");
-	_gfxHandright = g_hdb->_drawMan->loadPic("menu_hand_pointright");
+	_gfxInvSelect = g_hdb->_gfx->loadPic("inventory_normal");
+	_gfxHandright = g_hdb->_gfx->loadPic("menu_hand_pointright");
 
-	_gfxInfobar = g_hdb->_drawMan->loadPic("pic_infobar");
-	_gfxDarken = g_hdb->_drawMan->loadPic("screen_darken");
-	_gfxPausePlaque = g_hdb->_drawMan->loadPic("pause_plaque");
+	_gfxInfobar = g_hdb->_gfx->loadPic("pic_infobar");
+	_gfxDarken = g_hdb->_gfx->loadPic("screen_darken");
+	_gfxPausePlaque = g_hdb->_gfx->loadPic("pause_plaque");
 
 	_infobarDimmed = 0;
 
@@ -96,7 +96,7 @@ void Window::restartSystem() {
 	_dialogChoiceInfo.active = false;
 	_invWinInfo.active = false;
 	_dialogDelay = _invWinInfo.selection = 0;
-	_gemGfx = g_hdb->_drawMan->loadTile("ent_gem_white_sit01");
+	_gemGfx = g_hdb->_gfx->loadTile("ent_gem_white_sit01");
 	_infobarDimmed = 0;
 }
 
@@ -133,11 +133,11 @@ void Window::openDialog(const char *title, int tileIndex, const char *string, in
 		strncpy(_dialogInfo.string, string, sizeof(_dialogInfo.string) - 1);
 	else
 		strcpy(_dialogInfo.string, string);
-	g_hdb->_drawMan->getTextEdges(&e1, &e2, &e3, &e4);
-	g_hdb->_drawMan->setTextEdges(kDialogTextLeft, kDialogTextRight, 0, 480);
-	g_hdb->_drawMan->getDimensions(string, &width, &height);
-	g_hdb->_drawMan->getDimensions(title, &titleWidth, &titleHeight);
-	g_hdb->_drawMan->setTextEdges(e1, e2, e3, e4);
+	g_hdb->_gfx->getTextEdges(&e1, &e2, &e3, &e4);
+	g_hdb->_gfx->setTextEdges(kDialogTextLeft, kDialogTextRight, 0, 480);
+	g_hdb->_gfx->getDimensions(string, &width, &height);
+	g_hdb->_gfx->getDimensions(title, &titleWidth, &titleHeight);
+	g_hdb->_gfx->setTextEdges(e1, e2, e3, e4);
 	_dialogInfo.height = (height + 2) * 16;
 	w = _dialogInfo.width = width + 32;
 	_dialogInfo.titleWidth = titleWidth;
@@ -207,16 +207,16 @@ void Window::drawDialog() {
 	}
 
 	int e1, e2, e3, e4;
-	g_hdb->_drawMan->getTextEdges(&e1, &e2, &e3, &e4);
-	g_hdb->_drawMan->setTextEdges(_dialogInfo.x + 10, 480, 0, kScreenHeight);
-	g_hdb->_drawMan->setCursor(0, _dialogInfo.y - 7);
+	g_hdb->_gfx->getTextEdges(&e1, &e2, &e3, &e4);
+	g_hdb->_gfx->setTextEdges(_dialogInfo.x + 10, 480, 0, kScreenHeight);
+	g_hdb->_gfx->setCursor(0, _dialogInfo.y - 7);
 	if (_dialogInfo.title)
-		g_hdb->_drawMan->drawText(_dialogInfo.title);
-	g_hdb->_drawMan->setTextEdges(_dialogInfo.x + 16, _dialogInfo.x + _dialogInfo.width - 16, 0, kScreenHeight);
-	g_hdb->_drawMan->setCursor(0, _dialogInfo.y + 16);
+		g_hdb->_gfx->drawText(_dialogInfo.title);
+	g_hdb->_gfx->setTextEdges(_dialogInfo.x + 16, _dialogInfo.x + _dialogInfo.width - 16, 0, kScreenHeight);
+	g_hdb->_gfx->setCursor(0, _dialogInfo.y + 16);
 	if (_dialogInfo.string)
-		g_hdb->_drawMan->drawText(_dialogInfo.string);
-	g_hdb->_drawMan->setTextEdges(e1, e2, e3, e4);
+		g_hdb->_gfx->drawText(_dialogInfo.string);
+	g_hdb->_gfx->setTextEdges(e1, e2, e3, e4);
 }
 
 void Window::closeDialog() {
@@ -343,20 +343,20 @@ void Window::openDialogChoice(const char *title, const char *text, const char *f
 		strcpy(_dialogChoiceInfo.choices[i], choices[i]);
 	_dialogChoiceInfo.active = true;
 
-	g_hdb->_drawMan->getTextEdges(&e1, &e2, &e3, &e4);
-	g_hdb->_drawMan->setTextEdges(kOpenDialogTextLeft, kOpenDialogTextRight, 0, 480);
-	g_hdb->_drawMan->getDimensions(text, &width, &height);
-	g_hdb->_drawMan->getDimensions(title, &titleWidth, &titleHeight);
+	g_hdb->_gfx->getTextEdges(&e1, &e2, &e3, &e4);
+	g_hdb->_gfx->setTextEdges(kOpenDialogTextLeft, kOpenDialogTextRight, 0, 480);
+	g_hdb->_gfx->getDimensions(text, &width, &height);
+	g_hdb->_gfx->getDimensions(title, &titleWidth, &titleHeight);
 
 	for (i = 0; i < 10; i++)
 		if (choices[i]) {
 			int	w, h;
-			g_hdb->_drawMan->getDimensions(choices[i], &w, &h);
+			g_hdb->_gfx->getDimensions(choices[i], &w, &h);
 			if (w > width)
 				width = w;
 		}
 
-	g_hdb->_drawMan->setTextEdges(e1, e2, e3, e4);
+	g_hdb->_gfx->setTextEdges(e1, e2, e3, e4);
 	_dialogChoiceInfo.textHeight = (height + 1) * 16;
 	_dialogChoiceInfo.height = (height + 2 + numChoices) * 16;
 	_dialogChoiceInfo.width = width + 48;
@@ -406,21 +406,21 @@ void Window::drawDialogChoice() {
 		_gGfxTitleR->drawMasked(_dialogChoiceInfo.x + (blocks + 1) * 16, _dialogChoiceInfo.y - 10);
 	}
 
-	g_hdb->_drawMan->getTextEdges(&e1, &e2, &e3, &e4);
-	g_hdb->_drawMan->setTextEdges(_dialogChoiceInfo.x + 10, kOpenDialogTextRight, 0, 480);
-	g_hdb->_drawMan->setCursor(0, _dialogChoiceInfo.y - 7);
+	g_hdb->_gfx->getTextEdges(&e1, &e2, &e3, &e4);
+	g_hdb->_gfx->setTextEdges(_dialogChoiceInfo.x + 10, kOpenDialogTextRight, 0, 480);
+	g_hdb->_gfx->setCursor(0, _dialogChoiceInfo.y - 7);
 	if (_dialogChoiceInfo.title)
-		g_hdb->_drawMan->drawText(_dialogChoiceInfo.title);
-	g_hdb->_drawMan->setTextEdges(_dialogChoiceInfo.x + 16, kOpenDialogTextRight, 0, 480);
-	g_hdb->_drawMan->setCursor(0, _dialogChoiceInfo.y + 16);
+		g_hdb->_gfx->drawText(_dialogChoiceInfo.title);
+	g_hdb->_gfx->setTextEdges(_dialogChoiceInfo.x + 16, kOpenDialogTextRight, 0, 480);
+	g_hdb->_gfx->setCursor(0, _dialogChoiceInfo.y + 16);
 	if (_dialogChoiceInfo.text)
-		g_hdb->_drawMan->drawText(_dialogChoiceInfo.text);
+		g_hdb->_gfx->drawText(_dialogChoiceInfo.text);
 
 	for (i = 0; i < _dialogChoiceInfo.numChoices; i++) {
-		g_hdb->_drawMan->setCursor(_dialogChoiceInfo.x + 48, _dialogChoiceInfo.y + _dialogChoiceInfo.textHeight + 16 * i);
-		g_hdb->_drawMan->drawText(_dialogChoiceInfo.choices[i]);
+		g_hdb->_gfx->setCursor(_dialogChoiceInfo.x + 48, _dialogChoiceInfo.y + _dialogChoiceInfo.textHeight + 16 * i);
+		g_hdb->_gfx->drawText(_dialogChoiceInfo.choices[i]);
 	}
-	g_hdb->_drawMan->setTextEdges(e1, e2, e3, e4);
+	g_hdb->_gfx->setTextEdges(e1, e2, e3, e4);
 
 	_gfxHandright->drawMasked(_dialogChoiceInfo.x + 10, 4 + _dialogChoiceInfo.y + _dialogChoiceInfo.textHeight + 16 * _dialogChoiceInfo.selection);
 }
@@ -490,10 +490,10 @@ void Window::openMessageBar(const char *title, int time) {
 	_msgInfo.timer = (time * kGameFPS);
 	strcpy(_msgInfo.title, title);
 
-	g_hdb->_drawMan->getTextEdges(&e1, &e2, &e3, &e4);
-	g_hdb->_drawMan->setTextEdges(kDialogTextLeft, kDialogTextRight, 0, 480);
-	g_hdb->_drawMan->getDimensions(title, &width, &height);
-	g_hdb->_drawMan->setTextEdges(e1, e2, e3, e4);
+	g_hdb->_gfx->getTextEdges(&e1, &e2, &e3, &e4);
+	g_hdb->_gfx->setTextEdges(kDialogTextLeft, kDialogTextRight, 0, 480);
+	g_hdb->_gfx->getDimensions(title, &width, &height);
+	g_hdb->_gfx->setTextEdges(e1, e2, e3, e4);
 
 	_msgInfo.height = (height + 2) * 16;
 	_msgInfo.width = width + 32;
@@ -518,11 +518,11 @@ void Window::drawMessageBar() {
 
 	drawBorder(_msgInfo.x, _msgInfo.y, _msgInfo.width, _msgInfo.height, false);
 
-	g_hdb->_drawMan->getTextEdges(&e1, &e2, &e3, &e4);
-	g_hdb->_drawMan->setTextEdges(_msgInfo.x + 16, _msgInfo.x + _msgInfo.width - 16, 0, 320);
-	g_hdb->_drawMan->setCursor(_msgInfo.x + 16, _msgInfo.y + 16);
-	g_hdb->_drawMan->drawText(_msgInfo.title);
-	g_hdb->_drawMan->setTextEdges(e1, e2, e3, e4);
+	g_hdb->_gfx->getTextEdges(&e1, &e2, &e3, &e4);
+	g_hdb->_gfx->setTextEdges(_msgInfo.x + 16, _msgInfo.x + _msgInfo.width - 16, 0, 320);
+	g_hdb->_gfx->setCursor(_msgInfo.x + 16, _msgInfo.y + 16);
+	g_hdb->_gfx->drawText(_msgInfo.title);
+	g_hdb->_gfx->setTextEdges(e1, e2, e3, e4);
 
 	//
 	// time to go away?  see if we have any more msgs in the queue...
@@ -554,10 +554,10 @@ void Window::nextMsgQueued() {
 	strcpy(_msgInfo.title, _msgQueueStr[0]);
 	_msgInfo.timer = (_msgQueueWait[0] * kGameFPS);
 
-	g_hdb->_drawMan->getTextEdges(&e1, &e2, &e3, &e4);
-	g_hdb->_drawMan->setTextEdges(kDialogTextLeft, kDialogTextRight, 0, 480);
-	g_hdb->_drawMan->getDimensions(_msgInfo.title, &width, &height);
-	g_hdb->_drawMan->setTextEdges(e1, e2, e3, e4);
+	g_hdb->_gfx->getTextEdges(&e1, &e2, &e3, &e4);
+	g_hdb->_gfx->setTextEdges(kDialogTextLeft, kDialogTextRight, 0, 480);
+	g_hdb->_gfx->getDimensions(_msgInfo.title, &width, &height);
+	g_hdb->_gfx->setTextEdges(e1, e2, e3, e4);
 
 	_msgInfo.height = (height + 2) * 16;
 
@@ -623,8 +623,8 @@ void Window::drawInventory() {
 	// Draw the Gem Amount
 	gems = g_hdb->_ai->getGemAmount();
 	sprintf(string, "%d", gems);
-	g_hdb->_drawMan->setCursor(drawX + 32, drawY + 8);
-	g_hdb->_drawMan->drawText(string);
+	g_hdb->_gfx->setCursor(drawX + 32, drawY + 8);
+	g_hdb->_gfx->drawText(string);
 
 	// Draw the mini monkeystone
 	mstones = g_hdb->_ai->getMonkeystoneAmount();
@@ -634,8 +634,8 @@ void Window::drawInventory() {
 
 		// Draw the monkeystone amount
 		sprintf(string, "%d", mstones);
-		g_hdb->_drawMan->setCursor(drawX + 28, drawY + 8);
-		g_hdb->_drawMan->drawText(string);
+		g_hdb->_gfx->setCursor(drawX + 28, drawY + 8);
+		g_hdb->_gfx->drawText(string);
 	}
 
 	// If you have an inventory, draw the selection cursor
@@ -651,8 +651,8 @@ void Window::drawInventory() {
 		if (sel) {
 			int centerX = baseX - 4 + (kScreenWidth - baseX) / 2;
 			drawY = _invWinInfo.y + (kInvItemSpaceY * 4) + 16;
-			g_hdb->_drawMan->setCursor(centerX - g_hdb->_drawMan->stringLength(sel->printedName) / 2, drawY);
-			g_hdb->_drawMan->drawText(sel->printedName);
+			g_hdb->_gfx->setCursor(centerX - g_hdb->_gfx->stringLength(sel->printedName) / 2, drawY);
+			g_hdb->_gfx->drawText(sel->printedName);
 		}
 	}
 }
@@ -680,9 +680,9 @@ void Window::openDeliveries(bool animate) {
 	for (int i = 0; i < g_hdb->_ai->getDeliveriesAmount(); i++) {
 		d = g_hdb->_ai->getDeliveryItem(i);
 		if (d->itemGfxName[0])
-			d->itemGfx = g_hdb->_drawMan->loadTile(d->itemGfxName);
+			d->itemGfx = g_hdb->_gfx->loadTile(d->itemGfxName);
 		if (d->destGfxName[0])
-			d->destGfx = g_hdb->_drawMan->loadTile(d->destGfxName);
+			d->destGfx = g_hdb->_gfx->loadTile(d->destGfxName);
 	}
 
 	warning("STUB: Play SND_POP");
@@ -728,8 +728,8 @@ void Window::drawDeliveries() {
 					_gfxIndent->draw(drawX, drawY);
 					d->itemGfx->drawMasked(drawX, drawY);
 
-					g_hdb->_drawMan->setCursor(centerX - g_hdb->_drawMan->stringLength(d->itemTextName) / 2, kDlvItemTextY);
-					g_hdb->_drawMan->drawText(d->itemTextName);
+					g_hdb->_gfx->setCursor(centerX - g_hdb->_gfx->stringLength(d->itemTextName) / 2, kDlvItemTextY);
+					g_hdb->_gfx->drawText(d->itemTextName);
 					if (!_dlvsInfo.go2) {
 						_dlvsInfo.go2 = true;
 						_dlvsInfo.delay2 = g_hdb->getTimeSlice() + 500;
@@ -742,8 +742,8 @@ void Window::drawDeliveries() {
 					// Draw TO
 					_gfxArrowTo->drawMasked(_dlvsInfo.x + kDlvItemSpaceX * _dlvsInfo.selected + 8, drawY + kTileHeight);
 
-					g_hdb->_drawMan->setCursor(centerX - g_hdb->_drawMan->stringLength("to") / 2, kDlvItemTextY + 12);
-					g_hdb->_drawMan->drawText("to");
+					g_hdb->_gfx->setCursor(centerX - g_hdb->_gfx->stringLength("to") / 2, kDlvItemTextY + 12);
+					g_hdb->_gfx->drawText("to");
 					if (!_dlvsInfo.go3) {
 						_dlvsInfo.go3 = true;
 						_dlvsInfo.delay3 = g_hdb->getTimeSlice() + 500;
@@ -757,9 +757,9 @@ void Window::drawDeliveries() {
 					_gfxIndent->draw(drawX, drawY + kTileHeight + 16);
 					d->destGfx->drawMasked(drawX, drawY + kTileHeight + 16);
 
-					g_hdb->_drawMan->setCursor(centerX - (g_hdb->_drawMan->stringLength(d->destTextName) + g_hdb->_drawMan->stringLength("to")) / 2, kDlvItemTextY + 12);
-					g_hdb->_drawMan->drawText("to ");
-					g_hdb->_drawMan->drawText(d->destTextName);
+					g_hdb->_gfx->setCursor(centerX - (g_hdb->_gfx->stringLength(d->destTextName) + g_hdb->_gfx->stringLength("to")) / 2, kDlvItemTextY + 12);
+					g_hdb->_gfx->drawText("to ");
+					g_hdb->_gfx->drawText(d->destTextName);
 
 					warning("STUB: Play crazy sound");
 					_dlvsInfo.animate = false;
@@ -775,11 +775,11 @@ void Window::drawDeliveries() {
 			d->destGfx->drawMasked(drawX, drawY + kTileHeight + 16);
 
 			if (!_dlvsInfo.animate && inv == _dlvsInfo.selected) {
-				g_hdb->_drawMan->setCursor(centerX - g_hdb->_drawMan->stringLength(d->itemTextName)/2, kDlvItemTextY);
-				g_hdb->_drawMan->drawText(d->itemTextName);
-				g_hdb->_drawMan->setCursor(centerX - (g_hdb->_drawMan->stringLength(d->destTextName) + g_hdb->_drawMan->stringLength("to ")) / 2, kDlvItemTextY + 12);
-				g_hdb->_drawMan->drawText("to ");
-				g_hdb->_drawMan->drawText(d->destTextName);
+				g_hdb->_gfx->setCursor(centerX - g_hdb->_gfx->stringLength(d->itemTextName)/2, kDlvItemTextY);
+				g_hdb->_gfx->drawText(d->itemTextName);
+				g_hdb->_gfx->setCursor(centerX - (g_hdb->_gfx->stringLength(d->destTextName) + g_hdb->_gfx->stringLength("to ")) / 2, kDlvItemTextY + 12);
+				g_hdb->_gfx->drawText("to ");
+				g_hdb->_gfx->drawText(d->destTextName);
 			}
 
 			drawX += kDlvItemSpaceX;
@@ -792,8 +792,8 @@ void Window::drawDeliveries() {
 
 	// Draw "No Deliveries" or the arrow that points to the currently selected one
 	if (!inv) {
-		g_hdb->_drawMan->setCursor(baseX + 16, _dlvsInfo.y);
-		g_hdb->_drawMan->drawText("No Deliveries");
+		g_hdb->_gfx->setCursor(baseX + 16, _dlvsInfo.y);
+		g_hdb->_gfx->drawText("No Deliveries");
 	} else if (!_dlvsInfo.animate) {
 		int dx, dy, rowtwo;
 
@@ -845,7 +845,7 @@ void Window::textOut(const char *text, int x, int y, int timer) {
 
 	if (x < 0) {
 		int pw, lines;
-		g_hdb->_drawMan->getDimensions(t->text, &pw, &lines);
+		g_hdb->_gfx->getDimensions(t->text, &pw, &lines);
 		t->x = kTextOutCenterX - pw / 2;
 	}
 
@@ -854,7 +854,7 @@ void Window::textOut(const char *text, int x, int y, int timer) {
 
 void Window::centerTextOut(const char *text, int y, int timer) {
 	int width, lines;
-	g_hdb->_drawMan->getDimensions(text, &width, &lines);
+	g_hdb->_gfx->getDimensions(text, &width, &lines);
 	textOut(text, kTextOutCenterX - ((width - 8) >> 1), y, timer);
 }
 
@@ -866,15 +866,15 @@ void Window::drawTextOut() {
 	if (_textOutList.empty())
 		return;
 
-	g_hdb->_drawMan->getTextEdges(&e1, &e2, &e3, &e4);
-	g_hdb->_drawMan->setTextEdges(0, 480, 0, kScreenHeight);
+	g_hdb->_gfx->getTextEdges(&e1, &e2, &e3, &e4);
+	g_hdb->_gfx->setTextEdges(0, 480, 0, kScreenHeight);
 
 	time = g_system->getMillis();
 
 	for (uint i = 0; i < _textOutList.size(); i++) {
 		t = _textOutList[i];
-		g_hdb->_drawMan->setCursor(t->x, t->y);
-		g_hdb->_drawMan->drawText(t->text);
+		g_hdb->_gfx->setCursor(t->x, t->y);
+		g_hdb->_gfx->drawText(t->text);
 
 		if (t->timer < time) {
 			_textOutList.remove_at(i);
@@ -882,7 +882,7 @@ void Window::drawTextOut() {
 		}
 	}
 
-	g_hdb->_drawMan->setTextEdges(e1, e2, e3, e4);
+	g_hdb->_gfx->setTextEdges(e1, e2, e3, e4);
 }
 
 void Window::closeTextOut() {


Commit: d55370ac82768b2f733aab4e723bda08cb36bb44
    https://github.com/scummvm/scummvm/commit/d55370ac82768b2f733aab4e723bda08cb36bb44
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:07+02:00

Commit Message:
HDB: Rename class DrawMan -> Gfx

Changed paths:
    engines/hdb/gfx.cpp
    engines/hdb/gfx.h
    engines/hdb/hdb.cpp
    engines/hdb/hdb.h


diff --git a/engines/hdb/gfx.cpp b/engines/hdb/gfx.cpp
index 0f6de88..c347d64 100644
--- a/engines/hdb/gfx.cpp
+++ b/engines/hdb/gfx.cpp
@@ -24,7 +24,7 @@
 
 namespace HDB {
 
-DrawMan::DrawMan() {
+Gfx::Gfx() {
 	_tLookupArray = NULL;
 	_gfxCache = new Common::Array<GfxCache *>;
 	_globalSurface.create(kScreenWidth, kScreenHeight, g_hdb->_format);
@@ -32,12 +32,12 @@ DrawMan::DrawMan() {
 	_systemInit = false;
 }
 
-DrawMan::~DrawMan() {
+Gfx::~Gfx() {
 	delete _gfxCache;
 	_globalSurface.free();
 }
 
-bool DrawMan::init() {
+bool Gfx::init() {
 
 	// Set the default cursor pos & char clipping
 	setCursor(0, 0);
@@ -136,17 +136,17 @@ bool DrawMan::init() {
 	return true;
 }
 
-void DrawMan::fillScreen(uint32 color) {
+void Gfx::fillScreen(uint32 color) {
 	_globalSurface.fillRect(Common::Rect(kScreenWidth, kScreenHeight), color);
 	g_system->fillScreen(color);
 }
 
-void DrawMan::updateVideo() {
+void Gfx::updateVideo() {
 	updateFade();
-	debug(9, "STUB: DrawMan::updateVideo incomplete");
+	debug(9, "STUB: Gfx::updateVideo incomplete");
 }
 
-void DrawMan::drawPointer() {
+void Gfx::drawPointer() {
 	static int anim = 0;
 	static uint32 animTime = 0;
 
@@ -164,11 +164,11 @@ void DrawMan::drawPointer() {
 		_mousePointer[anim]->drawMasked(g_hdb->_input->getMouseX() - 16, g_hdb->_input->getMouseY() - 16);
 }
 
-void DrawMan::setPointerState(int value) {
+void Gfx::setPointerState(int value) {
 	_pointerDisplayable = value;
 }
 
-void DrawMan::setFade(bool fadeIn, bool black, int steps) {
+void Gfx::setFade(bool fadeIn, bool black, int steps) {
 	_fadeInfo.isFadeIn = fadeIn;
 	_fadeInfo.isBlack = black;
 
@@ -186,12 +186,12 @@ void DrawMan::setFade(bool fadeIn, bool black, int steps) {
 	_fadeInfo.active = true;
 }
 
-void DrawMan::updateFade() {
+void Gfx::updateFade() {
 	_fadeInfo.active = false;
-	debug(9, "STUB: DrawMan::updateFade incomplete");
+	debug(9, "STUB: Gfx::updateFade incomplete");
 }
 
-Picture *DrawMan::loadPic(const char *picName) {
+Picture *Gfx::loadPic(const char *picName) {
 	Picture *pic = new Picture;
 	Common::SeekableReadStream *stream = g_hdb->_fileMan->findFirstData(picName, TYPE_PIC);
 	if (!stream)
@@ -200,7 +200,7 @@ Picture *DrawMan::loadPic(const char *picName) {
 	return pic;
 }
 
-Tile *DrawMan::loadTile(const char *tileName) {
+Tile *Gfx::loadTile(const char *tileName) {
 	Tile *tile = new Tile;
 	Common::SeekableReadStream *stream = g_hdb->_fileMan->findFirstData(tileName, TYPE_TILE32);
 	if (!stream)
@@ -209,7 +209,7 @@ Tile *DrawMan::loadTile(const char *tileName) {
 	return tile;
 }
 
-Tile *DrawMan::getTile(int index) {
+Tile *Gfx::getTile(int index) {
 
 	if (index < 0 || index > _numTiles) {
 		if (index != 0xFFFF)
@@ -232,12 +232,12 @@ Tile *DrawMan::getTile(int index) {
 	return _tLookupArray[index].tData;
 }
 
-void DrawMan::cacheTileSequence(int tileIndex, int count) {
+void Gfx::cacheTileSequence(int tileIndex, int count) {
 	for (int i = tileIndex; i < tileIndex + count; i++)
 		getTile(i);
 }
 
-int DrawMan::getTileIndex(const char *name) {
+int Gfx::getTileIndex(const char *name) {
 	if (!name) {
 		return -1;
 	}
@@ -249,7 +249,7 @@ int DrawMan::getTileIndex(const char *name) {
 	return -1;
 }
 
-Picture *DrawMan::getPicture(const char *name) {
+Picture *Gfx::getPicture(const char *name) {
 	Common::SeekableReadStream *stream = g_hdb->_fileMan->findFirstData(name, TYPE_PIC);
 	Picture *picture = new Picture;
 	picture->load(stream);
@@ -257,7 +257,7 @@ Picture *DrawMan::getPicture(const char *name) {
 }
 
 // Returns: true->Tile, false->Pic
-bool DrawMan::selectGfxType(const char *name) {
+bool Gfx::selectGfxType(const char *name) {
 	// Check for Pic types
 	if (Common::matchString(name, "clubup1"))
 		return false;
@@ -303,7 +303,7 @@ bool DrawMan::selectGfxType(const char *name) {
 	return true;
 }
 
-Tile *DrawMan::getTileGfx(const char *name, uint32 size) {
+Tile *Gfx::getTileGfx(const char *name, uint32 size) {
 	// Try to find graphic
 	for (Common::Array<GfxCache *>::iterator it = _gfxCache->begin(); it != _gfxCache->end(); it++) {
 		if (Common::matchString((*it)->name, name)) {
@@ -331,7 +331,7 @@ Tile *DrawMan::getTileGfx(const char *name, uint32 size) {
 	return gc->tileGfx;
 }
 
-Picture *DrawMan::getPicGfx(const char *name, uint32 size) {
+Picture *Gfx::getPicGfx(const char *name, uint32 size) {
 	// Try to find graphic
 	for (Common::Array<GfxCache *>::iterator it = _gfxCache->begin(); it != _gfxCache->end(); it++) {
 		if (Common::matchString((*it)->name, name)) {
@@ -359,7 +359,7 @@ Picture *DrawMan::getPicGfx(const char *name, uint32 size) {
 	return gc->picGfx;
 }
 
-int DrawMan::isSky(int index) {
+int Gfx::isSky(int index) {
 	if (!index) {
 		return 0;
 	}
@@ -373,7 +373,7 @@ int DrawMan::isSky(int index) {
 	return 0;
 }
 
-void DrawMan::setSky(int skyIndex) {
+void Gfx::setSky(int skyIndex) {
 	int tileIndex = _skyTiles[skyIndex - 1];
 	_currentSky = skyIndex;
 
@@ -396,7 +396,7 @@ void DrawMan::setSky(int skyIndex) {
 	}
 }
 
-void DrawMan::setup3DStars() {
+void Gfx::setup3DStars() {
 	for (int i = 0; i < kNum3DStars; i++) {
 		_stars3D[i].x = g_hdb->_rnd->getRandomNumber(kScreenWidth);
 		_stars3D[i].y = g_hdb->_rnd->getRandomNumber(kScreenHeight);
@@ -406,7 +406,7 @@ void DrawMan::setup3DStars() {
 	}
 }
 
-void DrawMan::setup3DStarsLeft() {
+void Gfx::setup3DStarsLeft() {
 	for (int i = 0; i < kNum3DStars; i++) {
 		_stars3DSlow[i].x = g_hdb->_rnd->getRandomNumber(kScreenWidth);
 		_stars3DSlow[i].y = g_hdb->_rnd->getRandomNumber(kScreenHeight);
@@ -415,7 +415,7 @@ void DrawMan::setup3DStarsLeft() {
 	}
 }
 
-void DrawMan::draw3DStars() {
+void Gfx::draw3DStars() {
 	fillScreen(0);
 	for (int i = 0; i < kNum3DStars; i++) {
 		_starField[_stars3D[i].color]->drawMasked((int)_stars3D[i].x, (int)_stars3D[i].y);
@@ -426,7 +426,7 @@ void DrawMan::draw3DStars() {
 	}
 }
 
-void DrawMan::draw3DStarsLeft() {
+void Gfx::draw3DStarsLeft() {
 	fillScreen(0);
 	for (int i = 0; i < kNum3DStars; i++) {
 		_starField[_stars3DSlow[i].color]->drawMasked((int)_stars3DSlow[i].x, (int)_stars3DSlow[i].y);
@@ -437,7 +437,7 @@ void DrawMan::draw3DStarsLeft() {
 	}
 }
 
-void DrawMan::drawSky() {
+void Gfx::drawSky() {
 	int tile = _skyTiles[_currentSky - 1];
 
 	if (tile == _tileSkyStars) {
@@ -461,11 +461,11 @@ void DrawMan::drawSky() {
 	}
 }
 
-int DrawMan::animateTile(int tileIndex) {
+int Gfx::animateTile(int tileIndex) {
 	return _tLookupArray[tileIndex].animIndex;
 }
 
-bool DrawMan::loadFont(const char *string) {
+bool Gfx::loadFont(const char *string) {
 	Common::SeekableReadStream *stream = g_hdb->_fileMan->findFirstData(string, TYPE_FONT);
 	if (!stream)
 		return false;
@@ -522,7 +522,7 @@ bool DrawMan::loadFont(const char *string) {
 	return true;
 }
 
-void DrawMan::drawText(const char *string) {
+void Gfx::drawText(const char *string) {
 	if (!_systemInit)
 		return;
 
@@ -592,7 +592,7 @@ void DrawMan::drawText(const char *string) {
 }
 
 // Calculates pixel width of a string
-void DrawMan::getDimensions(const char *string, int *pixelsWide, int *lines) {
+void Gfx::getDimensions(const char *string, int *pixelsWide, int *lines) {
 	if (!string) {
 		*pixelsWide = kFontSpace;
 		*lines = 1;
@@ -646,42 +646,42 @@ void DrawMan::getDimensions(const char *string, int *pixelsWide, int *lines) {
 	*lines = height;
 }
 
-int DrawMan::stringLength(const char *string) {
+int Gfx::stringLength(const char *string) {
 	int w, h;
 	getDimensions(string, &w, &h);
 	return w;
 }
 
-void DrawMan::setTextEdges(int left, int right, int top, int bottom) {
+void Gfx::setTextEdges(int left, int right, int top, int bottom) {
 	_eLeft = left;
 	_eRight = right;
 	_eTop = top;
 	_eBottom = bottom;
 }
 
-void DrawMan::getTextEdges(int *left, int *right, int *top, int *bottom) {
+void Gfx::getTextEdges(int *left, int *right, int *top, int *bottom) {
 	*left = _eLeft;
 	*right = _eRight;
 	*top = _eTop;
 	*bottom = _eBottom;
 }
 
-void DrawMan::setKernLead(int kern, int lead) {
+void Gfx::setKernLead(int kern, int lead) {
 	_fontHeader.kerning = kern;
 	_fontHeader.leading = lead;
 }
 
-void DrawMan::getKernLead(int *kern, int *lead) {
+void Gfx::getKernLead(int *kern, int *lead) {
 	*kern = _fontHeader.kerning;
 	*lead = _fontHeader.leading;
 }
 
-void DrawMan::setCursor(int x, int y) {
+void Gfx::setCursor(int x, int y) {
 	_cursorX = x;
 	_cursorY = y;
 }
 
-void DrawMan::getCursor(int *x, int *y) {
+void Gfx::getCursor(int *x, int *y) {
 	*x = _cursorX;
 	*y = _cursorY;
 }
diff --git a/engines/hdb/gfx.h b/engines/hdb/gfx.h
index 1ace112..964af02 100644
--- a/engines/hdb/gfx.h
+++ b/engines/hdb/gfx.h
@@ -82,11 +82,11 @@ struct CharInfo {
 	int32 offset;	// From the start of the font charInfo chunk
 };
 
-class DrawMan {
+class Gfx {
 public:
 
-	DrawMan();
-	~DrawMan();
+	Gfx();
+	~Gfx();
 
 	Graphics::ManagedSurface _globalSurface;
 
diff --git a/engines/hdb/hdb.cpp b/engines/hdb/hdb.cpp
index 0eb1da5..63b12c0 100644
--- a/engines/hdb/hdb.cpp
+++ b/engines/hdb/hdb.cpp
@@ -43,7 +43,7 @@ HDBGame::HDBGame(OSystem *syst, const ADGameDescription *gameDesc) : Engine(syst
 	_systemInit = false;
 	g_hdb = this;
 	_fileMan = new FileMan;
-	_gfx = new DrawMan;
+	_gfx = new Gfx;
 	_lua = new LuaScript;
 	_map = new Map;
 	_ai = new AI;
@@ -80,7 +80,7 @@ bool HDBGame::init() {
 		error("FileMan::openMPC: Cannot find the hyperspace.mpc data file.");
 	}
 	if (!_gfx->init()) {
-		error("DrawMan::init: Couldn't initialize DrawMan");
+		error("Gfx::init: Couldn't initialize Gfx");
 	}
 	if (!_input->init()) {
 		error("Input::init: Couldn't initialize Input");
@@ -150,7 +150,7 @@ void HDBGame::paint() {
 		_gfx->drawPointer();
 		break;
 	case GAME_LOADING:
-		warning("STUB: DrawMan::DrawLoadingScreen required");
+		warning("STUB: Gfx::DrawLoadingScreen required");
 		break;
 	}
 
diff --git a/engines/hdb/hdb.h b/engines/hdb/hdb.h
index 09ddede..6628848 100644
--- a/engines/hdb/hdb.h
+++ b/engines/hdb/hdb.h
@@ -130,7 +130,7 @@ public:
 	*/
 
 	FileMan *_fileMan;
-	DrawMan *_gfx;
+	Gfx *_gfx;
 	LuaScript *_lua;
 	Map *_map;
 	AI *_ai;


Commit: 2c520373d93e6f5b7f2cf717842fa4e9b99c446f
    https://github.com/scummvm/scummvm/commit/2c520373d93e6f5b7f2cf717842fa4e9b99c446f
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:07+02:00

Commit Message:
HDB: Rename map-loader.* -> map.*

Changed paths:
  A engines/hdb/map.cpp
  A engines/hdb/map.h
  R engines/hdb/map-loader.cpp
  R engines/hdb/map-loader.h
    engines/hdb/hdb.h
    engines/hdb/module.mk


diff --git a/engines/hdb/hdb.h b/engines/hdb/hdb.h
index 6628848..d3e983b 100644
--- a/engines/hdb/hdb.h
+++ b/engines/hdb/hdb.h
@@ -44,7 +44,7 @@
 #include "hdb/file-manager.h"
 #include "hdb/input.h"
 #include "hdb/lua-script.h"
-#include "hdb/map-loader.h"
+#include "hdb/map.h"
 #include "hdb/window.h"
 
 #define MAX_SNDCACHE_MEM	0x400000	// 4Mb of sounds in memory
diff --git a/engines/hdb/map-loader.cpp b/engines/hdb/map-loader.cpp
deleted file mode 100644
index e829b3d..0000000
--- a/engines/hdb/map-loader.cpp
+++ /dev/null
@@ -1,992 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- */
-
-#include "hdb/hdb.h"
-
-namespace HDB {
-
-Map::Map() {
-	_mapLoaded = false;
-
-	for (int i = 0; i < kMaxGratings; i++) {
-		_gratings[i] = new Foreground;
-	}
-
-	for (int i = 0; i < kMaxForegrounds; i++) {
-		_foregrounds[i] = new Foreground;
-	}
-}
-
-Map::~Map() {
-	for (int i = 0; i < kMaxGratings; i++) {
-		delete _gratings[i];
-	}
-
-	for (int i = 0; i < kMaxForegrounds; i++) {
-		delete _foregrounds[i];
-	}
-}
-
-int Map::loadTiles() {
-
-	int tile, temp;
-	int skyIndex = 0;
-
-	// Load all tiles
-	for (uint j = 0; j < _height; j++) {
-		for (uint i = 0; i < _width; i++) {
-			tile = _background[j * _width + i];
-			if ((temp = g_hdb->_gfx->isSky(tile)) && !skyIndex) {
-				skyIndex = temp;
-			}
-			g_hdb->_gfx->getTile(tile);
-			g_hdb->_gfx->getTile(_foreground[j * _width + i]);
-		}
-	}
-
-	return skyIndex;
-}
-
-bool Map::load(Common::SeekableReadStream *stream) {
-	if (_mapLoaded) {
-		return false;
-	}
-
-	debug(5, "map stream size: %d(%x)", stream->size(), stream->size());
-
-	// Load MSM data header
-	stream->read(_name, 32);
-	_width = stream->readUint16LE();
-	_height = stream->readUint16LE();
-	_backgroundOffset = stream->readUint32LE();
-	_foregroundOffset = stream->readUint32LE();
-	_iconNum = stream->readUint16LE();
-	_infoNum = stream->readUint16LE();            // not used in the original
-	_iconListOffset = stream->readUint32LE();
-	_infoListOffset = stream->readUint32LE();     // not used in the original
-
-	debug(5, "map: w: %d(%x), h: %d(%x) bg: %x fg: %x icon#: %d(%x) icon: %x info#: %d(%x) info: %x",
-			_width, _width, _height, _height, _backgroundOffset, _foregroundOffset, _iconNum, _iconNum,
-			_iconListOffset, _infoNum, _infoNum, _infoListOffset);
-
-	// Reading Background
-	_background = new int16[_width * _height];
-	stream->seek(_backgroundOffset);
-	for (int i = 0; i < _width * _height; i++) {
-		_background[i] = stream->readUint16LE();
-	}
-	if (gDebugLevel >= 5) {
-		debug(5, "Background:");
-		Common::hexdump((const byte *)_background, 512);
-	}
-
-	// Reading Foreground
-	_foreground = new int16[_width * _height];
-	stream->seek(_foregroundOffset);
-	for (int i = 0; i < _width * _height; i++) {
-		_foreground[i] = stream->readUint16LE();
-	}
-
-	if (gDebugLevel >= 5) {
-		debug(5, "Foreground:");
-		Common::hexdump((const byte *)_foreground, 512);
-	}
-
-	// Reading Icon List
-	_iconList = new MSMIcon[_iconNum];
-	for (uint i = 0; i < _iconNum; i++) {
-		_iconList[i].icon = stream->readUint16LE();
-		_iconList[i].x = stream->readUint16LE();
-		_iconList[i].y = stream->readUint16LE();
-
-		stream->read(_iconList[i].funcInit, 32);
-		stream->read(_iconList[i].funcAction, 32);
-		stream->read(_iconList[i].funcUse, 32);
-
-		_iconList[i].dir = stream->readUint16LE();
-		_iconList[i].level = stream->readUint16LE();
-		_iconList[i].value1 = stream->readUint16LE();
-		_iconList[i].value2 = stream->readUint16LE();
-	}
-
-	/*
-		TODO: Add the InfoList when it comes up
-	*/
-
-	/*
-		TODO: Set the InMapName once its setup
-	*/
-
-	_mapExplosions = new byte[_width * _height];
-	_mapExpBarrels = new byte[_width * _height];
-	_mapLaserBeams = new byte[_width * _height];
-
-	int sky = loadTiles();
-	g_hdb->_gfx->setSky(sky);
-	_mapX = _mapY = 0;
-
-	// Setup animating Tile lists
-	for (int i = 0; i < _width*_height; i++) {
-		addBGTileAnimation(i % _width, i / _width);
-		addFGTileAnimation(i % _width, i / _width);
-	}
-
-	struct {
-		AIType type;
-		AIDir dir;
-	} aiInfo[] = {
-		{ AI_GUY,			DIR_DOWN },
-		{ AI_GUY,			DIR_UP },
-		{ AI_GUY,			DIR_RIGHT },
-		{ AI_GUY,			DIR_LEFT },
-
-		{ ITEM_ENV_WHITE,	DIR_NONE },
-		{ ITEM_ENV_BLUE,	DIR_NONE },
-		{ ITEM_ENV_RED,		DIR_NONE },
-		{ ITEM_ENV_GREEN,	DIR_NONE },
-
-		{ AI_LASER,			DIR_RIGHT },
-		{ AI_LASER,			DIR_DOWN },
-		{ AI_LASER,			DIR_LEFT },
-		{ AI_LASER,			DIR_UP },
-
-		{ AI_DIVERTER,		DIR_DOWN },
-		{ AI_DIVERTER,		DIR_UP },
-		{ AI_DIVERTER,		DIR_RIGHT },
-		{ AI_DIVERTER,		DIR_LEFT },
-
-		{ AI_FOURFIRER,		DIR_RIGHT },
-		{ AI_FOURFIRER,		DIR_DOWN},
-		{ AI_FOURFIRER,		DIR_LEFT },
-		{ AI_FOURFIRER,		DIR_UP },
-
-		{ INFO_ARROW_TURN,	DIR_DOWN },
-		{ INFO_ARROW_TURN,	DIR_UP },
-		{ INFO_ARROW_TURN,	DIR_RIGHT },
-		{ INFO_ARROW_TURN,	DIR_LEFT },
-
-		{ INFO_ARROW_STOP,	DIR_DOWN },
-		{ INFO_ARROW_STOP,	DIR_UP },
-		{ INFO_ARROW_STOP,	DIR_RIGHT },
-		{ INFO_ARROW_STOP,	DIR_LEFT },
-
-		{ ITEM_CELL,		DIR_NONE },
-
-		{ AI_CRATE,			DIR_NONE },
-		{ AI_LIGHTBARREL,	DIR_NONE },
-		{ AI_HEAVYBARREL,	DIR_NONE },
-		{ AI_BOOMBARREL,	DIR_NONE },
-
-		{ ITEM_TRANSCEIVER, DIR_NONE },
-		{ ITEM_CLUB,		DIR_NONE },
-		{ ITEM_ROBOSTUNNER, DIR_NONE },
-		{ ITEM_SLUGSLINGER, DIR_NONE },
-
-		{ AI_SCIENTIST,		DIR_DOWN },
-		{ AI_SCIENTIST,		DIR_UP },
-		{ AI_SCIENTIST,		DIR_RIGHT },
-		{ AI_SCIENTIST,		DIR_LEFT },
-
-		{ AI_WORKER,		DIR_DOWN },
-		{ AI_WORKER,		DIR_UP },
-		{ AI_WORKER,		DIR_RIGHT },
-		{ AI_WORKER,		DIR_LEFT },
-
-		{ AI_SHOCKBOT,		DIR_DOWN },
-		{ AI_SHOCKBOT,		DIR_UP },
-		{ AI_SHOCKBOT,		DIR_RIGHT },
-		{ AI_SHOCKBOT,		DIR_LEFT },
-
-		{ AI_RIGHTBOT,		DIR_DOWN },
-		{ AI_RIGHTBOT,		DIR_UP },
-		{ AI_RIGHTBOT,		DIR_RIGHT },
-		{ AI_RIGHTBOT,		DIR_LEFT },
-
-		{ AI_PUSHBOT,		DIR_DOWN },
-		{ AI_PUSHBOT,		DIR_UP },
-		{ AI_PUSHBOT,		DIR_RIGHT },
-		{ AI_PUSHBOT,		DIR_LEFT },
-
-		{ AI_LISTENBOT,		DIR_DOWN },
-		{ AI_LISTENBOT,		DIR_UP },
-		{ AI_LISTENBOT,		DIR_RIGHT },
-		{ AI_LISTENBOT,		DIR_LEFT },
-
-		{ ITEM_MONKEYSTONE, DIR_NONE },
-
-		{ INFO_TELEPORTER1,	DIR_NONE },
-		{ INFO_TELEPORTER2,	DIR_NONE },
-		{ INFO_TELEPORTER3,	DIR_NONE },
-		{ INFO_TELEPORTER4,	DIR_NONE },
-		{ INFO_TELEPORTER5,	DIR_NONE },
-		{ INFO_TELEPORTER6,	DIR_NONE },
-		{ INFO_TELEPORTER7,	DIR_NONE },
-		{ INFO_TELEPORTER8,	DIR_NONE },
-		{ INFO_TELEPORTER9,	DIR_NONE },
-		{ INFO_TELEPORTER10,	DIR_NONE },
-		{ INFO_TELEPORTER11,	DIR_NONE },
-		{ INFO_TELEPORTER12,	DIR_NONE },
-		{ INFO_TELEPORTER13,	DIR_NONE },
-		{ INFO_TELEPORTER14,	DIR_NONE },
-		{ INFO_TELEPORTER15,	DIR_NONE },
-		{ INFO_TELEPORTER16,	DIR_NONE },
-		{ INFO_TELEPORTER17,	DIR_NONE },
-		{ INFO_TELEPORTER18,	DIR_NONE },
-		{ INFO_TELEPORTER19,	DIR_NONE },
-		{ INFO_TELEPORTER20,	DIR_NONE },
-
-		{ INFO_LEVELEXIT,	DIR_NONE },
-
-		{ INFO_ACTION1,		DIR_NONE },
-		{ INFO_ACTION2,		DIR_NONE },
-		{ INFO_ACTION3,		DIR_NONE },
-		{ INFO_ACTION4,		DIR_NONE },
-		{ INFO_ACTION5,		DIR_NONE },
-		{ INFO_ACTION6,		DIR_NONE },
-		{ INFO_ACTION7,		DIR_NONE },
-		{ INFO_ACTION8,		DIR_NONE },
-		{ INFO_ACTION9,		DIR_NONE },
-		{ INFO_ACTION10,	DIR_NONE },
-		{ INFO_ACTION11,	DIR_NONE },
-		{ INFO_ACTION12,	DIR_NONE },
-		{ INFO_ACTION13,	DIR_NONE },
-		{ INFO_ACTION14,	DIR_NONE },
-		{ INFO_ACTION15,	DIR_NONE },
-		{ INFO_ACTION16,	DIR_NONE },
-		{ INFO_ACTION17,	DIR_NONE },
-		{ INFO_ACTION18,	DIR_NONE },
-		{ INFO_ACTION19,	DIR_NONE },
-		{ INFO_ACTION20,	DIR_NONE },
-
-		{ AI_SPACEDUDE,		DIR_DOWN },
-		{ AI_SPACEDUDE,		DIR_UP },
-		{ AI_SPACEDUDE,		DIR_RIGHT },
-		{ AI_SPACEDUDE,		DIR_LEFT },
-
-		{ AI_SERGEANT,		DIR_DOWN },
-		{ AI_SERGEANT,		DIR_UP },
-		{ AI_SERGEANT,		DIR_RIGHT },
-		{ AI_SERGEANT,		DIR_LEFT },
-
-		{ AI_MAINTBOT,		DIR_DOWN },
-		{ AI_MAINTBOT,		DIR_UP },
-		{ AI_MAINTBOT,		DIR_RIGHT },
-		{ AI_MAINTBOT,		DIR_LEFT },
-
-		{ INFO_ACTION_AUTO,	DIR_NONE },
-
-		{ ITEM_GEM_WHITE,	DIR_NONE },
-		{ ITEM_GEM_BLUE,	DIR_NONE },
-		{ ITEM_GEM_RED,		DIR_NONE },
-		{ ITEM_GEM_GREEN,	DIR_NONE },
-
-		{ INFO_SET_MUSIC,	DIR_NONE },
-		{ INFO_LUA,			DIR_NONE },
-		{ INFO_HERE,		DIR_NONE },
-
-		{ AI_VORTEXIAN,		DIR_DOWN },
-
-		{ AI_CHICKEN,		DIR_DOWN },
-		{ AI_CHICKEN,		DIR_UP },
-		{ AI_CHICKEN,		DIR_RIGHT },
-		{ AI_CHICKEN,		DIR_LEFT },
-
-		{ ITEM_GOO_CUP,		DIR_NONE },
-		{ ITEM_TEACUP,		DIR_NONE },
-		{ ITEM_COOKIE,		DIR_NONE },
-		{ ITEM_BURGER,		DIR_NONE },
-		{ ITEM_PDA,			DIR_NONE },
-		{ ITEM_BOOK,		DIR_NONE },
-		{ ITEM_CLIPBOARD,	DIR_NONE },
-		{ ITEM_NOTE,		DIR_NONE },
-		{ ITEM_KEYCARD_WHITE,	DIR_NONE },
-		{ ITEM_KEYCARD_BLUE,	DIR_NONE },
-		{ ITEM_KEYCARD_RED,		DIR_NONE },
-		{ ITEM_KEYCARD_GREEN,	DIR_NONE },
-		{ ITEM_KEYCARD_PURPLE,	DIR_NONE },
-		{ ITEM_KEYCARD_BLACK,	DIR_NONE },
-		{ AI_MAGIC_EGG,		DIR_NONE },
-		{ AI_ICE_BLOCK,		DIR_NONE },
-		{ ITEM_CABKEY,		DIR_NONE },
-
-		{ AI_DEADWORKER,	DIR_NONE },
-		{ AI_OMNIBOT,		DIR_DOWN },
-		{ AI_OMNIBOT,		DIR_UP },
-		{ AI_OMNIBOT,		DIR_RIGHT },
-		{ AI_OMNIBOT,		DIR_LEFT },
-		{ AI_TURNBOT,		DIR_DOWN },
-		{ AI_TURNBOT,		DIR_UP },
-		{ AI_TURNBOT,		DIR_RIGHT },
-		{ AI_TURNBOT,		DIR_LEFT },
-		{ AI_DOLLY,			DIR_DOWN },
-		{ AI_DOLLY,			DIR_UP },
-		{ AI_DOLLY,			DIR_RIGHT },
-		{ AI_DOLLY,			DIR_LEFT },
-
-		{ INFO_TRIGGER,		DIR_NONE },
-
-		{ ITEM_DOLLYTOOL1,	DIR_NONE },
-		{ ITEM_DOLLYTOOL2,	DIR_NONE },
-		{ ITEM_DOLLYTOOL3,	DIR_NONE },
-		{ ITEM_DOLLYTOOL4,	DIR_NONE },
-
-		{ AI_RAILRIDER_ON,	DIR_UP },
-		{ AI_RAILRIDER_ON,	DIR_DOWN },
-		{ AI_RAILRIDER_ON,	DIR_LEFT },
-		{ AI_RAILRIDER_ON,	DIR_RIGHT },
-		{ AI_RAILRIDER,		DIR_UP },
-		{ AI_RAILRIDER,		DIR_DOWN },
-		{ AI_RAILRIDER,		DIR_LEFT },
-		{ AI_RAILRIDER,		DIR_RIGHT },
-
-		{ ITEM_SODA,		DIR_NONE },
-		{ INFO_ARROW_4WAY,	DIR_NONE },
-		{ AI_DEADEYE,		DIR_DOWN },
-		{ AI_DEADEYE,		DIR_UP },
-		{ AI_DEADEYE,		DIR_RIGHT },
-		{ AI_DEADEYE,		DIR_LEFT },
-		{ AI_MEERKAT,		DIR_NONE },
-		{ AI_FATFROG,		DIR_DOWN },
-		{ AI_FATFROG,		DIR_RIGHT },
-		{ AI_FATFROG,		DIR_LEFT },
-		{ AI_GOODFAIRY,		DIR_DOWN },
-		{ AI_GOODFAIRY,		DIR_UP },
-		{ AI_GOODFAIRY,		DIR_RIGHT },
-		{ AI_GOODFAIRY,		DIR_LEFT },
-		{ AI_BADFAIRY,		DIR_DOWN },
-		{ AI_BADFAIRY,		DIR_UP },
-		{ AI_BADFAIRY,		DIR_RIGHT },
-		{ AI_BADFAIRY,		DIR_LEFT },
-		{ AI_ACCOUNTANT,	DIR_DOWN },
-		{ AI_ACCOUNTANT,	DIR_UP },
-		{ AI_ACCOUNTANT,	DIR_RIGHT },
-		{ AI_ACCOUNTANT,	DIR_LEFT },
-		{ AI_ICEPUFF,		DIR_NONE },
-		{ AI_DRAGON,		DIR_NONE },
-		{ AI_BUZZFLY,		DIR_DOWN },
-		{ AI_BUZZFLY,		DIR_UP },
-		{ AI_BUZZFLY,		DIR_RIGHT },
-		{ AI_BUZZFLY,		DIR_LEFT },
-
-		{ AI_FROGSTATUE,	DIR_NONE },
-		{ ITEM_SLICER,		DIR_NONE },
-		{ INFO_FAIRY_SRC,	DIR_NONE },
-		{ INFO_FAIRY_SRC2,	DIR_NONE },
-		{ INFO_FAIRY_SRC3,	DIR_NONE },
-		{ INFO_FAIRY_SRC4,	DIR_NONE },
-		{ INFO_FAIRY_SRC5,	DIR_NONE },
-		{ INFO_FAIRY_DEST,	DIR_NONE },
-		{ INFO_FAIRY_DEST2,	DIR_NONE },
-		{ INFO_FAIRY_DEST3,	DIR_NONE },
-		{ INFO_FAIRY_DEST4,	DIR_NONE },
-		{ INFO_FAIRY_DEST5,	DIR_NONE },
-		{ INFO_QMARK,		DIR_NONE },
-		{ INFO_DEBUG,		DIR_NONE },
-		{ AI_NONE,			DIR_NONE },
-
-		{ AI_NONE,			DIR_NONE }
-	};
-
-	// Scan all icons and init all Entities
-	warning("STUB: Map::load: SetupProgressBar");
-	for (int i = 0; i < _iconNum; i++) {
-		// Don't spawn Action Mode Entities in Puzzle Mode
-		if (!g_hdb->getActionMode()) {
-			switch (aiInfo[_iconList[i].icon].type) {
-			case AI_DEADEYE:
-				if (_iconList[i].value1 == 1)	// For non-moving DeadEyes
-					break;
-			case AI_FOURFIRER:
-			case AI_LISTENBOT:
-			case ITEM_CLUB:
-			case ITEM_ROBOSTUNNER:
-			case ITEM_SLUGSLINGER:
-				continue;
-			default:
-				warning("MAP-LOADER: load: Unintended Type");
-			}
-		}
-
-		// Handle special icons that aren't moving AI entities
-		switch (aiInfo[_iconList[i].icon].type) {
-		default:
-			g_hdb->_ai->spawn(
-				aiInfo[_iconList[i].icon].type,
-				aiInfo[_iconList[i].icon].dir,
-				_iconList[i].x,
-				_iconList[i].y,
-				_iconList[i].funcInit,
-				_iconList[i].funcAction,
-				_iconList[i].funcUse,
-				(AIDir)_iconList[i].dir,
-				_iconList[i].level,
-				_iconList[i].value1,
-				_iconList[i].value2,
-				0
-			);
-			break;
-		case INFO_ARROW_4WAY:
-			g_hdb->_ai->addToPathList(
-				_iconList[i].x,
-				_iconList[i].y,
-				2,
-				aiInfo[_iconList[i].icon].dir
-			);
-			break;
-		case INFO_ARROW_TURN:
-			g_hdb->_ai->addToPathList(
-				_iconList[i].x,
-				_iconList[i].y,
-				1,
-				aiInfo[_iconList[i].icon].dir
-			);
-			break;
-		case INFO_ARROW_STOP:
-			g_hdb->_ai->addToPathList(
-				_iconList[i].x,
-				_iconList[i].y,
-				0,
-				aiInfo[_iconList[i].icon].dir
-			);
-			break;
-
-		case INFO_ACTION1:
-		case INFO_ACTION2:
-		case INFO_ACTION3:
-		case INFO_ACTION4:
-		case INFO_ACTION5:
-		case INFO_ACTION6:
-		case INFO_ACTION7:
-		case INFO_ACTION8:
-		case INFO_ACTION9:
-		case INFO_ACTION10:
-		case INFO_ACTION11:
-		case INFO_ACTION12:
-		case INFO_ACTION13:
-		case INFO_ACTION14:
-		case INFO_ACTION15:
-		case INFO_ACTION16:
-		case INFO_ACTION17:
-		case INFO_ACTION18:
-		case INFO_ACTION19:
-		case INFO_ACTION20:
-			g_hdb->_ai->addToActionList(
-				aiInfo[_iconList[i].icon].type - INFO_ACTION1,
-				_iconList[i].x,
-				_iconList[i].y,
-				_iconList[i].funcInit,
-				_iconList[i].funcUse
-			);
-			break;
-		case INFO_ACTION_AUTO:
-			g_hdb->_ai->addToAutoList(
-				_iconList[i].x,
-				_iconList[i].y,
-				_iconList[i].funcInit,
-				_iconList[i].funcUse
-			);
-			break;
-
-		case INFO_TELEPORTER1:
-		case INFO_TELEPORTER2:
-		case INFO_TELEPORTER3:
-		case INFO_TELEPORTER4:
-		case INFO_TELEPORTER5:
-		case INFO_TELEPORTER6:
-		case INFO_TELEPORTER7:
-		case INFO_TELEPORTER8:
-		case INFO_TELEPORTER9:
-		case INFO_TELEPORTER10:
-		case INFO_TELEPORTER11:
-		case INFO_TELEPORTER12:
-		case INFO_TELEPORTER13:
-		case INFO_TELEPORTER14:
-		case INFO_TELEPORTER15:
-		case INFO_TELEPORTER16:
-		case INFO_TELEPORTER17:
-		case INFO_TELEPORTER18:
-		case INFO_TELEPORTER19:
-		case INFO_TELEPORTER20:
-			g_hdb->_ai->addToTeleportList(
-				aiInfo[_iconList[i].icon].type - INFO_TELEPORTER1,
-				_iconList[i].x,
-				_iconList[i].y,
-				_iconList[i].dir,
-				_iconList[i].level,
-				_iconList[i].value1,
-				_iconList[i].value2,
-				_iconList[i].funcUse
-			);
-			break;
-
-		case INFO_SET_MUSIC:
-		case INFO_PROMOTE:
-		case INFO_DEMOTE:
-			break;
-
-		case INFO_LUA:
-			g_hdb->_ai->addToLuaList(
-				_iconList[i].x,
-				_iconList[i].y,
-				_iconList[i].value1,
-				_iconList[i].value2,
-				_iconList[i].funcInit,
-				_iconList[i].funcAction,
-				_iconList[i].funcUse
-			);
-			break;
-		case INFO_HERE:
-			g_hdb->_ai->addToHereList(
-				_iconList[i].funcInit,
-				_iconList[i].x,
-				_iconList[i].y
-			);
-			break;
-		case INFO_TRIGGER:
-			g_hdb->_ai->addToTriggerList(
-				_iconList[i].funcInit,
-				_iconList[i].funcUse,
-				_iconList[i].x,
-				_iconList[i].y,
-				_iconList[i].value1,
-				_iconList[i].value2,
-				_iconList[i].funcAction
-			);
-			break;
-
-		case INFO_FAIRY_SRC:
-		case INFO_FAIRY_SRC2:
-		case INFO_FAIRY_SRC3:
-		case INFO_FAIRY_SRC4:
-		case INFO_FAIRY_SRC5:
-			warning("STUB: Map::load: AddToFairystones(SRC) required");
-			break;
-
-		case INFO_FAIRY_DEST:
-		case INFO_FAIRY_DEST2:
-		case INFO_FAIRY_DEST3:
-		case INFO_FAIRY_DEST4:
-		case INFO_FAIRY_DEST5:
-			warning("STUB: Map::load: AddToFairystones(DEST) required");
-			break;
-		}
-	}
-
-	g_hdb->_ai->initAllEnts();
-
-	_mapLoaded = true;
-
-	return true;
-}
-
-void Map::draw() {
-	if (!_mapLoaded) {
-		return;
-	}
-
-	int matrixY;
-	int screenX, screenY;
-	int maxTileX, maxTileY;
-
-	// Calculate Tile Offsets and Panning Offsets
-	_mapTileX = _mapX / kTileWidth;
-	_mapTileY = _mapY / kTileHeight;
-	_mapTileXOff = -(_mapX % kTileWidth);
-	_mapTileYOff = -(_mapY % kTileHeight);
-
-	matrixY = _mapTileY * _width;
-	screenY = _mapTileYOff;
-
-	/*
-		Note from Original Source:
-		need to set the number of tiles to draw on the screen.  Most of the time
-		we need to draw an extra tile because we're displaying a half-tile, but
-		sometimes the offset is exactly at 0 and thus we don't need to draw a
-		tile offscreen that we'll never see.  In fact, doing this fixes a bug
-		that could occur because we would be accessing map data that's outside the map
-		when we're at the very bottom of the map.
-	*/
-
-	maxTileX = (_mapTileXOff >= -8) ? kScreenXTiles - 1 : kScreenXTiles;
-	maxTileY = (!_mapTileYOff) ? kScreenYTiles - 1 : kScreenYTiles;
-
-	if (matrixY + (maxTileY - 1)*_width > _height * _width) {
-		return;
-	}
-
-	_numForegrounds = _numGratings = 0;
-
-	for (int j = 0; j < maxTileY; j++) {
-		screenX = _mapTileXOff;
-		for (int i = 0; i < maxTileX; i++) {
-
-			// Draw Background Tile
-			int16 tileIndex = _background[matrixY + _mapTileX + i];
-			if (tileIndex < 0) {
-				tileIndex = 0;
-			}
-
-			// Draw if not a sky tile
-			if (!g_hdb->_gfx->isSky(tileIndex)) {
-				g_hdb->_gfx->getTile(tileIndex)->draw(screenX, screenY);
-			}
-
-			// Draw Foreground Tile
-			tileIndex = _foreground[matrixY + _mapTileX + i];
-			if (tileIndex >= 0) {
-				Tile *fTile = g_hdb->_gfx->getTile(tileIndex);
-				if (fTile && !(fTile->_flags & kFlagInvisible)) {
-
-					if ((fTile->_flags & kFlagGrating) && (_numGratings < kMaxGratings)) {
-						// Check for Gratings Flag
-						_gratings[_numGratings]->x = screenX;
-						_gratings[_numGratings]->y = screenY;
-						_gratings[_numGratings]->tile = tileIndex;
-						if (_numGratings < kMaxGratings)
-							_numGratings++;
-					} else if ((fTile->_flags & kFlagForeground)) {
-						// Check for Foregrounds Flag
-						_foregrounds[_numForegrounds]->x = screenX;
-						_foregrounds[_numForegrounds]->y = screenY;
-						_foregrounds[_numForegrounds]->tile = tileIndex;
-						if (_numForegrounds < kMaxForegrounds)
-							_numForegrounds++;
-					} else {
-						if (fTile->_flags & kFlagMasked) {
-							fTile->drawMasked(screenX, screenY);
-						} else {
-							fTile->draw(screenX, screenY);
-						}
-					}
-				}
-			}
-
-			screenX += kTileWidth;
-		}
-		matrixY += _width;
-		screenY += kTileWidth;
-	}
-
-	// Animate FAST Map Tiles
-	if (!(_animCycle % kAnimFastFrames)) {
-		for (Common::Array<uint32>::iterator it = _listBGAnimFast.begin(); it != _listBGAnimFast.end(); it++) {
-			_background[(*it)] = g_hdb->_gfx->animateTile(_background[(*it)]);
-		}
-
-		for (Common::Array<uint32>::iterator it = _listFGAnimFast.begin(); it != _listFGAnimFast.end(); it++) {
-			_foreground[(*it)] = g_hdb->_gfx->animateTile(_foreground[(*it)]);
-		}
-	}
-
-	// Animate MEDIUM Map Tiles
-	if (!(_animCycle % kAnimFastFrames)) {
-		for (Common::Array<uint32>::iterator it = _listBGAnimMedium.begin(); it != _listBGAnimMedium.end(); it++) {
-			_background[(*it)] = g_hdb->_gfx->animateTile(_background[(*it)]);
-		}
-
-		for (Common::Array<uint32>::iterator it = _listFGAnimMedium.begin(); it != _listFGAnimMedium.end(); it++) {
-			_foreground[(*it)] = g_hdb->_gfx->animateTile(_foreground[(*it)]);
-		}
-	}
-
-	// Animate SLOW Map Tiles
-	if (!(_animCycle % kAnimFastFrames)) {
-		for (Common::Array<uint32>::iterator it = _listBGAnimSlow.begin(); it != _listBGAnimSlow.end(); it++) {
-			_background[(*it)] = g_hdb->_gfx->animateTile(_background[(*it)]);
-		}
-
-		for (Common::Array<uint32>::iterator it = _listFGAnimSlow.begin(); it != _listFGAnimSlow.end(); it++) {
-			_foreground[(*it)] = g_hdb->_gfx->animateTile(_foreground[(*it)]);
-		}
-	}
-
-	_animCycle++;
-}
-
-void Map::drawEnts() {
-	g_hdb->_ai->drawEnts(_mapX, _mapY, kScreenXTiles * kTileWidth, kScreenYTiles * kTileHeight);
-}
-
-void Map::drawGratings() {
-	for (int i = 0; i < _numGratings; i++) {
-		g_hdb->_gfx->getTile(_gratings[i]->tile)->drawMasked(_gratings[i]->x, _gratings[i]->y);
-	}
-
-	debug(8, "Gratings Count: %d", _numGratings);
-}
-
-void Map::drawForegrounds() {
-	for (int i = 0; i < _numForegrounds; i++) {
-		g_hdb->_gfx->getTile(_foregrounds[i]->tile)->drawMasked(_foregrounds[i]->x, _foregrounds[i]->y);
-	}
-
-	debug(8, "Foregrounds Count: %d", _numForegrounds);
-}
-
-uint32 Map::getMapBGTileFlags(int x, int y) {
-	if (x < 0 || x >= _width || y < 0 || y >= _height) {
-		return 0;
-	}
-	Tile *tile = g_hdb->_gfx->getTile(_background[y * _width + x]);
-	if (tile)
-		return tile->_flags;
-	return 0;
-}
-
-uint32 Map::getMapFGTileFlags(int x, int y) {
-	if (x < 0 || x >= _width || y < 0 || y >= _height) {
-		return 0;
-	}
-	Tile *tile = g_hdb->_gfx->getTile(_foreground[y * _width + x]);
-	if (tile)
-		return tile->_flags;
-	return 0;
-}
-
-int16 Map::getMapBGTileIndex(int x, int y) {
-	if (x < 0 || x >= _width || y < 0 || y >= _height) {
-		return 0;
-	}
-	return _background[y * _width + x];
-}
-
-int16 Map::getMapFGTileIndex(int x, int y) {
-	if (x < 0 || x >= _width || y < 0 || y >= _height) {
-		return 0;
-	}
-	return _foreground[y * _width + x];
-}
-
-void Map::setMapBGTileIndex(int x, int y, int index) {
-	if (x < 0 || x >= _width || y < 0 || y >= _height) {
-		return;
-	}
-	_background[y * _width + x] = index;
-}
-
-void Map::setMapFGTileIndex(int x, int y, int index) {
-	if (x < 0 || x >= _width || y < 0 || y >= _height) {
-		return;
-	}
-	_foreground[y * _width + x] = index;
-}
-
-void Map::addBGTileAnimation(int x, int y) {
-
-	int i = y * _width + x;
-
-	Tile *tile = g_hdb->_gfx->getTile(_background[i]);
-	if (!tile)
-		return;
-	uint32 flags = tile->_flags;
-
-	// BACKGROUND
-	if (flags & kFlagAnimFast) {
-		_listBGAnimFast.push_back(i);
-	} else if (flags & kFlagAnimSlow) {
-		_listBGAnimSlow.push_back(i);
-	} else if (flags & kFlagAnimMedium) {
-		_listBGAnimMedium.push_back(i);
-	}
-}
-
-void Map::addFGTileAnimation(int x, int y) {
-
-	int i = y * _width + x;
-
-	Tile *tile = g_hdb->_gfx->getTile(_foreground[i]);
-	if (!tile)
-		return;
-	uint32 flags = tile->_flags;
-
-	// FOREGROUND
-	if (flags & kFlagAnimFast) {
-		_listFGAnimFast.push_back(i);
-	} else if (flags & kFlagAnimSlow) {
-		_listFGAnimSlow.push_back(i);
-	} else if (flags & kFlagAnimMedium) {
-		_listFGAnimMedium.push_back(i);
-	}
-}
-
-void Map::removeBGTileAnimation(int x, int y) {
-	int i = y * _width + x;
-
-	Tile *tile = g_hdb->_gfx->getTile(_background[i]);
-	if (!tile)
-		return;
-	uint32 flags = tile->_flags;
-
-	if (flags & kFlagAnimFast) {
-		for (Common::Array<uint32>::iterator it = _listBGAnimFast.begin(); it!=_listBGAnimFast.end(); it++)
-			if ((uint)i == (*it)) {
-				_listBGAnimFast.erase(it);
-				break;
-			}
-	} else if (flags & kFlagAnimSlow) {
-		for (Common::Array<uint32>::iterator it = _listBGAnimSlow.begin(); it != _listBGAnimSlow.end(); it++)
-			if ((uint)i == (*it)) {
-				_listBGAnimSlow.erase(it);
-				break;
-			}
-	} else if (flags & kFlagAnimMedium) {
-		for (Common::Array<uint32>::iterator it = _listBGAnimMedium.begin(); it != _listBGAnimMedium.end(); it++)
-			if ((uint)i == (*it)) {
-				_listBGAnimMedium.erase(it);
-				break;
-			}
-	}
-}
-
-void Map::removeFGTileAnimation(int x, int y) {
-	int i = y * _width + x;
-
-	Tile *tile = g_hdb->_gfx->getTile(_foreground[i]);
-	if (!tile)
-		return;
-	uint32 flags = tile->_flags;
-
-	if (flags & kFlagAnimFast) {
-		for (Common::Array<uint32>::iterator it = _listFGAnimFast.begin(); it!=_listFGAnimFast.end(); it++)
-			if ((uint)i == (*it)) {
-				_listFGAnimFast.erase(it);
-				break;
-			}
-	} else if (flags & kFlagAnimSlow) {
-		for (Common::Array<uint32>::iterator it = _listFGAnimSlow.begin(); it != _listFGAnimSlow.end(); it++)
-			if ((uint)i == (*it)) {
-				_listFGAnimSlow.erase(it);
-				break;
-			}
-	} else if (flags & kFlagAnimMedium) {
-		for (Common::Array<uint32>::iterator it = _listFGAnimMedium.begin(); it != _listFGAnimMedium.end(); it++)
-			if ((uint)i == (*it)) {
-				_listFGAnimMedium.erase(it);
-				break;
-			}
-	}
-}
-
-void Map::getMapXY(int *x, int *y) {
-	*x = _mapX;
-	*y = _mapY;
-}
-
-void Map::setMapXY(int x, int y) {
-	if (x < 0) {
-		x = 0;
-	} else if (x > (_width * kTileWidth - 480)) {
-		x = _width * kTileWidth - 480;
-	}
-
-	if (y < 0) {
-		y = 0;
-	} else if (y > (_height * kTileHeight - 480)) {
-		y = _height * kTileHeight - 480;
-	}
-
-	_mapX = x;
-	_mapY = y;
-}
-
-// Sets _mapX and _mapY and tries to center the map around X, Y
-void Map::centerMapXY(int x, int y) {
-	int checkx = x / kTileWidth;
-	int checky = y / kTileHeight;
-
-	int minx, miny, maxx, maxy;
-
-	// Scan from centerX to right edge
-	maxx = (_width - (16/2)) * kTileWidth;
-	for (int i = checkx + 1; i <= checkx + (16 / 2); i++) {
-		if (!getMapBGTileIndex(i, checky)) {
-			maxx = (i - (16 / 2)) * kTileWidth;
-			break;
-		}
-	}
-
-	// Scan from centerX to left edge
-	minx = 0;
-	for (int i = checkx - 1; i >= checkx - (16 / 2); i--) {
-		if (!getMapBGTileIndex(i, checky)) {
-			// +1 because we don't want to see one whole tile
-			minx = (1 + i + (16 / 2)) * kTileWidth;
-			break;
-		}
-	}
-
-	// Scan from centerY to bottom edge
-	maxy = (_height - (16/2)) * kTileHeight;
-	for (int i = checky + 1; i <= checky + (16 / 2); i++) {
-		if (!getMapBGTileIndex(checkx, i)) {
-			maxy = (i - (16 / 2)) * kTileHeight;
-			break;
-		}
-	}
-
-	// Scan from centerY to top edge
-	miny = 0;
-	for (int i = checky - 1; i >= checkx - (16 / 2); i--) {
-		if (!getMapBGTileIndex(checkx, i)) {
-			// +! because we don't want to see one whole tile
-			miny = (1 + i + (16 / 2)) * kTileHeight;
-			break;
-		}
-	}
-
-	if (x < minx) {
-		x = minx;
-	} else if (x > maxx) {
-		x = maxx;
-	}
-
-	if (y < miny) {
-		y = miny;
-	} else if (y > maxy) {
-		y = maxy;
-	}
-
-	x -= (480 / 2);
-	y -= (480 / 2);
-
-	setMapXY(x, y);
-}
-
-bool Map::checkEntOnScreen(AIEntity *e) {
-	return ((e->x > _mapX - 32) && (e->x < _mapX + kScreenXTiles * kTileWidth) && (e->y > _mapY - 32) && (e->y < kScreenYTiles * kTileHeight));
-}
-
-bool Map::checkXYOnScreen(int x, int y) {
-	return ((x > _mapX - 32) && (x < _mapX + kScreenXTiles * kTileWidth) && (y > _mapY - 32) && (y < kScreenYTiles * kTileHeight));
-}
-
-bool Map::checkOneTileExistInRange(int tileIndex, int count) {
-	for (int i = 0; i < _width*_height; i++) {
-		if (_background[i] >= tileIndex && _background[i] < tileIndex + count)
-			return true;
-		if (_foreground[i] >= tileIndex && _foreground[i] < tileIndex + count)
-			return true;
-	}
-	return true;
-}
-
-}
diff --git a/engines/hdb/map-loader.h b/engines/hdb/map-loader.h
deleted file mode 100644
index 151bef9..0000000
--- a/engines/hdb/map-loader.h
+++ /dev/null
@@ -1,171 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- */
-
-#ifndef HDB_MAP_LOADER_H
-#define HDB_MAP_LOADER_H
-
-#include "common/system.h"
-
-namespace HDB {
-
-enum {
-	kScreenXTiles = 17,
-	kScreenYTiles = 16,
-	kMaxGratings = 250,
-	kMaxForegrounds = 250
-};
-
-struct MSMIcon {
-	uint16	icon;					// index into icon list
-	uint16	x;
-	uint16	y;
-
-	char	funcInit[32];		// Lua init function for this entity
-	char	funcAction[32];
-	char	funcUse[32];
-	uint16	dir;					// direction entity is facing
-	uint16	level;					// which floor level entity is on
-	uint16	value1, value2;
-
-	MSMIcon(): icon(0), x(0), y(0), funcInit(""), funcAction(""), funcUse(""), dir(0), level(0), value1(0), value2(0) {}
-};
-
-struct Foreground {
-	uint16 x;
-	uint16 y;
-	uint16 tile;
-
-	Foreground() : x(0), y(0), tile(0) {}
-};
-
-struct SeeThroughTile {
-	uint16 x;
-	uint16 y;
-	uint16 tile;
-
-	SeeThroughTile() : x(0), y(0), tile(0) {}
-};
-
-class Map {
-public:
-	Map();
-	~Map();
-
-	int loadTiles();
-	bool load(Common::SeekableReadStream *stream);
-	void draw();
-	void drawEnts();
-	void drawGratings();
-	void drawForegrounds();
-
-	bool isLoaded() {
-		return _mapLoaded;
-	}
-
-	bool onScreen(int x, int y) {
-		if ((x >= _mapX / kTileWidth) && (x < (_mapX / kTileWidth) + kScreenXTiles) && (y >= _mapY / kTileHeight) && (y < (_mapY / kTileHeight) + kScreenYTiles))
-			return true;
-		return false;
-	}
-
-	uint32 getMapBGTileFlags(int x, int y);
-	uint32 getMapFGTileFlags(int x, int y);
-	int16 getMapBGTileIndex(int x, int y);
-	int16 getMapFGTileIndex(int x, int y);
-	void setMapBGTileIndex(int x, int y, int index);
-	void setMapFGTileIndex(int x, int y, int index);
-	void addBGTileAnimation(int x, int y);
-	void addFGTileAnimation(int x, int y);
-	void removeBGTileAnimation(int x, int y);
-	void removeFGTileAnimation(int x, int y);
-
-	void getMapXY(int *x, int *y);
-	void setMapXY(int x, int y);
-	void centerMapXY(int x, int y);
-	bool checkEntOnScreen(AIEntity *);
-	bool checkXYOnScreen(int x, int y);
-
-	// Check if one of the tiles in a range exists in the map on either layer
-	bool checkOneTileExistInRange(int tileIndex, int count);
-
-	bool explosionExist(int x, int y) {
-		return _mapExplosions[y * _width + x];
-	}
-	void setExplosion(int x, int y, int value) {
-		_mapExplosions[y * _width + x] = value;
-	}
-
-	bool boomBarrelExist(int x, int y) {
-		return _mapExpBarrels[y * _width + x];
-	}
-	void setBoomBarrel(int x, int y, int value) {
-		_mapExpBarrels[y * _width + x] = value;
-	}
-
-	bool laserBeamExist(int x, int y) {
-		return _mapLaserBeams[y * _width + x];
-	}
-	void setLaserBeam(int x, int y, int value) {
-		_mapLaserBeams[y * _width + x] = value;
-	}
-	void clearLaserBeams() {
-		memset(_mapLaserBeams, 0, _width * _height);
-	}
-
-	uint16 _width, _height;
-	int _mapX, _mapY; // Coordinates of Map
-	int _mapTileX, _mapTileY; // Tile Coordinates of Map
-	int _mapTileXOff, _mapTileYOff; // Tile Coordinates Offset (0-31)
-
-	Foreground *_gratings[kMaxGratings], *_foregrounds[kMaxForegrounds];
-	int _numGratings, _numForegrounds;
-
-	int _animCycle;	// Tile Animation Counter
-	Common::Array<uint32> _listBGAnimSlow;
-	Common::Array<uint32> _listBGAnimMedium;
-	Common::Array<uint32> _listBGAnimFast;
-	Common::Array<uint32> _listFGAnimSlow;
-	Common::Array<uint32> _listFGAnimMedium;
-	Common::Array<uint32> _listFGAnimFast;
-
-private:
-	char _name[32];
-	uint32 _backgroundOffset;
-	uint32 _foregroundOffset;
-	uint16 _iconNum;
-	uint32 _iconListOffset;
-	uint16 _infoNum;
-	uint32 _infoListOffset;
-
-	int16 *_background;
-	int16 *_foreground;
-	MSMIcon *_iconList;
-
-	byte *_mapExplosions;
-	byte *_mapExpBarrels;
-	byte *_mapLaserBeams;
-
-	bool _mapLoaded;
-};
-}
-
-#endif // !HDB_MAP_LOADER_H
diff --git a/engines/hdb/map.cpp b/engines/hdb/map.cpp
new file mode 100644
index 0000000..e829b3d
--- /dev/null
+++ b/engines/hdb/map.cpp
@@ -0,0 +1,992 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "hdb/hdb.h"
+
+namespace HDB {
+
+Map::Map() {
+	_mapLoaded = false;
+
+	for (int i = 0; i < kMaxGratings; i++) {
+		_gratings[i] = new Foreground;
+	}
+
+	for (int i = 0; i < kMaxForegrounds; i++) {
+		_foregrounds[i] = new Foreground;
+	}
+}
+
+Map::~Map() {
+	for (int i = 0; i < kMaxGratings; i++) {
+		delete _gratings[i];
+	}
+
+	for (int i = 0; i < kMaxForegrounds; i++) {
+		delete _foregrounds[i];
+	}
+}
+
+int Map::loadTiles() {
+
+	int tile, temp;
+	int skyIndex = 0;
+
+	// Load all tiles
+	for (uint j = 0; j < _height; j++) {
+		for (uint i = 0; i < _width; i++) {
+			tile = _background[j * _width + i];
+			if ((temp = g_hdb->_gfx->isSky(tile)) && !skyIndex) {
+				skyIndex = temp;
+			}
+			g_hdb->_gfx->getTile(tile);
+			g_hdb->_gfx->getTile(_foreground[j * _width + i]);
+		}
+	}
+
+	return skyIndex;
+}
+
+bool Map::load(Common::SeekableReadStream *stream) {
+	if (_mapLoaded) {
+		return false;
+	}
+
+	debug(5, "map stream size: %d(%x)", stream->size(), stream->size());
+
+	// Load MSM data header
+	stream->read(_name, 32);
+	_width = stream->readUint16LE();
+	_height = stream->readUint16LE();
+	_backgroundOffset = stream->readUint32LE();
+	_foregroundOffset = stream->readUint32LE();
+	_iconNum = stream->readUint16LE();
+	_infoNum = stream->readUint16LE();            // not used in the original
+	_iconListOffset = stream->readUint32LE();
+	_infoListOffset = stream->readUint32LE();     // not used in the original
+
+	debug(5, "map: w: %d(%x), h: %d(%x) bg: %x fg: %x icon#: %d(%x) icon: %x info#: %d(%x) info: %x",
+			_width, _width, _height, _height, _backgroundOffset, _foregroundOffset, _iconNum, _iconNum,
+			_iconListOffset, _infoNum, _infoNum, _infoListOffset);
+
+	// Reading Background
+	_background = new int16[_width * _height];
+	stream->seek(_backgroundOffset);
+	for (int i = 0; i < _width * _height; i++) {
+		_background[i] = stream->readUint16LE();
+	}
+	if (gDebugLevel >= 5) {
+		debug(5, "Background:");
+		Common::hexdump((const byte *)_background, 512);
+	}
+
+	// Reading Foreground
+	_foreground = new int16[_width * _height];
+	stream->seek(_foregroundOffset);
+	for (int i = 0; i < _width * _height; i++) {
+		_foreground[i] = stream->readUint16LE();
+	}
+
+	if (gDebugLevel >= 5) {
+		debug(5, "Foreground:");
+		Common::hexdump((const byte *)_foreground, 512);
+	}
+
+	// Reading Icon List
+	_iconList = new MSMIcon[_iconNum];
+	for (uint i = 0; i < _iconNum; i++) {
+		_iconList[i].icon = stream->readUint16LE();
+		_iconList[i].x = stream->readUint16LE();
+		_iconList[i].y = stream->readUint16LE();
+
+		stream->read(_iconList[i].funcInit, 32);
+		stream->read(_iconList[i].funcAction, 32);
+		stream->read(_iconList[i].funcUse, 32);
+
+		_iconList[i].dir = stream->readUint16LE();
+		_iconList[i].level = stream->readUint16LE();
+		_iconList[i].value1 = stream->readUint16LE();
+		_iconList[i].value2 = stream->readUint16LE();
+	}
+
+	/*
+		TODO: Add the InfoList when it comes up
+	*/
+
+	/*
+		TODO: Set the InMapName once its setup
+	*/
+
+	_mapExplosions = new byte[_width * _height];
+	_mapExpBarrels = new byte[_width * _height];
+	_mapLaserBeams = new byte[_width * _height];
+
+	int sky = loadTiles();
+	g_hdb->_gfx->setSky(sky);
+	_mapX = _mapY = 0;
+
+	// Setup animating Tile lists
+	for (int i = 0; i < _width*_height; i++) {
+		addBGTileAnimation(i % _width, i / _width);
+		addFGTileAnimation(i % _width, i / _width);
+	}
+
+	struct {
+		AIType type;
+		AIDir dir;
+	} aiInfo[] = {
+		{ AI_GUY,			DIR_DOWN },
+		{ AI_GUY,			DIR_UP },
+		{ AI_GUY,			DIR_RIGHT },
+		{ AI_GUY,			DIR_LEFT },
+
+		{ ITEM_ENV_WHITE,	DIR_NONE },
+		{ ITEM_ENV_BLUE,	DIR_NONE },
+		{ ITEM_ENV_RED,		DIR_NONE },
+		{ ITEM_ENV_GREEN,	DIR_NONE },
+
+		{ AI_LASER,			DIR_RIGHT },
+		{ AI_LASER,			DIR_DOWN },
+		{ AI_LASER,			DIR_LEFT },
+		{ AI_LASER,			DIR_UP },
+
+		{ AI_DIVERTER,		DIR_DOWN },
+		{ AI_DIVERTER,		DIR_UP },
+		{ AI_DIVERTER,		DIR_RIGHT },
+		{ AI_DIVERTER,		DIR_LEFT },
+
+		{ AI_FOURFIRER,		DIR_RIGHT },
+		{ AI_FOURFIRER,		DIR_DOWN},
+		{ AI_FOURFIRER,		DIR_LEFT },
+		{ AI_FOURFIRER,		DIR_UP },
+
+		{ INFO_ARROW_TURN,	DIR_DOWN },
+		{ INFO_ARROW_TURN,	DIR_UP },
+		{ INFO_ARROW_TURN,	DIR_RIGHT },
+		{ INFO_ARROW_TURN,	DIR_LEFT },
+
+		{ INFO_ARROW_STOP,	DIR_DOWN },
+		{ INFO_ARROW_STOP,	DIR_UP },
+		{ INFO_ARROW_STOP,	DIR_RIGHT },
+		{ INFO_ARROW_STOP,	DIR_LEFT },
+
+		{ ITEM_CELL,		DIR_NONE },
+
+		{ AI_CRATE,			DIR_NONE },
+		{ AI_LIGHTBARREL,	DIR_NONE },
+		{ AI_HEAVYBARREL,	DIR_NONE },
+		{ AI_BOOMBARREL,	DIR_NONE },
+
+		{ ITEM_TRANSCEIVER, DIR_NONE },
+		{ ITEM_CLUB,		DIR_NONE },
+		{ ITEM_ROBOSTUNNER, DIR_NONE },
+		{ ITEM_SLUGSLINGER, DIR_NONE },
+
+		{ AI_SCIENTIST,		DIR_DOWN },
+		{ AI_SCIENTIST,		DIR_UP },
+		{ AI_SCIENTIST,		DIR_RIGHT },
+		{ AI_SCIENTIST,		DIR_LEFT },
+
+		{ AI_WORKER,		DIR_DOWN },
+		{ AI_WORKER,		DIR_UP },
+		{ AI_WORKER,		DIR_RIGHT },
+		{ AI_WORKER,		DIR_LEFT },
+
+		{ AI_SHOCKBOT,		DIR_DOWN },
+		{ AI_SHOCKBOT,		DIR_UP },
+		{ AI_SHOCKBOT,		DIR_RIGHT },
+		{ AI_SHOCKBOT,		DIR_LEFT },
+
+		{ AI_RIGHTBOT,		DIR_DOWN },
+		{ AI_RIGHTBOT,		DIR_UP },
+		{ AI_RIGHTBOT,		DIR_RIGHT },
+		{ AI_RIGHTBOT,		DIR_LEFT },
+
+		{ AI_PUSHBOT,		DIR_DOWN },
+		{ AI_PUSHBOT,		DIR_UP },
+		{ AI_PUSHBOT,		DIR_RIGHT },
+		{ AI_PUSHBOT,		DIR_LEFT },
+
+		{ AI_LISTENBOT,		DIR_DOWN },
+		{ AI_LISTENBOT,		DIR_UP },
+		{ AI_LISTENBOT,		DIR_RIGHT },
+		{ AI_LISTENBOT,		DIR_LEFT },
+
+		{ ITEM_MONKEYSTONE, DIR_NONE },
+
+		{ INFO_TELEPORTER1,	DIR_NONE },
+		{ INFO_TELEPORTER2,	DIR_NONE },
+		{ INFO_TELEPORTER3,	DIR_NONE },
+		{ INFO_TELEPORTER4,	DIR_NONE },
+		{ INFO_TELEPORTER5,	DIR_NONE },
+		{ INFO_TELEPORTER6,	DIR_NONE },
+		{ INFO_TELEPORTER7,	DIR_NONE },
+		{ INFO_TELEPORTER8,	DIR_NONE },
+		{ INFO_TELEPORTER9,	DIR_NONE },
+		{ INFO_TELEPORTER10,	DIR_NONE },
+		{ INFO_TELEPORTER11,	DIR_NONE },
+		{ INFO_TELEPORTER12,	DIR_NONE },
+		{ INFO_TELEPORTER13,	DIR_NONE },
+		{ INFO_TELEPORTER14,	DIR_NONE },
+		{ INFO_TELEPORTER15,	DIR_NONE },
+		{ INFO_TELEPORTER16,	DIR_NONE },
+		{ INFO_TELEPORTER17,	DIR_NONE },
+		{ INFO_TELEPORTER18,	DIR_NONE },
+		{ INFO_TELEPORTER19,	DIR_NONE },
+		{ INFO_TELEPORTER20,	DIR_NONE },
+
+		{ INFO_LEVELEXIT,	DIR_NONE },
+
+		{ INFO_ACTION1,		DIR_NONE },
+		{ INFO_ACTION2,		DIR_NONE },
+		{ INFO_ACTION3,		DIR_NONE },
+		{ INFO_ACTION4,		DIR_NONE },
+		{ INFO_ACTION5,		DIR_NONE },
+		{ INFO_ACTION6,		DIR_NONE },
+		{ INFO_ACTION7,		DIR_NONE },
+		{ INFO_ACTION8,		DIR_NONE },
+		{ INFO_ACTION9,		DIR_NONE },
+		{ INFO_ACTION10,	DIR_NONE },
+		{ INFO_ACTION11,	DIR_NONE },
+		{ INFO_ACTION12,	DIR_NONE },
+		{ INFO_ACTION13,	DIR_NONE },
+		{ INFO_ACTION14,	DIR_NONE },
+		{ INFO_ACTION15,	DIR_NONE },
+		{ INFO_ACTION16,	DIR_NONE },
+		{ INFO_ACTION17,	DIR_NONE },
+		{ INFO_ACTION18,	DIR_NONE },
+		{ INFO_ACTION19,	DIR_NONE },
+		{ INFO_ACTION20,	DIR_NONE },
+
+		{ AI_SPACEDUDE,		DIR_DOWN },
+		{ AI_SPACEDUDE,		DIR_UP },
+		{ AI_SPACEDUDE,		DIR_RIGHT },
+		{ AI_SPACEDUDE,		DIR_LEFT },
+
+		{ AI_SERGEANT,		DIR_DOWN },
+		{ AI_SERGEANT,		DIR_UP },
+		{ AI_SERGEANT,		DIR_RIGHT },
+		{ AI_SERGEANT,		DIR_LEFT },
+
+		{ AI_MAINTBOT,		DIR_DOWN },
+		{ AI_MAINTBOT,		DIR_UP },
+		{ AI_MAINTBOT,		DIR_RIGHT },
+		{ AI_MAINTBOT,		DIR_LEFT },
+
+		{ INFO_ACTION_AUTO,	DIR_NONE },
+
+		{ ITEM_GEM_WHITE,	DIR_NONE },
+		{ ITEM_GEM_BLUE,	DIR_NONE },
+		{ ITEM_GEM_RED,		DIR_NONE },
+		{ ITEM_GEM_GREEN,	DIR_NONE },
+
+		{ INFO_SET_MUSIC,	DIR_NONE },
+		{ INFO_LUA,			DIR_NONE },
+		{ INFO_HERE,		DIR_NONE },
+
+		{ AI_VORTEXIAN,		DIR_DOWN },
+
+		{ AI_CHICKEN,		DIR_DOWN },
+		{ AI_CHICKEN,		DIR_UP },
+		{ AI_CHICKEN,		DIR_RIGHT },
+		{ AI_CHICKEN,		DIR_LEFT },
+
+		{ ITEM_GOO_CUP,		DIR_NONE },
+		{ ITEM_TEACUP,		DIR_NONE },
+		{ ITEM_COOKIE,		DIR_NONE },
+		{ ITEM_BURGER,		DIR_NONE },
+		{ ITEM_PDA,			DIR_NONE },
+		{ ITEM_BOOK,		DIR_NONE },
+		{ ITEM_CLIPBOARD,	DIR_NONE },
+		{ ITEM_NOTE,		DIR_NONE },
+		{ ITEM_KEYCARD_WHITE,	DIR_NONE },
+		{ ITEM_KEYCARD_BLUE,	DIR_NONE },
+		{ ITEM_KEYCARD_RED,		DIR_NONE },
+		{ ITEM_KEYCARD_GREEN,	DIR_NONE },
+		{ ITEM_KEYCARD_PURPLE,	DIR_NONE },
+		{ ITEM_KEYCARD_BLACK,	DIR_NONE },
+		{ AI_MAGIC_EGG,		DIR_NONE },
+		{ AI_ICE_BLOCK,		DIR_NONE },
+		{ ITEM_CABKEY,		DIR_NONE },
+
+		{ AI_DEADWORKER,	DIR_NONE },
+		{ AI_OMNIBOT,		DIR_DOWN },
+		{ AI_OMNIBOT,		DIR_UP },
+		{ AI_OMNIBOT,		DIR_RIGHT },
+		{ AI_OMNIBOT,		DIR_LEFT },
+		{ AI_TURNBOT,		DIR_DOWN },
+		{ AI_TURNBOT,		DIR_UP },
+		{ AI_TURNBOT,		DIR_RIGHT },
+		{ AI_TURNBOT,		DIR_LEFT },
+		{ AI_DOLLY,			DIR_DOWN },
+		{ AI_DOLLY,			DIR_UP },
+		{ AI_DOLLY,			DIR_RIGHT },
+		{ AI_DOLLY,			DIR_LEFT },
+
+		{ INFO_TRIGGER,		DIR_NONE },
+
+		{ ITEM_DOLLYTOOL1,	DIR_NONE },
+		{ ITEM_DOLLYTOOL2,	DIR_NONE },
+		{ ITEM_DOLLYTOOL3,	DIR_NONE },
+		{ ITEM_DOLLYTOOL4,	DIR_NONE },
+
+		{ AI_RAILRIDER_ON,	DIR_UP },
+		{ AI_RAILRIDER_ON,	DIR_DOWN },
+		{ AI_RAILRIDER_ON,	DIR_LEFT },
+		{ AI_RAILRIDER_ON,	DIR_RIGHT },
+		{ AI_RAILRIDER,		DIR_UP },
+		{ AI_RAILRIDER,		DIR_DOWN },
+		{ AI_RAILRIDER,		DIR_LEFT },
+		{ AI_RAILRIDER,		DIR_RIGHT },
+
+		{ ITEM_SODA,		DIR_NONE },
+		{ INFO_ARROW_4WAY,	DIR_NONE },
+		{ AI_DEADEYE,		DIR_DOWN },
+		{ AI_DEADEYE,		DIR_UP },
+		{ AI_DEADEYE,		DIR_RIGHT },
+		{ AI_DEADEYE,		DIR_LEFT },
+		{ AI_MEERKAT,		DIR_NONE },
+		{ AI_FATFROG,		DIR_DOWN },
+		{ AI_FATFROG,		DIR_RIGHT },
+		{ AI_FATFROG,		DIR_LEFT },
+		{ AI_GOODFAIRY,		DIR_DOWN },
+		{ AI_GOODFAIRY,		DIR_UP },
+		{ AI_GOODFAIRY,		DIR_RIGHT },
+		{ AI_GOODFAIRY,		DIR_LEFT },
+		{ AI_BADFAIRY,		DIR_DOWN },
+		{ AI_BADFAIRY,		DIR_UP },
+		{ AI_BADFAIRY,		DIR_RIGHT },
+		{ AI_BADFAIRY,		DIR_LEFT },
+		{ AI_ACCOUNTANT,	DIR_DOWN },
+		{ AI_ACCOUNTANT,	DIR_UP },
+		{ AI_ACCOUNTANT,	DIR_RIGHT },
+		{ AI_ACCOUNTANT,	DIR_LEFT },
+		{ AI_ICEPUFF,		DIR_NONE },
+		{ AI_DRAGON,		DIR_NONE },
+		{ AI_BUZZFLY,		DIR_DOWN },
+		{ AI_BUZZFLY,		DIR_UP },
+		{ AI_BUZZFLY,		DIR_RIGHT },
+		{ AI_BUZZFLY,		DIR_LEFT },
+
+		{ AI_FROGSTATUE,	DIR_NONE },
+		{ ITEM_SLICER,		DIR_NONE },
+		{ INFO_FAIRY_SRC,	DIR_NONE },
+		{ INFO_FAIRY_SRC2,	DIR_NONE },
+		{ INFO_FAIRY_SRC3,	DIR_NONE },
+		{ INFO_FAIRY_SRC4,	DIR_NONE },
+		{ INFO_FAIRY_SRC5,	DIR_NONE },
+		{ INFO_FAIRY_DEST,	DIR_NONE },
+		{ INFO_FAIRY_DEST2,	DIR_NONE },
+		{ INFO_FAIRY_DEST3,	DIR_NONE },
+		{ INFO_FAIRY_DEST4,	DIR_NONE },
+		{ INFO_FAIRY_DEST5,	DIR_NONE },
+		{ INFO_QMARK,		DIR_NONE },
+		{ INFO_DEBUG,		DIR_NONE },
+		{ AI_NONE,			DIR_NONE },
+
+		{ AI_NONE,			DIR_NONE }
+	};
+
+	// Scan all icons and init all Entities
+	warning("STUB: Map::load: SetupProgressBar");
+	for (int i = 0; i < _iconNum; i++) {
+		// Don't spawn Action Mode Entities in Puzzle Mode
+		if (!g_hdb->getActionMode()) {
+			switch (aiInfo[_iconList[i].icon].type) {
+			case AI_DEADEYE:
+				if (_iconList[i].value1 == 1)	// For non-moving DeadEyes
+					break;
+			case AI_FOURFIRER:
+			case AI_LISTENBOT:
+			case ITEM_CLUB:
+			case ITEM_ROBOSTUNNER:
+			case ITEM_SLUGSLINGER:
+				continue;
+			default:
+				warning("MAP-LOADER: load: Unintended Type");
+			}
+		}
+
+		// Handle special icons that aren't moving AI entities
+		switch (aiInfo[_iconList[i].icon].type) {
+		default:
+			g_hdb->_ai->spawn(
+				aiInfo[_iconList[i].icon].type,
+				aiInfo[_iconList[i].icon].dir,
+				_iconList[i].x,
+				_iconList[i].y,
+				_iconList[i].funcInit,
+				_iconList[i].funcAction,
+				_iconList[i].funcUse,
+				(AIDir)_iconList[i].dir,
+				_iconList[i].level,
+				_iconList[i].value1,
+				_iconList[i].value2,
+				0
+			);
+			break;
+		case INFO_ARROW_4WAY:
+			g_hdb->_ai->addToPathList(
+				_iconList[i].x,
+				_iconList[i].y,
+				2,
+				aiInfo[_iconList[i].icon].dir
+			);
+			break;
+		case INFO_ARROW_TURN:
+			g_hdb->_ai->addToPathList(
+				_iconList[i].x,
+				_iconList[i].y,
+				1,
+				aiInfo[_iconList[i].icon].dir
+			);
+			break;
+		case INFO_ARROW_STOP:
+			g_hdb->_ai->addToPathList(
+				_iconList[i].x,
+				_iconList[i].y,
+				0,
+				aiInfo[_iconList[i].icon].dir
+			);
+			break;
+
+		case INFO_ACTION1:
+		case INFO_ACTION2:
+		case INFO_ACTION3:
+		case INFO_ACTION4:
+		case INFO_ACTION5:
+		case INFO_ACTION6:
+		case INFO_ACTION7:
+		case INFO_ACTION8:
+		case INFO_ACTION9:
+		case INFO_ACTION10:
+		case INFO_ACTION11:
+		case INFO_ACTION12:
+		case INFO_ACTION13:
+		case INFO_ACTION14:
+		case INFO_ACTION15:
+		case INFO_ACTION16:
+		case INFO_ACTION17:
+		case INFO_ACTION18:
+		case INFO_ACTION19:
+		case INFO_ACTION20:
+			g_hdb->_ai->addToActionList(
+				aiInfo[_iconList[i].icon].type - INFO_ACTION1,
+				_iconList[i].x,
+				_iconList[i].y,
+				_iconList[i].funcInit,
+				_iconList[i].funcUse
+			);
+			break;
+		case INFO_ACTION_AUTO:
+			g_hdb->_ai->addToAutoList(
+				_iconList[i].x,
+				_iconList[i].y,
+				_iconList[i].funcInit,
+				_iconList[i].funcUse
+			);
+			break;
+
+		case INFO_TELEPORTER1:
+		case INFO_TELEPORTER2:
+		case INFO_TELEPORTER3:
+		case INFO_TELEPORTER4:
+		case INFO_TELEPORTER5:
+		case INFO_TELEPORTER6:
+		case INFO_TELEPORTER7:
+		case INFO_TELEPORTER8:
+		case INFO_TELEPORTER9:
+		case INFO_TELEPORTER10:
+		case INFO_TELEPORTER11:
+		case INFO_TELEPORTER12:
+		case INFO_TELEPORTER13:
+		case INFO_TELEPORTER14:
+		case INFO_TELEPORTER15:
+		case INFO_TELEPORTER16:
+		case INFO_TELEPORTER17:
+		case INFO_TELEPORTER18:
+		case INFO_TELEPORTER19:
+		case INFO_TELEPORTER20:
+			g_hdb->_ai->addToTeleportList(
+				aiInfo[_iconList[i].icon].type - INFO_TELEPORTER1,
+				_iconList[i].x,
+				_iconList[i].y,
+				_iconList[i].dir,
+				_iconList[i].level,
+				_iconList[i].value1,
+				_iconList[i].value2,
+				_iconList[i].funcUse
+			);
+			break;
+
+		case INFO_SET_MUSIC:
+		case INFO_PROMOTE:
+		case INFO_DEMOTE:
+			break;
+
+		case INFO_LUA:
+			g_hdb->_ai->addToLuaList(
+				_iconList[i].x,
+				_iconList[i].y,
+				_iconList[i].value1,
+				_iconList[i].value2,
+				_iconList[i].funcInit,
+				_iconList[i].funcAction,
+				_iconList[i].funcUse
+			);
+			break;
+		case INFO_HERE:
+			g_hdb->_ai->addToHereList(
+				_iconList[i].funcInit,
+				_iconList[i].x,
+				_iconList[i].y
+			);
+			break;
+		case INFO_TRIGGER:
+			g_hdb->_ai->addToTriggerList(
+				_iconList[i].funcInit,
+				_iconList[i].funcUse,
+				_iconList[i].x,
+				_iconList[i].y,
+				_iconList[i].value1,
+				_iconList[i].value2,
+				_iconList[i].funcAction
+			);
+			break;
+
+		case INFO_FAIRY_SRC:
+		case INFO_FAIRY_SRC2:
+		case INFO_FAIRY_SRC3:
+		case INFO_FAIRY_SRC4:
+		case INFO_FAIRY_SRC5:
+			warning("STUB: Map::load: AddToFairystones(SRC) required");
+			break;
+
+		case INFO_FAIRY_DEST:
+		case INFO_FAIRY_DEST2:
+		case INFO_FAIRY_DEST3:
+		case INFO_FAIRY_DEST4:
+		case INFO_FAIRY_DEST5:
+			warning("STUB: Map::load: AddToFairystones(DEST) required");
+			break;
+		}
+	}
+
+	g_hdb->_ai->initAllEnts();
+
+	_mapLoaded = true;
+
+	return true;
+}
+
+void Map::draw() {
+	if (!_mapLoaded) {
+		return;
+	}
+
+	int matrixY;
+	int screenX, screenY;
+	int maxTileX, maxTileY;
+
+	// Calculate Tile Offsets and Panning Offsets
+	_mapTileX = _mapX / kTileWidth;
+	_mapTileY = _mapY / kTileHeight;
+	_mapTileXOff = -(_mapX % kTileWidth);
+	_mapTileYOff = -(_mapY % kTileHeight);
+
+	matrixY = _mapTileY * _width;
+	screenY = _mapTileYOff;
+
+	/*
+		Note from Original Source:
+		need to set the number of tiles to draw on the screen.  Most of the time
+		we need to draw an extra tile because we're displaying a half-tile, but
+		sometimes the offset is exactly at 0 and thus we don't need to draw a
+		tile offscreen that we'll never see.  In fact, doing this fixes a bug
+		that could occur because we would be accessing map data that's outside the map
+		when we're at the very bottom of the map.
+	*/
+
+	maxTileX = (_mapTileXOff >= -8) ? kScreenXTiles - 1 : kScreenXTiles;
+	maxTileY = (!_mapTileYOff) ? kScreenYTiles - 1 : kScreenYTiles;
+
+	if (matrixY + (maxTileY - 1)*_width > _height * _width) {
+		return;
+	}
+
+	_numForegrounds = _numGratings = 0;
+
+	for (int j = 0; j < maxTileY; j++) {
+		screenX = _mapTileXOff;
+		for (int i = 0; i < maxTileX; i++) {
+
+			// Draw Background Tile
+			int16 tileIndex = _background[matrixY + _mapTileX + i];
+			if (tileIndex < 0) {
+				tileIndex = 0;
+			}
+
+			// Draw if not a sky tile
+			if (!g_hdb->_gfx->isSky(tileIndex)) {
+				g_hdb->_gfx->getTile(tileIndex)->draw(screenX, screenY);
+			}
+
+			// Draw Foreground Tile
+			tileIndex = _foreground[matrixY + _mapTileX + i];
+			if (tileIndex >= 0) {
+				Tile *fTile = g_hdb->_gfx->getTile(tileIndex);
+				if (fTile && !(fTile->_flags & kFlagInvisible)) {
+
+					if ((fTile->_flags & kFlagGrating) && (_numGratings < kMaxGratings)) {
+						// Check for Gratings Flag
+						_gratings[_numGratings]->x = screenX;
+						_gratings[_numGratings]->y = screenY;
+						_gratings[_numGratings]->tile = tileIndex;
+						if (_numGratings < kMaxGratings)
+							_numGratings++;
+					} else if ((fTile->_flags & kFlagForeground)) {
+						// Check for Foregrounds Flag
+						_foregrounds[_numForegrounds]->x = screenX;
+						_foregrounds[_numForegrounds]->y = screenY;
+						_foregrounds[_numForegrounds]->tile = tileIndex;
+						if (_numForegrounds < kMaxForegrounds)
+							_numForegrounds++;
+					} else {
+						if (fTile->_flags & kFlagMasked) {
+							fTile->drawMasked(screenX, screenY);
+						} else {
+							fTile->draw(screenX, screenY);
+						}
+					}
+				}
+			}
+
+			screenX += kTileWidth;
+		}
+		matrixY += _width;
+		screenY += kTileWidth;
+	}
+
+	// Animate FAST Map Tiles
+	if (!(_animCycle % kAnimFastFrames)) {
+		for (Common::Array<uint32>::iterator it = _listBGAnimFast.begin(); it != _listBGAnimFast.end(); it++) {
+			_background[(*it)] = g_hdb->_gfx->animateTile(_background[(*it)]);
+		}
+
+		for (Common::Array<uint32>::iterator it = _listFGAnimFast.begin(); it != _listFGAnimFast.end(); it++) {
+			_foreground[(*it)] = g_hdb->_gfx->animateTile(_foreground[(*it)]);
+		}
+	}
+
+	// Animate MEDIUM Map Tiles
+	if (!(_animCycle % kAnimFastFrames)) {
+		for (Common::Array<uint32>::iterator it = _listBGAnimMedium.begin(); it != _listBGAnimMedium.end(); it++) {
+			_background[(*it)] = g_hdb->_gfx->animateTile(_background[(*it)]);
+		}
+
+		for (Common::Array<uint32>::iterator it = _listFGAnimMedium.begin(); it != _listFGAnimMedium.end(); it++) {
+			_foreground[(*it)] = g_hdb->_gfx->animateTile(_foreground[(*it)]);
+		}
+	}
+
+	// Animate SLOW Map Tiles
+	if (!(_animCycle % kAnimFastFrames)) {
+		for (Common::Array<uint32>::iterator it = _listBGAnimSlow.begin(); it != _listBGAnimSlow.end(); it++) {
+			_background[(*it)] = g_hdb->_gfx->animateTile(_background[(*it)]);
+		}
+
+		for (Common::Array<uint32>::iterator it = _listFGAnimSlow.begin(); it != _listFGAnimSlow.end(); it++) {
+			_foreground[(*it)] = g_hdb->_gfx->animateTile(_foreground[(*it)]);
+		}
+	}
+
+	_animCycle++;
+}
+
+void Map::drawEnts() {
+	g_hdb->_ai->drawEnts(_mapX, _mapY, kScreenXTiles * kTileWidth, kScreenYTiles * kTileHeight);
+}
+
+void Map::drawGratings() {
+	for (int i = 0; i < _numGratings; i++) {
+		g_hdb->_gfx->getTile(_gratings[i]->tile)->drawMasked(_gratings[i]->x, _gratings[i]->y);
+	}
+
+	debug(8, "Gratings Count: %d", _numGratings);
+}
+
+void Map::drawForegrounds() {
+	for (int i = 0; i < _numForegrounds; i++) {
+		g_hdb->_gfx->getTile(_foregrounds[i]->tile)->drawMasked(_foregrounds[i]->x, _foregrounds[i]->y);
+	}
+
+	debug(8, "Foregrounds Count: %d", _numForegrounds);
+}
+
+uint32 Map::getMapBGTileFlags(int x, int y) {
+	if (x < 0 || x >= _width || y < 0 || y >= _height) {
+		return 0;
+	}
+	Tile *tile = g_hdb->_gfx->getTile(_background[y * _width + x]);
+	if (tile)
+		return tile->_flags;
+	return 0;
+}
+
+uint32 Map::getMapFGTileFlags(int x, int y) {
+	if (x < 0 || x >= _width || y < 0 || y >= _height) {
+		return 0;
+	}
+	Tile *tile = g_hdb->_gfx->getTile(_foreground[y * _width + x]);
+	if (tile)
+		return tile->_flags;
+	return 0;
+}
+
+int16 Map::getMapBGTileIndex(int x, int y) {
+	if (x < 0 || x >= _width || y < 0 || y >= _height) {
+		return 0;
+	}
+	return _background[y * _width + x];
+}
+
+int16 Map::getMapFGTileIndex(int x, int y) {
+	if (x < 0 || x >= _width || y < 0 || y >= _height) {
+		return 0;
+	}
+	return _foreground[y * _width + x];
+}
+
+void Map::setMapBGTileIndex(int x, int y, int index) {
+	if (x < 0 || x >= _width || y < 0 || y >= _height) {
+		return;
+	}
+	_background[y * _width + x] = index;
+}
+
+void Map::setMapFGTileIndex(int x, int y, int index) {
+	if (x < 0 || x >= _width || y < 0 || y >= _height) {
+		return;
+	}
+	_foreground[y * _width + x] = index;
+}
+
+void Map::addBGTileAnimation(int x, int y) {
+
+	int i = y * _width + x;
+
+	Tile *tile = g_hdb->_gfx->getTile(_background[i]);
+	if (!tile)
+		return;
+	uint32 flags = tile->_flags;
+
+	// BACKGROUND
+	if (flags & kFlagAnimFast) {
+		_listBGAnimFast.push_back(i);
+	} else if (flags & kFlagAnimSlow) {
+		_listBGAnimSlow.push_back(i);
+	} else if (flags & kFlagAnimMedium) {
+		_listBGAnimMedium.push_back(i);
+	}
+}
+
+void Map::addFGTileAnimation(int x, int y) {
+
+	int i = y * _width + x;
+
+	Tile *tile = g_hdb->_gfx->getTile(_foreground[i]);
+	if (!tile)
+		return;
+	uint32 flags = tile->_flags;
+
+	// FOREGROUND
+	if (flags & kFlagAnimFast) {
+		_listFGAnimFast.push_back(i);
+	} else if (flags & kFlagAnimSlow) {
+		_listFGAnimSlow.push_back(i);
+	} else if (flags & kFlagAnimMedium) {
+		_listFGAnimMedium.push_back(i);
+	}
+}
+
+void Map::removeBGTileAnimation(int x, int y) {
+	int i = y * _width + x;
+
+	Tile *tile = g_hdb->_gfx->getTile(_background[i]);
+	if (!tile)
+		return;
+	uint32 flags = tile->_flags;
+
+	if (flags & kFlagAnimFast) {
+		for (Common::Array<uint32>::iterator it = _listBGAnimFast.begin(); it!=_listBGAnimFast.end(); it++)
+			if ((uint)i == (*it)) {
+				_listBGAnimFast.erase(it);
+				break;
+			}
+	} else if (flags & kFlagAnimSlow) {
+		for (Common::Array<uint32>::iterator it = _listBGAnimSlow.begin(); it != _listBGAnimSlow.end(); it++)
+			if ((uint)i == (*it)) {
+				_listBGAnimSlow.erase(it);
+				break;
+			}
+	} else if (flags & kFlagAnimMedium) {
+		for (Common::Array<uint32>::iterator it = _listBGAnimMedium.begin(); it != _listBGAnimMedium.end(); it++)
+			if ((uint)i == (*it)) {
+				_listBGAnimMedium.erase(it);
+				break;
+			}
+	}
+}
+
+void Map::removeFGTileAnimation(int x, int y) {
+	int i = y * _width + x;
+
+	Tile *tile = g_hdb->_gfx->getTile(_foreground[i]);
+	if (!tile)
+		return;
+	uint32 flags = tile->_flags;
+
+	if (flags & kFlagAnimFast) {
+		for (Common::Array<uint32>::iterator it = _listFGAnimFast.begin(); it!=_listFGAnimFast.end(); it++)
+			if ((uint)i == (*it)) {
+				_listFGAnimFast.erase(it);
+				break;
+			}
+	} else if (flags & kFlagAnimSlow) {
+		for (Common::Array<uint32>::iterator it = _listFGAnimSlow.begin(); it != _listFGAnimSlow.end(); it++)
+			if ((uint)i == (*it)) {
+				_listFGAnimSlow.erase(it);
+				break;
+			}
+	} else if (flags & kFlagAnimMedium) {
+		for (Common::Array<uint32>::iterator it = _listFGAnimMedium.begin(); it != _listFGAnimMedium.end(); it++)
+			if ((uint)i == (*it)) {
+				_listFGAnimMedium.erase(it);
+				break;
+			}
+	}
+}
+
+void Map::getMapXY(int *x, int *y) {
+	*x = _mapX;
+	*y = _mapY;
+}
+
+void Map::setMapXY(int x, int y) {
+	if (x < 0) {
+		x = 0;
+	} else if (x > (_width * kTileWidth - 480)) {
+		x = _width * kTileWidth - 480;
+	}
+
+	if (y < 0) {
+		y = 0;
+	} else if (y > (_height * kTileHeight - 480)) {
+		y = _height * kTileHeight - 480;
+	}
+
+	_mapX = x;
+	_mapY = y;
+}
+
+// Sets _mapX and _mapY and tries to center the map around X, Y
+void Map::centerMapXY(int x, int y) {
+	int checkx = x / kTileWidth;
+	int checky = y / kTileHeight;
+
+	int minx, miny, maxx, maxy;
+
+	// Scan from centerX to right edge
+	maxx = (_width - (16/2)) * kTileWidth;
+	for (int i = checkx + 1; i <= checkx + (16 / 2); i++) {
+		if (!getMapBGTileIndex(i, checky)) {
+			maxx = (i - (16 / 2)) * kTileWidth;
+			break;
+		}
+	}
+
+	// Scan from centerX to left edge
+	minx = 0;
+	for (int i = checkx - 1; i >= checkx - (16 / 2); i--) {
+		if (!getMapBGTileIndex(i, checky)) {
+			// +1 because we don't want to see one whole tile
+			minx = (1 + i + (16 / 2)) * kTileWidth;
+			break;
+		}
+	}
+
+	// Scan from centerY to bottom edge
+	maxy = (_height - (16/2)) * kTileHeight;
+	for (int i = checky + 1; i <= checky + (16 / 2); i++) {
+		if (!getMapBGTileIndex(checkx, i)) {
+			maxy = (i - (16 / 2)) * kTileHeight;
+			break;
+		}
+	}
+
+	// Scan from centerY to top edge
+	miny = 0;
+	for (int i = checky - 1; i >= checkx - (16 / 2); i--) {
+		if (!getMapBGTileIndex(checkx, i)) {
+			// +! because we don't want to see one whole tile
+			miny = (1 + i + (16 / 2)) * kTileHeight;
+			break;
+		}
+	}
+
+	if (x < minx) {
+		x = minx;
+	} else if (x > maxx) {
+		x = maxx;
+	}
+
+	if (y < miny) {
+		y = miny;
+	} else if (y > maxy) {
+		y = maxy;
+	}
+
+	x -= (480 / 2);
+	y -= (480 / 2);
+
+	setMapXY(x, y);
+}
+
+bool Map::checkEntOnScreen(AIEntity *e) {
+	return ((e->x > _mapX - 32) && (e->x < _mapX + kScreenXTiles * kTileWidth) && (e->y > _mapY - 32) && (e->y < kScreenYTiles * kTileHeight));
+}
+
+bool Map::checkXYOnScreen(int x, int y) {
+	return ((x > _mapX - 32) && (x < _mapX + kScreenXTiles * kTileWidth) && (y > _mapY - 32) && (y < kScreenYTiles * kTileHeight));
+}
+
+bool Map::checkOneTileExistInRange(int tileIndex, int count) {
+	for (int i = 0; i < _width*_height; i++) {
+		if (_background[i] >= tileIndex && _background[i] < tileIndex + count)
+			return true;
+		if (_foreground[i] >= tileIndex && _foreground[i] < tileIndex + count)
+			return true;
+	}
+	return true;
+}
+
+}
diff --git a/engines/hdb/map.h b/engines/hdb/map.h
new file mode 100644
index 0000000..151bef9
--- /dev/null
+++ b/engines/hdb/map.h
@@ -0,0 +1,171 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef HDB_MAP_LOADER_H
+#define HDB_MAP_LOADER_H
+
+#include "common/system.h"
+
+namespace HDB {
+
+enum {
+	kScreenXTiles = 17,
+	kScreenYTiles = 16,
+	kMaxGratings = 250,
+	kMaxForegrounds = 250
+};
+
+struct MSMIcon {
+	uint16	icon;					// index into icon list
+	uint16	x;
+	uint16	y;
+
+	char	funcInit[32];		// Lua init function for this entity
+	char	funcAction[32];
+	char	funcUse[32];
+	uint16	dir;					// direction entity is facing
+	uint16	level;					// which floor level entity is on
+	uint16	value1, value2;
+
+	MSMIcon(): icon(0), x(0), y(0), funcInit(""), funcAction(""), funcUse(""), dir(0), level(0), value1(0), value2(0) {}
+};
+
+struct Foreground {
+	uint16 x;
+	uint16 y;
+	uint16 tile;
+
+	Foreground() : x(0), y(0), tile(0) {}
+};
+
+struct SeeThroughTile {
+	uint16 x;
+	uint16 y;
+	uint16 tile;
+
+	SeeThroughTile() : x(0), y(0), tile(0) {}
+};
+
+class Map {
+public:
+	Map();
+	~Map();
+
+	int loadTiles();
+	bool load(Common::SeekableReadStream *stream);
+	void draw();
+	void drawEnts();
+	void drawGratings();
+	void drawForegrounds();
+
+	bool isLoaded() {
+		return _mapLoaded;
+	}
+
+	bool onScreen(int x, int y) {
+		if ((x >= _mapX / kTileWidth) && (x < (_mapX / kTileWidth) + kScreenXTiles) && (y >= _mapY / kTileHeight) && (y < (_mapY / kTileHeight) + kScreenYTiles))
+			return true;
+		return false;
+	}
+
+	uint32 getMapBGTileFlags(int x, int y);
+	uint32 getMapFGTileFlags(int x, int y);
+	int16 getMapBGTileIndex(int x, int y);
+	int16 getMapFGTileIndex(int x, int y);
+	void setMapBGTileIndex(int x, int y, int index);
+	void setMapFGTileIndex(int x, int y, int index);
+	void addBGTileAnimation(int x, int y);
+	void addFGTileAnimation(int x, int y);
+	void removeBGTileAnimation(int x, int y);
+	void removeFGTileAnimation(int x, int y);
+
+	void getMapXY(int *x, int *y);
+	void setMapXY(int x, int y);
+	void centerMapXY(int x, int y);
+	bool checkEntOnScreen(AIEntity *);
+	bool checkXYOnScreen(int x, int y);
+
+	// Check if one of the tiles in a range exists in the map on either layer
+	bool checkOneTileExistInRange(int tileIndex, int count);
+
+	bool explosionExist(int x, int y) {
+		return _mapExplosions[y * _width + x];
+	}
+	void setExplosion(int x, int y, int value) {
+		_mapExplosions[y * _width + x] = value;
+	}
+
+	bool boomBarrelExist(int x, int y) {
+		return _mapExpBarrels[y * _width + x];
+	}
+	void setBoomBarrel(int x, int y, int value) {
+		_mapExpBarrels[y * _width + x] = value;
+	}
+
+	bool laserBeamExist(int x, int y) {
+		return _mapLaserBeams[y * _width + x];
+	}
+	void setLaserBeam(int x, int y, int value) {
+		_mapLaserBeams[y * _width + x] = value;
+	}
+	void clearLaserBeams() {
+		memset(_mapLaserBeams, 0, _width * _height);
+	}
+
+	uint16 _width, _height;
+	int _mapX, _mapY; // Coordinates of Map
+	int _mapTileX, _mapTileY; // Tile Coordinates of Map
+	int _mapTileXOff, _mapTileYOff; // Tile Coordinates Offset (0-31)
+
+	Foreground *_gratings[kMaxGratings], *_foregrounds[kMaxForegrounds];
+	int _numGratings, _numForegrounds;
+
+	int _animCycle;	// Tile Animation Counter
+	Common::Array<uint32> _listBGAnimSlow;
+	Common::Array<uint32> _listBGAnimMedium;
+	Common::Array<uint32> _listBGAnimFast;
+	Common::Array<uint32> _listFGAnimSlow;
+	Common::Array<uint32> _listFGAnimMedium;
+	Common::Array<uint32> _listFGAnimFast;
+
+private:
+	char _name[32];
+	uint32 _backgroundOffset;
+	uint32 _foregroundOffset;
+	uint16 _iconNum;
+	uint32 _iconListOffset;
+	uint16 _infoNum;
+	uint32 _infoListOffset;
+
+	int16 *_background;
+	int16 *_foreground;
+	MSMIcon *_iconList;
+
+	byte *_mapExplosions;
+	byte *_mapExpBarrels;
+	byte *_mapLaserBeams;
+
+	bool _mapLoaded;
+};
+}
+
+#endif // !HDB_MAP_LOADER_H
diff --git a/engines/hdb/module.mk b/engines/hdb/module.mk
index e55658f..57972cb 100644
--- a/engines/hdb/module.mk
+++ b/engines/hdb/module.mk
@@ -17,7 +17,7 @@ MODULE_OBJS := \
 	hdb.o \
 	input.o \
 	lua-script.o \
-	map-loader.o \
+	map.o \
 	window.o
 
 MODULE_DIRS += \


Commit: 2369415b305e9b0569548049196f9baf0cf58021
    https://github.com/scummvm/scummvm/commit/2369415b305e9b0569548049196f9baf0cf58021
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:07+02:00

Commit Message:
HDB: Add Crate related functions

Changed paths:
    engines/hdb/ai-player.cpp


diff --git a/engines/hdb/ai-player.cpp b/engines/hdb/ai-player.cpp
index 6c8ff00..a5a3649 100644
--- a/engines/hdb/ai-player.cpp
+++ b/engines/hdb/ai-player.cpp
@@ -557,15 +557,46 @@ void aiSpacedudeInit2(AIEntity *e) {
 }
 
 void aiCrateAction(AIEntity *e) {
-	warning("STUB: AI: aiCrateAction required");
+	// if crate isn't moving somewhere, don't move it
+	if (!e->goalX) {
+		// crate is stopped in the water... should it continue downstream?
+		// not if it's marked by the Number of the Beast!
+		if (e->state == STATE_FLOATING) {
+			if (e->value1 != 0x666) {
+				int flags = g_hdb->_map->getMapBGTileFlags(e->tileX, e->tileY);
+				if (flags & (kFlagPushRight | kFlagPushLeft | kFlagPushUp | kFlagPushDown)) {
+					g_hdb->_ai->setEntityGoal(e, e->tileX, e->tileY);
+					g_hdb->_ai->animateEntity(e);
+				} else
+					g_hdb->_ai->animEntFrames(e);
+			} else
+				g_hdb->_ai->animEntFrames(e);
+		}
+		return;
+	}
+
+	g_hdb->_ai->animateEntity(e);
 }
 
 void aiCrateInit2(AIEntity *e) {
-	warning("STUB: AI: aiCrateInit2 required");
+	// point all crate move frames to the standing one
+	e->movedownFrames =
+		e->moveleftFrames =
+		e->moverightFrames =
+		e->moveupFrames = 1;
+
+	e->movedownGfx[0] =
+		e->moveupGfx[0] =
+		e->moveleftGfx[0] =
+		e->moverightGfx[0] = e->standdownGfx[0];
+
+	e->draw = e->standdownGfx[0];			// standing frame - doesn't move
 }
 
 void aiCrateInit(AIEntity *e) {
-	warning("STUB: AI: aiCrateInit required");
+	e->moveSpeed = kPushMoveSpeed;
+	e->aiAction = aiCrateAction;
+	e->value1 = 0;
 }
 
 void aiBarrelLightAction(AIEntity *e) {


Commit: ea8e108cb6ac5aaf9c42904a15f807435c6713b0
    https://github.com/scummvm/scummvm/commit/ea8e108cb6ac5aaf9c42904a15f807435c6713b0
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:07+02:00

Commit Message:
HDB: Add Light Barrel related functions

Changed paths:
    engines/hdb/ai-player.cpp


diff --git a/engines/hdb/ai-player.cpp b/engines/hdb/ai-player.cpp
index a5a3649..e12831f 100644
--- a/engines/hdb/ai-player.cpp
+++ b/engines/hdb/ai-player.cpp
@@ -600,15 +600,33 @@ void aiCrateInit(AIEntity *e) {
 }
 
 void aiBarrelLightAction(AIEntity *e) {
-	warning("STUB: AI: aiBarrelLightAction required");
+	if (!e->goalX) {
+		if (e->state == STATE_FLOATING)
+			g_hdb->_ai->animEntFrames(e);
+		return;
+	}
+
+	g_hdb->_ai->animateEntity(e);
 }
 
 void aiBarrelLightInit2(AIEntity *e) {
-	warning("STUB: AI: aiBarrelLightInit2 required");
+	// point all light barrel move frames to the standing one
+	e->movedownFrames =
+		e->moveleftFrames =
+		e->moverightFrames =
+		e->moveupFrames = 1;
+
+	e->movedownGfx[0] =
+		e->moveupGfx[0] =
+		e->moveleftGfx[0] =
+		e->moverightGfx[0] = e->standdownGfx[0];
+
+	e->draw = e->standdownGfx[0];			// standing frame - doesn't move
 }
 
 void aiBarrelLightInit(AIEntity *e) {
-	warning("STUB: AI: aiBarrelLightInit required");
+	e->moveSpeed = kPushMoveSpeed;
+	e->aiAction = aiBarrelLightAction;
 }
 
 void aiBarrelHeavyAction(AIEntity *e) {


Commit: 3b35cb5aa73088459ec223a2ed0f01355eaf1b2f
    https://github.com/scummvm/scummvm/commit/3b35cb5aa73088459ec223a2ed0f01355eaf1b2f
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:07+02:00

Commit Message:
HDB: Add Heavy Barrel related functions

Changed paths:
    engines/hdb/ai-player.cpp


diff --git a/engines/hdb/ai-player.cpp b/engines/hdb/ai-player.cpp
index e12831f..da2ccd7 100644
--- a/engines/hdb/ai-player.cpp
+++ b/engines/hdb/ai-player.cpp
@@ -630,15 +630,33 @@ void aiBarrelLightInit(AIEntity *e) {
 }
 
 void aiBarrelHeavyAction(AIEntity *e) {
-	warning("STUB: AI: aiBarrelHeavyAction required");
+	if (!e->goalX) {
+		if (e->state == STATE_FLOATING)
+			g_hdb->_ai->animEntFrames(e);
+		return;
+	}
+
+	g_hdb->_ai->animateEntity(e);
 }
 
 void aiBarrelHeavyInit2(AIEntity *e) {
-	warning("STUB: AI: aiBarrelHeavyInit2 required");
+	// point all heavy barrel move frames to the standing one
+	e->movedownFrames =
+		e->moveleftFrames =
+		e->moverightFrames =
+		e->moveupFrames = 1;
+
+	e->movedownGfx[0] =
+		e->moveupGfx[0] =
+		e->moveleftGfx[0] =
+		e->moverightGfx[0] = e->standdownGfx[0];
+
+	e->draw = e->standdownGfx[0];			// standing frame - doesn't move
 }
 
 void aiBarrelHeavyInit(AIEntity *e) {
-	warning("STUB: AI: aiBarrelHeavyInit required");
+	e->moveSpeed = kPushMoveSpeed;
+	e->aiAction = aiBarrelHeavyAction;
 }
 
 void aiBarrelExplosionEnd(AIEntity *e) {


Commit: 77ebf4ae50f08fdde20261bf902852c410e9448c
    https://github.com/scummvm/scummvm/commit/77ebf4ae50f08fdde20261bf902852c410e9448c
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:07+02:00

Commit Message:
HDB: Add Exploding Barrel related functions

Changed paths:
    engines/hdb/ai-player.cpp


diff --git a/engines/hdb/ai-player.cpp b/engines/hdb/ai-player.cpp
index da2ccd7..a2ff6ef 100644
--- a/engines/hdb/ai-player.cpp
+++ b/engines/hdb/ai-player.cpp
@@ -668,19 +668,41 @@ void aiBarrelExplosionAction(AIEntity *e) {
 }
 
 void aiBarrelExplode(AIEntity *e) {
-	warning("STUB: AI: aiBarrelExplode required");
+	e->state = STATE_EXPLODING;
+	e->animDelay = e->animCycle;
+	e->animFrame = 0;
+	warning("STUB: Play SND_BARREL_EXPLODE");
+	g_hdb->_map->setBoomBarrel(e->tileX, e->tileY, 0);
 }
 
 void aiBarrelExplodeInit(AIEntity *e) {
-	warning("STUB: AI: aiBarrelExplodeInit required");
+	e->moveSpeed = kPushMoveSpeed;
+	e->aiAction = aiBarrelExplodeAction;
+	g_hdb->_map->setBoomBarrel(e->tileX, e->tileY, 1);
 }
 
 void aiBarrelExplodeInit2(AIEntity *e) {
-	warning("STUB: AI: aiBarrelExplodeInit2 required");
+	// point all exploding barrel MOVE frames to the standing one
+	e->blinkFrames =
+		e->movedownFrames =
+		e->moveleftFrames =
+		e->moverightFrames =
+		e->moveupFrames = 1;
+
+	e->blinkGfx[0] =
+		e->movedownGfx[0] =
+		e->moveupGfx[0] =
+		e->moveleftGfx[0] =
+		e->moverightGfx[0] = e->standdownGfx[0];
+
+	e->draw = e->standdownGfx[0];			// standing frame - doesn't move
 }
 
 void aiBarrelExplodeAction(AIEntity *e) {
-	warning("STUB: AI: aiBarrelExplodeAction required");
+	if (e->goalX)
+		g_hdb->_ai->animateEntity(e);
+	else if (e->state == STATE_EXPLODING)
+		g_hdb->_ai->animEntFrames(e);
 }
 
 void aiBarrelExplodeSpread(AIEntity *e) {
@@ -688,11 +710,14 @@ void aiBarrelExplodeSpread(AIEntity *e) {
 }
 
 void aiBarrelExplosionEnd(int x, int y) {
-	warning("STUB: AI: aiBarrelExplosionEnd(int, int) required");
+	g_hdb->_map->setExplosion(x, y, 0);
 }
 
 void aiBarrelBlowup(AIEntity *e, int x, int y) {
-	warning("STUB: AI: aiBarrelBlowup required");
+	g_hdb->_ai->addAnimateTarget(x * kTileWidth,
+		y * kTileHeight, 0, 3, ANIM_NORMAL, false, false, GROUP_EXPLOSION_BOOM_SIT);
+	g_hdb->_map->setExplosion(x, y, 1);
+	g_hdb->_ai->addCallback(AI_BARREL_EXPLOSION_END, x, y, e->animCycle * 4);
 }
 
 void aiScientistInit(AIEntity *e) {


Commit: e76a7381145900bf0238b4e23e7da63dd2c5c691
    https://github.com/scummvm/scummvm/commit/e76a7381145900bf0238b4e23e7da63dd2c5c691
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:07+02:00

Commit Message:
HDB: Unstub aiBarrelExplodeSpread()

Changed paths:
    engines/hdb/ai-player.cpp


diff --git a/engines/hdb/ai-player.cpp b/engines/hdb/ai-player.cpp
index a2ff6ef..2588b1b 100644
--- a/engines/hdb/ai-player.cpp
+++ b/engines/hdb/ai-player.cpp
@@ -706,7 +706,107 @@ void aiBarrelExplodeAction(AIEntity *e) {
 }
 
 void aiBarrelExplodeSpread(AIEntity *e) {
-	warning("STUB: AI: aiBarrelExplodeSpread required");
+	AIEntity *e2;
+	int	x = e->tileX;
+	int	y = e->tileY;
+	int	xv, yv;
+	int	index = e->animFrame;
+	int	xv1[4] = {-1,  1, -1,  0};
+	int yv1[4] = {-1, -1,  0, -1};
+	int xv2[4] = {1,  0,  1, -1};
+	int yv2[4] = {0,  1,  1,  1};
+
+	// are we just starting an explosion ring?
+	if (e->animDelay != e->animCycle)
+		return;
+
+	// the animation frame is the index into which set of 2 explosions to spawn
+	xv = xv1[index];
+	yv = yv1[index];
+
+	// explosion 1: check to see if we can explode (non-solid tile)
+	// if so, spawn it and mark it in the explosion matrix
+	if (!(g_hdb->_map->getMapBGTileFlags(x + xv, y + yv) & kFlagSolid) && !g_hdb->_map->explosionExist(x + xv, y + yv)) {
+		aiBarrelBlowup(e, x + xv, y + yv);
+		// are we blowing up on another BOOMBARREL?  if so, start it exploding.
+		e2 = g_hdb->_ai->findEntity(x + xv, y + yv);
+		if (e2 && e2->state != STATE_EXPLODING) {
+			switch (e2->type) {
+			case AI_GUY:
+				g_hdb->_ai->killPlayer(DEATH_FRIED);
+				break;
+			case AI_BOOMBARREL:
+				aiBarrelExplode(e2);
+				break;
+			case AI_OMNIBOT:
+			case AI_TURNBOT:
+			case AI_SHOCKBOT:
+			case AI_RIGHTBOT:
+			case AI_PUSHBOT:
+			case AI_RAILRIDER:
+			case AI_MAINTBOT:
+			case AI_DEADEYE:
+			case AI_FATFROG:
+			case AI_ICEPUFF:
+			case AI_MEERKAT:
+			case AI_BUZZFLY:
+			case AI_GOODFAIRY:
+			case AI_GATEPUDDLE:
+			case AI_BADFAIRY:
+				g_hdb->_ai->addAnimateTarget(x * kTileWidth,
+					y * kTileHeight, 0, 3, ANIM_NORMAL, false, false, GROUP_EXPLOSION_BOOM_SIT);
+				if (e2->type != AI_LASERBEAM)
+					g_hdb->_ai->removeEntity(e2);
+				break;
+			default:
+				break;
+			}
+		}
+	}
+
+	xv = xv2[index];
+	yv = yv2[index];
+
+	// explosion 2: check to see if we can explode (non-solid tile)
+	// if so, spawn it and mark it in the explosion matrix
+
+	if (!(g_hdb->_map->getMapBGTileFlags(x + xv, y + yv) & kFlagSolid) && !g_hdb->_map->explosionExist(x + xv, y + yv)) {
+		aiBarrelBlowup(e, x + xv, y + yv);
+		// are we blowing up on another BOOMBARREL?  if so, start it exploding.
+		e2 = g_hdb->_ai->findEntity(x + xv, y + yv);
+		if (e2 && e2->state != STATE_EXPLODING) {
+			switch (e2->type) {
+			case AI_GUY:
+				g_hdb->_ai->killPlayer(DEATH_FRIED);
+				break;
+			case AI_BOOMBARREL:
+				aiBarrelExplode(e2);
+				break;
+			case AI_OMNIBOT:
+			case AI_TURNBOT:
+			case AI_SHOCKBOT:
+			case AI_RIGHTBOT:
+			case AI_PUSHBOT:
+			case AI_RAILRIDER:
+			case AI_MAINTBOT:
+			case AI_DEADEYE:
+			case AI_FATFROG:
+			case AI_ICEPUFF:
+			case AI_MEERKAT:
+			case AI_BUZZFLY:
+			case AI_GOODFAIRY:
+			case AI_GATEPUDDLE:
+			case AI_BADFAIRY:
+				g_hdb->_ai->addAnimateTarget(x * kTileWidth,
+					y * kTileHeight, 0, 3, ANIM_NORMAL, false, false, GROUP_EXPLOSION_BOOM_SIT);
+				if (e2->type != AI_LASERBEAM)
+					g_hdb->_ai->removeEntity(e2);
+				break;
+			default:
+				break;
+			}
+		}
+	}
 }
 
 void aiBarrelExplosionEnd(int x, int y) {


Commit: 9c7344ac30691dd57230d7d83fdf74de3318b965
    https://github.com/scummvm/scummvm/commit/9c7344ac30691dd57230d7d83fdf74de3318b965
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:07+02:00

Commit Message:
HDB: Add SlugAttack related functions

Changed paths:
    engines/hdb/ai-player.cpp


diff --git a/engines/hdb/ai-player.cpp b/engines/hdb/ai-player.cpp
index 2588b1b..a4547f5 100644
--- a/engines/hdb/ai-player.cpp
+++ b/engines/hdb/ai-player.cpp
@@ -833,19 +833,148 @@ void aiScientistInit2(AIEntity *e) {
 }
 
 void aiSlugAttackAction(AIEntity *e) {
-	warning("STUB: AI: aiSlugAttackAction required");
+	int xv[5] = {9, 0, 0, -1, 1}, yv[5] = {9, -1, 1, 0, 0};
+	AIEntity *hit;
+	int	result;
+
+	if (e->goalX)
+		g_hdb->_ai->animateEntity(e);
+
+	g_hdb->_ai->checkActionList(e, e->tileX, e->tileY, false);
+	g_hdb->_ai->checkAutoList(e, e->tileX, e->tileY);
+
+	hit = g_hdb->_ai->findEntityIgnore(e->tileX, e->tileY, e);
+	if (hit && hit->type == AI_GUY)
+		hit = NULL;
+
+	// don't hit anything you can walk through...
+	if (hit && true == g_hdb->_ai->getTableEnt(hit->type))
+		hit = NULL;
+
+	// don't hit floating stuff
+	if (hit && hit->state == STATE_FLOATING)
+		hit = NULL;
+
+	uint32 bg_flags = g_hdb->_map->getMapBGTileFlags(e->tileX, e->tileY);
+	uint32 fg_flags = g_hdb->_map->getMapFGTileFlags(e->tileX, e->tileY);
+	result = (e->level == 1 ? (bg_flags & (kFlagSolid)) : !(fg_flags & kFlagGrating) && (bg_flags & (kFlagSolid)));
+	if (hit) {
+		warning("STUB: Play SND_SLUG_HIT");
+		warning("STUB: Play MetalOrFleshSnd");
+		switch (hit->type) {
+		case AI_MEERKAT:
+			if (hit->sequence > 2) {		// out of the ground?
+				g_hdb->_ai->addAnimateTarget(hit->x, hit->y, 0, 3, ANIM_NORMAL, false, false, GROUP_STEAM_PUFF_SIT);
+				g_hdb->_ai->stunEnemy(hit, 8);
+			} else {
+				g_hdb->_ai->setEntityGoal(e, e->tileX + xv[e->dir], e->tileY + yv[e->dir]);
+				e->state = STATE_MOVEDOWN;		// so it will draw & animate
+				g_hdb->_ai->animateEntity(e);
+				return;
+			}
+			break;
+		case AI_ICEPUFF:
+			if (hit->state == STATE_ICEP_APPEAR ||
+				hit->state == STATE_ICEP_THROWDOWN ||
+				hit->state == STATE_ICEP_THROWLEFT ||
+				hit->state == STATE_ICEP_THROWRIGHT) {
+				g_hdb->_ai->addAnimateTarget(hit->x, hit->y, 0, 3, ANIM_NORMAL, false, false, GROUP_STEAM_PUFF_SIT);
+				g_hdb->_ai->stunEnemy(hit, 8);
+			} else {
+				g_hdb->_ai->setEntityGoal(e, e->tileX + xv[e->dir], e->tileY + yv[e->dir]);
+				e->state = STATE_MOVEDOWN;		// so it will draw & animate
+				g_hdb->_ai->animateEntity(e);
+				return;
+			}
+			break;
+		case AI_OMNIBOT:
+		case AI_TURNBOT:
+		case AI_SHOCKBOT:
+		case AI_RIGHTBOT:
+		case AI_PUSHBOT:
+		case AI_LISTENBOT:
+		case AI_MAINTBOT:
+		case AI_FATFROG:
+		case AI_BADFAIRY:
+		case AI_BUZZFLY:
+			g_hdb->_ai->addAnimateTarget(e->x, e->y, 0, 3, ANIM_NORMAL, false, false, GROUP_STEAM_PUFF_SIT);
+			g_hdb->_ai->stunEnemy(hit, 8);
+			break;
+
+		case AI_CHICKEN:
+			g_hdb->_ai->addAnimateTarget(hit->x, hit->y, 0, 3, ANIM_NORMAL, false, false, GROUP_STEAM_PUFF_SIT);
+			g_hdb->_ai->removeEntity(hit);
+			break;
+		case AI_BOOMBARREL:
+			warning("STUB: Play SND_CLUB_HIT_METAL");
+			aiBarrelExplode(hit);
+			aiBarrelBlowup(hit, hit->tileX, hit->tileY);
+			break;
+			// ACTION MODE entities go away - except the FOURFIRER
+		case AI_GATEPUDDLE:
+			g_hdb->_ai->addAnimateTarget(e->x, e->y, 0, 7, ANIM_NORMAL, false, false, TELEPORT_FLASH);
+			g_hdb->_ai->removeEntity(hit);
+			warning("STUB: Play SND_TELEPORT");
+			break;
+		case AI_DEADEYE:
+			g_hdb->_ai->addAnimateTarget(e->tileX * kTileWidth,
+				e->tileY * kTileHeight, 0, 3, ANIM_NORMAL, false, false, GROUP_EXPLOSION_BOOM_SIT);
+			g_hdb->_ai->removeEntity(hit);
+			warning("STUB: Play SND_BARREL_EXPLODE");
+			break;
+
+		case AI_NONE:
+			if (hit->value1 == (int)AI_DRAGON) {
+				// pull dragon's coords out of "lua_func_use" string.
+				char num1[4], num2[4];
+				memset(num1, 0, 4);
+				memset(num2, 0, 4);
+				memcpy(num1, hit->luaFuncUse, 3);
+				memcpy(num2, hit->luaFuncUse + 3, 3);
+
+				warning("STUB: Play SND_CLUB_HIT_FLESH");
+				AIEntity *found = g_hdb->_ai->findEntity(atoi(num1), atoi(num2));
+				if (found)
+					aiDragonWake(found);
+				g_hdb->_ai->addAnimateTarget(e->x, e->y, 0, 3, ANIM_NORMAL, false, false, GEM_FLASH);
+			}
+			break;
+		case AI_DRAGON:
+			aiDragonWake(hit);
+			break;
+		default:
+			break;
+		}
+		g_hdb->_ai->removeEntity(e);	// bye bye!
+		return;
+	} else if (result) {		// hit a wall
+		warning("STUB: Play SND_SLUG_HIT");
+		g_hdb->_ai->addAnimateTarget(e->x, e->y, 0, 3, ANIM_NORMAL, false, false, GROUP_STEAM_PUFF_SIT);
+		g_hdb->_ai->removeEntity(e);
+	} else {
+		g_hdb->_ai->setEntityGoal(e, e->tileX + xv[e->dir], e->tileY + yv[e->dir]);
+		e->state = STATE_MOVEDOWN;		// so it will draw & animate
+		g_hdb->_ai->animateEntity(e);
+	}
 }
 
 void aiSlugAttackDraw(AIEntity *e, int mx, int my) {
-	warning("STUB: AI: aiSlugAttackDraw required");
+	g_hdb->_ai->_slugAttackGfx[e->animFrame]->drawMasked(e->x - mx + 8, e->y - my + 8);
 }
 
 void aiSlugAttackInit(AIEntity *e) {
-	warning("STUB: AI: aiSlugAttackInit required");
+	int xv[5] = {9, 0, 0, -1, 1}, yv[5] = {9, -1, 1, 0, 0};
+	e->moveSpeed = kPlayerMoveSpeed << 1;
+	g_hdb->_ai->setEntityGoal(e, e->tileX + xv[e->dir], e->tileY + yv[e->dir]);
+	e->draw = NULL;					// use custom draw function
+	e->aiDraw = aiSlugAttackDraw;
+	e->state = STATE_MOVEDOWN;		// so it will draw & animate
+	e->aiAction = aiSlugAttackAction;
+	warning("STUB: Play SND_SLUG_FIRE");
 }
 
 void aiSlugAttackInit2(AIEntity *e) {
-	warning("STUB: AI: aiSlugAttackInit2 required");
+	e->movedownFrames = 4;
 }
 
 void aiDeadWorkerInit(AIEntity *e) {


Commit: 44de6935533a4b0cfaa3db9a685f27a765359c0d
    https://github.com/scummvm/scummvm/commit/44de6935533a4b0cfaa3db9a685f27a765359c0d
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:07+02:00

Commit Message:
HDB: Add FrogStatue related functions

Changed paths:
    engines/hdb/ai-player.cpp


diff --git a/engines/hdb/ai-player.cpp b/engines/hdb/ai-player.cpp
index a4547f5..c55c392 100644
--- a/engines/hdb/ai-player.cpp
+++ b/engines/hdb/ai-player.cpp
@@ -1002,15 +1002,33 @@ void aiAccountantInit2(AIEntity *e) {
 }
 
 void aiFrogStatueInit(AIEntity *e) {
-	warning("STUB: AI: aiFrogStatueInit required");
+	e->moveSpeed = kPushMoveSpeed;
+	e->aiAction = aiFrogStatueAction;
 }
 
 void aiFrogStatueInit2(AIEntity *e) {
-	warning("STUB: AI: aiFrogStatueInit2 required");
+	// point all frog statue MOVE frames to the standing one
+	e->blinkFrames =
+		e->movedownFrames =
+		e->moveleftFrames =
+		e->moverightFrames =
+		e->moveupFrames = 1;
+
+	e->blinkGfx[0] =
+		e->movedownGfx[0] =
+		e->moveupGfx[0] =
+		e->moveleftGfx[0] =
+		e->moverightGfx[0] = e->standdownGfx[0];
+
+	e->draw = e->standdownGfx[0];			// standing frame - doesn't move
 }
 
 void aiFrogStatueAction(AIEntity *e) {
-	warning("STUB: AI: aiFrogStatueAction required");
+	// if frog statue isn't moving somewhere, don't move it
+	if (!e->goalX)
+		return;
+
+	g_hdb->_ai->animateEntity(e);
 }
 
 void aiRoboStunnerAction(AIEntity *e) {


Commit: 80c2d35ba6c1340bd1ceada4b400ad956564b499
    https://github.com/scummvm/scummvm/commit/80c2d35ba6c1340bd1ceada4b400ad956564b499
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:07+02:00

Commit Message:
HDB: Add envelope related functions

Changed paths:
    engines/hdb/ai-player.cpp


diff --git a/engines/hdb/ai-player.cpp b/engines/hdb/ai-player.cpp
index c55c392..2760af6 100644
--- a/engines/hdb/ai-player.cpp
+++ b/engines/hdb/ai-player.cpp
@@ -1232,11 +1232,12 @@ void aiDragonUse(AIEntity *e) {
 }
 
 void aiEnvelopeGreenInit(AIEntity *e) {
-	warning("STUB: AI: aiEnvelopeGreenInit required");
+	strcpy(e->printedName, "Green envelope");
+	e->aiAction = aiGetItemAction;
 }
 
 void aiEnvelopeGreenInit2(AIEntity *e) {
-	warning("STUB: AI: aiEnvelopeGreenInit2 required");
+	e->draw = e->standdownGfx[0];
 }
 
 void aiGemBlueInit(AIEntity *e) {
@@ -1496,27 +1497,30 @@ void aiCellInit(AIEntity *e) {
 }
 
 void aiEnvelopeWhiteInit(AIEntity *e) {
-	warning("STUB: AI: aiEnvelopeWhiteInit required");
+	strcpy(e->printedName, "White envelope");
+	e->aiAction = aiGetItemAction;
 }
 
 void aiEnvelopeWhiteInit2(AIEntity *e) {
-	warning("STUB: AI: aiEnvelopeWhiteInit2 required");
+	e->draw = e->standdownGfx[0];
 }
 
 void aiEnvelopeBlueInit(AIEntity *e) {
-	warning("STUB: AI: aiEnvelopeBlueInit required");
+	strcpy(e->printedName, "Blue envelope");
+	e->aiAction = aiGetItemAction;
 }
 
 void aiEnvelopeBlueInit2(AIEntity *e) {
-	warning("STUB: AI: aiEnvelopeBlueInit2 required");
+	e->draw = e->standdownGfx[0];
 }
 
 void aiEnvelopeRedInit(AIEntity *e) {
-	warning("STUB: AI: aiEnvelopeRedInit required");
+	strcpy(e->printedName, "Red envelope");
+	e->aiAction = aiGetItemAction;
 }
 
 void aiEnvelopeRedInit2(AIEntity *e) {
-	warning("STUB: AI: aiEnvelopeRedInit2 required");
+	e->draw = e->standdownGfx[0];
 }
 
 void aiTransceiverInit(AIEntity *e) {


Commit: cb0f3bc776473619177053f8ecb7e19a0ca9a0ee
    https://github.com/scummvm/scummvm/commit/cb0f3bc776473619177053f8ecb7e19a0ca9a0ee
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:07+02:00

Commit Message:
HDB: Add Book related functions

Changed paths:
    engines/hdb/ai-player.cpp


diff --git a/engines/hdb/ai-player.cpp b/engines/hdb/ai-player.cpp
index 2760af6..2e3e78e 100644
--- a/engines/hdb/ai-player.cpp
+++ b/engines/hdb/ai-player.cpp
@@ -1289,11 +1289,12 @@ void aiBurgerInit2(AIEntity *e) {
 }
 
 void aiBookInit(AIEntity *e) {
-	warning("STUB: AI: aiBookInit required");
+	strcpy(e->printedName, "a Book");
+	e->aiAction = aiGetItemAction;
 }
 
 void aiBookInit2(AIEntity *e) {
-	warning("STUB: AI: aiBookInit2 required");
+	e->draw = e->standdownGfx[0];
 }
 
 void aiClipboardInit(AIEntity *e) {


Commit: d945f28c6abd5013a0b7ac981a3abdd86104f384
    https://github.com/scummvm/scummvm/commit/d945f28c6abd5013a0b7ac981a3abdd86104f384
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:07+02:00

Commit Message:
HDB: Add Clipboard related functions

Changed paths:
    engines/hdb/ai-player.cpp


diff --git a/engines/hdb/ai-player.cpp b/engines/hdb/ai-player.cpp
index 2e3e78e..e169524 100644
--- a/engines/hdb/ai-player.cpp
+++ b/engines/hdb/ai-player.cpp
@@ -1298,11 +1298,12 @@ void aiBookInit2(AIEntity *e) {
 }
 
 void aiClipboardInit(AIEntity *e) {
-	warning("STUB: AI: aiClipboardInit required");
+	strcpy(e->printedName, "a Clipboard");
+	e->aiAction = aiGetItemAction;
 }
 
 void aiClipboardInit2(AIEntity *e) {
-	warning("STUB: AI: aiClipboardInit2 required");
+	e->draw = e->standdownGfx[0];
 }
 
 void aiNoteInit(AIEntity *e) {


Commit: 240ab4e36fa86196e2d429c833ac929a6f71b356
    https://github.com/scummvm/scummvm/commit/240ab4e36fa86196e2d429c833ac929a6f71b356
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:07+02:00

Commit Message:
HDB: Add Note related functions

Changed paths:
    engines/hdb/ai-player.cpp


diff --git a/engines/hdb/ai-player.cpp b/engines/hdb/ai-player.cpp
index e169524..5a0b98d 100644
--- a/engines/hdb/ai-player.cpp
+++ b/engines/hdb/ai-player.cpp
@@ -1307,11 +1307,12 @@ void aiClipboardInit2(AIEntity *e) {
 }
 
 void aiNoteInit(AIEntity *e) {
-	warning("STUB: AI: aiNoteInit required");
+	strcpy(e->printedName, "a Note");
+	e->aiAction = aiGetItemAction;
 }
 
 void aiNoteInit2(AIEntity *e) {
-	warning("STUB: AI: aiNoteInit2 required");
+	e->draw = e->standdownGfx[0];
 }
 
 void aiKeycardWhiteInit(AIEntity *e) {


Commit: 7fdef04af98d813e172edf60df160c0628b6931b
    https://github.com/scummvm/scummvm/commit/7fdef04af98d813e172edf60df160c0628b6931b
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:07+02:00

Commit Message:
HDB: Add PDA related functions

Changed paths:
    engines/hdb/ai-player.cpp


diff --git a/engines/hdb/ai-player.cpp b/engines/hdb/ai-player.cpp
index 5a0b98d..64c95d5 100644
--- a/engines/hdb/ai-player.cpp
+++ b/engines/hdb/ai-player.cpp
@@ -1480,11 +1480,12 @@ void aiItemChickenInit2(AIEntity *e) {
 }
 
 void aiPdaInit(AIEntity *e) {
-	warning("STUB: AI: aiPdaInit required");
+	strcpy(e->printedName, "a P.D.A.");
+	e->aiAction = aiGetItemAction;
 }
 
 void aiPdaInit2(AIEntity *e) {
-	warning("STUB: AI: aiPdaInit2 required");
+	e->draw = e->standdownGfx[0];
 }
 
 void aiCellUse(AIEntity *e) {


Commit: dcce09471d348a37fa22f072951aaa1053c79b00
    https://github.com/scummvm/scummvm/commit/dcce09471d348a37fa22f072951aaa1053c79b00
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:07+02:00

Commit Message:
HDB: Add Cell related functions

Changed paths:
    engines/hdb/ai-player.cpp


diff --git a/engines/hdb/ai-player.cpp b/engines/hdb/ai-player.cpp
index 64c95d5..3912428 100644
--- a/engines/hdb/ai-player.cpp
+++ b/engines/hdb/ai-player.cpp
@@ -1493,11 +1493,12 @@ void aiCellUse(AIEntity *e) {
 }
 
 void aiCellInit2(AIEntity *e) {
-	warning("STUB: AI: aiCellInit2 required");
+	e->draw = e->standdownGfx[0];
 }
 
 void aiCellInit(AIEntity *e) {
-	warning("STUB: AI: aiCellInit required");
+	strcpy(e->printedName, "Energy Cell");
+	e->aiAction = aiGetItemAction;
 }
 
 void aiEnvelopeWhiteInit(AIEntity *e) {


Commit: 6247f1ebec805205758d03d6107ae0ee3c4bce50
    https://github.com/scummvm/scummvm/commit/6247f1ebec805205758d03d6107ae0ee3c4bce50
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:08+02:00

Commit Message:
HDB: Implement Window::closeAll()

Now the player is not locked when pressing ESC with dialog on screen

Changed paths:
    engines/hdb/ai-cinematic.cpp
    engines/hdb/window.cpp
    engines/hdb/window.h


diff --git a/engines/hdb/ai-cinematic.cpp b/engines/hdb/ai-cinematic.cpp
index bda993d..58287a8 100644
--- a/engines/hdb/ai-cinematic.cpp
+++ b/engines/hdb/ai-cinematic.cpp
@@ -404,7 +404,9 @@ void AI::cineAbort() {
 		if (_cine[i]->cmdType == C_STARTMAP || _cine[i]->cmdType == C_STOPCINE)
 			_cine[0] = _cine[i];
 	}
-	warning("STUB: Window: closeAll() required");
+
+	g_hdb->_window->closeAll();
+
 	if (_player)
 		stopEntity(_player);
 	_cineAborted = true;
diff --git a/engines/hdb/window.cpp b/engines/hdb/window.cpp
index 0b26a21..5d5b7d3 100644
--- a/engines/hdb/window.cpp
+++ b/engines/hdb/window.cpp
@@ -116,6 +116,13 @@ void Window::checkPause(uint x, uint y) {
 	}
 }
 
+void Window::closeAll() {
+	closeDialog();
+	closeDialogChoice();
+	closeMsg();
+	closeTextOut();
+}
+
 void Window::openDialog(const char *title, int tileIndex, const char *string, int more, const char *luaMore) {
 	if (_dialogInfo.active)
 		return;
diff --git a/engines/hdb/window.h b/engines/hdb/window.h
index e03e26f..b74f5ee 100644
--- a/engines/hdb/window.h
+++ b/engines/hdb/window.h
@@ -135,6 +135,8 @@ public:
 	void restartSystem();
 	void setInfobarDark(int value);
 
+	void closeAll();
+
 	// Pause Functions
 	void drawPause();
 	void checkPause(uint x, uint y);


Commit: 6ffe0217097b07198952c7751b00f72aa83453d4
    https://github.com/scummvm/scummvm/commit/6ffe0217097b07198952c7751b00f72aa83453d4
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:08+02:00

Commit Message:
HDB: Reset _dialogInfo before each dialog.

This makes possible to close the choice dialog.

Changed paths:
    engines/hdb/window.cpp


diff --git a/engines/hdb/window.cpp b/engines/hdb/window.cpp
index 5d5b7d3..a0902cf 100644
--- a/engines/hdb/window.cpp
+++ b/engines/hdb/window.cpp
@@ -127,6 +127,8 @@ void Window::openDialog(const char *title, int tileIndex, const char *string, in
 	if (_dialogInfo.active)
 		return;
 
+	memset(&_dialogInfo, 0, sizeof(_dialogInfo));
+
 	_dialogInfo.tileIndex = tileIndex;
 	strcpy(_dialogInfo.title, title);
 	_dialogInfo.active = true;


Commit: 41c1353edc7800af5bec95c082e594429b28301e
    https://github.com/scummvm/scummvm/commit/41c1353edc7800af5bec95c082e594429b28301e
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:08+02:00

Commit Message:
HDB: More portable struct initializers

Changed paths:
    engines/hdb/ai.h
    engines/hdb/gfx.h
    engines/hdb/map.h
    engines/hdb/window.h


diff --git a/engines/hdb/ai.h b/engines/hdb/ai.h
index bf6503f..f2259ba 100644
--- a/engines/hdb/ai.h
+++ b/engines/hdb/ai.h
@@ -446,7 +446,13 @@ struct AIEntity {
 	uint16		moverightFrames;
 	Tile		*moverightGfx[kMaxAnimFrames];
 
-	AIEntity() : luaFuncInit(""), luaFuncAction(""), luaFuncUse(""), entityName(""), printedName("") {
+	AIEntity() {
+		luaFuncInit[0] = 0;
+		luaFuncAction[0] = 0;
+		luaFuncUse[0] = 0;
+		entityName[0] = 0;
+		printedName[0] = 0;
+
 		type = AI_NONE;
 		state = STATE_NONE;
 		dir = DIR_NONE;
@@ -585,7 +591,12 @@ struct DlvEnt {
 
 	char id[32];
 
-	DlvEnt() : itemTextName(""), itemGfxName(""), itemGfx(NULL), destTextName(""), destGfxName(""), destGfx(NULL) {}
+	DlvEnt() : itemGfx(NULL), destGfx(NULL) {
+		itemTextName[0] = 0;
+		itemGfxName[0] = 0;
+		destTextName[0] = 0;
+		destGfxName[0] = 0;
+	}
 };
 
 struct Waypoint {
@@ -601,7 +612,11 @@ struct LuaT {
 	char luaFuncAction[32];
 	char luaFuncUse[32];
 
-	LuaT() : x(0), y(0), value1(0), value2(0), luaFuncInit(""), luaFuncAction(""), luaFuncUse("") {}
+	LuaT() : x(0), y(0), value1(0), value2(0) {
+		luaFuncInit[0] = 0;
+		luaFuncAction[0] = 0;
+		luaFuncUse[0] = 0;
+	}
 };
 
 struct ActionInfo {
@@ -611,7 +626,11 @@ struct ActionInfo {
 	char luaFuncUse[32];
 	char entityName[32];
 
-	ActionInfo() : x1(0), y1(0), x2(0), y2(0), luaFuncInit(""), luaFuncUse(""), entityName("") {}
+	ActionInfo() : x1(0), y1(0), x2(0), y2(0) {
+		luaFuncInit[0] = 0;
+		luaFuncUse[0] = 0;
+		entityName[0] = 0;
+	}
 };
 
 struct TeleInfo {
@@ -625,7 +644,10 @@ struct TeleInfo {
 	char luaFuncUse1[32];
 	char luaFuncUse2[32];
 
-	TeleInfo() : x1(0), y1(0), x2(0), y2(0), dir1(DIR_NONE), dir2(DIR_NONE), level1(0), level2(0), usable1(0), usable2(0), anim1(0), anim2(0), luaFuncUse1(""), luaFuncUse2("") {}
+	TeleInfo() : x1(0), y1(0), x2(0), y2(0), dir1(DIR_NONE), dir2(DIR_NONE), level1(0), level2(0), usable1(0), usable2(0), anim1(0), anim2(0) {
+		luaFuncUse1[0] = 0;
+		luaFuncUse2[0] = 0;
+	}
 };
 
 struct SingleTele {
@@ -642,7 +664,11 @@ struct AutoAction {
 	char luaFuncUse[32];
 	char entityName[32];
 
-	AutoAction() : x(0), y(0), activated(false), luaFuncInit(""), luaFuncUse(""), entityName("") {}
+	AutoAction() : x(0), y(0), activated(false) {
+		luaFuncInit[0] = 0;
+		luaFuncUse[0] = 0;
+		entityName[0] = 0;
+	}
 };
 
 struct ArrowPath {
@@ -665,7 +691,11 @@ struct Trigger {
 	char luaFuncInit[32];
 	char luaFuncUse[32];
 
-	Trigger() : id(""), x(0), y(0), value1(0), value2(0), luaFuncInit(""), luaFuncUse("") {}
+	Trigger() : x(0), y(0), value1(0), value2(0) {
+		id[0] = 0;
+		luaFuncInit[0] = 0;
+		luaFuncUse[0] = 0;
+	}
 };
 
 struct CallbackDef {
@@ -706,7 +736,7 @@ struct CineBlit {
 	const char *id;
 	bool masked;
 
-	CineBlit() : x(0), y(0), pic(NULL), name(""), id(""), masked(false) {}
+	CineBlit() : x(0), y(0), pic(NULL), name(NULL), id(NULL), masked(false) {}
 };
 
 #define onEvenTile(x, y)		( !(x & 31) && !(y & 31) )
diff --git a/engines/hdb/gfx.h b/engines/hdb/gfx.h
index 964af02..d369edc 100644
--- a/engines/hdb/gfx.h
+++ b/engines/hdb/gfx.h
@@ -66,7 +66,7 @@ struct GfxCache {
 	uint32 size;
 	int16 loaded;
 
-	GfxCache() : name(""), tileGfx(NULL), size(0), loaded(0) {}
+	GfxCache() : tileGfx(NULL), size(0), loaded(0) { name[0] = 0; }
 };
 
 struct FontInfo {
diff --git a/engines/hdb/map.h b/engines/hdb/map.h
index 151bef9..fcbd82e 100644
--- a/engines/hdb/map.h
+++ b/engines/hdb/map.h
@@ -46,7 +46,11 @@ struct MSMIcon {
 	uint16	level;					// which floor level entity is on
 	uint16	value1, value2;
 
-	MSMIcon(): icon(0), x(0), y(0), funcInit(""), funcAction(""), funcUse(""), dir(0), level(0), value1(0), value2(0) {}
+	MSMIcon(): icon(0), x(0), y(0), dir(0), level(0), value1(0), value2(0) {
+		funcInit[0] = 0;
+		funcAction[0] = 0;
+		funcUse[0] = 0;
+	}
 };
 
 struct Foreground {
diff --git a/engines/hdb/window.h b/engines/hdb/window.h
index b74f5ee..f2175d4 100644
--- a/engines/hdb/window.h
+++ b/engines/hdb/window.h
@@ -59,9 +59,13 @@ struct DialogInfo {
 	int			el, er, et, eb;			// saves the text edges
 	char		luaMore[64];			// the name of the function to call after clicking the MORE button
 
-	DialogInfo() : title(""), tileIndex(0), string(""), active(false), x(0), y(0),
+	DialogInfo() : tileIndex(0), active(false), x(0), y(0),
 		width(0), height(0), titleWidth(0), gfx(NULL), more(0), el(0), er(0), et(0),
-		eb(0), luaMore("") {}
+		eb(0) {
+			title[0] = 0;
+			string[0] = 0;
+			luaMore[0] = 0;
+		}
 };
 
 struct DialogChoiceInfo {
@@ -81,11 +85,14 @@ struct DialogChoiceInfo {
 	int			numChoices;			// how many choices possible
 	char		choices[10][64];		// ptrs to choice text
 
-	DialogChoiceInfo() : title(""), text(""), func(""), active(false), x(0), y(0),
+	DialogChoiceInfo() : active(false), x(0), y(0),
 		width(0), height(0), textHeight(0), titleWidth(0), el(0), er(0), et(0),
 		eb(0), timeout(0), selection(0), numChoices(0) {
+		title[0] = 0;
+		text[0] = 0;
+		func[0] = 0;
 		for (int i = 0; i < 10; i++)
-			strcpy(choices[i], "");
+			choices[i][0] = 0;
 	}
 };
 
@@ -96,7 +103,9 @@ struct MessageInfo {
 	int			x, y;
 	int			width, height;
 
-	MessageInfo() : active(false), title(""), timer(0), x(0), y(0), width(0), height(0) {}
+	MessageInfo() : active(false), timer(0), x(0), y(0), width(0), height(0) {
+		title[0] = 0;
+	}
 };
 
 struct InvWinInfo {
@@ -125,7 +134,9 @@ struct TOut {
 	int x, y;
 	uint32 timer;
 
-	TOut() : text(""), x(0), y(0), timer(0) {}
+	TOut() : x(0), y(0), timer(0) {
+		text[0] = 0;
+	}
 };
 
 class Window {


Commit: 662f874c5476ecd5b2cd4df55778acb0c32e9350
    https://github.com/scummvm/scummvm/commit/662f874c5476ecd5b2cd4df55778acb0c32e9350
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:08+02:00

Commit Message:
HDB: Fix tile animations

Changed paths:
    engines/hdb/gfx.cpp


diff --git a/engines/hdb/gfx.cpp b/engines/hdb/gfx.cpp
index c347d64..3dfe644 100644
--- a/engines/hdb/gfx.cpp
+++ b/engines/hdb/gfx.cpp
@@ -88,6 +88,7 @@ bool Gfx::init() {
 		// ELSE IF we're in an anim group and have just reached the end
 		if (!strncmp(_tLookupArray[index].filename, search, strlen(search)) && found == -1) {
 			found = index;
+			memset(search, 0, sizeof(search));
 			strncpy(search, _tLookupArray[index].filename, strlen(_tLookupArray[index].filename) - 2);
 		} else if (!strncmp(_tLookupArray[index].filename, search, strlen(search)) && found >= 0)
 			_tLookupArray[index - 1].animIndex = index;


Commit: 480b665e875fd391e8bec68ff73a0429f2f43fe4
    https://github.com/scummvm/scummvm/commit/480b665e875fd391e8bec68ff73a0429f2f43fe4
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:08+02:00

Commit Message:
HDB: Use constant as framerate

Changed paths:
    engines/hdb/hdb.cpp


diff --git a/engines/hdb/hdb.cpp b/engines/hdb/hdb.cpp
index 63b12c0..7cff30e 100644
--- a/engines/hdb/hdb.cpp
+++ b/engines/hdb/hdb.cpp
@@ -528,7 +528,7 @@ Common::Error HDBGame::run() {
 		paint();
 
 		g_system->updateScreen();
-		g_system->delayMillis(1000/60);
+		g_system->delayMillis(1000 / kGameFPS);
 	}
 
 	return Common::kNoError;


Commit: d5e932496930ad8f85b163baba3302b61d86d1d1
    https://github.com/scummvm/scummvm/commit/d5e932496930ad8f85b163baba3302b61d86d1d1
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:08+02:00

Commit Message:
HDB: Initialise variable

Changed paths:
    engines/hdb/map.cpp


diff --git a/engines/hdb/map.cpp b/engines/hdb/map.cpp
index e829b3d..ee0c67b 100644
--- a/engines/hdb/map.cpp
+++ b/engines/hdb/map.cpp
@@ -27,6 +27,8 @@ namespace HDB {
 Map::Map() {
 	_mapLoaded = false;
 
+	_animCycle = 0;
+
 	for (int i = 0; i < kMaxGratings; i++) {
 		_gratings[i] = new Foreground;
 	}


Commit: 2e171ad5fe0f34ec788b9a057819b10583e46bf8
    https://github.com/scummvm/scummvm/commit/2e171ad5fe0f34ec788b9a057819b10583e46bf8
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:08+02:00

Commit Message:
HDB: Fix tile animation speed

Changed paths:
    engines/hdb/map.cpp


diff --git a/engines/hdb/map.cpp b/engines/hdb/map.cpp
index ee0c67b..ccad3b4 100644
--- a/engines/hdb/map.cpp
+++ b/engines/hdb/map.cpp
@@ -700,7 +700,7 @@ void Map::draw() {
 	}
 
 	// Animate MEDIUM Map Tiles
-	if (!(_animCycle % kAnimFastFrames)) {
+	if (!(_animCycle % kAnimMediumFrames)) {
 		for (Common::Array<uint32>::iterator it = _listBGAnimMedium.begin(); it != _listBGAnimMedium.end(); it++) {
 			_background[(*it)] = g_hdb->_gfx->animateTile(_background[(*it)]);
 		}
@@ -711,7 +711,7 @@ void Map::draw() {
 	}
 
 	// Animate SLOW Map Tiles
-	if (!(_animCycle % kAnimFastFrames)) {
+	if (!(_animCycle % kAnimSlowFrames)) {
 		for (Common::Array<uint32>::iterator it = _listBGAnimSlow.begin(); it != _listBGAnimSlow.end(); it++) {
 			_background[(*it)] = g_hdb->_gfx->animateTile(_background[(*it)]);
 		}
@@ -802,11 +802,11 @@ void Map::addBGTileAnimation(int x, int y) {
 	uint32 flags = tile->_flags;
 
 	// BACKGROUND
-	if (flags & kFlagAnimFast) {
+	if ((flags & kFlagAnimFast) == kFlagAnimFast) {	// check 'fast' first since it's a combo of slow & medium
 		_listBGAnimFast.push_back(i);
-	} else if (flags & kFlagAnimSlow) {
+	} else if ((flags & kFlagAnimSlow) == kFlagAnimSlow) {
 		_listBGAnimSlow.push_back(i);
-	} else if (flags & kFlagAnimMedium) {
+	} else if ((flags & kFlagAnimMedium) == kFlagAnimMedium) {
 		_listBGAnimMedium.push_back(i);
 	}
 }


Commit: 7d08524b77a1bebf2ad5e472442525a57c29b70c
    https://github.com/scummvm/scummvm/commit/7d08524b77a1bebf2ad5e472442525a57c29b70c
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:08+02:00

Commit Message:
HDB: Shift Bots stubs to ai-bots.cpp

Changed paths:
    engines/hdb/ai-bots.cpp
    engines/hdb/ai-player.cpp


diff --git a/engines/hdb/ai-bots.cpp b/engines/hdb/ai-bots.cpp
index 2d451b6..056cc4a 100644
--- a/engines/hdb/ai-bots.cpp
+++ b/engines/hdb/ai-bots.cpp
@@ -1215,4 +1215,176 @@ void aiDeadEyeAction(AIEntity *e) {
 		e->sequence = 64;
 }
 
+void aiLaserAction(AIEntity *e) {
+	warning("STUB: AI: aiLaserAction required");
+}
+
+void aiLaserDraw(AIEntity *e, int mx, int my) {
+	warning("STUB: AI: aiLaserDraw required");
+}
+
+void aiDiverterAction(AIEntity *e) {
+	warning("STUB: AI: aiDiverterAction required");
+}
+
+void aiDiverterDraw(AIEntity *e, int mx, int my) {
+	warning("STUB: AI: aiDiverterDraw required");
+}
+
+void aiMeerkatDraw(AIEntity *e, int mx, int my) {
+	warning("STUB: AI: aiMeerkatDraw required");
+}
+
+void aiMeerkatAction(AIEntity *e) {
+	warning("STUB: AI: aiMeerkatAction required");
+}
+
+void aiMeerkatLookAround(AIEntity *e) {
+	warning("STUB: AI: aiMeerkatLookAround required");
+}
+
+void aiFatFrogAction(AIEntity *e) {
+	warning("STUB: AI: aiFatFrogAction required");
+}
+
+void aiFatFrogTongueDraw(AIEntity *e, int mx, int my) {
+	warning("STUB: AI: aiFatFrogTongueDraw required");
+}
+
+void aiGoodFairyAction(AIEntity *e) {
+	warning("STUB: AI: aiGoodFairyAction required");
+}
+
+void aiBadFairyAction(AIEntity *e) {
+	warning("STUB: AI: aiBadFairyAction required");
+}
+
+void aiGatePuddleAction(AIEntity *e) {
+	warning("STUB: AI: aiGatePuddleAction required");
+}
+
+void aiIcePuffSnowballAction(AIEntity *e) {
+	warning("STUB: AI: aiIcePuffSnowballAction required");
+}
+
+void aiIcePuffSnowballDraw(AIEntity *e, int mx, int my) {
+	warning("STUB: AI: aiIcePuffSnowballDraw required");
+}
+
+void aiIcePuffAction(AIEntity *e) {
+	warning("STUB: AI: aiIcePuffAction required");
+}
+
+void aiBuzzflyAction(AIEntity *e) {
+	warning("STUB: AI: aiBuzzflyAction required");
+}
+
+void aiDragonAction(AIEntity *e) {
+	warning("STUB: AI: aiDragonAction required");
+}
+
+void aiDragonDraw(AIEntity *e, int mx, int my) {
+	warning("STUB: AI: aiDragonDraw required");
+}
+
+void aiListenBotInit(AIEntity *e) {
+	warning("STUB: AI: aiListenBotInit required");
+}
+
+void aiListenBotInit2(AIEntity *e) {
+	warning("STUB: AI: aiListenBotInit2 required");
+}
+
+void aiLaserInit(AIEntity *e) {
+	warning("STUB: AI: aiLaserInit required");
+}
+
+void aiLaserInit2(AIEntity *e) {
+	warning("STUB: AI: aiLaserInit2 required");
+}
+
+void aiDiverterInit(AIEntity *e) {
+	warning("STUB: AI: aiDiverterInit required");
+}
+
+void aiDiverterInit2(AIEntity *e) {
+	warning("STUB: AI: aiDiverterInit2 required");
+}
+
+void aiMeerkatInit(AIEntity *e) {
+	warning("STUB: AI: aiMeerkatInit required");
+}
+
+void aiMeerkatInit2(AIEntity *e) {
+	warning("STUB: AI: aiMeerkatInit2 required");
+}
+
+void aiFatFrogInit(AIEntity *e) {
+	warning("STUB: AI: aiFatFrogInit required");
+}
+
+void aiFatFrogInit2(AIEntity *e) {
+	warning("STUB: AI: aiFatFrogInit2 required");
+}
+
+void aiGoodFairyInit(AIEntity *e) {
+	warning("STUB: AI: aiGoodFairyInit required");
+}
+
+void aiGoodFairyInit2(AIEntity *e) {
+	warning("STUB: AI: aiGoodFairyInit2 required");
+}
+
+void aiGoodFairyMoveaway(AIEntity *e) {
+	warning("STUB: AI: aiGoodFairyMoveaway required");
+}
+
+void aiBadFairyInit(AIEntity *e) {
+	warning("STUB: AI: aiBadFairyInit required");
+}
+
+void aiBadFairyInit2(AIEntity *e) {
+	warning("STUB: AI: aiBadFairyInit2 required");
+}
+
+void aiGatePuddleInit(AIEntity *e) {
+	warning("STUB: AI: aiGatePuddleInit required");
+}
+
+void aiGatePuddleInit2(AIEntity *e) {
+	warning("STUB: AI: aiGatePuddleInit2 required");
+}
+
+void aiIcePuffInit(AIEntity *e) {
+	warning("STUB: AI: aiIcePuffInit required");
+}
+
+void aiIcePuffInit2(AIEntity *e) {
+	warning("STUB: AI: aiIcePuffInit2 required");
+}
+
+void aiBuzzflyInit(AIEntity *e) {
+	warning("STUB: AI: aiBuzzflyInit required");
+}
+
+void aiBuzzflyInit2(AIEntity *e) {
+	warning("STUB: AI: aiBuzzflyInit2 required");
+}
+
+void aiDragonInit(AIEntity *e) {
+	warning("STUB: AI: aiDragonInit required");
+}
+
+void aiDragonInit2(AIEntity *e) {
+	warning("STUB: AI: aiDragonInit2 required");
+}
+
+void aiDragonWake(AIEntity *e) {
+	warning("STUB: AI: aiDragonWake required");
+}
+
+void aiDragonUse(AIEntity *e) {
+	warning("STUB: AI: aiDragonUse required");
+}
+
 } // End of Namespace
diff --git a/engines/hdb/ai-player.cpp b/engines/hdb/ai-player.cpp
index 3912428..6a32df5 100644
--- a/engines/hdb/ai-player.cpp
+++ b/engines/hdb/ai-player.cpp
@@ -1059,178 +1059,6 @@ void aiSlugSlingerInit2(AIEntity *e) {
 	warning("STUB: AI: aiSlugSlingerInit2 required");
 }
 
-void aiLaserAction(AIEntity *e) {
-	warning("STUB: AI: aiLaserAction required");
-}
-
-void aiLaserDraw(AIEntity *e, int mx, int my) {
-	warning("STUB: AI: aiLaserDraw required");
-}
-
-void aiDiverterAction(AIEntity *e) {
-	warning("STUB: AI: aiDiverterAction required");
-}
-
-void aiDiverterDraw(AIEntity *e, int mx, int my) {
-	warning("STUB: AI: aiDiverterDraw required");
-}
-
-void aiMeerkatDraw(AIEntity *e, int mx, int my) {
-	warning("STUB: AI: aiMeerkatDraw required");
-}
-
-void aiMeerkatAction(AIEntity *e) {
-	warning("STUB: AI: aiMeerkatAction required");
-}
-
-void aiMeerkatLookAround(AIEntity *e) {
-	warning("STUB: AI: aiMeerkatLookAround required");
-}
-
-void aiFatFrogAction(AIEntity *e) {
-	warning("STUB: AI: aiFatFrogAction required");
-}
-
-void aiFatFrogTongueDraw(AIEntity *e, int mx, int my) {
-	warning("STUB: AI: aiFatFrogTongueDraw required");
-}
-
-void aiGoodFairyAction(AIEntity *e) {
-	warning("STUB: AI: aiGoodFairyAction required");
-}
-
-void aiBadFairyAction(AIEntity *e) {
-	warning("STUB: AI: aiBadFairyAction required");
-}
-
-void aiGatePuddleAction(AIEntity *e) {
-	warning("STUB: AI: aiGatePuddleAction required");
-}
-
-void aiIcePuffSnowballAction(AIEntity *e) {
-	warning("STUB: AI: aiIcePuffSnowballAction required");
-}
-
-void aiIcePuffSnowballDraw(AIEntity *e, int mx, int my) {
-	warning("STUB: AI: aiIcePuffSnowballDraw required");
-}
-
-void aiIcePuffAction(AIEntity *e) {
-	warning("STUB: AI: aiIcePuffAction required");
-}
-
-void aiBuzzflyAction(AIEntity *e) {
-	warning("STUB: AI: aiBuzzflyAction required");
-}
-
-void aiDragonAction(AIEntity *e) {
-	warning("STUB: AI: aiDragonAction required");
-}
-
-void aiDragonDraw(AIEntity *e, int mx, int my) {
-	warning("STUB: AI: aiDragonDraw required");
-}
-
-void aiListenBotInit(AIEntity *e) {
-	warning("STUB: AI: aiListenBotInit required");
-}
-
-void aiListenBotInit2(AIEntity *e) {
-	warning("STUB: AI: aiListenBotInit2 required");
-}
-
-void aiLaserInit(AIEntity *e) {
-	warning("STUB: AI: aiLaserInit required");
-}
-
-void aiLaserInit2(AIEntity *e) {
-	warning("STUB: AI: aiLaserInit2 required");
-}
-
-void aiDiverterInit(AIEntity *e) {
-	warning("STUB: AI: aiDiverterInit required");
-}
-
-void aiDiverterInit2(AIEntity *e) {
-	warning("STUB: AI: aiDiverterInit2 required");
-}
-
-void aiMeerkatInit(AIEntity *e) {
-	warning("STUB: AI: aiMeerkatInit required");
-}
-
-void aiMeerkatInit2(AIEntity *e) {
-	warning("STUB: AI: aiMeerkatInit2 required");
-}
-
-void aiFatFrogInit(AIEntity *e) {
-	warning("STUB: AI: aiFatFrogInit required");
-}
-
-void aiFatFrogInit2(AIEntity *e) {
-	warning("STUB: AI: aiFatFrogInit2 required");
-}
-
-void aiGoodFairyInit(AIEntity *e) {
-	warning("STUB: AI: aiGoodFairyInit required");
-}
-
-void aiGoodFairyInit2(AIEntity *e) {
-	warning("STUB: AI: aiGoodFairyInit2 required");
-}
-
-void aiGoodFairyMoveaway(AIEntity *e) {
-	warning("STUB: AI: aiGoodFairyMoveaway required");
-}
-
-void aiBadFairyInit(AIEntity *e) {
-	warning("STUB: AI: aiBadFairyInit required");
-}
-
-void aiBadFairyInit2(AIEntity *e) {
-	warning("STUB: AI: aiBadFairyInit2 required");
-}
-
-void aiGatePuddleInit(AIEntity *e) {
-	warning("STUB: AI: aiGatePuddleInit required");
-}
-
-void aiGatePuddleInit2(AIEntity *e) {
-	warning("STUB: AI: aiGatePuddleInit2 required");
-}
-
-void aiIcePuffInit(AIEntity *e) {
-	warning("STUB: AI: aiIcePuffInit required");
-}
-
-void aiIcePuffInit2(AIEntity *e) {
-	warning("STUB: AI: aiIcePuffInit2 required");
-}
-
-void aiBuzzflyInit(AIEntity *e) {
-	warning("STUB: AI: aiBuzzflyInit required");
-}
-
-void aiBuzzflyInit2(AIEntity *e) {
-	warning("STUB: AI: aiBuzzflyInit2 required");
-}
-
-void aiDragonInit(AIEntity *e) {
-	warning("STUB: AI: aiDragonInit required");
-}
-
-void aiDragonInit2(AIEntity *e) {
-	warning("STUB: AI: aiDragonInit2 required");
-}
-
-void aiDragonWake(AIEntity *e) {
-	warning("STUB: AI: aiDragonWake required");
-}
-
-void aiDragonUse(AIEntity *e) {
-	warning("STUB: AI: aiDragonUse required");
-}
-
 void aiEnvelopeGreenInit(AIEntity *e) {
 	strcpy(e->printedName, "Green envelope");
 	e->aiAction = aiGetItemAction;


Commit: d88f4fb7c0a8600d57652419faa51b175a0aac10
    https://github.com/scummvm/scummvm/commit/d88f4fb7c0a8600d57652419faa51b175a0aac10
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:08+02:00

Commit Message:
HDB: Add callbackDoorOpenClose() and use function

Changed paths:
    engines/hdb/ai-player.cpp
    engines/hdb/ai-use.cpp


diff --git a/engines/hdb/ai-player.cpp b/engines/hdb/ai-player.cpp
index 6a32df5..ca5797c 100644
--- a/engines/hdb/ai-player.cpp
+++ b/engines/hdb/ai-player.cpp
@@ -1444,10 +1444,6 @@ void aiNoneInit2(AIEntity *e) {
 	warning("STUB: AI: aiNoneInit2 required");
 }
 
-void callbackDoorOpenClose(int x, int y) {
-	warning("STUB: AI: callbackDoorOpenClose required");
-}
-
 // Utility Functions
 void aiAnimateStanddown(AIEntity *e, int speed) {
 	if (e->value2-- > 0)
diff --git a/engines/hdb/ai-use.cpp b/engines/hdb/ai-use.cpp
index 83a294d..188244c 100644
--- a/engines/hdb/ai-use.cpp
+++ b/engines/hdb/ai-use.cpp
@@ -67,10 +67,30 @@ bool AI::useTouchplateOn(AIEntity *e, int x, int y, int targetX, int targetY, in
 	return false;
 }
 
+void callbackDoorOpenClose(int x, int y) {
+	int	tileIndex = g_hdb->_map->getMapBGTileIndex(x, y);
+
+	// is the door gonna close on something?  if so, wait again
+	if (!g_hdb->_ai->findEntity(x, y)) {
+		g_hdb->_ai->addCallback(CALLBACK_DOOR_OPEN_CLOSE, x, y, kDelay5Seconds);
+		return;
+	}
+
+	g_hdb->_ai->addAnimateTarget(x, y, tileIndex, tileIndex + 3, ANIM_SLOW, false, true, NULL);
+	if (g_hdb->_map->onScreen(x, y))
+		warning("STUB: Play SND_DOOR_OPEN_CLOSE");
+	return;
+}
+
 // Normal Door
 bool AI::useDoorOpenClose(AIEntity *e, int x, int y) {
-	warning("STUB: Define useDoorOpenClose");
-	return false;
+	int tileIndex = g_hdb->_map->getMapBGTileIndex(x, y);
+
+	addAnimateTarget(x, y, tileIndex, tileIndex - 3, ANIM_SLOW, false, true, NULL);
+	addCallback(CALLBACK_DOOR_OPEN_CLOSE, x, y, kDelay5Seconds);
+	if (g_hdb->_map->onScreen(x, y))
+		warning("Play SND_DOOR_OPEN_CLOSE");
+	return true;
 }
 
 void callbackAutoDoorOpenClose(int x, int y) {


Commit: 60958086c2bf81b4d0523e24ce8b7463336007df
    https://github.com/scummvm/scummvm/commit/60958086c2bf81b4d0523e24ce8b7463336007df
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:08+02:00

Commit Message:
HDB: Add aiGemAttack functions

Changed paths:
    engines/hdb/ai-player.cpp


diff --git a/engines/hdb/ai-player.cpp b/engines/hdb/ai-player.cpp
index ca5797c..f430a65 100644
--- a/engines/hdb/ai-player.cpp
+++ b/engines/hdb/ai-player.cpp
@@ -484,15 +484,114 @@ void aiPlayerDraw(AIEntity *e, int mx, int my) {
 }
 
 void aiGemAttackInit(AIEntity *e) {
-	warning("STUB: AI: aiGemAttackInit required");
-}
-
-void aiGemAttackInit2(AIEntity *e) {
-	warning("STUB: AI: aiGemAttackInit2 required");
+	int xv[5] = {9, 0, 0, -1, 1}, yv[5] = {9, -1, 1, 0, 0};
+	e->moveSpeed = kPlayerMoveSpeed << 1;
+	g_hdb->_ai->setEntityGoal(e, e->tileX + xv[e->dir], e->tileY + yv[e->dir]);
+	e->state = STATE_MOVEDOWN;		// so it will draw & animate
+	e->sequence = 0;	// flying out at something
+	e->aiAction = aiGemAttackAction;
+	e->draw = e->movedownGfx[0];
+	warning("Play SND_GEM_THROW");
 }
 
 void aiGemAttackAction(AIEntity *e) {
-	warning("STUB: AI: aiGemAttackAction required");
+	int xv[5] = {9, 0, 0, -1, 1}, yv[5] = {9, -1, 1, 0, 0};
+	AIEntity *hit;
+	int		result;
+
+	switch (e->sequence) {
+		// flying out at something
+	case 0:
+		if (e->goalX)
+			g_hdb->_ai->animateEntity(e);
+		else {
+			g_hdb->_ai->checkActionList(e, e->tileX, e->tileY, false);
+			g_hdb->_ai->checkAutoList(e, e->tileX, e->tileY);
+
+			hit = g_hdb->_ai->findEntityIgnore(e->tileX, e->tileY, e);
+			uint32 bgFlags = g_hdb->_map->getMapBGTileFlags(e->tileX, e->tileY);
+			uint32 fgFlags = g_hdb->_map->getMapFGTileFlags(e->tileX, e->tileY);
+			result = (e->level == 1 ? (bgFlags & (kFlagSolid)) : !(fgFlags & kFlagGrating) && (bgFlags & (kFlagSolid)));
+			if (hit) {
+				switch (hit->type) {
+				case AI_CHICKEN:
+					g_hdb->_ai->addAnimateTarget(hit->x, hit->y, 0, 3, ANIM_NORMAL, false, false, GROUP_STEAM_PUFF_SIT);
+					g_hdb->_ai->removeEntity(hit);
+					warning("Play SND_CHICKEN_BAGAWK");
+					break;
+				case AI_BADFAIRY:
+					g_hdb->_ai->stunEnemy(hit, 2);
+					g_hdb->_ai->addAnimateTarget(hit->x, hit->y, 0, 3, ANIM_NORMAL, false, false, GEM_FLASH);
+					break;
+				case AI_NONE:
+					if (hit->value1 == (int)AI_DRAGON) {
+						// pull dragon's coords out of "lua_func_use" string.
+						char num1[4], num2[4];
+						memset(num1, 0, 4);
+						memset(num2, 0, 4);
+						memcpy(num1, hit->luaFuncUse, 3);
+						memcpy(num2, hit->luaFuncUse + 3, 3);
+
+						warning("Play SND_CLUB_HIT_FLESH");
+						AIEntity *found = g_hdb->_ai->findEntity(atoi(num1), atoi(num2));
+						if (found)
+							aiDragonWake(found);
+					}
+					g_hdb->_ai->addAnimateTarget(e->x, e->y, 0, 3, ANIM_NORMAL, false, false, GEM_FLASH);
+					warning("Play SND_INV_SELECT");
+					break;
+				case AI_DRAGON:
+					warning("Play SND_CLUB_HIT_FLESH");
+					aiDragonWake(hit);
+				default:
+					g_hdb->_ai->addAnimateTarget(e->x, e->y, 0, 3, ANIM_NORMAL, false, false, GEM_FLASH);
+					warning("Play SND_CLUB_HIT_FLESH");
+				}
+				if (e->value1)
+					e->sequence = 1;
+				else
+					g_hdb->_ai->removeEntity(e);	// bye bye!
+				return;
+			} else if (result) {		// hit a wall
+					g_hdb->_ai->addAnimateTarget(e->x, e->y, 0, 3, ANIM_NORMAL, false, false, GEM_FLASH);
+					warning("Play SND_INV_SELECT");
+					// come back to daddy?
+					if (e->value1)
+						e->sequence = 1;
+					else {
+						g_hdb->_ai->removeEntity(e);
+						return;
+					}
+			} else {
+					g_hdb->_ai->setEntityGoal(e, e->tileX + xv[e->dir], e->tileY + yv[e->dir]);
+					e->state = STATE_MOVEDOWN;		// so it will draw & animate
+			}
+			g_hdb->_ai->animateEntity(e);
+		}
+		break;
+		// coming back to daddy?
+	case 1:
+		AIEntity *p = g_hdb->_ai->getPlayer();
+		if (e->x < p->x)
+			e->x++;
+		else
+			e->x--;
+
+		if (e->y < p->y)
+			e->y++;
+		else
+			e->y--;
+
+		if (abs(e->x - p->x) < 4 && abs(e->y - p->y) < 4)
+		{
+			int	amt = g_hdb->_ai->getGemAmount();
+			g_hdb->_ai->setGemAmount(amt + 1);
+			g_hdb->_ai->addAnimateTarget(e->x, e->y, 0, 3, ANIM_NORMAL, false, false, GEM_FLASH);
+			g_hdb->_ai->removeEntity(e);
+			warning("Play SND_GET_GEM");
+		}
+		break;
+	}
 }
 
 void aiChickenAction(AIEntity *e) {


Commit: 34f0992c4d911c18a194358dd5d61792c4b6cb69
    https://github.com/scummvm/scummvm/commit/34f0992c4d911c18a194358dd5d61792c4b6cb69
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:08+02:00

Commit Message:
HDB: Add aiChicken functions

Changed paths:
    engines/hdb/ai-player.cpp


diff --git a/engines/hdb/ai-player.cpp b/engines/hdb/ai-player.cpp
index f430a65..5b045b5 100644
--- a/engines/hdb/ai-player.cpp
+++ b/engines/hdb/ai-player.cpp
@@ -595,19 +595,34 @@ void aiGemAttackAction(AIEntity *e) {
 }
 
 void aiChickenAction(AIEntity *e) {
-	warning("STUB: AI: aiChickenAction required");
+	static int delay = 64;
+
+	if (g_hdb->_map->checkEntOnScreen(e) && !delay) {
+		warning("Play SND_CHICKEN_AMBIENT");
+		delay = g_hdb->_rnd->getRandomNumber(128) + 160;
+		aiChickenUse(e);
+	}
+
+	if (delay)
+		delay--;
+
+	if (e->goalX)
+		g_hdb->_ai->animateEntity(e);
+	else
+		g_hdb->_ai->animEntFrames(e);
 }
 
 void aiChickenUse(AIEntity *e) {
-	warning("STUB: AI: aiChickenUse required");
+	warning("Play SND_CHICKEN_BAGAWK");
 }
 
 void aiChickenInit(AIEntity *e) {
-	warning("STUB: AI: aiChickenInit required");
+	e->aiUse = aiChickenUse;
+	e->aiAction = aiChickenAction;
 }
 
 void aiChickenInit2(AIEntity *e) {
-	warning("STUB: AI: aiChickenInit2 required");
+	e->draw = e->standdownGfx[0];
 }
 
 void aiDollyInit(AIEntity *e) {


Commit: a1fbe844b4b8b1f07538d75ec7bf2140dc4adad1
    https://github.com/scummvm/scummvm/commit/a1fbe844b4b8b1f07538d75ec7bf2140dc4adad1
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:08+02:00

Commit Message:
HDB: Add aiRoboStunner functions

Changed paths:
    engines/hdb/ai-player.cpp


diff --git a/engines/hdb/ai-player.cpp b/engines/hdb/ai-player.cpp
index 5b045b5..14b71eb 100644
--- a/engines/hdb/ai-player.cpp
+++ b/engines/hdb/ai-player.cpp
@@ -1146,15 +1146,17 @@ void aiFrogStatueAction(AIEntity *e) {
 }
 
 void aiRoboStunnerAction(AIEntity *e) {
-	warning("STUB: AI: aiRoboStunnerAction required");
+	aiAnimateStanddown(e, 1);
+	aiGetItemAction(e);
 }
 
 void aiRoboStunnerInit(AIEntity *e) {
-	warning("STUB: AI: aiRoboStunnerInit required");
+	e->aiAction = aiRoboStunnerAction;
+	strcpy(e->printedName, "Robostunner");
 }
 
 void aiRoboStunnerInit2(AIEntity *e) {
-	warning("STUB: AI: aiRoboStunnerInit2 required");
+	e->draw = e->standdownGfx[0];
 }
 
 void aiClubInit(AIEntity *e) {


Commit: 7e586c9f21fee4c3b3ddf56532f88291eab1e073
    https://github.com/scummvm/scummvm/commit/7e586c9f21fee4c3b3ddf56532f88291eab1e073
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:08+02:00

Commit Message:
HDB: Add aiClub functions

Changed paths:
    engines/hdb/ai-player.cpp


diff --git a/engines/hdb/ai-player.cpp b/engines/hdb/ai-player.cpp
index 14b71eb..1110c42 100644
--- a/engines/hdb/ai-player.cpp
+++ b/engines/hdb/ai-player.cpp
@@ -1160,11 +1160,12 @@ void aiRoboStunnerInit2(AIEntity *e) {
 }
 
 void aiClubInit(AIEntity *e) {
-	warning("STUB: AI: aiClubInit required");
+	strcpy(e->printedName, "Creature Clubber");
+	e->aiAction = aiGetItemAction;
 }
 
 void aiClubInit2(AIEntity *e) {
-	warning("STUB: AI: aiClubInit2 required");
+	e->draw = e->standdownGfx[0];
 }
 
 void aiSlugSlingerInit(AIEntity *e) {


Commit: c0e2f9b4794b0d539407358c4090a16acf367ca5
    https://github.com/scummvm/scummvm/commit/c0e2f9b4794b0d539407358c4090a16acf367ca5
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:08+02:00

Commit Message:
HDB: Add aiSlugSlinger functions

Changed paths:
    engines/hdb/ai-player.cpp


diff --git a/engines/hdb/ai-player.cpp b/engines/hdb/ai-player.cpp
index 1110c42..05a757a 100644
--- a/engines/hdb/ai-player.cpp
+++ b/engines/hdb/ai-player.cpp
@@ -1169,11 +1169,12 @@ void aiClubInit2(AIEntity *e) {
 }
 
 void aiSlugSlingerInit(AIEntity *e) {
-	warning("STUB: AI: aiSlugSlingerInit required");
+	strcpy(e->printedName, "Slugslinger");
+	e->aiAction = aiGetItemAction;
 }
 
 void aiSlugSlingerInit2(AIEntity *e) {
-	warning("STUB: AI: aiSlugSlingerInit2 required");
+	e->draw = e->standdownGfx[0];
 }
 
 void aiEnvelopeGreenInit(AIEntity *e) {


Commit: 5617ec541ae9965e6547343930e0b76c8ac0d170
    https://github.com/scummvm/scummvm/commit/5617ec541ae9965e6547343930e0b76c8ac0d170
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:08+02:00

Commit Message:
HDB: Add Gem functions

Changed paths:
    engines/hdb/ai-player.cpp


diff --git a/engines/hdb/ai-player.cpp b/engines/hdb/ai-player.cpp
index 05a757a..982b7d1 100644
--- a/engines/hdb/ai-player.cpp
+++ b/engines/hdb/ai-player.cpp
@@ -1187,27 +1187,27 @@ void aiEnvelopeGreenInit2(AIEntity *e) {
 }
 
 void aiGemBlueInit(AIEntity *e) {
-	warning("STUB: AI: aiGemBlueInit required");
+	e->aiAction = aiGemAction;
 }
 
 void aiGemBlueInit2(AIEntity *e) {
-	warning("STUB: AI: aiGemBlueInit2 required");
+	e->draw = e->standdownGfx[0];
 }
 
 void aiGemRedInit(AIEntity *e) {
-	warning("STUB: AI: aiGemRedInit required");
+	e->aiAction = aiGemAction;
 }
 
 void aiGemRedInit2(AIEntity *e) {
-	warning("STUB: AI: aiGemRedInit2 required");
+	e->draw = e->standdownGfx[0];
 }
 
 void aiGemGreenInit(AIEntity *e) {
-	warning("STUB: AI: aiGemGreenInit required");
+	e->aiAction = aiGemAction;
 }
 
 void aiGemGreenInit2(AIEntity *e) {
-	warning("STUB: AI: aiGemGreenInit2 required");
+	e->draw = e->standdownGfx[0];
 }
 
 void aiTeaCupInit(AIEntity *e) {
@@ -1511,19 +1511,36 @@ void aiMonkeystoneUse2(AIEntity *e) {
 }
 
 void aiGemAction(AIEntity *e) {
-	warning("STUB: AI: aiGemAction required");
-}
+	AIEntity *p;
+	int tolerance;
+
+	e->animFrame++;
+	if (e->animFrame >= e->standdownFrames) {
+		e->animFrame = 0;
+
+		// every 4th frame, check for player collision &
+		// add to inventory if it happens
+		p = g_hdb->_ai->getPlayer();
+		tolerance = 16;
+		if (g_hdb->_ai->playerRunning())
+			tolerance = 24;
 
-void aiGemAction2(AIEntity *e) {
-	warning("STUB: AI: aiGemAction2 required");
+		if (e->onScreen && abs(p->x - e->x) < tolerance && abs(p->y - e->y) < tolerance && e->level == p->level) {
+			g_hdb->_ai->addAnimateTarget(e->x, e->y, 0, 3, ANIM_NORMAL, false, false, GEM_FLASH);
+			g_hdb->_ai->addToInventory(e);
+			warning("Play SND_GET_GEM");
+			return;
+		}
+	}
+	e->draw = e->standdownGfx[e->animFrame];
 }
 
 void aiGemWhiteInit(AIEntity *e) {
-	warning("STUB: AI: aiGemWhiteInit required");
+	e->aiAction = aiGemAction;
 }
 
 void aiGemWhiteInit2(AIEntity *e) {
-	warning("STUB: AI: aiGemWhiteInit2 required");
+	e->draw = e->standdownGfx[0];
 }
 
 void aiGooCupUse(AIEntity *e) {


Commit: b0b096402cf808b5f7b849aa652a45e56a4c2477
    https://github.com/scummvm/scummvm/commit/b0b096402cf808b5f7b849aa652a45e56a4c2477
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:08+02:00

Commit Message:
HDB: Add functions for TeaCup, Burger and Cookie

Changed paths:
    engines/hdb/ai-player.cpp


diff --git a/engines/hdb/ai-player.cpp b/engines/hdb/ai-player.cpp
index 982b7d1..6a7cc27 100644
--- a/engines/hdb/ai-player.cpp
+++ b/engines/hdb/ai-player.cpp
@@ -1211,27 +1211,30 @@ void aiGemGreenInit2(AIEntity *e) {
 }
 
 void aiTeaCupInit(AIEntity *e) {
-	warning("STUB: AI: aiTeaCupInit required");
+	strcpy(e->printedName, "a Teacup");
+	e->aiAction = aiGetItemAction;
 }
 
 void aiTeaCupInit2(AIEntity *e) {
-	warning("STUB: AI: aiTeaCupInit2 required");
+	e->draw = e->standdownGfx[0];
 }
 
 void aiCookieInit(AIEntity *e) {
-	warning("STUB: AI: aiCookieInit required");
+	strcpy(e->printedName, "a Cookie");
+	e->aiAction = aiGetItemAction;
 }
 
 void aiCookieInit2(AIEntity *e) {
-	warning("STUB: AI: aiCookieInit2 required");
+	e->draw = e->standdownGfx[0];
 }
 
 void aiBurgerInit(AIEntity *e) {
-	warning("STUB: AI: aiBurgerInit required");
+	strcpy(e->printedName, "a Burger");
+	e->aiAction = aiGetItemAction;
 }
 
 void aiBurgerInit2(AIEntity *e) {
-	warning("STUB: AI: aiBurgerInit2 required");
+	e->draw = e->standdownGfx[0];
 }
 
 void aiBookInit(AIEntity *e) {


Commit: c6f4bdc2c1231d4122f644b54c86898172ff823c
    https://github.com/scummvm/scummvm/commit/c6f4bdc2c1231d4122f644b54c86898172ff823c
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:08+02:00

Commit Message:
HDB: Add Keycard functions

Changed paths:
    engines/hdb/ai-player.cpp


diff --git a/engines/hdb/ai-player.cpp b/engines/hdb/ai-player.cpp
index 6a7cc27..38faa84 100644
--- a/engines/hdb/ai-player.cpp
+++ b/engines/hdb/ai-player.cpp
@@ -1265,51 +1265,57 @@ void aiNoteInit2(AIEntity *e) {
 }
 
 void aiKeycardWhiteInit(AIEntity *e) {
-	warning("STUB: AI: aiKeycardWhiteInit required");
+	strcpy(e->printedName, "a White keycard");
+	e->aiAction = aiGetItemAction;
 }
 
 void aiKeycardWhiteInit2(AIEntity *e) {
-	warning("STUB: AI: aiKeycardWhiteInit2 required");
+	e->draw = e->standdownGfx[0];
 }
 
 void aiKeycardBlueInit(AIEntity *e) {
-	warning("STUB: AI: aiKeycardBlueInit required");
+	strcpy(e->printedName, "a Blue keycard");
+	e->aiAction = aiGetItemAction;
 }
 
 void aiKeycardBlueInit2(AIEntity *e) {
-	warning("STUB: AI: aiKeycardBlueInit2 required");
+	e->draw = e->standdownGfx[0];
 }
 
 void aiKeycardRedInit(AIEntity *e) {
-	warning("STUB: AI: aiKeycardRedInit required");
+	strcpy(e->printedName, "a Red keycard");
+	e->aiAction = aiGetItemAction;
 }
 
 void aiKeycardRedInit2(AIEntity *e) {
-	warning("STUB: AI: aiKeycardRedInit2 required");
+	e->draw = e->standdownGfx[0];
 }
 
 void aiKeycardGreenInit(AIEntity *e) {
-	warning("STUB: AI: aiKeycardGreenInit required");
+	strcpy(e->printedName, "a Green keycard");
+	e->aiAction = aiGetItemAction;
 }
 
 void aiKeycardGreenInit2(AIEntity *e) {
-	warning("STUB: AI: aiKeycardGreenInit2 required");
+	e->draw = e->standdownGfx[0];
 }
 
 void aiKeycardPurpleInit(AIEntity *e) {
-	warning("STUB: AI: aiKeycardPurpleInit required");
+	strcpy(e->printedName, "a Purple keycard");
+	e->aiAction = aiGetItemAction;
 }
 
 void aiKeycardPurpleInit2(AIEntity *e) {
-	warning("STUB: AI: aiKeycardPurpleInit2 required");
+	e->draw = e->standdownGfx[0];
 }
 
 void aiKeycardBlackInit(AIEntity *e) {
-	warning("STUB: AI: aiKeycardBlackInit required");
+	strcpy(e->printedName, "a Black keycard");
+	e->aiAction = aiGetItemAction;
 }
 
 void aiKeycardBlackInit2(AIEntity *e) {
-	warning("STUB: AI: aiKeycardBlackInit2 required");
+	e->draw = e->standdownGfx[0];
 }
 
 void aiSeedInit(AIEntity *e) {


Commit: a870b934218fb6782709858ead4aab7a73295809
    https://github.com/scummvm/scummvm/commit/a870b934218fb6782709858ead4aab7a73295809
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:08+02:00

Commit Message:
HDB: Add Seed and Soda functions

Changed paths:
    engines/hdb/ai-player.cpp


diff --git a/engines/hdb/ai-player.cpp b/engines/hdb/ai-player.cpp
index 38faa84..2a56792 100644
--- a/engines/hdb/ai-player.cpp
+++ b/engines/hdb/ai-player.cpp
@@ -1319,19 +1319,21 @@ void aiKeycardBlackInit2(AIEntity *e) {
 }
 
 void aiSeedInit(AIEntity *e) {
-	warning("STUB: AI: aiSeedInit required");
+	strcpy(e->printedName, "some Henscratch");
+	e->aiAction = aiGetItemAction;
 }
 
 void aiSeedInit2(AIEntity *e) {
-	warning("STUB: AI: aiSeedInit2 required");
+	e->draw = e->standdownGfx[0];
 }
 
 void aiSodaInit(AIEntity *e) {
-	warning("STUB: AI: aiSodaInit required");
+	strcpy(e->printedName, "a Dr. Frostee");
+	e->aiAction = aiGetItemAction;
 }
 
 void aiSodaInit2(AIEntity *e) {
-	warning("STUB: AI: aiSodaInit2 required");
+	e->draw = e->standdownGfx[0];
 }
 
 void aiDollyTool1Init(AIEntity *e) {


Commit: dd53729b810c1a3c89c06a7b6cccaee0a705edd7
    https://github.com/scummvm/scummvm/commit/dd53729b810c1a3c89c06a7b6cccaee0a705edd7
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:08+02:00

Commit Message:
HDB: Add Dolly Tools, Splicer, Package and Router

Changed paths:
    engines/hdb/ai-player.cpp


diff --git a/engines/hdb/ai-player.cpp b/engines/hdb/ai-player.cpp
index 2a56792..ea2f6c9 100644
--- a/engines/hdb/ai-player.cpp
+++ b/engines/hdb/ai-player.cpp
@@ -1337,59 +1337,66 @@ void aiSodaInit2(AIEntity *e) {
 }
 
 void aiDollyTool1Init(AIEntity *e) {
-	warning("STUB: AI: aiDollyTool1Init required");
+	strcpy(e->printedName, "Dolly's Wrench");
+	e->aiAction = aiGetItemAction;
 }
 
 void aiDollyTool1Init2(AIEntity *e) {
-	warning("STUB: AI: aiDollyTool1Init2 required");
+	e->draw = e->standdownGfx[0];
 }
 
 void aiDollyTool2Init(AIEntity *e) {
-	warning("STUB: AI: aiDollyTool2Init required");
+	strcpy(e->printedName, "Dolly's Torch");
+	e->aiAction = aiGetItemAction;
 }
 
 void aiDollyTool2Init2(AIEntity *e) {
-	warning("STUB: AI: aiDollyTool2Init2 required");
+	e->draw = e->standdownGfx[0];
 }
 
 void aiDollyTool3Init(AIEntity *e) {
-	warning("STUB: AI: aiDollyTool3Init required");
+	strcpy(e->printedName, "Dolly's EMF Resonator");
+	e->aiAction = aiGetItemAction;
 }
 
 void aiDollyTool3Init2(AIEntity *e) {
-	warning("STUB: AI: aiDollyTool3Init2 required");
+	e->draw = e->standdownGfx[0];
 }
 
 void aiDollyTool4Init(AIEntity *e) {
-	warning("STUB: AI: aiDollyTool4Init required");
+	strcpy(e->printedName, "Dolly's Toolbox");
+	e->aiAction = aiGetItemAction;
 }
 
 void aiDollyTool4Init2(AIEntity *e) {
-	warning("STUB: AI: aiDollyTool4Init2 required");
+	e->draw = e->standdownGfx[0];
 }
 
 void aiRouterInit(AIEntity *e) {
-	warning("STUB: AI: aiRouterInit required");
+	strcpy(e->printedName, "a Computer Router");
+	e->aiAction = aiGetItemAction;
 }
 
 void aiRouterInit2(AIEntity *e) {
-	warning("STUB: AI: aiRouterInit2 required");
+	e->draw = e->standdownGfx[0];
 }
 
 void aiSlicerInit(AIEntity *e) {
-	warning("STUB: AI: aiSlicerInit required");
+	strcpy(e->printedName, "a Pizza Slicer");
+	e->aiAction = aiGetItemAction;
 }
 
 void aiSlicerInit2(AIEntity *e) {
-	warning("STUB: AI: aiSlicerInit2 required");
+	e->draw = e->standdownGfx[0];
 }
 
 void aiPackageInit(AIEntity *e) {
-	warning("STUB: AI: aiPackageInit required");
+	strcpy(e->printedName, "a Package");
+	e->aiAction = aiGetItemAction;
 }
 
 void aiPackageInit2(AIEntity *e) {
-	warning("STUB: AI: aiPackageInit2 required");
+	e->draw = e->standdownGfx[0];
 }
 
 void aiMagicEggAction(AIEntity *e) {


Commit: 70fb0e81cc46e4e2590a434c40cfd40d0e313186
    https://github.com/scummvm/scummvm/commit/70fb0e81cc46e4e2590a434c40cfd40d0e313186
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:08+02:00

Commit Message:
HDB: Add functions for Magic Egg

Changed paths:
    engines/hdb/ai-player.cpp


diff --git a/engines/hdb/ai-player.cpp b/engines/hdb/ai-player.cpp
index ea2f6c9..80d131f 100644
--- a/engines/hdb/ai-player.cpp
+++ b/engines/hdb/ai-player.cpp
@@ -1400,19 +1400,51 @@ void aiPackageInit2(AIEntity *e) {
 }
 
 void aiMagicEggAction(AIEntity *e) {
-	warning("STUB: AI: aiMagicEggAction required");
+	// if magic egg isn't moving somewhere, don't move it
+	if (!e->goalX)
+		return;
+
+	g_hdb->_ai->animateEntity(e);
 }
 
 void aiMagicEggInit(AIEntity *e) {
-	warning("STUB: AI: aiMagicEggInit required");
+	e->moveSpeed = kPushMoveSpeed;
+	e->aiAction = aiMagicEggAction;
 }
 
 void aiMagicEggInit2(AIEntity *e) {
-	warning("STUB: AI: aiMagicEggInit2 required");
+	// point all magic egg move frames to the standing one
+	e->movedownFrames =
+		e->moveleftFrames =
+		e->moverightFrames =
+		e->moveupFrames = 1;
+
+	e->movedownGfx[0] =
+		e->moveupGfx[0] =
+		e->moveleftGfx[0] =
+		e->moverightGfx[0] = e->standdownGfx[0];
+
+	e->draw = e->standdownGfx[0];			// standing frame - doesn't move
 }
 
 void aiMagicEggUse(AIEntity *e) {
-	warning("STUB: AI: aiMagicEggUse required");
+	if (!scumm_strnicmp(e->luaFuncAction, "ai_", 3) || !scumm_strnicmp(e->luaFuncAction, "item_", 5)) {
+		int	i = 0;
+		AIEntity *spawned = NULL;
+		while (aiEntList[i].type != END_AI_TYPES) {
+			if (!_stricmp(aiEntList[i].luaName, e->luaFuncAction)) {
+				spawned = g_hdb->_ai->spawn(aiEntList[i].type, e->dir, e->tileX, e->tileY, NULL, NULL, NULL, DIR_NONE, e->level, 0, 0, 1);
+				break;
+			}
+			i++;
+		}
+		if (spawned) {
+			g_hdb->_ai->addAnimateTarget(e->tileX * kTileWidth,
+			e->tileY * kTileHeight, 0, 3, ANIM_NORMAL, false, false, GROUP_EXPLOSION_BOOM_SIT);
+			warning("Play SND_BARREL_EXPLODE");
+			g_hdb->_ai->removeEntity(e);
+		}
+	}
 }
 
 void aiIceBlockAction(AIEntity *e) {


Commit: 7871ad60076fc155d7f585eb5be0f00831edfd45
    https://github.com/scummvm/scummvm/commit/7871ad60076fc155d7f585eb5be0f00831edfd45
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:08+02:00

Commit Message:
HDB: Add IceBlock, ItemChicken and CabKey

Changed paths:
    engines/hdb/ai-player.cpp


diff --git a/engines/hdb/ai-player.cpp b/engines/hdb/ai-player.cpp
index 80d131f..8713be7 100644
--- a/engines/hdb/ai-player.cpp
+++ b/engines/hdb/ai-player.cpp
@@ -1448,31 +1448,47 @@ void aiMagicEggUse(AIEntity *e) {
 }
 
 void aiIceBlockAction(AIEntity *e) {
-	warning("STUB: AI: aiIceBlockAction required");
+	// if ice block isn't moving somewhere, don't move it
+	if (!e->goalX)
+		return;
+
+	g_hdb->_ai->animateEntity(e);
 }
 
 void aiIceBlockInit(AIEntity *e) {
-	warning("STUB: AI: aiIceBlockInit required");
+	e->moveSpeed = kPushMoveSpeed;
+	e->aiAction = aiIceBlockAction;
 }
 
 void aiIceBlockInit2(AIEntity *e) {
-	warning("STUB: AI: aiIceBlockInit2 required");
+	// point all ice block move frames to the standing one
+	e->movedownFrames =
+		e->moveleftFrames =
+		e->moverightFrames =
+		e->moveupFrames = 1;
+
+	e->movedownGfx[0] =
+		e->moveupGfx[0] =
+		e->moveleftGfx[0] =
+		e->moverightGfx[0] = e->standdownGfx[0];
+
+	e->draw = e->standdownGfx[0];			// standing frame - doesn't move
 }
 
 void aiCabKeyInit(AIEntity *e) {
-	warning("STUB: AI: aiCabKeyInit required");
+	strcpy(e->printedName, "a Cabinet key");
 }
 
 void aiCabKeyInit2(AIEntity *e) {
-	warning("STUB: AI: aiCabKeyInit2 required");
+	e->draw = e->standdownGfx[0];
 }
 
 void aiItemChickenInit(AIEntity *e) {
-	warning("STUB: AI: aiItemChickenInit required");
+	strcpy(e->printedName, "Cooper's chicken");
 }
 
 void aiItemChickenInit2(AIEntity *e) {
-	warning("STUB: AI: aiItemChickenInit2 required");
+	e->draw = e->standdownGfx[0];
 }
 
 void aiPdaInit(AIEntity *e) {


Commit: 169c4d86f645c91e9bc9883082871492004906f9
    https://github.com/scummvm/scummvm/commit/169c4d86f645c91e9bc9883082871492004906f9
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:08+02:00

Commit Message:
HDB: Add Transceiver functions

Changed paths:
    engines/hdb/ai-player.cpp


diff --git a/engines/hdb/ai-player.cpp b/engines/hdb/ai-player.cpp
index 8713be7..6b0f5b6 100644
--- a/engines/hdb/ai-player.cpp
+++ b/engines/hdb/ai-player.cpp
@@ -1541,20 +1541,25 @@ void aiEnvelopeRedInit2(AIEntity *e) {
 }
 
 void aiTransceiverInit(AIEntity *e) {
-	warning("STUB: AI: aiTransceiverInit required");
+	e->aiAction = aiTransceiverAction;
+	strcpy(e->printedName, "Transceiver");
 }
 
 void aiTransceiverInit2(AIEntity *e) {
-	warning("STUB: AI: aiTransceiverInit2 required");
+	e->draw = e->standdownGfx[0];
 }
 
 void aiTransceiverAction(AIEntity *e) {
-	warning("STUB: AI: aiTransceiverAction required");
+	aiAnimateStanddown(e, 5);
+	if (e->onScreen)
+		aiGetItemAction(e);
 }
 
+#if 0
 void aiTransceiverUse(AIEntity *e) {
 	warning("STUB: AI: aiTransceiverUse required");
 }
+#endif
 
 void aiMonkeystoneInit(AIEntity *e) {
 	warning("STUB: AI: aiMonkeystoneInit required");


Commit: bbecaabf326365271c53ad4a3968b156b1aa2f30
    https://github.com/scummvm/scummvm/commit/bbecaabf326365271c53ad4a3968b156b1aa2f30
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:09+02:00

Commit Message:
HDB: Add Monkeystone and GooCup functions

Changed paths:
    engines/hdb/ai-player.cpp


diff --git a/engines/hdb/ai-player.cpp b/engines/hdb/ai-player.cpp
index 6b0f5b6..1aa1c3c 100644
--- a/engines/hdb/ai-player.cpp
+++ b/engines/hdb/ai-player.cpp
@@ -1561,24 +1561,42 @@ void aiTransceiverUse(AIEntity *e) {
 }
 #endif
 
+char monkBuff[32];
+
 void aiMonkeystoneInit(AIEntity *e) {
-	warning("STUB: AI: aiMonkeystoneInit required");
+	e->aiUse = aiMonkeystoneUse;
+	e->aiAction = aiMonkeystoneAction;
 }
 
 void aiMonkeystoneAction(AIEntity *e) {
-	warning("STUB: AI: aiMonkeystoneAction required");
+	if (!e->onScreen)
+		return;
+
+	AIEntity *p = g_hdb->_ai->getPlayer();
+	if (abs(p->x - e->x) < 16 && abs(p->y - e->y) < 16 && e->level == p->level) {
+		if (e->luaFuncUse[0])
+			g_hdb->_lua->callFunction(e->luaFuncUse, 0);
+
+		g_hdb->_ai->addToInventory(e);
+		aiMonkeystoneUse(NULL);
+	}
 }
 
 void aiMonkeystoneInit2(AIEntity *e) {
-	warning("STUB: AI: aiMonkeystoneInit2 required");
+	e->draw = e->standdownGfx[0];
 }
 
 void aiMonkeystoneUse(AIEntity *e) {
-	warning("STUB: AI: aiMonkeystoneUse required");
-}
+	int	val = g_hdb->_ai->getMonkeystoneAmount();
+	sprintf(monkBuff, "You have %d Monkeystone", val);
+	if (val > 1)
+		strcat(monkBuff, "s");
+	strcat(monkBuff, "!");
+	warning("STUB: Play SND_GET_MONKEYSTONE");
+	g_hdb->_window->openMessageBar(monkBuff, kMsgDelay);
 
-void aiMonkeystoneUse2(AIEntity *e) {
-	warning("STUB: AI: aiMonkeystoneUse2 required");
+	// have we unlocked a secret star(tm)???
+	warning("STUB: Set Secret Stars");
 }
 
 void aiGemAction(AIEntity *e) {
@@ -1615,15 +1633,16 @@ void aiGemWhiteInit2(AIEntity *e) {
 }
 
 void aiGooCupUse(AIEntity *e) {
-	warning("STUB: AI: aiGooCupUse required");
+	g_hdb->_window->openMessageBar("Got a... cup of goo.", kMsgDelay);
 }
 
 void aiGooCupInit(AIEntity *e) {
-	warning("STUB: AI: aiGooCupInit required");
+	e->aiUse = aiGooCupUse;
+	e->aiAction = aiGetItemAction;
 }
 
 void aiGooCupInit2(AIEntity *e) {
-	warning("STUB: AI: aiGooCupInit2 required");
+	e->draw = e->standdownGfx[0];
 }
 
 void aiVortexianAction(AIEntity *e) {


Commit: b8a98fdcfe7e6c6c8896e85494113fd65d5ebda6
    https://github.com/scummvm/scummvm/commit/b8a98fdcfe7e6c6c8896e85494113fd65d5ebda6
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:09+02:00

Commit Message:
HDB: Add Vortexian and AI_NONE functions

Changed paths:
    engines/hdb/ai-player.cpp


diff --git a/engines/hdb/ai-player.cpp b/engines/hdb/ai-player.cpp
index 1aa1c3c..a249884 100644
--- a/engines/hdb/ai-player.cpp
+++ b/engines/hdb/ai-player.cpp
@@ -1650,23 +1650,20 @@ void aiVortexianAction(AIEntity *e) {
 }
 
 void aiVortexianUse(AIEntity *e) {
-	warning("STUB: AI: aiVortexianUse required");
 }
 
 void aiVortexianInit(AIEntity *e) {
-	warning("STUB: AI: aiVortexianInit required");
+	e->aiUse = aiVortexianUse;
+	e->aiAction = aiVortexianAction;
+	e->value1 = 5;
+	e->value2 = 128;
 }
 
 void aiVortexianInit2(AIEntity *e) {
-	warning("STUB: AI: aiVortexianInit2 required");
+	e->draw = e->standdownGfx[0];
 }
 
 void aiNoneInit(AIEntity *e) {
-	warning("STUB: AI: aiNoneInit required");
-}
-
-void aiNoneInit2(AIEntity *e) {
-	warning("STUB: AI: aiNoneInit2 required");
 }
 
 // Utility Functions


Commit: 34b9457adcb7ffc428fc8ce069e8a10dc3e79077
    https://github.com/scummvm/scummvm/commit/34b9457adcb7ffc428fc8ce069e8a10dc3e79077
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:09+02:00

Commit Message:
HDB: Delete functions missing from original

Changed paths:
    engines/hdb/ai-player.cpp
    engines/hdb/ai.h


diff --git a/engines/hdb/ai-player.cpp b/engines/hdb/ai-player.cpp
index a249884..eefede5 100644
--- a/engines/hdb/ai-player.cpp
+++ b/engines/hdb/ai-player.cpp
@@ -773,14 +773,6 @@ void aiBarrelHeavyInit(AIEntity *e) {
 	e->aiAction = aiBarrelHeavyAction;
 }
 
-void aiBarrelExplosionEnd(AIEntity *e) {
-	warning("STUB: AI: aiBarrelExplosionEnd required");
-}
-
-void aiBarrelExplosionAction(AIEntity *e) {
-	warning("STUB: AI: aiBarrelExplosionAction required");
-}
-
 void aiBarrelExplode(AIEntity *e) {
 	e->state = STATE_EXPLODING;
 	e->animDelay = e->animCycle;
diff --git a/engines/hdb/ai.h b/engines/hdb/ai.h
index f2259ba..1ab2b86 100644
--- a/engines/hdb/ai.h
+++ b/engines/hdb/ai.h
@@ -47,6 +47,7 @@ enum {
 	kPlayerTouchPWait = 16,
 	kMaxCineGfx = 10,
 	kRunToggleDelay = 2,
+	kMsgDelay = 3,
 	kYouGotX = -1,
 	kYouGotY = (kScreenHeight - 16)
 };


Commit: bebd51479ebc5f2cdd25b872f80db03b048b8937
    https://github.com/scummvm/scummvm/commit/bebd51479ebc5f2cdd25b872f80db03b048b8937
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:09+02:00

Commit Message:
HDB: Add traceStraightPath()

Changed paths:
    engines/hdb/ai-waypoint.cpp
    engines/hdb/ai.h


diff --git a/engines/hdb/ai-waypoint.cpp b/engines/hdb/ai-waypoint.cpp
index 70847ab..c930a0c 100644
--- a/engines/hdb/ai-waypoint.cpp
+++ b/engines/hdb/ai-waypoint.cpp
@@ -71,6 +71,140 @@ void AI::clearWaypoints() {
 	_numWaypoints = 0;
 }
 
+bool AI::traceStraightPath(int x1, int y1, int *x2, int *y2, int *level) {
+	int	xVel, yVel, ok, entOK;
+	AIEntity *e;
+
+	// this checks to make sure we're only going vert or horz
+	if (x1 != *x2 && y1 != *y2)
+		return false;
+
+	// this sets a -1, 0, or 1 step value
+	xVel = *x2 - x1;
+	if (xVel < 0)
+		xVel = -1;
+	if (xVel > 0)
+		xVel = 1;
+
+	yVel = *y2 - y1;
+	if (yVel < 0)
+		yVel = -1;
+	if (yVel > 0)
+		yVel = 1;
+
+	while (1) {
+		// clear tile ahead?
+		entOK = ok = 0;
+		uint32 flags = g_hdb->_map->getMapBGTileFlags(x1, y1);
+		if (flags & kFlagStairTop)
+			*level = 2;
+		else if (flags & kFlagStairBot)
+			*level = 1;
+
+		// Floor level 1
+		if (*level < 2) {
+			ok = !(flags & (kFlagPlayerBlock | kFlagMonsterBlock));
+			// if it's blocking, is it rad or plasma? (might be melted stuff on it)
+			if (!ok) {
+				ok = ((flags & kFlagPlasmaFloor) == kFlagPlasmaFloor) +
+					((flags & kFlagPlasmaFloor) == kFlagRadFloor);
+				e = findEntity(x1, y1);
+				if (e && g_hdb->_ai->walkThroughEnt(e->type))
+					entOK = 1;
+				else if (ok && e && (e->state == STATE_FLOATING || e->state == STATE_MELTED || e == _player))
+					entOK = ok = 1;
+				else
+					ok = 0;
+			} else if (ok &&
+				((flags & kFlagWater) == kFlagWater ||
+				(flags & kFlagSlime) == kFlagSlime)) {
+				// if it's non-blocking, is there water or slime?
+				e = findEntity(x1, y1);
+				if (e && g_hdb->_ai->walkThroughEnt(e->type))
+					entOK = 1;
+				else
+					if (e && (e->state == STATE_FLOATING || e->state == STATE_MELTED || e == _player))
+						entOK = ok = 1;
+					else
+						ok = 0;
+				}
+		} else {
+			// Floor level 2
+			if (g_hdb->_map->getMapFGTileIndex(x1, y1) >= 0)			// is there a foregnd tile? its flags take precedence on Level 2
+				ok = !(g_hdb->_map->getMapFGTileFlags(x1, y1) & (kFlagPlayerBlock | kFlagMonsterBlock));
+			else {
+				flags = g_hdb->_map->getMapBGTileFlags(x1, y1);
+				ok = !(flags & (kFlagPlayerBlock | kFlagMonsterBlock));
+				// if it's blocking, is it rad or plasma? (might be melted stuff on it)
+				if (!ok) {
+					ok = ((flags & kFlagPlasmaFloor) == kFlagPlasmaFloor) +
+						((flags & kFlagPlasmaFloor) == kFlagRadFloor);
+					e = findEntity(x1, y1);
+					if (e && g_hdb->_ai->walkThroughEnt(e->type))
+						entOK = 1;
+					else if (ok && e && (e->state == STATE_FLOATING || e->state == STATE_MELTED || e == _player))
+							entOK = ok = 1;
+					else
+						ok = 0;
+				} else if (ok &&
+					((flags & kFlagWater) == kFlagWater ||
+					(flags & kFlagSlime) == kFlagSlime)) {
+					// if it's non-blocking, is there water or slime?
+					e = findEntity(x1, y1);
+					if (e && g_hdb->_ai->walkThroughEnt(e->type))
+						entOK = 1;
+					else
+						if (e && (e->state == STATE_FLOATING || e->state == STATE_MELTED || e == _player))
+							entOK = ok = 1;
+						else
+							ok = 0;
+				}
+			}
+		}
+
+		if (ok) {
+			e = findEntity(x1, y1);
+			if (e == _player)
+				e = NULL;
+			else if (g_hdb->_map->laserBeamExist(x1, y1)) {
+				*x2 = x1 - xVel;
+				*y2 = y1 - yVel;
+				return true;
+			} else if (e && (e->level != _player->level) && (g_hdb->_map->getMapFGTileFlags(e->tileX, e->tileY) & kFlagGrating)) {
+				// on the same level????
+				entOK = 1;
+			}
+
+			if (e && !entOK) {
+				if (g_hdb->_ai->walkThroughEnt(e->type)) {
+					// yes! are we at desired location?
+					if (x1 == *x2 && y1 == *y2)
+						return true;
+				} else {
+					// solid tile! back up one and return!
+					*x2 = x1 - xVel;
+					*y2 = y1 - yVel;
+					return true;
+				}
+			} else if (x1 == *x2 && y1 == *y2) {
+				// yes! are we at desired location?
+				return true;
+			}
+		} else	{
+			// solid tile! back up one and return!
+			*x2 = x1 - xVel;
+			*y2 = y1 - yVel;
+
+			return true;
+		}
+
+		x1 += xVel;
+		y1 += yVel;
+	}
+
+	return true;
+}
+
 Tile *AI::getStandFrameDir(AIEntity *e) {
 	switch (e->dir) {
 	case DIR_DOWN:
diff --git a/engines/hdb/ai.h b/engines/hdb/ai.h
index 1ab2b86..80f7a71 100644
--- a/engines/hdb/ai.h
+++ b/engines/hdb/ai.h
@@ -946,6 +946,7 @@ public:
 	void addWaypoint(int px, int py, int x, int y, int level);
 	void removeFirstWaypoint();
 	void clearWaypoints();
+	bool traceStraightPath(int x1, int y1, int *x2, int *y2, int *lvl);
 	Tile *getStandFrameDir(AIEntity *e);
 	void drawWayPoints();
 	int waypointsLeft() {


Commit: b8b47c09fd7862e3f7b212ef8a2686cab5320858
    https://github.com/scummvm/scummvm/commit/b8b47c09fd7862e3f7b212ef8a2686cab5320858
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:09+02:00

Commit Message:
HDB: Unstub addWaypoint()

Changed paths:
    engines/hdb/ai-waypoint.cpp


diff --git a/engines/hdb/ai-waypoint.cpp b/engines/hdb/ai-waypoint.cpp
index c930a0c..6e153a6 100644
--- a/engines/hdb/ai-waypoint.cpp
+++ b/engines/hdb/ai-waypoint.cpp
@@ -29,7 +29,8 @@ void AI::addWaypoint(int px, int py, int x, int y, int level) {
 		return;
 
 	// Check for duplicates
-	for (int i = 0; i < _numWaypoints; i++)
+	int i;
+	for (i = 0; i < _numWaypoints; i++)
 		if (_waypoints[i].x == x && _waypoints[i].y == y)
 			return;
 
@@ -37,9 +38,299 @@ void AI::addWaypoint(int px, int py, int x, int y, int level) {
 	int nx = x;
 	int ny = y;
 	if (!_numWaypoints) {
-		warning("STUB: addWaypoint: Setup First Waypoint");
+		// if player is already moving and this is the first waypoint, forget it.
+		// player is using the keyboard and must be fully stopped before laying 
+		// the first waypoint
+		if (_player->goalX)
+			return;
+
+		// trace from player to new spot
+		// return value of 0 only means a diagonal was selected!
+		if (!traceStraightPath(px, py, &nx, &ny, &level)) {
+			int	tx, ty, tx2, ty2;
+
+			// it didn't work, so player is probably trying some diagonal movement.
+			// let's break it down into two waypoints: one horz, one vert
+			tx = nx;
+			ty = py;
+			tx2 = nx;
+			ty2 = ny;
+			int	lvl1, lvl2;
+
+			lvl1 = lvl2 = level;
+
+			if (traceStraightPath(px, py, &tx, &ty, &lvl1)) {
+				if (tx != nx || ty != py) {
+					tx = px;
+					ty = ny;
+					tx2 = nx;
+					ty2 = ny;
+
+					lvl1 = lvl2 = level;
+
+					if (traceStraightPath(px, py, &tx, &ty, &lvl1)) {
+						if (tx != px || ty != ny)
+							return;
+
+						traceStraightPath(tx, ty, &nx, &ny, &lvl2);
+
+						if (tx2 != nx || ty2 != ny)
+							return;
+
+						_waypoints[_numWaypoints].x = tx;
+						_waypoints[_numWaypoints].y = ty;
+						_waypoints[_numWaypoints].level = lvl1;
+						_numWaypoints++;
+						_waypoints[_numWaypoints].x = nx;
+						_waypoints[_numWaypoints].y = ny;
+						_waypoints[_numWaypoints].level = lvl2;
+						_numWaypoints++;
+						warning("STUB: Play SND_MENU_SLIDER");
+
+						if (onEvenTile(_player->x, _player->y))
+							setEntityGoal(_player, tx, ty);
+					}
+				}
+
+				traceStraightPath(tx, ty, &tx2, &ty2, &lvl2);
+
+				if (tx2 != nx || ty2 != ny) {
+					tx = px;
+					ty = ny;
+					tx2 = nx;
+					ty2 = ny;
+
+					lvl1 = lvl2 = level;
+
+					if (traceStraightPath(px, py, &tx, &ty, &lvl1)) {
+						if (tx != px || ty != ny)
+							return;
+
+						traceStraightPath(tx, ty, &nx, &ny, &lvl2);
+
+						if (tx2 != nx || ty2 != ny)
+							return;
+
+						_waypoints[_numWaypoints].x = tx;
+						_waypoints[_numWaypoints].y = ty;
+						_waypoints[_numWaypoints].level = lvl1;
+						_numWaypoints++;
+						_waypoints[_numWaypoints].x = nx;
+						_waypoints[_numWaypoints].y = ny;
+						_waypoints[_numWaypoints].level = lvl2;
+						_numWaypoints++;
+						warning("STUB: Play SND_MENU_SLIDER");
+
+						if (onEvenTile(_player->x, _player->y))
+							setEntityGoal(_player, tx, ty);
+					}
+				}
+
+				_waypoints[_numWaypoints].x = tx;
+				_waypoints[_numWaypoints].y = ty;
+				_waypoints[_numWaypoints].level = lvl1;
+				_numWaypoints++;
+				_waypoints[_numWaypoints].x = nx;
+				_waypoints[_numWaypoints].y = ny;
+				_waypoints[_numWaypoints].level = lvl2;
+				_numWaypoints++;
+				warning("STUB: Play SND_MENU_SLIDER");
+
+				if (onEvenTile(_player->x, _player->y))
+					setEntityGoal(_player, tx, ty);
+			} else {
+				tx = px;
+				ty = ny;
+				tx2 = nx;
+				ty2 = ny;
+
+				lvl1 = lvl2 = level;
+
+				if (traceStraightPath(px, py, &tx, &ty, &lvl1)) {
+					if (tx != px || ty != ny)
+						return;
+
+					traceStraightPath(tx, ty, &nx, &ny, &lvl2);
+
+					if (tx2 != nx || ty2 != ny)
+						return;
+
+					_waypoints[_numWaypoints].x = tx;
+					_waypoints[_numWaypoints].y = ty;
+					_waypoints[_numWaypoints].level = lvl1;
+					_numWaypoints++;
+					_waypoints[_numWaypoints].x = nx;
+					_waypoints[_numWaypoints].y = ny;
+					_waypoints[_numWaypoints].level = lvl2;
+					_numWaypoints++;
+					warning("STUB: Play SND_MENU_SLIDER");
+
+					if (onEvenTile(_player->x, _player->y))
+						setEntityGoal(_player, tx, ty);
+				}
+			}
+			return;
+		}
+
+		// create a waypoint @ the player x,y? NO!
+		if ((nx != px || ny != py) && onEvenTile(_player->x, _player->y))
+			setEntityGoal(_player, nx, ny);
+		else
+			return;
 	} else {
-		warning("STUB: addWaypoint: Setup additional Waypoints");
+		// trace from last waypoint to new spot
+		level = _waypoints[_numWaypoints - 1].level;
+
+		if (!traceStraightPath(_waypoints[_numWaypoints - 1].x, _waypoints[_numWaypoints - 1].y, &nx, &ny, &level)) {
+			int		tx, ty, tx2, ty2;
+
+			// it didn't work, so player is probably trying some diagonal movement.
+			// let's break it down into two waypoints: one horz, one vert
+			px = _waypoints[_numWaypoints - 1].x;
+			py = _waypoints[_numWaypoints - 1].y;
+			level = _waypoints[_numWaypoints - 1].level;
+
+			tx = nx;
+			ty = py;
+			tx2 = nx;
+			ty2 = ny;
+			int	lvl1, lvl2;
+
+			lvl1 = lvl2 = level;
+
+			if (traceStraightPath(px, py, &tx, &ty, &lvl1)) {
+				if (tx != nx || ty != py) {
+					tx = px;
+					ty = ny;
+					tx2 = nx;
+					ty2 = ny;
+
+					lvl1 = lvl2 = level;
+
+					if (traceStraightPath(px, py, &tx, &ty, &lvl1)) {
+						if (tx != px || ty != ny)
+							return;
+
+						traceStraightPath(tx, ty, &nx, &ny, &lvl2);
+
+						if (tx2 != nx || ty2 != ny)
+							return;
+
+						if (_numWaypoints < kMaxWaypoints) {
+							_waypoints[_numWaypoints].x = tx;
+							_waypoints[_numWaypoints].y = ty;
+							_waypoints[_numWaypoints].level = lvl1;
+							_numWaypoints++;
+							warning("STUB: Play SND_MENU_SLIDER");
+						}
+
+						if (_numWaypoints < kMaxWaypoints) {
+							_waypoints[_numWaypoints].x = nx;
+							_waypoints[_numWaypoints].y = ny;
+							_waypoints[_numWaypoints].level = lvl2;
+							_numWaypoints++;
+							warning("STUB: Play SND_MENU_SLIDER");
+						}
+					}
+				}
+
+				traceStraightPath(tx, ty, &tx2, &ty2, &lvl2);
+
+				if (tx2 != nx || ty2 != ny) {
+					tx = px;
+					ty = ny;
+					tx2 = nx;
+					ty2 = ny;
+
+					lvl1 = lvl2 = level;
+
+					if (traceStraightPath(px, py, &tx, &ty, &lvl1)) {
+						if (tx != px || ty != ny)
+							return;
+
+						traceStraightPath(tx, ty, &nx, &ny, &lvl2);
+
+						if (tx2 != nx || ty2 != ny)
+							return;
+
+						if (_numWaypoints < kMaxWaypoints) {
+							_waypoints[_numWaypoints].x = tx;
+							_waypoints[_numWaypoints].y = ty;
+							_waypoints[_numWaypoints].level = lvl1;
+							_numWaypoints++;
+							warning("STUB: Play SND_MENU_SLIDER");
+						}
+
+						if (_numWaypoints < kMaxWaypoints) {
+							_waypoints[_numWaypoints].x = nx;
+							_waypoints[_numWaypoints].y = ny;
+							_waypoints[_numWaypoints].level = lvl2;
+							_numWaypoints++;
+							warning("STUB: Play SND_MENU_SLIDER");
+						}
+					}
+				}
+
+				if (_numWaypoints < kMaxWaypoints) {
+					_waypoints[_numWaypoints].x = tx;
+					_waypoints[_numWaypoints].y = ty;
+					_waypoints[_numWaypoints].level = lvl1;
+					_numWaypoints++;
+					warning("STUB: Play SND_MENU_SLIDER");
+				}
+
+				if (_numWaypoints < kMaxWaypoints) {
+					_waypoints[_numWaypoints].x = nx;
+					_waypoints[_numWaypoints].y = ny;
+					_waypoints[_numWaypoints].level = lvl2;
+					_numWaypoints++;
+					warning("STUB: Play SND_MENU_SLIDER");
+				}
+			} else {
+				tx = px;
+				ty = ny;
+				tx2 = nx;
+				ty2 = ny;
+
+				lvl1 = lvl2 = level;
+
+				if (traceStraightPath(px, py, &tx, &ty, &lvl1)) {
+					if (tx != px || ty != ny)
+						return;
+
+					traceStraightPath(tx, ty, &nx, &ny, &lvl2);
+
+					if (tx2 != nx || ty2 != ny)
+						return;
+
+					if (_numWaypoints < kMaxWaypoints) {
+						_waypoints[_numWaypoints].x = tx;
+						_waypoints[_numWaypoints].y = ty;
+						_waypoints[_numWaypoints].level = lvl1;
+						_numWaypoints++;
+						warning("STUB: Play SND_MENU_SLIDER");
+					}
+
+					if (_numWaypoints < kMaxWaypoints) {
+						_waypoints[_numWaypoints].x = nx;
+						_waypoints[_numWaypoints].y = ny;
+						_waypoints[_numWaypoints].level = lvl2;
+						_numWaypoints++;
+						warning("STUB: Play SND_MENU_SLIDER");
+					}
+				}
+			}
+			return;
+		}
+
+		// create a waypoint @ the player x,y? NO!
+		if (nx == px && ny == py)
+			return;
+
+		// make sure potential waypoint isn't on other waypoints!			
+		for (i = 0; i < _numWaypoints; i++)
+			if (_waypoints[i].x == nx && _waypoints[i].y == ny)
+				return;
 	}
 
 	if (_numWaypoints < kMaxWaypoints) {


Commit: 5d874c540e4f52ff5b32f8679b98ea57d7c1611c
    https://github.com/scummvm/scummvm/commit/5d874c540e4f52ff5b32f8679b98ea57d7c1611c
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:09+02:00

Commit Message:
HDB: Add and init Sound subsystem

Changed paths:
  A engines/hdb/sound.cpp
  A engines/hdb/sound.h
    engines/hdb/hdb.cpp
    engines/hdb/hdb.h
    engines/hdb/module.mk


diff --git a/engines/hdb/hdb.cpp b/engines/hdb/hdb.cpp
index 7cff30e..978e85c 100644
--- a/engines/hdb/hdb.cpp
+++ b/engines/hdb/hdb.cpp
@@ -48,6 +48,7 @@ HDBGame::HDBGame(OSystem *syst, const ADGameDescription *gameDesc) : Engine(syst
 	_map = new Map;
 	_ai = new AI;
 	_input = new Input;
+	_sound = new Sound;
 	_window = new Window;
 	_rnd = new Common::RandomSource("hdb");
 
@@ -63,6 +64,7 @@ HDBGame::~HDBGame() {
 	delete _map;
 	delete _ai;
 	delete _input;
+	delete _sound;
 	delete _window;
 	delete _rnd;
 
@@ -91,6 +93,9 @@ bool HDBGame::init() {
 	if (!_lua->init()) {
 		error("LuaScript::init: Couldn't load the GLOBAL_LUA code.");
 	}
+	if (!_sound->init()) {
+		error("Window::init: Couldn't initialize Sound");
+	}
 	if (!_window->init()) {
 		error("Window::init: Couldn't initialize Window");
 	}
diff --git a/engines/hdb/hdb.h b/engines/hdb/hdb.h
index d3e983b..c93cdf4 100644
--- a/engines/hdb/hdb.h
+++ b/engines/hdb/hdb.h
@@ -45,6 +45,7 @@
 #include "hdb/input.h"
 #include "hdb/lua-script.h"
 #include "hdb/map.h"
+#include "hdb/sound.h"
 #include "hdb/window.h"
 
 #define MAX_SNDCACHE_MEM	0x400000	// 4Mb of sounds in memory
@@ -135,6 +136,7 @@ public:
 	Map *_map;
 	AI *_ai;
 	Input *_input;
+	Sound *_sound;
 	Window *_window;
 
 	// Random Source
diff --git a/engines/hdb/module.mk b/engines/hdb/module.mk
index 57972cb..e6417b9 100644
--- a/engines/hdb/module.mk
+++ b/engines/hdb/module.mk
@@ -18,6 +18,7 @@ MODULE_OBJS := \
 	input.o \
 	lua-script.o \
 	map.o \
+	sound.o \
 	window.o
 
 MODULE_DIRS += \
diff --git a/engines/hdb/sound.cpp b/engines/hdb/sound.cpp
new file mode 100644
index 0000000..12f64ad
--- /dev/null
+++ b/engines/hdb/sound.cpp
@@ -0,0 +1,41 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "hdb/hdb.h"
+
+namespace HDB {
+
+bool Sound::init() {
+	return true;
+}
+
+bool Sound::playSound(int index) {
+	warning("STUB: Play Sound");
+	return true;
+}
+
+bool Sound::playVoice(int index, int actor) {
+	warning("STUB: Play Voice");
+	return true;
+}
+
+} // End of Namespace
diff --git a/engines/hdb/sound.h b/engines/hdb/sound.h
new file mode 100644
index 0000000..1493ad2
--- /dev/null
+++ b/engines/hdb/sound.h
@@ -0,0 +1,1390 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef HDB_SOUND_H
+#define HDB_SOUND_H
+
+namespace HDB {
+
+enum SoundType {
+	SONG_NONE,
+	SND_GUI_INPUT,
+	SND_MAIL_PROCESS,
+	SND_MONKEY_OOHOOH,
+	SND_GET_GEM,
+	SND_MENU_ACCEPT,
+	SND_MENU_BACKOUT,
+	SND_MENU_SLIDER,
+	SND_DIALOG_CLOSE,
+	SND_CRATE_SLIDE,
+	SND_LIGHT_SLIDE,
+	SND_HEAVY_SLIDE,
+	SND_POP,
+	SND_TELEPORT,
+	SND_FOOTSTEPS,
+	SND_SPLASH,
+	SND_CELLHOLDER_USE_REJECT,
+	SND_CHICKEN_AMBIENT,
+	SND_FERRET_SQUEAK,
+	SND_SWITCH_USE,
+	SND_MOVE_SELECTION,
+	SND_NOTICE,
+	SND_MAINTBOT_WHOOSH1,
+	SND_MAINTBOT_WHOOSH2,
+	SND_SHIPMOVING_INTRO,
+	SND_DIALOG_OPEN,
+	SND_TOUCHPLATE_CLICK,
+	SND_DOOR_OPEN_CLOSE,
+	SND_MBOT_HYEAH,
+	SND_MBOT_YEAH,
+	SND_MBOT_WHISTLE1,
+	SND_CLUB_MISS,
+	SND_CLUB_HIT_METAL,
+	SND_CLUB_HIT_FLESH,
+	SND_FROG_LICK,
+	SND_ROBOT_STUNNED,
+	SND_QUEST_FAILED,
+	SND_GET_MONKEYSTONE,
+	SND_INSERT_CELL,
+	SND_CABINET_OPEN,
+	SND_CABINET_CLOSE,
+	SND_MAILSORTER_HAPPY,
+	SND_QUEST_COMPLETE,
+	SND_TRY_AGAIN,
+	SND_AIRLOCK_CLOSE,
+	SND_BYE,
+	SND_FART,
+	SND_FART2,
+	SND_GUY_UHUH,
+	SND_GUY_DYING,
+	SND_GEM_THROW,
+	SND_INV_SELECT,
+	SND_INFOCOMP,
+	SND_CLOCK_BONK,
+	SND_HDB,
+	SND_VORTEX_SAVE,
+	SND_GET_GOO,
+	SND_MANNY_CRASH,
+	SND_BARREL_EXPLODE,
+	SND_BARREL_MELTING,
+	SND_CHICKEN_BAGAWK,
+	SND_CHICKEN_DEATH,
+	SND_GET_THING,
+	SND_STEPS_ICE,
+	SND_FOURFIRE_TURN,
+	SND_FOUR_FIRE,
+	SND_SHOCKBOT_AMBIENT,
+	SND_SHOCKBOT_SHOCK,
+	SND_RAILRIDER_ONTRACK,
+	SND_RAILRIDER_TASTE,
+	SND_RAILRIDER_EXIT,
+	SND_GUY_FRIED,
+	SND_MAILSORTER_UNHAPPY,
+	SND_GET_CLUB,
+	SND_BUZZFLY_FLY,
+	SND_BUZZFLY_STUNNED,
+	SND_BUZZFLY_STING,
+	SND_FATFROG_STUNNED,
+	SND_NOPUSH_SIZZLE,
+	SND_OMNIBOT_FIRE,
+	SND_RIGHTBOT_TURN,
+	SND_RIGHTBOT_STUNNED,
+	SND_MONKEY_WIN,
+	SND_FALL_DOWN_HOLE,
+	SND_MBOT_HMMM,
+	SND_MBOT_HMMM2,
+	SND_MBOT_DEATH,
+	SND_MBOT_WHISTLE2,
+	SND_MBOT_WHISTLE3,
+	SND_DEADEYE_AMB01,
+	SND_DEADEYE_AMB02,
+	SND_DEADEYE_ATTACK01,
+	SND_DEADEYE_ATTACK02,
+	SND_FROG_RIBBIT1,
+	SND_FROG_RIBBIT2,
+	SND_MEERKAT_BITE,
+	SND_BRIDGE_EXTEND,
+	SND_BRIDGE_START,
+	SND_BRIDGE_END,
+	SND_MACHINE_AMBIENT1,
+	SND_GET_STUNNER,
+	SND_GET_SLUG,
+	SND_GUY_DROWN,
+	SND_GUY_GRABBED,
+	SND_BEEPBEEPBEEP,
+	SND_PANIC,
+	SND_PANIC_COUNT,
+	SND_PANIC_DEATH,
+	SND_LASER_LOOP,
+	SND_SLOT_WIN,
+	SND_SLOT_SPIN,
+	SND_SLOT_STOP,
+	SND_GOOD_FAERIE_AMBIENT,
+	SND_GOOD_FAERIE_SPELL,
+	SND_GOOD_FAERIE_STUNNED,
+	SND_ICEPUFF_WARNING,
+	SND_ICEPUFF_THROW,
+	SND_ICEPUFF_STUNNED,
+	SND_ICEPUFF_APPEAR,
+	SND_GUY_PLUMMET,
+	SND_PUSH_DIVERTER,
+	SND_TURNBOT_TURN,
+	SND_PUSHBOT_STRAIN,
+	SND_MONKEYSTONE_SECRET_STAR,
+	SND_OMNIBOT_AMBIENT,
+	SND_PUSHBOT_STUNNED,
+	SND_MEERKAT_WARNING,
+	SND_MEERKAT_APPEAR,
+	SND_MEERKAT_STUNNED,
+	SND_TURNBOT_STUNNED,
+	SND_DRAGON_WAKE,
+	SND_DRAGON_FALLASLEEP,
+	SND_DRAGON_BREATHEFIRE,
+	SND_BADFAIRY_AMBIENT,
+	SND_BADFAIRY_SPELL,
+	SND_BADFAIRY_STUNNED,
+	SND_DEMIGOD_AMBIENT,
+	SND_DEMIGOD_HOLYSPEECH,
+	SND_DEMIGOD_UNHAPPY,
+	SND_GATEPUDDLE_AMBIENT,
+	SND_GATEPUDDLE_DISSIPATE,
+	SND_GATEPUDDLE_SPAWN,
+	SND_REALSLOT_SPIN,
+	SND_REALSLOT_STOP,
+	SND_REALSLOT_WIN,
+	SND_SLUG_FIRE,
+	SND_SLUG_HIT,
+	SND_STUNNER_FIRE,
+	SND_UNLOCKED_ITEM,
+
+	SONG_TITLE,
+	SONG_MENU,
+	SONG_ROBO,
+	SONG_MEXI,
+	SONG_BASSO,
+	SONG_WIND,
+	SONG_INDUSTRO,
+	SONG_JACKIN,
+	SONG_SNEAKERS,
+	SONG_QUIET,
+	SONG_JEEBIES,
+	SONG_VIBRACIOUS,
+	SONG_ROMANTIC,
+	SONG_ARETHERE,
+
+	SONG_CORRIDOR,
+	SONG_MOKE,
+	SONG_TILES,
+	SONG_DARKVIB,
+	SONG_EXPER,
+
+	V00_AIRLOCK_01,
+	V00_ARNIE_01,
+
+	V00_BRAD_01,
+	V00_BRAD_02,
+	V00_BRAD_03,
+
+	V00_BUSTER_01,
+	V00_BUSTER_02,
+	V00_BUSTER_03,
+	V00_BUSTER_04,
+	V00_BUSTER_05,
+	V00_BUSTER_06,
+	V00_BUSTER_07,
+	V00_BUSTER_08,
+	V00_BUSTER_09,
+	V00_BUSTER_10,
+	V00_BUSTER_11,
+	V00_BUSTER_12,
+	V00_BUSTER_13A,
+	V00_BUSTER_13B,
+	V00_BUSTER_14,
+	V00_BUSTER_15,
+	V00_BUSTER_16,
+	V00_BUSTER_17,
+	V00_BUSTER_18,
+	V00_BUSTER_19,
+
+	V00_CHICKEN_01,
+
+	V00_CHUTEGUARD_01,
+	V00_CHUTEGUARD_02,
+	V00_CHUTEGUARD_03,
+	V00_CHUTEGUARD_04,
+	V00_CHUTEGUARD_05,
+
+	V00_COOPER_01,
+	V00_COOPER_02,
+	V00_COOPER_03,
+	V00_COOPER_04,
+	V00_COOPER_05,
+
+	V00_DINERS_01,
+	V00_DINERS_02,
+	V00_DINERS_03,
+	V00_DINERS_04,
+	V00_DINERS_05,
+	V00_DINERS_06,
+
+	V00_DOLLY_01,
+	V00_DOLLY_02,
+	V00_DOLLY_03,
+	V00_DOLLY_04,
+	V00_DOLLY_05,
+	V00_DOLLY_06,
+	V00_DOLLY_07,
+	V00_DOLLY_08,
+	V00_DOLLY_09,
+
+	V00_DOREK_01,
+	V00_DOREK_02,
+	V00_DOREK_03,
+	V00_DOREK_04,
+
+	V00_ENGCOMPUTER_01,
+	V00_ENGCOMPUTER_02,
+
+	V00_FARBLE_01,
+	V00_FARBLE_02,
+	V00_FARBLE_03,
+	V00_FARBLE_04,
+	V00_FARBLE_05,
+	V00_FARBLE_06,
+	V00_FARBLE_07,
+	V00_FARBLE_08,
+
+	V00_GRUNETT_01,
+	V00_GRUNETT_02,
+	V00_GRUNETT_03,
+	V00_GRUNETT_04,
+
+	V00_GUY_01,
+	V00_GUY_02,
+	V00_GUY_03,
+	V00_GUY_04,
+	V00_GUY_05,
+	V00_GUY_06,
+	V00_GUY_07,
+	V00_GUY_08,
+	V00_GUY_09,
+	V00_GUY_10A,
+	V00_GUY_10B,
+	V00_GUY_11,
+	V00_GUY_12,
+	V00_GUY_13,
+	V00_GUY_14,
+	V00_GUY_15,
+	V00_GUY_16,
+	V00_GUY_17,
+	V00_GUY_18,
+
+	V00_HUMBERT_01,
+	V00_HUMBERT_02,
+
+	V00_ILLIAC_01,
+	V00_INFOCOMP_01,
+
+	V00_JAQUES_01,
+	V00_JAQUES_03,
+	V00_JAQUES_04,
+	V00_JAQUES_05,
+
+	V00_LUMBAR_01,
+
+	V00_MAILSORTER_01,
+	V00_MAILSORTER_02,
+	V00_MAILSORTER_03,
+	V00_MAILSORTER_04,
+	V00_MAILSORTER_05,
+	V00_MAILSORTER_06,
+	V00_MAILSORTER_07,
+	V00_MAILSORTER_08,
+	V00_MAILSORTER_09,
+	V00_MAILSORTER_10,
+	V00_MAILSORTER_11,
+	V00_MAILSORTER_12,
+	V00_MAILSORTER_13,
+	V00_MAILSORTER_14,
+	V00_MAILSORTER_15,
+
+	V00_MANNY_01,
+	V00_MANNY_02,
+	V00_MANNY_03,
+	V00_MANNY_04,
+	V00_MANNY_05,
+	V00_MANNY_06,
+	V00_MANNY_07,
+	V00_MANNY_08,
+	V00_MANNY_09,
+	V00_MANNY_10,
+	V00_MANNY_11,
+	V00_MANNY_12,
+	V00_MANNY_13,
+	V00_MANNY_14,
+	V00_MANNY_15,
+	V00_MANNY_16,
+	V00_MANNY_17,
+	V00_MANNY_18,
+
+	V00_NOTEBRICK_01,
+
+	V00_PILOTS_01,
+	V00_PILOTS_02,
+
+	V00_POLONEY_01,
+	V00_POLONEY_02,
+	V00_POLONEY_03,
+	V00_POLONEY_04,
+	V00_POLONEY_05,
+	V00_POLONEY_06,
+
+	V00_SARGE_01,
+	V00_SARGE_02,
+	V00_SARGE_03,
+	V00_SARGE_04,
+	V00_SARGE_05,
+	V00_SARGE_06,
+	V00_SARGE_07,
+	V00_SARGE_08,
+	V00_SARGE_09,
+	V00_SARGE_10,
+	V00_SARGE_11,
+	V00_SARGE_12,
+	V00_SARGE_13,
+	V00_SARGE_14,
+	V00_SARGE_15,
+	V00_SARGE_16,
+
+	V01_ALABASTER_01,
+	V01_ALABASTER_02,
+	V01_ALABASTER_03,
+	V01_ALABASTER_04,
+	V01_ALABASTER_05,
+	V01_ALABASTER_06,
+	V01_BRAKER_01,
+	V01_BRAKER_02,
+	V01_BRAKER_03,
+	V01_BRAKER_04,
+	V01_CHISTE_01,
+	V01_CHISTE_02,
+	V01_CHISTE_03,
+	V01_CHISTE_04,
+	V01_CHISTE_05,
+	V01_CHISTE_06,
+	V01_CHISTE_07,
+	V01_CHISTE_08,
+	V01_CHISTE_09,
+	V01_CHISTE_10,
+	V01_CHISTE_11,
+	V01_CHISTE_12,
+	V01_CHISTE_13,
+	V01_CHISTE_14,
+	V01_COVERT_01,
+	V01_COVERT_02,
+	V01_COVERT_03,
+	V01_COVERT_04,
+	V01_COVERT_05,
+	V01_COVERT_06,
+	V01_COVERT_07,
+	V01_COVERT_08,
+	V01_COVERT_09,
+	V01_COVERT_10,
+	V01_COVERT_11,
+	V01_COVERT_12,
+	V01_COVERT_13,
+	V01_DAGEAUBE_01,
+	V01_DAGEAUBE_02,
+	V01_DAGEAUBE_03,
+	V01_DAGEAUBE_04,
+	V01_DAGEAUBE_05,
+	V01_EMC2_01,
+	V01_EMC2_02,
+	V01_GIZZARD_01,
+	V01_GIZZARD_02,
+	V01_GUY_01,
+	V01_GUY_02,
+	V01_GUY_03,
+	V01_GUY_04,
+	V01_GUY_05,
+	V01_HIDROW_01,
+	V01_HIDROW_02,
+	V01_HIDROW_03,
+	V01_KEBOTTLE_01,
+	V01_KEBOTTLE_02,
+	V01_KEBOTTLE_03,
+	V01_KEBOTTLE_04,
+	V01_KEBOTTLE_05,
+	V01_KEBOTTLE_06,
+	V01_KEBOTTLE_07,
+	V01_PONTE_01,
+	V01_PONTE_02,
+	V01_PONTE_03,
+	V01_PONTE_04,
+	V01_PONTE_05,
+	V01_PONTE_06,
+	V01_PONTE_07,
+	V01_PONTE_08,
+	V01_PONTE_09,
+	V01_PONTE_10,
+	V01_POPOPOLIS_01,
+	V01_POPOPOLIS_02,
+	V01_POPOPOLIS_03,
+	V01_POPOPOLIS_04,
+	V01_POPOPOLIS_05,
+	V01_POPOPOLIS_06,
+	V01_POPOPOLIS_07,
+	V01_POPOPOLIS_08,
+	V01_POPOPOLIS_09,
+	V01_POPOPOLIS_10,
+	V01_POPOPOLIS_11,
+	V01_POPOPOLIS_12,
+	V01_POPOPOLIS_13,
+	V01_POPOPOLIS_14,
+	V01_POPOPOLIS_15,
+	V01_POPOPOLIS_16,
+	V01_POPOPOLIS_17,
+	V01_POPOPOLIS_18,
+	V01_POPOPOLIS_19,
+	V01_POPOPOLIS_20,
+	V01_POPOPOLIS_21,
+	V01_POPOPOLIS_22,
+	V01_POPOPOLIS_23,
+	V01_POPOPOLIS_24,
+	V01_POPOPOLIS_25,
+	V01_POPOPOLIS_26,
+	V01_POPOPOLIS_27,
+	V01_POPOPOLIS_28,
+	V01_POPOPOLIS_29,
+	V01_POPOPOLIS_30,
+	V01_POPOPOLIS_31,
+	V01_POPOPOLIS_32,
+	V01_POPOPOLIS_33,
+	V01_POPOPOLIS_34,
+	V01_POPOPOLIS_35,
+	V01_POPOPOLIS_36,
+	V01_POPOPOLIS_37,
+	V01_SARGE_01,
+	V01_SARGE_02,
+	V01_SARGE_03,
+	V01_SARGE_04,
+	V01_SOBREDELLE_01,
+	V01_SOBREDELLE_02,
+	V01_SOBREDELLE_03,
+	V01_WAYNE_01,
+	V01_WAYNE_02,
+	V01_ZIQUOZ_01,
+	V01_ZIQUOZ_02,
+	V01_ZIQUOZ_03,
+
+	V02_AGUSTO_01,
+	V02_AGUSTO_02,
+	V02_ALBONDIGAS_01,
+	V02_ALBONDIGAS_02,
+	V02_BUMPER_01,
+	V02_BUMPER_02,
+	V02_BUMPER_03,
+	V02_BUMPER_04,
+	V02_BUMPER_05,
+	V02_BUMPER_06,
+	V02_BUMPER_07,
+	V02_DELGADO_01,
+	V02_FEBRARO_01,
+	V02_GUY_01,
+	V02_GUY_02,
+	V03_ACROPHO_01,
+	V03_ACROPHO_02,
+	V03_ACROPHO_03,
+	V03_ACROPHO_04,
+	V03_ENERO_01,
+	V03_ENERO_02,
+	V03_ENERO_03,
+	V03_ENERO_04,
+	V03_ENERO_05,
+	V03_GAIA_01,
+	V03_GAIA_02,
+	V03_GAIA_03,
+	V03_GAIA_04,
+	V03_GAIA_05,
+	V03_GAIA_06,
+	V03_LAGO_01,
+	V03_LAGO_02,
+	V03_LAGO_04,
+	V03_LAGO_05,
+	V03_LAGO_06,
+	V03_LAGO_07,
+	V04_BONIFACE_01,
+	V04_BONIFACE_02,
+	V04_BONIFACE_03,
+	V04_BONIFACE_04,
+	V04_BONIFACE_05,
+	V04_BONIFACE_06,
+	V04_BONIFACE_07,
+	V04_JULIO_01,
+	V04_JULIO_02,
+	V04_JULIO_04,
+	V04_MARZO_01,
+	V04_OCTUBRE_01,
+	V04_OCTUBRE_02,
+	V04_OCTUBRE_03,
+
+	V05_ABRIL_01,
+	V05_ABRIL_02,
+	V05_ABRIL_03,
+	V05_ABRIL_04,
+	V05_ABRIL_05,
+	V05_GELIGELLA_01,
+	V05_GELIGELLA_02,
+	V05_RAILRIDER_01,
+	V05_RAILRIDER_02,
+	V05_RAILRIDER_03,
+	V05_RAILRIDER_04,
+	V05_EVERLOO_01,
+	V05_EVERLOO_02,
+	V05_EVERLOO_03,
+	V05_EVERLOO_04,
+	V06_AZUL_01,
+	V06_AZUL_02,
+	V06_AZUL_03,
+	V06_AZUL_04,
+	V06_AZUL_05,
+	V06_AZUL_06,
+	V06_AZUL_07,
+	V06_AZUL_08,
+	V06_GUY_01,
+	V06_GUY_02,
+	V06_GUY_03,
+	V06_GUY_04,
+	V06_HANSON_01,
+	V06_HANSON_03,
+	V06_HANSON_04,
+	V06_HANSON_05,
+	V06_HANSON_06,
+	V06_HANSON_07,
+	V06_HANSON_08,
+	V06_HANSON_09,
+	V06_HANSON_10,
+	V06_HANSON_11,
+	V06_HANSON_12,
+	V06_JUNIO_01,
+	V06_JUNIO_02,
+	V06_JUNIO_03,
+	V06_JUNIO_04,
+	V06_JUNIO_05,
+	V06_JUNIO_06,
+	V06_JUNIO_07,
+	V06_JUNIO_08,
+	V06_JUNIO_09,
+	V06_NARANJA_01,
+	V06_NARANJA_02,
+	V06_NARANJA_03,
+	V06_NARANJA_04,
+	V06_NARANJA_05,
+	V06_SEPTEMBRE_01,
+	V06_SEPTEMBRE_02,
+	V06_SEPTEMBRE_03,
+	V06_SEPTEMBRE_04,
+	V06_SEPTEMBRE_05,
+	V06_SEPTEMBRE_06,
+	V06_SEPTEMBRE_07,
+	V06_SEPTEMBRE_08,
+	V06_SEPTEMBRE_09,
+	V06_WORKER_01,
+	V06_WORKER_02,
+	V06_WORKER_03,
+	V06_WORKER_04,
+	V07_CERCO_01,
+	V07_CERCO_02,
+	V07_COMPUTER_01,
+	V07_MAYO_01,
+	V07_MAYO_02,
+	V07_NOVIEMBRE_01,
+	V07_NOVIEMBRE_02,
+	V07_NOVIEMBRE_03,
+	V07_PANITO_01,
+	V07_PANITO_02,
+	V07_PANITO_03,
+	V07_PANITO_04,
+	V07_PANITO_05,
+	V08_COOKIE_01,
+	V08_COOKIE_02,
+	V08_DICIEMBRE_01,
+	V08_GUY_01,
+	V08_GUY_02,
+	V08_GUY_03,
+	V08_MACHINA_01,
+	V08_MACHINA_02,
+	V08_MACHINA_03,
+	V08_MACHINA_04,
+	V08_MACHINA_05,
+	V08_MACHINA_06,
+	V08_MACHINA_07,
+	V08_MACHINA_08,
+	V08_MACHINA_09,
+	V08_MESA_01,
+	V08_MESA_02,
+	V08_MESA_03,
+	V08_MESA_04,
+	V08_SHAKIR_01,
+	V08_SHAKIR_02,
+	V08_SHAKIR_03,
+	V09_VIOLETA_01,
+	V09_VIOLETA_02,
+	V09_VIOLETA_03,
+	V09_VIOLETA_04,
+	V10_CHICKEN_01,
+	V10_COOPER_01,
+	V10_COOPER_02,
+	V10_COOPER_03,
+	V10_COOPER_04,
+	V10_COOPER_05,
+	V10_COOPER_06,
+	V10_COOPER_07,
+	V10_COOPER_08,
+	V10_COOPER_09,
+	V10_DOLLY_01,
+	V10_DOLLY_02,
+	V10_DOLLY_03,
+	V10_DOLLY_04,
+	V10_DOLLY_05,
+	V10_DOLLY_06,
+	V10_DOLLY_07,
+	V10_DOLLY_08,
+	V10_DOLLY_09,
+	V10_DOLLY_10,
+	V10_ENGCOMPUTER_01,
+	V10_FARBLE_01,
+	V10_FARBLE_02,
+	V10_FARBLE_03,
+	V10_FARBLE_04,
+	V10_FARBLE_05,
+	V10_FARBLE_06,
+	V10_GRUNETT_01,
+	V10_GRUNETT_02,
+	V10_GRUNETT_03,
+	V10_GRUNETT_04,
+	V10_GRUNETT_05,
+	V10_GRUNETT_06,
+	V10_GUY_01,
+	V10_GUY_02,
+	V10_GUY_03,
+	V10_GUY_04,
+	V10_GUY_05,
+	V10_GUY_06,
+	V10_GUY_07,
+	V10_GUY_08,
+	V10_INFOCOMP_01,
+	V10_NOTEBRICK_01,
+	V10_PILOTS_01,
+	V10_PILOTS_02,
+	V10_PILOTS_03,
+	V10_PILOTS_04,
+	V10_PILOTS_05,
+	V10_SARGE_01,
+	V10_SARGE_02,
+	V10_SARGE_03,
+	V10_SARGE_04,
+	V10_SARGE_05,
+	V11_ANCHOVY_01,
+	V11_ANCHOVY_02,
+	V11_ANCHOVY_03,
+	V11_ANCHOVY_04,
+	V11_ANCHOVY_05,
+	V11_ARBIVALL_01,
+	V11_ARBIVALL_02,
+	V11_ARBIVALL_03,
+	V11_ARBIVALL_04,
+	V11_ARBIVALL_05,
+	V11_ARBIVALL_06,
+	V11_ARBIVALL_07,
+	V11_ARNIE_01,
+	V11_BELINDA_01,
+	V11_BLOCK_01,
+	V11_BLOCK_02,
+	V11_BLOCK_03,
+	V11_BRAD_01,
+	V11_BRAD_02,
+	V11_BRAD_03,
+	V11_BUSTER_01,
+	V11_BUSTER_02,
+	V11_BUSTER_03,
+	V11_DINERS_01,
+	V11_DINERS_02,
+	V11_DOPPLER_01,
+	V11_DOPPLER_02,
+	V11_DOPPLER_03,
+	V11_DOPPLER_04,
+	V11_DOPPLER_05,
+	V11_DOREK_01,
+	V11_DOREK_02,
+	V11_DOREK_03,
+	V11_DOZER_01,
+	V11_DOZER_02,
+	V11_DOZER_03,
+	V11_DOZER_04,
+	V11_GNAPPE_01,
+	V11_GNAPPE_02,
+	V11_GNAPPE_03,
+	V11_GNAPPE_04,
+	V11_GNAPPE_05,
+	V11_GNODIMY_01,
+	V11_GNODIMY_02,
+	V11_GNODIMY_03,
+	V11_GNODIMY_04,
+	V11_GUY_01,
+	V11_GUY_02,
+	V11_GUY_03,
+	V11_GUY_04,
+	V11_GUY_05,
+	V11_GUY_06,
+	V11_GUY_07,
+	V11_GUY_08,
+	V11_GUY_09,
+	V11_GUY_10,
+	V11_GUY_11,
+	V11_GUY_12,
+	V11_GUY_13,
+	V11_GUY_15,
+	V11_GUY_16,
+	V11_GUY_17,
+	V11_HAMBRE_01,
+	V11_HAMBRE_02,
+	V11_HAMBRE_03,
+	V11_HAMBRE_04,
+	V11_HAMBRE_05,
+	V11_HUMBERT_01,
+	V11_ILLIAC_01,
+	V11_JAQUES_01,
+	V11_JAQUES_02,
+	V11_JAQUES_03,
+	V11_JAQUES_04,
+	V11_LUMBAR_01,
+	V11_MAN_IN_STALL_01,
+	V11_MAN_IN_STALL_02,
+	V11_MAN_IN_STALL_03,
+	V11_MAN_IN_STALL_04,
+	V11_MAN_IN_STALL_05,
+	V11_MANNY_01,
+	V11_MUMPS_01,
+	V11_MUMPS_02,
+	V11_MUMPS_03,
+	V11_MUMPS_04,
+	V11_MUMPS_05,
+	V11_MUMPS_06,
+	V11_MUMPS_07,
+	V11_MUMPS_08,
+	V11_MUMPS_09,
+	V11_MUMPS_10,
+	V11_MUMPS_11,
+	V11_MUMPS_12,
+	V11_MUMPS_13,
+	V11_MUMPS_14,
+	V11_MUMPS_15,
+	V11_MUMPS_16,
+	V11_MUMPS_17,
+	V11_MUMPS_18,
+	V11_MUMPS_19,
+	V11_MUMPS_20,
+	V11_MUMPS_22,
+	V11_MUMPS_23,
+	V11_MUMPS_24,
+	V11_MUMPS_25,
+	V11_MUMPS_26,
+	V11_PEDIMENT_01,
+	V11_PEDIMENT_02,
+	V11_PEDIMENT_03,
+	V11_PEDIMENT_04,
+	V11_PEDIMENT_05,
+	V11_PEDIMENT_06,
+	V11_PEDIMENT_07,
+	V11_PEDIMENT_08,
+	V11_POLONEY_01,
+	V11_POLONEY_02,
+	V11_POLONEY_03,
+	V11_SAUSAGE_01,
+	V11_SAUSAGE_02,
+	V11_SAUSAGE_03,
+	V11_SAUSAGE_04,
+	V11_SAUSAGE_05,
+	V11_SAUSAGE_06,
+	V11_SAUSAGE_07,
+	V11_SAUSAGE_08,
+	V11_SAUSAGE_09,
+	V11_SAUSAGE_10,
+	V12_ABLE_01,
+	V12_ABLE_02,
+	V12_ABLE_03,
+	V12_BUSY_01,
+	V12_BUSY_02,
+	V12_BUSY_03,
+	V12_BUSY_04,
+	V12_BUSY_05,
+	V12_BUSY_06,
+	V12_BUSY_07,
+	V12_BUSY_08,
+	V12_CHARLIE_01,
+	V12_CHARLIE_02,
+	V12_CONUNDRUM_01,
+	V12_CONUNDRUM_02,
+	V12_CONUNDRUM_03,
+	V12_CONUNDRUM_04,
+	V12_CONUNDRUM_05,
+	V12_FOXTROT_01,
+	V12_FOXTROT_02,
+	V12_GUY_01,
+	V12_GUY_02,
+	V12_GUY_03,
+	V12_HAUTE_01,
+	V12_HAUTE_02,
+	V12_HAUTE_03,
+	V12_HAUTE_04,
+	V12_HAUTE_05,
+	V12_HAUTE_06,
+	V12_HOVER_01,
+	V12_HOVER_02,
+	V12_RUBE_01,
+	V12_RUBE_02,
+	V12_RUBE_03,
+	V12_RUBE_04,
+	V12_RUBE_05,
+	V12_RUBE_06,
+	V12_RUBE_07,
+	V12_RUBE_08,
+	V12_RUBE_09,
+	V12_RUBE_10,
+	V12_TEKT_01,
+	V12_TEKT_02,
+	V12_TEKT_03,
+	V12_TEKT_04,
+	V12_TEKT_05,
+	V12_TEKT_06,
+	V12_TEKT_07,
+	V13_ANIBLE_01,
+	V13_ANIBLE_02,
+	V13_FLOWER_01,
+	V13_FLOWER_02,
+	V13_FOOCHANE_01,
+	V13_FOOCHANE_02,
+	V13_FOOCHANE_03,
+	V13_FOOCHANE_04,
+	V13_GHULABUL_01,
+	V13_GHULABUL_02,
+	V13_GHULABUL_03,
+	V13_GHULABUL_04,
+	V13_GHULABUL_05,
+	V13_GHULABUL_06,
+	V13_GHULABUL_07,
+	V13_GUY_01,
+	V13_GUY_02,
+	V13_HAVENGIN_01,
+	V13_MELO_01,
+	V13_MELO_02,
+	V13_MELO_03,
+	V13_MITAKO_01,
+	V13_MITAKO_02,
+	V13_MITAKO_03,
+	V13_SPOONIE_01,
+	V13_SPOONIE_02,
+	V13_SPOONIE_03,
+	V13_SPOONIE_04,
+	V13_SPOONIE_05,
+	V13_ZYGOTE_01,
+	V13_ZYGOTE_02,
+	V13_ZYGOTE_03,
+	V13_ZYGOTE_04,
+	V13_ZYGOTE_05,
+	V14_LAMORTE_01,
+	V14_LAMORTE_02,
+	V15_COPROLITE_01,
+	V15_COPROLITE_02,
+	V15_COPROLITE_03,
+	V15_COPROLITE_04,
+	V15_COPROLITE_05,
+	V15_COPROLITE_06,
+	V15_COPROLITE_07,
+	V15_COPROLITE_08,
+	V15_COPROLITE_09,
+	V15_COPROLITE_10,
+	V15_COPROLITE_11,
+	V15_COPROLITE_12,
+	V15_COPROLITE_13,
+	V15_COPROLITE_14,
+	V15_COPROLITE_15,
+	V15_COPROLITE_16,
+	V15_COPROLITE_17,
+	V15_COPROLITE_18,
+	V15_GUY_01,
+	V15_GUY_02,
+	V15_REED_01,
+	V15_REED_02,
+	V15_REED_03,
+	V16_DYING_01,
+	V16_DYING_02,
+	V16_GUY_01,
+	V16_GUY_02,
+	V16_GUY_03,
+	V17_ANDERSON_01,
+	V17_BARBER_01,
+	V17_CAMPBELL_01,
+	V17_DEVONSHIRE_01,
+	V17_EGGER_01,
+	V17_EMERALD_01,
+	V17_FLINGBESTER_01,
+	V17_GERSHWIN_01,
+	V17_GUY_01,
+	V17_GUY_02,
+	V17_GUY_03,
+	V17_GUY_04,
+	V17_HEPHASTUS_01,
+	V17_INIWA_01,
+	V17_INIWA_02,
+	V17_INIWA_03,
+	V17_KEYCODE_01,
+	V17_KEYCODE_02,
+	V17_KEYCODE_03,
+	V17_KEYCODE_04,
+	V17_TOERIG_01,
+	V17_TOERIG_02,
+	V17_WARNER_01,
+	V17_WARNER_02,
+	V17_WARNER_03,
+	V17_WARNER_04,
+	V17_YORP_01,
+	V17_YORP_02,
+	V18_DERECHA_01,
+	V18_GUY_01,
+	V18_IZQUIERDA_01,
+	V18_IZQUIERDA_02,
+	V18_IZQUIERDA_03,
+	V18_IZQUIERDA_04,
+	V18_IZQUIERDA_05,
+	V18_IZQUIERDA_06,
+	V19_CAVEAT_01,
+	V19_CAVEAT_02,
+	V19_ENDER_01,
+	V19_ENDER_02,
+	V19_FRUSTRATO_01,
+	V19_FRUSTRATO_02,
+	V19_FRUSTRATO_03,
+	V19_FRUSTRATO_04,
+	V19_FRUSTRATO_05,
+	V19_FRUSTRATO_06,
+	V19_FRUSTRATO_07,
+	V19_FRUSTRATO_08,
+	V19_FRUSTRATO_09,
+	V19_FRUSTRATO_10,
+	V19_GUY_01,
+	V19_GUY_02,
+	V19_GUY_03,
+	V19_INTER_01,
+	V19_INTER_02,
+	V19_LONE_01,
+	V19_LONE_02,
+	V19_LONE_03,
+	V19_PHILLIPS_01,
+	V19_PHILLIPS_02,
+	V19_PHILLIPS_03,
+	V19_PHILLIPS_04,
+	V19_PHILLIPS_05,
+	V19_RAILRIDER_01,
+	V19_RAILRIDER_02,
+	V19_RAILRIDER_03,
+	V19_RAILRIDER_04,
+	V19_REDRUM_01,
+	V19_REDRUM_02,
+	V19_REDRUM_03,
+	V19_REDRUM_04,
+	V19_REDRUM_05,
+	V19_REDRUM_06,
+	V19_STANDARD_01,
+	V19_STANDARD_02,
+	V20_ARNIE_01,
+	V20_ARNIE_02,
+	V20_BRAD_01,
+	V20_BRAD_02,
+	V20_BUSTER_01,
+	V20_BUSTER_02,
+	V20_BUSTER_03,
+	V20_COOPER_01,
+	V20_COOPER_02,
+	V20_DINERS_01,
+	V20_DINERS_02,
+	V20_DOLLY_01,
+	V20_DOREK_01,
+	V20_DOREK_02,
+	V20_DOREK_03,
+	V20_FARBLE_01,
+	V20_FARBLE_02,
+	V20_GRUNETT_01,
+	V20_GRUNETT_02,
+	V20_GUY_01,
+	V20_GUY_02,
+	V20_GUY_03,
+	V20_GUY_04,
+	V20_GUY_05,
+	V20_GUY_06,
+	V20_HUMBERT_01,
+	V20_ILLIAC_01,
+	V20_JACQUES_01,
+	V20_JACQUES_02,
+	V20_LUMBAR_01,
+	V20_MANNY_01,
+	V20_POLONEY_01,
+	V20_POLONEY_02,
+	V20_SARGE_01,
+	V20_SARGE_02,
+	V20_SARGE_03,
+	V20_SARGE_04,
+	V20_SARGE_05,
+	V21_ANTIMA_01,
+	V21_ANTIMA_02,
+	V21_ANTIMA_03,
+	V21_ANTIMA_04,
+	V21_ANTIMA_05,
+	V21_ANTIMA_06,
+	V21_ANTIMA_07,
+	V21_BRAN_ONOMI_01,
+	V21_BRAN_ONOMI_02,
+	V21_BRAN_ONOMI_03,
+	V21_CONTENNE_01,
+	V21_CONTENNE_02,
+	V21_CONTENNE_03,
+	V21_CONTENNE_04,
+	V21_CONTENNE_05,
+	V21_CONTENNE_06,
+	V21_CONTENNE_07,
+	V21_COUHOUSE_01,
+	V21_COUHOUSE_02,
+	V21_COUHOUSE_03,
+	V21_DEBENSHIRE_01,
+	V21_DEBENSHIRE_02,
+	V21_DEBENSHIRE_03,
+	V21_DEBENSHIRE_04,
+	V21_FEMURIA_01,
+	V21_FEMURIA_02,
+	V21_FEMURIA_03,
+	V21_FEMURIA_04,
+	V21_FEMURIA_05,
+	V21_GLARATTE_01,
+	V21_GLARATTE_02,
+	V21_GLARATTE_03,
+	V21_GLARATTE_04,
+	V21_GUY_01,
+	V21_GUY_02,
+	V21_GUY_03,
+	V21_GUY_04,
+	V21_GUY_05,
+	V21_GUY_06,
+	V21_GUY_07,
+	V21_GUY_08,
+	V21_GUY_09,
+	V21_HYPERBOLE_01,
+	V21_KREN_KREN_01,
+	V21_KREN_KREN_02,
+	V21_KREN_KREN_03,
+	V21_KREN_KREN_04,
+	V21_KREN_KREN_05,
+	V21_LITOTE_01,
+	V21_PERIOUS_01,
+	V21_PERIOUS_02,
+	V21_PERIOUS_03,
+	V21_PHAEDRUS_01,
+	V21_PHAEDRUS_02,
+	V21_PHAEDRUS_04,
+	V21_PHAEDRUS_05,
+	V21_PHAEDRUS_06,
+	V21_PHAEDRUS_07,
+	V21_PHAEDRUS_08,
+	V21_PHAEDRUS_09,
+	V21_PHAEDRUS_10,
+	V21_PHAEDRUS_11,
+	V21_PHAEDRUS_12,
+	V21_PHAEDRUS_13,
+	V21_PHAEDRUS_14,
+	V21_PHAEDRUS_15,
+	V21_PHAEDRUS_16,
+	V21_PHAEDRUS_17,
+	V21_PHAEDRUS_18,
+	V21_PHAEDRUS_19,
+	V21_PHAEDRUS_20,
+	V21_PHAEDRUS_21,
+	V21_PHAEDRUS_22,
+	V21_PHAEDRUS_23,
+	V21_PHAEDRUS_24,
+	V21_PHAEDRUS_25,
+	V21_PHAEDRUS_26,
+	V21_PHIPOLOSSI_01,
+	V21_PHIPOLOSSI_02,
+	V21_PHIPOLOSSI_03,
+	V21_PHIPOLOSSI_04,
+	V21_PHIPOLOSSI_05,
+	V21_PHIPOLOSSI_06,
+	V21_PLODDER_01,
+	V21_PLODDER_02,
+	V21_PLODDER_03,
+	V21_PLODDER_04,
+	V21_SARGE_01,
+	V21_SARGE_02,
+	V21_SARGE_03,
+	V21_SARGE_04,
+	V21_SARGE_05,
+	V21_SARGE_06,
+	V21_SARGE_07,
+	V21_SARGE_08,
+	V21_SATIRE_01,
+	V21_SATIRE_02,
+	V21_SHELLEY_01,
+	V21_SHELLEY_02,
+	V21_SHELLEY_03,
+	V21_SHELLEY_04,
+	V21_SHELLEY_05,
+	V21_VERILITH_01,
+	V21_VERILITH_02,
+	V21_VERILITH_03,
+	V21_VERILITH_04,
+	V21_VERILITH_05,
+	V22_GUY_01,
+	V22_OSCURO_01,
+	V22_OSCURO_02,
+	V22_VERILITH_01,
+	V22_VERILITH_02,
+	V22_VERILITH_03,
+	V22_VERILITH_04,
+	V23_GUY_01,
+	V23_GUY_02,
+	V23_GUY_03,
+	V23_INSANITO_01,
+	V23_INSANITO_02,
+	V23_INSANITO_03,
+	V23_INSANITO_04,
+	V23_INSANITO_05,
+	V23_VERILITH_01,
+	V24_GUY_01,
+	V24_GUY_02,
+	V24_GUY_03,
+	V24_MANAGOTA_01,
+	V24_MANAGOTA_02,
+	V24_MANAGOTA_03,
+	V24_MANAGOTA_04,
+	V25_BBOW_01,
+	V25_BBOW_02,
+	V25_BBOW_03,
+	V25_BBOW_04,
+	V25_GUY_01,
+	V25_GUY_02,
+	V25_VERILITH_01,
+	V26_GUY_01,
+	V26_GUY_02,
+	V26_GUY_03,
+	V26_GUY_04,
+	V26_GUY_05,
+	V26_FDOE_01,
+	V26_FDOE_02,
+	V26_FDOE_03,
+	V26_FDOE_04,
+	V27_AYONN_01,
+	V27_AYONN_02,
+	V27_AYONN_03,
+	V27_AYONN_04,
+	V27_BALE_01,
+	V27_BALE_02,
+	V27_BALE_03,
+	V27_GUY_01,
+	V27_GUY_02,
+	V27_GUY_03,
+	V27_ONABILDEN_01,
+	V27_ONABILDEN_02,
+	V27_ONABILDEN_03,
+	V27_ONABILDEN_04,
+	V28_FINN_01,
+	V28_FINN_02,
+	V28_FINN_03,
+	V28_GUY_01,
+	V28_GUY_02,
+	V28_GUY_03,
+	V29_ALERE_01,
+	V29_ALERE_02,
+	V29_ALERE_03,
+	V29_AOLOS_01,
+	V29_AOLOS_02,
+	V29_AOLOS_03,
+	V29_AOLOS_04,
+	V29_AOLOS_05,
+	V29_GUY_01,
+	V29_GUY_02,
+	V29_GUY_03,
+	V29_GUY_04,
+	V29_GUY_05,
+	V29_GUY_06,
+	V29_GUY_07,
+	V29_GUY_08,
+	V29_GUY_09,
+	V29_GUY_10,
+	V29_GUY_11,
+	V29_GUY_12,
+	V29_GUY_13,
+	V29_GUY_14,
+	V29_GUY_15,
+	V29_KORENAAR_01,
+	V29_KORENAAR_02,
+	V29_KORENAAR_03,
+	V29_KORENAAR_04,
+	V29_KORENAAR_05,
+	V29_PHARIBOS_01,
+	V29_PHARIBOS_02,
+	V29_VELEGAL_01,
+	V29_VELEGAL_02,
+	V30_AOLOS_01,
+	V30_AOLOS_02,
+	V30_AOLOS_03,
+	V30_AOLOS_04,
+	V30_AOLOS_05,
+	V30_AOLOS_06,
+	V30_AOLOS_07,
+	V30_AOLOS_08,
+	V30_AOLOS_09,
+	V30_AOLOS_11,
+	V30_AOLOS_12,
+	V30_AOLOS_13,
+	V30_AOLOS_14,
+	V30_AOLOS_15,
+	V30_AOLOS_16,
+	V30_AOLOS_17,
+	V30_AOLOS_18,
+	V30_AOLOS_19,
+	V30_AOLOS_20,
+	V30_CASINOX_01,
+	V30_CASINOX_02,
+	V30_CASINOX_03,
+	V30_CASINOX_04,
+	V30_CASINOX_05,
+	V30_CASINOX_06,
+	V30_CHICKEN_EXPLOSION_01,
+	V30_CHICKEN_EXPLOSION_02,
+	V30_DOPEFISH_01,
+	V30_DOPEFISH_02,
+	V30_DOPEFISH_03,
+	V30_DOPEFISH_04,
+	V30_GUY_01,
+	V30_GUY_02,
+	V30_JOHN_01,
+	V30_JOHN_02,
+	V30_JOHN_03,
+	V30_JOHN_04,
+	V30_JOHN_05,
+	V30_LUCAS_01,
+	V30_LUCAS_02,
+	V30_LUCAS_03,
+	V30_LUCAS_04,
+	V30_STEVIE_01,
+	V30_STEVIE_02,
+	V30_STEVIE_03,
+	V30_STEVIE_04,
+	V30_STEVIE_05,
+	V30_STEVIE_06,
+	V30_STEVIE_07,
+	V30_STEVIE_08,
+	V30_STEVIE_09,
+	V30_STEVIE_10,
+	V30_TOM_01,
+	V30_TOM_02,
+	V30_TOM_03,
+	V30_TOM_04,
+	V30_TOM_05,
+	V30_TOM_06,
+	V30_VERILITH_01,
+	V30_VERILITH_02,
+	V30_VERILITH_03,
+	V30_VERILITH_04,
+	V30_VERILITH_05,
+	V30_VERILITH_06,
+	V30_VERILITH_07,
+	OUTRO_DOLLY_01,
+	OUTRO_DOLLY_02,
+	OUTRO_DOLLY_03,
+	OUTRO_DOLLY_04,
+	OUTRO_DOLLY_05,
+	OUTRO_DOLLY_06,
+	OUTRO_DOLLY_07,
+	OUTRO_DOLLY_08,
+	OUTRO_DOLLY_09,
+	OUTRO_DOLLY_10,
+	OUTRO_DOLLY_11,
+	OUTRO_DOLLY_12,
+	OUTRO_DOLLY_13,
+	OUTRO_DOLLY_14,
+	OUTRO_DOLLY_15,
+	OUTRO_DOLLY_16,
+	OUTRO_DOLLY_17,
+	OUTRO_DOLLY_18,
+	OUTRO_DOREK_01,
+	OUTRO_DOREK_02,
+	OUTRO_DOREK_03,
+	OUTRO_DOREK_04,
+	OUTRO_DOREK_05,
+	OUTRO_DOREK_06,
+	OUTRO_GUY_01,
+	OUTRO_GUY_02,
+	OUTRO_GUY_03,
+	OUTRO_GUY_04,
+	OUTRO_GUY_05,
+	OUTRO_GUY_06,
+	OUTRO_JENKINS_01,
+	OUTRO_JENKINS_02,
+	OUTRO_JENKINS_03,
+	OUTRO_JENKINS_04,
+	OUTRO_JENKINS_05,
+	OUTRO_SARGE_01,
+	OUTRO_SARGE_02,
+	OUTRO_SARGE_03,
+	OUTRO_SARGE_04,
+	OUTRO_SARGE_05,
+	OUTRO_SARGE_06,
+	GUY_GOT_A_JOB,
+	GUY_WINS,
+
+	GUY_ENERGY_CELL,
+	GUY_COMPLETED,
+	GUY_GOT_SOMETHING,
+	HDB_INTRO,
+
+	LAST_SOUND
+};
+
+struct SoundLookUp {
+	SoundType idx;
+	char *name;			// name from MSD .h file
+	char*luaName;		// name for Lua code to use
+};
+
+class Sound {
+public:
+
+	bool init();
+
+	bool playSound(int index);
+	bool playVoice(int index, int actor);
+};
+
+} // End of Namespace
+
+#endif // !HDB_SOUND_H


Commit: 4622fb3b8026eb4cf457a7bf99e1f733cf5553b3
    https://github.com/scummvm/scummvm/commit/4622fb3b8026eb4cf457a7bf99e1f733cf5553b3
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:09+02:00

Commit Message:
HDB: Unstub playSound calls

Changed paths:
    engines/hdb/ai-bots.cpp
    engines/hdb/ai-funcs.cpp
    engines/hdb/ai-lists.cpp
    engines/hdb/ai-player.cpp
    engines/hdb/ai-use.cpp
    engines/hdb/ai-waypoint.cpp
    engines/hdb/input.cpp
    engines/hdb/lua-script.cpp
    engines/hdb/window.cpp


diff --git a/engines/hdb/ai-bots.cpp b/engines/hdb/ai-bots.cpp
index 056cc4a..b6dfd23 100644
--- a/engines/hdb/ai-bots.cpp
+++ b/engines/hdb/ai-bots.cpp
@@ -110,7 +110,7 @@ void aiOmniBotAction(AIEntity *e) {
 					omni->xVel = xv * kPlayerMoveSpeed * 2;
 					omni->yVel = yv * kPlayerMoveSpeed * 2;
 					if (g_hdb->_map->onScreen(e->tileX, e->tileY))
-						warning("STUB: aiOmniBotAction: Play SND_OMNIBOT_FIRE");
+						g_hdb->_sound->playSound(SND_OMNIBOT_FIRE);
 					if (!g_hdb->getActionMode()) {
 						omni->xVel >>= 1;
 						omni->yVel >>= 1;
@@ -122,7 +122,7 @@ void aiOmniBotAction(AIEntity *e) {
 	} else {
 		g_hdb->_ai->findPath(e);
 		if (e->onScreen)
-			warning("STUB: aiOmniBotAction: Play SND_OMNIBOT_AMBIENT");
+			g_hdb->_sound->playSound(SND_OMNIBOT_AMBIENT);
 	}
 
 	if (e->sequence)
@@ -213,7 +213,7 @@ void aiTurnBotAction(AIEntity *e) {
 		aiTurnBotChoose(e);
 		g_hdb->_ai->animateEntity(e);
 		if (e->onScreen)
-			warning("STUB: aiTurnBotAction: Play SND_TURNBOT_TURN");
+			g_hdb->_sound->playSound(SND_TURNBOT_TURN);
 	}
 
 	if (e->onScreen && onEvenTile(e->x, e->y) && g_hdb->_ai->checkPlayerCollision(e->x, e->y, 0) && !g_hdb->_ai->playerDead())
@@ -251,7 +251,7 @@ void aiShockBotAction(AIEntity *e) {
 		e->sequence = 20;
 		g_hdb->_ai->animEntFrames(e);
 		if (e->onScreen)
-			warning("STUB: aiShockBotAction: Play SND_SHOCKBOT_AMBIENT");
+			g_hdb->_sound->playSound(SND_SHOCKBOT_AMBIENT);
 
 	}
 
@@ -452,7 +452,7 @@ void aiRightBotFindGoal(AIEntity *e) {
 	e->xVel = xv * e->moveSpeed;
 	e->yVel = yv * e->moveSpeed;
 	if (e->onScreen)
-		warning("STUB: aiRightBotFindGoal: Play SND_RIGHTBOT_TURN");
+		g_hdb->_sound->playSound(SND_RIGHTBOT_TURN);
 }
 
 void aiRightBotAction(AIEntity *e) {
@@ -536,7 +536,7 @@ void aiPushBotAction(AIEntity *e) {
 				warning("STUB: aiPushBotAction: Switch Case for Sound");
 			} else {
 				if (e->onScreen)
-					warning("STUB: aiPushBotAction: Play SND_PUSHBOT_STRAIN");
+					g_hdb->_sound->playSound(SND_PUSHBOT_STRAIN);
 				e->dir = oneEighty[e->dir];
 				e->state = moveState[e->dir];
 				nx = e->tileX + xvAhead[e->dir];
@@ -680,7 +680,7 @@ void aiRailRiderOnAction(AIEntity *e) {
 		g_hdb->_ai->setPlayerInvisible(true);
 		g_hdb->_ai->setPlayerLock(true);
 		g_hdb->_ai->setEntityGoal(e, e->tileX + xv[e->dir], e->tileY + yv[e->dir]);
-		warning("STUB: aiRailRiderOnAction: Play SND_RAILRIDER_TASTE");
+		g_hdb->_sound->playSound(SND_RAILRIDER_TASTE);
 		e->sequence = 2;
 		e->value1 = 0;
 
@@ -734,7 +734,7 @@ void aiRailRiderOnAction(AIEntity *e) {
 						break;
 					}
 					g_hdb->_ai->setPlayerInvisible(false);
-					warning("STUB: aiRailRiderOnAction: Play SND_RAILRIDER_EXIT");
+					g_hdb->_sound->playSound(SND_RAILRIDER_EXIT);
 				} else if (arrowPath->type == 1) {
 					e->dir = arrowPath->dir;
 					g_hdb->_ai->setEntityGoal(e, e->tileX + xv[e->dir], e->tileY + yv[e->dir]);
@@ -742,7 +742,7 @@ void aiRailRiderOnAction(AIEntity *e) {
 			} else
 				g_hdb->_ai->setEntityGoal(e, e->tileX + xv[e->dir], e->tileY + yv[e->dir]);
 
-			warning("STUB: aiRailRiderOnAction: Play SND_RAILRIDER_ONTRACK");
+			g_hdb->_sound->playSound(SND_RAILRIDER_ONTRACK);
 		}
 
 		p->tileX = e->tileX;
@@ -818,7 +818,7 @@ void aiMaintBotAction(AIEntity *e) {
 	int	xvAhead[5] = {9, 0, 0,-1, 1}, yvAhead[5] = {9,-1, 1, 0, 0};
 	AIEntity *it;
 	int nx, ny;
-	debug(9, "STUB: aiMaintBotAction: Add sounds");
+	int	whistles[3] = {SND_MBOT_WHISTLE1, SND_MBOT_WHISTLE2, SND_MBOT_WHISTLE3};
 
 	// Waiting at an arrow (or hit by player)?
 	if (e->sequence) {
@@ -830,7 +830,10 @@ void aiMaintBotAction(AIEntity *e) {
 			switch (e->sequence) {
 			case 50:
 				if (e->onScreen && !e->int1) {
-					warning("STUB: aiMaintBotAction: Play SND_MBOT_HMMM or SND_MBOT_HMMM2");
+					if (g_hdb->_rnd->getRandomNumber(2) & 1)
+						g_hdb->_sound->playSound(SND_MBOT_HMMM2);
+					else
+						g_hdb->_sound->playSound(SND_MBOT_HMMM);
 				}
 				break;
 			// Need to USE the object
@@ -888,7 +891,7 @@ void aiMaintBotAction(AIEntity *e) {
 			// HMM
 			case 50:
 				if (e->onScreen && !e->int1)
-					warning("STUB: aiMaintBotAction: Play SND_MBOT_HMMM");
+					g_hdb->_sound->playSound(SND_MBOT_HMMM);
 				break;
 			// Look Right
 			case 40:
@@ -903,7 +906,7 @@ void aiMaintBotAction(AIEntity *e) {
 			// HMM2
 			case 25:
 				if (e->onScreen && !e->int1)
-					warning("STUB: aiMaintBotAction: Play SND_MBOT_HMM2");
+					g_hdb->_sound->playSound(SND_MBOT_HMMM2);
 				break;
 			// Decide direction and GO
 			case 0:
@@ -911,7 +914,7 @@ void aiMaintBotAction(AIEntity *e) {
 				e->dir = dirList[dir];
 				g_hdb->_ai->findPath(e);
 				if (e->onScreen)
-					warning("STUB: aiMaintBotAction: Play whistle");
+					g_hdb->_sound->playSound(whistles[g_hdb->_rnd->getRandomNumber(3)]);
 				break;
 			}
 		}
@@ -923,7 +926,7 @@ void aiMaintBotAction(AIEntity *e) {
 		g_hdb->_ai->animateEntity(e);
 		if (hitPlayer(e->x, e->y)) {
 			g_hdb->_ai->killPlayer(DEATH_GRABBED);
-			warning("STUB: aiMaintBotAction: Play SND_MBOT_DEATH");
+			g_hdb->_sound->playSound(SND_MBOT_DEATH);
 		}
 	} else {
 		// Check if there's an arrow UNDER the bot, and if its RED
@@ -942,7 +945,7 @@ void aiMaintBotAction(AIEntity *e) {
 				return;
 			} else if (ar->type == 1) {
 				g_hdb->_ai->findPath(e);
-				warning("STUB: aiMaintBotAction: Play whistle");
+				g_hdb->_sound->playSound(whistles[g_hdb->_rnd->getRandomNumber(3)]);
 			} else {
 				e->sequence = 64;
 				e->dir2 = e->dir;
@@ -975,7 +978,7 @@ void aiFourFirerAction(AIEntity *e) {
 		e->state = state[e->dir];
 		e->value1 = 16;
 		if (e->onScreen)
-			warning("STUB: aiFourFirerAction: Play SND_FOURFIRE_TURN");
+			g_hdb->_sound->playSound(SND_FOURFIRE_TURN);
 	}
 	e->value1--;
 
@@ -1011,7 +1014,7 @@ void aiFourFirerAction(AIEntity *e) {
 	if (shoot && !hit && result) {
 		fire = g_hdb->_ai->spawn(AI_OMNIBOT_MISSILE, e->dir, e->tileX + xv, e->tileY + yv, NULL, NULL, NULL, DIR_NONE, e->level, 0, 0, 1);
 		if (g_hdb->_map->onScreen(e->tileX, e->tileY))
-			warning("STUB: aiFourFirerAction: Play SND_FOUR_FIRE");
+			g_hdb->_sound->playSound(SND_FOUR_FIRE);
 		fire->xVel = xv * kPlayerMoveSpeed * 2;
 		fire->yVel = yv * kPlayerMoveSpeed * 2;
 		if (!g_hdb->getActionMode()) {
@@ -1056,9 +1059,9 @@ void aiDeadEyeWalkInPlace(AIEntity *e) {
 		e->state = s;
 		if (e->onScreen) {
 			if (e->sequence == 50)
-				warning("STUB: aiDeadEyeWalkInPlace: Play SND_DEADEYE_AMB01");
+				g_hdb->_sound->playSound(SND_DEADEYE_AMB01);
 			else if (e->sequence == 10)
-				warning("STUB: aiDeadEyeWalkInPlace: Play SND_DEADEYE_AMB02");
+				g_hdb->_sound->playSound(SND_DEADEYE_AMB02);
 		}
 		break;
 	case 0:
@@ -1127,7 +1130,7 @@ void aiDeadEyeAction(AIEntity *e) {
 				if (okToMove) {
 					e->moveSpeed = kPlayerMoveSpeed << 1;
 					g_hdb->_ai->setEntityGoal(e, newX, newY);
-					p->tileX & 1 ? warning("STUB: aiDeadEyeAction: Play SND_DEADEYE_ATTACK01") : warning("STUB: aiDeadEyeAction: Play SND_DEADEYE_ATTACK02");
+					p->tileX & 1 ? g_hdb->_sound->playSound(SND_DEADEYE_ATTACK01) : g_hdb->_sound->playSound(SND_DEADEYE_ATTACK02);
 				}
 				g_hdb->_ai->animateEntity(e);
 				return;
@@ -1148,9 +1151,9 @@ void aiDeadEyeAction(AIEntity *e) {
 
 			if (e->onScreen) {
 				if (e->sequence == 50)
-					warning("STUB: aiDeadEyeAction: Play SND_DEADEYE_AMB01");
+					g_hdb->_sound->playSound(SND_DEADEYE_AMB01);
 				else if (e->sequence == 10)
-					warning("STUB: aiDeadEyeAction: Play SND_DEADEYE_AMB01");
+					g_hdb->_sound->playSound(SND_DEADEYE_AMB02);
 			}
 			break;
 		case 0:
diff --git a/engines/hdb/ai-funcs.cpp b/engines/hdb/ai-funcs.cpp
index c68410e..f16c1f0 100644
--- a/engines/hdb/ai-funcs.cpp
+++ b/engines/hdb/ai-funcs.cpp
@@ -770,32 +770,32 @@ void AI::killPlayer(Death method) {
 	switch (method) {
 	case DEATH_NORMAL:
 		_player->state = STATE_DYING;
-		warning("STUB: killPlayer: Play SND_GUY_DYING");
+		g_hdb->_sound->playSound(SND_GUY_DYING);
 		break;
 	case DEATH_FRIED:
 		_player->state = STATE_HORRIBLE1;
-		warning("STUB: killPlayer: Play SND_GUY_FRIED");
+		g_hdb->_sound->playSound(SND_GUY_FRIED);
 		break;
 	case DEATH_SHOCKED:
 		_player->state = STATE_HORRIBLE2;
-		warning("STUB: killPlayer: Play SND_GUY_DYING");
-		warning("STUB: killPlayer: Play SND_SHOCKBOT_SHOCK");
+		g_hdb->_sound->playSound(SND_GUY_DYING);
+		g_hdb->_sound->playSound(SND_SHOCKBOT_SHOCK);
 		break;
 	case DEATH_GRABBED:
 		_player->state = STATE_HORRIBLE3;
-		warning("STUB: killPlayer: Play SND_GUY_GRABBED");
+		g_hdb->_sound->playSound(SND_GUY_GRABBED);
 		break;
 	case DEATH_DROWNED:
 		_player->state = STATE_HORRIBLE4;
-		warning("STUB: killPlayer: Play SND_GUY_DROWN");
+		g_hdb->_sound->playSound(SND_GUY_DROWN);
 		break;
 	case DEATH_PANICZONE:
 		_player->state = STATE_DYING;
-		warning("STUB: killPlayer: Play SND_PANIC_DEATH");
+		g_hdb->_sound->playSound(SND_PANIC_DEATH);
 		break;
 	case DEATH_PLUMMET:
 		_player->state = STATE_PLUMMET;
-		warning("STUB: killPlayer: Play SND_GUY_PLUMMET");
+		g_hdb->_sound->playSound(SND_GUY_PLUMMET);
 		break;
 	}
 
@@ -814,41 +814,41 @@ void AI::stunEnemy(AIEntity *e, int time) {
 	if (!ns)
 		switch (e->type) {
 		case AI_BUZZFLY:
-			warning("STUB: stunEnemy: Play sound");
+			g_hdb->_sound->playSound(SND_BUZZFLY_STUNNED);
 			break;
 		case AI_PUSHBOT:
-			warning("STUB: stunEnemy: Play sound");
+			g_hdb->_sound->playSound(SND_PUSHBOT_STUNNED);
 			break;
 		case AI_MEERKAT:
-			warning("STUB: stunEnemy: Play sound");
+			g_hdb->_sound->playSound(SND_MEERKAT_STUNNED);
 			break;
 		case AI_FATFROG:
-			warning("STUB: stunEnemy: Play sound");
+			g_hdb->_sound->playSound(SND_FATFROG_STUNNED);
 			break;
 		case AI_OMNIBOT:
 		case AI_SHOCKBOT:
 		case AI_LISTENBOT:
-			warning("STUB: stunEnemy: Play sound");
+			g_hdb->_sound->playSound(SND_ROBOT_STUNNED);
 			break;
 		case AI_GOODFAIRY:
-			warning("STUB: stunEnemy: Play sound");
+			g_hdb->_sound->playSound(SND_GOOD_FAERIE_STUNNED);
 			break;
 		case AI_BADFAIRY:
-			warning("STUB: stunEnemy: Play sound");
+			g_hdb->_sound->playSound(SND_BADFAIRY_STUNNED);
 			break;
 		case AI_ICEPUFF:
-			warning("STUB: stunEnemy: Play sound");
+			g_hdb->_sound->playSound(SND_ICEPUFF_STUNNED);
 			break;
 		case AI_RIGHTBOT:
-			warning("STUB: stunEnemy: Play sound");
+			g_hdb->_sound->playSound(SND_RIGHTBOT_STUNNED);
 			break;
 		case AI_BOOMBARREL:
-			warning("STUB: stunEnemy: Play sound");
+			g_hdb->_sound->playSound(SND_CLUB_HIT_METAL);
 			break;
 		case AI_CHICKEN:	// Fall through
-			warning("STUB: stunEnemy: Play sound");
+			g_hdb->_sound->playSound(SND_CHICKEN_DEATH);
 		default:
-			warning("STUB: stunEnemy: Play sound");
+			warning("STUB: stunEnemy: MetalOrFleshSnd");
 			break;
 		}
 }
@@ -1167,7 +1167,7 @@ void AI::animateEntity(AIEntity *e) {
 					if ((e->type == AI_CRATE || e->type == AI_HEAVYBARREL) && !checkFloating(e->tileX, e->tileY)) {
 						addAnimateTarget(e->x, e->y, 0, 3, ANIM_NORMAL, false, false, GROUP_SLIME_SPLASH_SIT);
 						floatEntity(e, STATE_FLOATING);
-						warning("STUB: animateEntity: Play SND_SPLASH");
+						g_hdb->_sound->playSound(SND_SPLASH);
 					} else if (!checkFloating(e->tileX, e->tileY)) {
 						if (e->type == AI_BOOMBARREL) {
 							aiBarrelExplode(e);
@@ -1176,14 +1176,14 @@ void AI::animateEntity(AIEntity *e) {
 						} else {
 							addAnimateTarget(e->x, e->y, 0, 3, ANIM_NORMAL, false, false, GROUP_STEAM_PUFF_SIT);
 							removeEntity(e);
-							warning("STUB: animateEntity: Play SND_BARREL_MELTING");
+							g_hdb->_sound->playSound(SND_BARREL_MELTING);
 						}
 					}
 				} else if ((flags & kFlagLightMelt) && e->type == AI_LIGHTBARREL) {
 					if (!checkFloating(e->tileX, e->tileY)) {
 						addAnimateTarget(e->x, e->y, 0, 3, ANIM_NORMAL, false, false, GROUP_STEAM_PUFF_SIT);
 						floatEntity(e, STATE_MELTED);
-						warning("STUB: animateEntity: Play SND_BARREL_MELTING");
+						g_hdb->_sound->playSound(SND_BARREL_MELTING);
 					}
 				} else if (flags & kFlagSlide) {
 					int xv = 0, yv = 0;
@@ -1205,7 +1205,7 @@ void AI::animateEntity(AIEntity *e) {
 						else if (flags & kFlagAnimSlow)
 							e->moveSpeed = kPlayerMoveSpeed >> 1;
 						setEntityGoal(e, e->tileX + xv, e->tileY + yv);
-						warning("STUB: animateEntity: Play SND_LIGHT_SLIDE");
+						g_hdb->_sound->playSound(SND_LIGHT_SLIDE);
 					}
 
 				} else if (!checkFloating(e->tileX, e->tileY)) {
@@ -1213,13 +1213,13 @@ void AI::animateEntity(AIEntity *e) {
 						// Make it disappear in the water
 						addAnimateTarget(e->x, e->y, 0, 3, ANIM_NORMAL, false, false, GROUP_WATER_SPLASH_SIT);
 						removeEntity(e);
-						warning("STUB: animateEntity: Play SND_SPLASH");
+						g_hdb->_sound->playSound(SND_SPLASH);
 						return;
 					} else {
 						// Make it float and splash in water
 						addAnimateTarget(e->x, e->y, 0, 3, ANIM_NORMAL, false, false, GROUP_WATER_SPLASH_SIT);
 						floatEntity(e, STATE_FLOATING);
-						warning("STUB: animateEntity: Play SND_SPLASH");
+						g_hdb->_sound->playSound(SND_SPLASH);
 						return;
 					}
 
@@ -1296,13 +1296,13 @@ void AI::animateEntity(AIEntity *e) {
 						// Evaporates in Slime
 						addAnimateTarget(e->x, e->y, 0, 3, ANIM_NORMAL, false, false, GROUP_STEAM_PUFF_SIT);
 						removeEntity(e);
-						warning("STUB: animateEntity: Play SND_SPLASH");
+						g_hdb->_sound->playSound(SND_SPLASH);
 						return;
 					} else {
 						// Drowns in water
 						addAnimateTarget(e->x, e->y, 0, 3, ANIM_NORMAL, false, false, GROUP_WATER_SPLASH_SIT);
 						removeEntity(e);
-						warning("STUB: animateEntity: Play SND_SPLASH");
+						g_hdb->_sound->playSound(SND_SPLASH);
 						return;
 					}
 				}
@@ -1401,7 +1401,7 @@ void AI::animEntFrames(AIEntity *e) {
 		max = _horrible2Frames;
 		click++;
 		if (click == 16) {
-			warning("STUB: Play SND_SHOCKBOT_SHOCK");
+			g_hdb->_sound->playSound(SND_SHOCKBOT_SHOCK);
 			click = 0;
 		}
 		break;
@@ -1413,7 +1413,7 @@ void AI::animEntFrames(AIEntity *e) {
 		max = _horrible3Frames;
 		click++;
 		if (click == 32) {
-			warning("STUB: Play SND_GUY_GRABBED");
+			g_hdb->_sound->playSound(SND_GUY_GRABBED);
 			click = 0;
 		}
 		break;
diff --git a/engines/hdb/ai-lists.cpp b/engines/hdb/ai-lists.cpp
index 1e6dee7..5126d14 100644
--- a/engines/hdb/ai-lists.cpp
+++ b/engines/hdb/ai-lists.cpp
@@ -670,7 +670,7 @@ bool AI::checkTeleportList(AIEntity *e, int x, int y) {
 			// Start up Teleport flash animation only if value1 is set to 1
 			if (anim1 == 1 || anim2 == 2) {
 				addAnimateTarget(e->x, e->y, 0, 7, ANIM_NORMAL, false, false, "teleporter_flash_sit");
-				warning("STUB: checkTeleporterList: Play SND_TELEPORT");
+				g_hdb->_sound->playSound(SND_TELEPORT);
 			}
 
 			// PANIC ZONE Teleports?
diff --git a/engines/hdb/ai-player.cpp b/engines/hdb/ai-player.cpp
index eefede5..5b7d979 100644
--- a/engines/hdb/ai-player.cpp
+++ b/engines/hdb/ai-player.cpp
@@ -135,7 +135,7 @@ void aiPlayerAction(AIEntity *e) {
 	// Draw the STUN lightning if it exists
 	if (e->sequence) {
 		e->aiDraw = aiPlayerDraw;
-		warning("STUB: Play SND_STUNNER_FIRE");
+		g_hdb->_sound->playSound(SND_STUNNER_FIRE);
 		hit = g_hdb->_ai->findEntity(e->tileX + xvAhead[e->dir], e->tileY + yvAhead[e->dir]);
 		if (hit)
 			switch (hit->type) {
@@ -395,7 +395,7 @@ void aiPlayerAction(AIEntity *e) {
 	int bgFlags, fgFlags;
 	if (e->goalX) {
 		if (onEvenTile(e->x, e->y)) {
-			g_hdb->_ai->playerOnIce() ? warning("STUB: Play SND_STEPS_ICE") : warning("STUB: Play SND_FOOTSTEPS");
+			g_hdb->_ai->playerOnIce() ? g_hdb->_sound->playSound(SND_STEPS_ICE) : g_hdb->_sound->playSound(SND_FOOTSTEPS);
 
 			// Did we just fall down a PLUMMET?
 			bgFlags = g_hdb->_map->getMapBGTileFlags(e->tileX, e->tileY);
@@ -491,7 +491,7 @@ void aiGemAttackInit(AIEntity *e) {
 	e->sequence = 0;	// flying out at something
 	e->aiAction = aiGemAttackAction;
 	e->draw = e->movedownGfx[0];
-	warning("Play SND_GEM_THROW");
+	g_hdb->_sound->playSound(SND_GEM_THROW);
 }
 
 void aiGemAttackAction(AIEntity *e) {
@@ -517,7 +517,7 @@ void aiGemAttackAction(AIEntity *e) {
 				case AI_CHICKEN:
 					g_hdb->_ai->addAnimateTarget(hit->x, hit->y, 0, 3, ANIM_NORMAL, false, false, GROUP_STEAM_PUFF_SIT);
 					g_hdb->_ai->removeEntity(hit);
-					warning("Play SND_CHICKEN_BAGAWK");
+					g_hdb->_sound->playSound(SND_CHICKEN_BAGAWK);
 					break;
 				case AI_BADFAIRY:
 					g_hdb->_ai->stunEnemy(hit, 2);
@@ -532,20 +532,20 @@ void aiGemAttackAction(AIEntity *e) {
 						memcpy(num1, hit->luaFuncUse, 3);
 						memcpy(num2, hit->luaFuncUse + 3, 3);
 
-						warning("Play SND_CLUB_HIT_FLESH");
+						g_hdb->_sound->playSound(SND_CLUB_HIT_FLESH);
 						AIEntity *found = g_hdb->_ai->findEntity(atoi(num1), atoi(num2));
 						if (found)
 							aiDragonWake(found);
 					}
 					g_hdb->_ai->addAnimateTarget(e->x, e->y, 0, 3, ANIM_NORMAL, false, false, GEM_FLASH);
-					warning("Play SND_INV_SELECT");
+					g_hdb->_sound->playSound(SND_INV_SELECT);
 					break;
 				case AI_DRAGON:
-					warning("Play SND_CLUB_HIT_FLESH");
+					g_hdb->_sound->playSound(SND_CLUB_HIT_FLESH);
 					aiDragonWake(hit);
 				default:
 					g_hdb->_ai->addAnimateTarget(e->x, e->y, 0, 3, ANIM_NORMAL, false, false, GEM_FLASH);
-					warning("Play SND_CLUB_HIT_FLESH");
+					g_hdb->_sound->playSound(SND_CLUB_HIT_FLESH);
 				}
 				if (e->value1)
 					e->sequence = 1;
@@ -554,7 +554,7 @@ void aiGemAttackAction(AIEntity *e) {
 				return;
 			} else if (result) {		// hit a wall
 					g_hdb->_ai->addAnimateTarget(e->x, e->y, 0, 3, ANIM_NORMAL, false, false, GEM_FLASH);
-					warning("Play SND_INV_SELECT");
+					g_hdb->_sound->playSound(SND_INV_SELECT);
 					// come back to daddy?
 					if (e->value1)
 						e->sequence = 1;
@@ -588,7 +588,7 @@ void aiGemAttackAction(AIEntity *e) {
 			g_hdb->_ai->setGemAmount(amt + 1);
 			g_hdb->_ai->addAnimateTarget(e->x, e->y, 0, 3, ANIM_NORMAL, false, false, GEM_FLASH);
 			g_hdb->_ai->removeEntity(e);
-			warning("Play SND_GET_GEM");
+			g_hdb->_sound->playSound(SND_GET_GEM);
 		}
 		break;
 	}
@@ -598,7 +598,7 @@ void aiChickenAction(AIEntity *e) {
 	static int delay = 64;
 
 	if (g_hdb->_map->checkEntOnScreen(e) && !delay) {
-		warning("Play SND_CHICKEN_AMBIENT");
+		g_hdb->_sound->playSound(SND_CHICKEN_AMBIENT);
 		delay = g_hdb->_rnd->getRandomNumber(128) + 160;
 		aiChickenUse(e);
 	}
@@ -613,7 +613,7 @@ void aiChickenAction(AIEntity *e) {
 }
 
 void aiChickenUse(AIEntity *e) {
-	warning("Play SND_CHICKEN_BAGAWK");
+	g_hdb->_sound->playSound(SND_CHICKEN_BAGAWK);
 }
 
 void aiChickenInit(AIEntity *e) {
@@ -646,7 +646,7 @@ void aiSergeantInit2(AIEntity *e) {
 
 void aiSergeantAction(AIEntity *e) {
 	if (e->goalX) {
-		debug(9, "STUB: AI-PLAYER: aiSergeantAction: Play SND_FOOTSTEPS sounds");
+		g_hdb->_sound->playSound(SND_FOOTSTEPS);
 		g_hdb->_ai->animateEntity(e);
 	} else
 		g_hdb->_ai->animEntFrames(e);
@@ -777,7 +777,7 @@ void aiBarrelExplode(AIEntity *e) {
 	e->state = STATE_EXPLODING;
 	e->animDelay = e->animCycle;
 	e->animFrame = 0;
-	warning("STUB: Play SND_BARREL_EXPLODE");
+	g_hdb->_sound->playSound(SND_BARREL_EXPLODE);
 	g_hdb->_map->setBoomBarrel(e->tileX, e->tileY, 0);
 }
 
@@ -965,7 +965,7 @@ void aiSlugAttackAction(AIEntity *e) {
 	uint32 fg_flags = g_hdb->_map->getMapFGTileFlags(e->tileX, e->tileY);
 	result = (e->level == 1 ? (bg_flags & (kFlagSolid)) : !(fg_flags & kFlagGrating) && (bg_flags & (kFlagSolid)));
 	if (hit) {
-		warning("STUB: Play SND_SLUG_HIT");
+		g_hdb->_sound->playSound(SND_SLUG_HIT);
 		warning("STUB: Play MetalOrFleshSnd");
 		switch (hit->type) {
 		case AI_MEERKAT:
@@ -1012,7 +1012,7 @@ void aiSlugAttackAction(AIEntity *e) {
 			g_hdb->_ai->removeEntity(hit);
 			break;
 		case AI_BOOMBARREL:
-			warning("STUB: Play SND_CLUB_HIT_METAL");
+			g_hdb->_sound->playSound(SND_CLUB_HIT_METAL);
 			aiBarrelExplode(hit);
 			aiBarrelBlowup(hit, hit->tileX, hit->tileY);
 			break;
@@ -1020,13 +1020,13 @@ void aiSlugAttackAction(AIEntity *e) {
 		case AI_GATEPUDDLE:
 			g_hdb->_ai->addAnimateTarget(e->x, e->y, 0, 7, ANIM_NORMAL, false, false, TELEPORT_FLASH);
 			g_hdb->_ai->removeEntity(hit);
-			warning("STUB: Play SND_TELEPORT");
+			g_hdb->_sound->playSound(SND_TELEPORT);
 			break;
 		case AI_DEADEYE:
 			g_hdb->_ai->addAnimateTarget(e->tileX * kTileWidth,
 				e->tileY * kTileHeight, 0, 3, ANIM_NORMAL, false, false, GROUP_EXPLOSION_BOOM_SIT);
 			g_hdb->_ai->removeEntity(hit);
-			warning("STUB: Play SND_BARREL_EXPLODE");
+			g_hdb->_sound->playSound(SND_BARREL_EXPLODE);
 			break;
 
 		case AI_NONE:
@@ -1038,7 +1038,7 @@ void aiSlugAttackAction(AIEntity *e) {
 				memcpy(num1, hit->luaFuncUse, 3);
 				memcpy(num2, hit->luaFuncUse + 3, 3);
 
-				warning("STUB: Play SND_CLUB_HIT_FLESH");
+				g_hdb->_sound->playSound(SND_CLUB_HIT_FLESH);
 				AIEntity *found = g_hdb->_ai->findEntity(atoi(num1), atoi(num2));
 				if (found)
 					aiDragonWake(found);
@@ -1054,7 +1054,7 @@ void aiSlugAttackAction(AIEntity *e) {
 		g_hdb->_ai->removeEntity(e);	// bye bye!
 		return;
 	} else if (result) {		// hit a wall
-		warning("STUB: Play SND_SLUG_HIT");
+		g_hdb->_sound->playSound(SND_SLUG_HIT);
 		g_hdb->_ai->addAnimateTarget(e->x, e->y, 0, 3, ANIM_NORMAL, false, false, GROUP_STEAM_PUFF_SIT);
 		g_hdb->_ai->removeEntity(e);
 	} else {
@@ -1076,7 +1076,7 @@ void aiSlugAttackInit(AIEntity *e) {
 	e->aiDraw = aiSlugAttackDraw;
 	e->state = STATE_MOVEDOWN;		// so it will draw & animate
 	e->aiAction = aiSlugAttackAction;
-	warning("STUB: Play SND_SLUG_FIRE");
+	g_hdb->_sound->playSound(SND_SLUG_FIRE);
 }
 
 void aiSlugAttackInit2(AIEntity *e) {
@@ -1433,7 +1433,7 @@ void aiMagicEggUse(AIEntity *e) {
 		if (spawned) {
 			g_hdb->_ai->addAnimateTarget(e->tileX * kTileWidth,
 			e->tileY * kTileHeight, 0, 3, ANIM_NORMAL, false, false, GROUP_EXPLOSION_BOOM_SIT);
-			warning("Play SND_BARREL_EXPLODE");
+			g_hdb->_sound->playSound(SND_BARREL_EXPLODE);
 			g_hdb->_ai->removeEntity(e);
 		}
 	}
@@ -1584,7 +1584,7 @@ void aiMonkeystoneUse(AIEntity *e) {
 	if (val > 1)
 		strcat(monkBuff, "s");
 	strcat(monkBuff, "!");
-	warning("STUB: Play SND_GET_MONKEYSTONE");
+	g_hdb->_sound->playSound(SND_GET_MONKEYSTONE);
 	g_hdb->_window->openMessageBar(monkBuff, kMsgDelay);
 
 	// have we unlocked a secret star(tm)???
@@ -1609,7 +1609,7 @@ void aiGemAction(AIEntity *e) {
 		if (e->onScreen && abs(p->x - e->x) < tolerance && abs(p->y - e->y) < tolerance && e->level == p->level) {
 			g_hdb->_ai->addAnimateTarget(e->x, e->y, 0, 3, ANIM_NORMAL, false, false, GEM_FLASH);
 			g_hdb->_ai->addToInventory(e);
-			warning("Play SND_GET_GEM");
+			g_hdb->_sound->playSound(SND_GET_GEM);
 			return;
 		}
 	}
@@ -1676,7 +1676,7 @@ void aiGenericAction(AIEntity *e) {
 	if (!e->goalX)
 		g_hdb->_ai->findPath(e);
 	else if (onEvenTile(e->x, e->y))
-		debug(9, "STUB: Play SND_FOOTSTEPS");
+		g_hdb->_sound->playSound(SND_FOOTSTEPS);
 	g_hdb->_ai->animateEntity(e);
 }
 
diff --git a/engines/hdb/ai-use.cpp b/engines/hdb/ai-use.cpp
index 188244c..10a8e4d 100644
--- a/engines/hdb/ai-use.cpp
+++ b/engines/hdb/ai-use.cpp
@@ -78,7 +78,7 @@ void callbackDoorOpenClose(int x, int y) {
 
 	g_hdb->_ai->addAnimateTarget(x, y, tileIndex, tileIndex + 3, ANIM_SLOW, false, true, NULL);
 	if (g_hdb->_map->onScreen(x, y))
-		warning("STUB: Play SND_DOOR_OPEN_CLOSE");
+		g_hdb->_sound->playSound(SND_DOOR_OPEN_CLOSE);
 	return;
 }
 
@@ -89,7 +89,7 @@ bool AI::useDoorOpenClose(AIEntity *e, int x, int y) {
 	addAnimateTarget(x, y, tileIndex, tileIndex - 3, ANIM_SLOW, false, true, NULL);
 	addCallback(CALLBACK_DOOR_OPEN_CLOSE, x, y, kDelay5Seconds);
 	if (g_hdb->_map->onScreen(x, y))
-		warning("Play SND_DOOR_OPEN_CLOSE");
+		g_hdb->_sound->playSound(SND_DOOR_OPEN_CLOSE);
 	return true;
 }
 
@@ -104,7 +104,7 @@ void callbackAutoDoorOpenClose(int x, int y) {
 
 	g_hdb->_ai->addAnimateTarget(x, y, tileIndex, tileIndex + 3, ANIM_SLOW, true, true, NULL);
 	if (g_hdb->_map->onScreen(x, y))
-		warning("STUB: callbackAutoDoorOpenClose: Play SND_DOOR_OPEN_CLOSE");
+		g_hdb->_sound->playSound(SND_DOOR_OPEN_CLOSE);
 	return;
 }
 
@@ -117,7 +117,7 @@ bool AI::useAutoDoorOpenClose(AIEntity *e, int x, int y) {
 	addAnimateTarget(x, y, tileIndex, tileIndex - 3, ANIM_SLOW, false, true, NULL);
 	addCallback(CALLBACK_AUTODOOR_OPEN_CLOSE, x, y, kDelay5Seconds);
 	if (g_hdb->_map->onScreen(x, y))
-		warning("useAutoDoorOpenClose: Play SND_DOOR_OPEN_CLOSE");
+		g_hdb->_sound->playSound(SND_DOOR_OPEN_CLOSE);
 	return false;
 }
 
diff --git a/engines/hdb/ai-waypoint.cpp b/engines/hdb/ai-waypoint.cpp
index 6e153a6..687c57c 100644
--- a/engines/hdb/ai-waypoint.cpp
+++ b/engines/hdb/ai-waypoint.cpp
@@ -85,7 +85,7 @@ void AI::addWaypoint(int px, int py, int x, int y, int level) {
 						_waypoints[_numWaypoints].y = ny;
 						_waypoints[_numWaypoints].level = lvl2;
 						_numWaypoints++;
-						warning("STUB: Play SND_MENU_SLIDER");
+						g_hdb->_sound->playSound(SND_MENU_SLIDER);
 
 						if (onEvenTile(_player->x, _player->y))
 							setEntityGoal(_player, tx, ty);
@@ -134,7 +134,7 @@ void AI::addWaypoint(int px, int py, int x, int y, int level) {
 				_waypoints[_numWaypoints].y = ny;
 				_waypoints[_numWaypoints].level = lvl2;
 				_numWaypoints++;
-				warning("STUB: Play SND_MENU_SLIDER");
+				g_hdb->_sound->playSound(SND_MENU_SLIDER);
 
 				if (onEvenTile(_player->x, _player->y))
 					setEntityGoal(_player, tx, ty);
@@ -163,7 +163,7 @@ void AI::addWaypoint(int px, int py, int x, int y, int level) {
 					_waypoints[_numWaypoints].y = ny;
 					_waypoints[_numWaypoints].level = lvl2;
 					_numWaypoints++;
-					warning("STUB: Play SND_MENU_SLIDER");
+					g_hdb->_sound->playSound(SND_MENU_SLIDER);
 
 					if (onEvenTile(_player->x, _player->y))
 						setEntityGoal(_player, tx, ty);
@@ -221,7 +221,7 @@ void AI::addWaypoint(int px, int py, int x, int y, int level) {
 							_waypoints[_numWaypoints].y = ty;
 							_waypoints[_numWaypoints].level = lvl1;
 							_numWaypoints++;
-							warning("STUB: Play SND_MENU_SLIDER");
+							g_hdb->_sound->playSound(SND_MENU_SLIDER);
 						}
 
 						if (_numWaypoints < kMaxWaypoints) {
@@ -229,7 +229,7 @@ void AI::addWaypoint(int px, int py, int x, int y, int level) {
 							_waypoints[_numWaypoints].y = ny;
 							_waypoints[_numWaypoints].level = lvl2;
 							_numWaypoints++;
-							warning("STUB: Play SND_MENU_SLIDER");
+							g_hdb->_sound->playSound(SND_MENU_SLIDER);
 						}
 					}
 				}
@@ -258,7 +258,7 @@ void AI::addWaypoint(int px, int py, int x, int y, int level) {
 							_waypoints[_numWaypoints].y = ty;
 							_waypoints[_numWaypoints].level = lvl1;
 							_numWaypoints++;
-							warning("STUB: Play SND_MENU_SLIDER");
+							g_hdb->_sound->playSound(SND_MENU_SLIDER);
 						}
 
 						if (_numWaypoints < kMaxWaypoints) {
@@ -266,7 +266,7 @@ void AI::addWaypoint(int px, int py, int x, int y, int level) {
 							_waypoints[_numWaypoints].y = ny;
 							_waypoints[_numWaypoints].level = lvl2;
 							_numWaypoints++;
-							warning("STUB: Play SND_MENU_SLIDER");
+							g_hdb->_sound->playSound(SND_MENU_SLIDER);
 						}
 					}
 				}
@@ -276,7 +276,7 @@ void AI::addWaypoint(int px, int py, int x, int y, int level) {
 					_waypoints[_numWaypoints].y = ty;
 					_waypoints[_numWaypoints].level = lvl1;
 					_numWaypoints++;
-					warning("STUB: Play SND_MENU_SLIDER");
+					g_hdb->_sound->playSound(SND_MENU_SLIDER);
 				}
 
 				if (_numWaypoints < kMaxWaypoints) {
@@ -284,7 +284,7 @@ void AI::addWaypoint(int px, int py, int x, int y, int level) {
 					_waypoints[_numWaypoints].y = ny;
 					_waypoints[_numWaypoints].level = lvl2;
 					_numWaypoints++;
-					warning("STUB: Play SND_MENU_SLIDER");
+					g_hdb->_sound->playSound(SND_MENU_SLIDER);
 				}
 			} else {
 				tx = px;
@@ -308,7 +308,7 @@ void AI::addWaypoint(int px, int py, int x, int y, int level) {
 						_waypoints[_numWaypoints].y = ty;
 						_waypoints[_numWaypoints].level = lvl1;
 						_numWaypoints++;
-						warning("STUB: Play SND_MENU_SLIDER");
+						g_hdb->_sound->playSound(SND_MENU_SLIDER);
 					}
 
 					if (_numWaypoints < kMaxWaypoints) {
@@ -316,7 +316,7 @@ void AI::addWaypoint(int px, int py, int x, int y, int level) {
 						_waypoints[_numWaypoints].y = ny;
 						_waypoints[_numWaypoints].level = lvl2;
 						_numWaypoints++;
-						warning("STUB: Play SND_MENU_SLIDER");
+						g_hdb->_sound->playSound(SND_MENU_SLIDER);
 					}
 				}
 			}
@@ -338,7 +338,7 @@ void AI::addWaypoint(int px, int py, int x, int y, int level) {
 		_waypoints[_numWaypoints].y = ny;
 		_waypoints[_numWaypoints].level = level;
 		_numWaypoints++;
-		warning("STUB: addWaypoint: Play SND_MENU_SLIDER");
+		g_hdb->_sound->playSound(SND_MENU_SLIDER);
 	}
 }
 
diff --git a/engines/hdb/input.cpp b/engines/hdb/input.cpp
index c9dbd2c..2c527e6 100644
--- a/engines/hdb/input.cpp
+++ b/engines/hdb/input.cpp
@@ -60,13 +60,13 @@ void Input::setButtons(uint16 b) {
 	if ((_buttons & kButtonA) && !changeState && (g_hdb->getGameState() != GAME_MENU)) {
 		if (g_hdb->_ai->cinematicsActive() && g_hdb->_ai->cineAbortable()) {
 			g_hdb->_ai->cineAbort();
-			warning("STUB: setButtons: Play SND_POP");
+			g_hdb->_sound->playSound(SND_POP);
 			return;
 		}
 
 		if (g_hdb->getGameState() == GAME_TITLE)
 			warning("STUB: setButtons: changeToMenu() required");
-		warning("STUB: setButtons: Play SND_MENU_BACKOUT");
+		g_hdb->_sound->playSound(SND_MENU_BACKOUT);
 		g_hdb->changeGameState();
 	}
 
@@ -181,7 +181,7 @@ void Input::stylusDown(int x, int y) {
 				g_hdb->_window->centerTextOut("Running Speed", kScreenHeight - 32, kRunToggleDelay * kGameFPS);
 			else
 				g_hdb->_window->centerTextOut("Walking Speed", kScreenHeight - 32, kRunToggleDelay * kGameFPS);
-			warning("STUB: Play SND_SWITCH_USE");
+			g_hdb->_sound->playSound(SND_SWITCH_USE);
 		}
 
 		g_hdb->setTargetXY(worldX, worldY);
@@ -268,7 +268,7 @@ void Input::updateMouseButtons(int l, int m, int r) {
 			return;
 
 		g_hdb->_ai->clearWaypoints();
-		warning("STUB: Play SND_POP");
+		g_hdb->_sound->playSound(SND_POP);
 	}
 
 	// Check if RButton has been pressed
diff --git a/engines/hdb/lua-script.cpp b/engines/hdb/lua-script.cpp
index 4b10868..6b18b21 100644
--- a/engines/hdb/lua-script.cpp
+++ b/engines/hdb/lua-script.cpp
@@ -705,32 +705,32 @@ static int animation(lua_State *L) {
 	case 0:
 		g_hdb->_ai->addAnimateTarget((int)x, (int)y, 0, 3, ANIM_NORMAL, false, false, GROUP_WATER_SPLASH_SIT);
 		if (playsnd)
-			warning("STUB: Play SND_SPLASH");
+			g_hdb->_sound->playSound(SND_SPLASH);
 		break;
 	case 1:
 		g_hdb->_ai->addAnimateTarget((int)x, (int)y, 0, 3, ANIM_NORMAL, false, false, GROUP_EXPLOSION_BOOM_SIT);
 		if (playsnd)
-			warning("STUB: Play SND_BARREL_EXPLODE");
+			g_hdb->_sound->playSound(SND_BARREL_EXPLODE);
 		break;
 	case 2:
 		g_hdb->_ai->addAnimateTarget((int)x, (int)y, 0, 3, ANIM_FAST, false, false, GROUP_STEAM_PUFF_SIT);
 		if (playsnd)
-			warning("STUB: Play SND_BARREL_MELTING");
+			g_hdb->_sound->playSound(SND_BARREL_MELTING);
 		break;
 	case 3:
 		g_hdb->_ai->addAnimateTarget((int)x, (int)y, 0, 7, ANIM_NORMAL, false, false, TELEPORT_FLASH);
 		if (playsnd)
-			warning("STUB: Play SND_TELEPORT");
+			g_hdb->_sound->playSound(SND_TELEPORT);
 		break;
 	case 4:
 		g_hdb->_ai->addAnimateTarget((int)x, (int)y, 0, 3, ANIM_NORMAL, false, false, GEM_FLASH);
 		if (playsnd)
-			warning("STUB: Play SND_GET_GEM");
+			g_hdb->_sound->playSound(SND_GET_GEM);
 		break;
 	case 5:
 		g_hdb->_ai->addAnimateTarget((int)x, (int)y, 0, 2, ANIM_NORMAL, false, false, GROUP_ENT_CHICKEN_DIE);
 		if (playsnd)
-			warning("STUB: Play SND_CHICKEN_DEATH");
+			g_hdb->_sound->playSound(SND_CHICKEN_DEATH);
 		break;
 	}
 
diff --git a/engines/hdb/window.cpp b/engines/hdb/window.cpp
index a0902cf..71e16e9 100644
--- a/engines/hdb/window.cpp
+++ b/engines/hdb/window.cpp
@@ -112,7 +112,7 @@ void Window::drawPause() {
 void Window::checkPause(uint x, uint y) {
 	if (x >= 480 / 2 - _gfxPausePlaque->_width / 2 && 480 / 2 + _gfxPausePlaque->_width / 2 > x && y >= kPauseY && y < kPauseY + _gfxPausePlaque->_height) {
 		g_hdb->togglePause();
-		warning("STUB: checkPause: Play SND_POP");
+		g_hdb->_sound->playSound(SND_POP);
 	}
 }
 
@@ -168,7 +168,7 @@ void Window::openDialog(const char *title, int tileIndex, const char *string, in
 	_dialogInfo.more = more;
 	if (luaMore)
 		strcpy(_dialogInfo.luaMore, luaMore);
-	warning("STUB: openDialog: Play SND_MOVE_SELECTION");
+	g_hdb->_sound->playSound(SND_MOVE_SELECTION);
 }
 
 void Window::drawDialog() {
@@ -230,7 +230,7 @@ void Window::drawDialog() {
 
 void Window::closeDialog() {
 	if (_dialogInfo.active) {
-		warning("STUB: closeDialog: Play SND_SWITCH_USE");
+		g_hdb->_sound->playSound(SND_SWITCH_USE);
 		_dialogInfo.active = false;
 		_dialogDelay = 0;
 		if (_dialogInfo.luaMore[0] && !g_hdb->_ai->cinematicsActive())
@@ -378,7 +378,7 @@ void Window::openDialogChoice(const char *title, const char *text, const char *f
 
 	_dialogChoiceInfo.selection = 0;
 	_dialogChoiceInfo.timeout = 0;
-	warning("STUB: Play SND_MOVE_SELECTION");
+	g_hdb->_sound->playSound(SND_MOVE_SELECTION);
 }
 
 void Window::drawDialogChoice() {
@@ -440,7 +440,7 @@ void Window::closeDialogChoice() {
 		g_hdb->_lua->pushFunction(_dialogChoiceInfo.func);
 		g_hdb->_lua->pushInt(_dialogChoiceInfo.selection);
 		g_hdb->_lua->call(1, 0);
-		warning("STUB: Play SND_SWITCH_USE");
+		g_hdb->_sound->playSound(SND_SWITCH_USE);
 	}
 }
 
@@ -450,7 +450,7 @@ bool Window::checkDialogChoiceClose(int x, int y) {
 
 	if (x >= _dialogChoiceInfo.x && x < _dialogChoiceInfo.x + _dialogChoiceInfo.width &&
 		y >= _dialogChoiceInfo.y + _dialogChoiceInfo.textHeight && y < _dialogChoiceInfo.y + _dialogChoiceInfo.textHeight + _dialogChoiceInfo.numChoices * 16) {
-		warning("STUB: Play SND_SWITCH_USE");
+		g_hdb->_sound->playSound(SND_SWITCH_USE);
 		_dialogChoiceInfo.selection = (y - (_dialogChoiceInfo.y + _dialogChoiceInfo.textHeight)) >> 4;
 		_dialogChoiceInfo.timeout = g_hdb->getTimeSlice() + 500;
 		return true;
@@ -463,14 +463,14 @@ void Window::dialogChoiceMoveup() {
 	_dialogChoiceInfo.selection--;
 	if (_dialogChoiceInfo.selection < 0)
 		_dialogChoiceInfo.selection = _dialogChoiceInfo.numChoices - 1;
-	warning("STUB: Play SND_MOVE_SELECTION");
+	g_hdb->_sound->playSound(SND_MOVE_SELECTION);
 }
 
 void Window::dialogChoiceMovedown() {
 	_dialogChoiceInfo.selection++;
 	if (_dialogChoiceInfo.selection >= _dialogChoiceInfo.numChoices)
 		_dialogChoiceInfo.selection = 0;
-	warning("STUB: Play SND_MOVE_SELECTION");
+	g_hdb->_sound->playSound(SND_MOVE_SELECTION);
 }
 
 void Window::openMessageBar(const char *title, int time) {
@@ -585,7 +585,7 @@ void Window::nextMsgQueued() {
 
 void Window::closeMsg() {
 	nextMsgQueued();
-	warning("STUB: Play SND_DIALOG_CLOSE");
+	g_hdb->_sound->playSound(SND_DIALOG_CLOSE);
 }
 
 void Window::drawInventory() {
@@ -678,7 +678,7 @@ void Window::checkInvSelect(int x, int y) {
 		// If this is a weapon, choose it
 		warning("STUB: checkInvSelect: ChooseWeapon() required");
 
-		warning("STUB: checkInvSelect: Play SND_POP");
+		g_hdb->_sound->playSound(SND_POP);
 	}
 }
 
@@ -694,7 +694,7 @@ void Window::openDeliveries(bool animate) {
 			d->destGfx = g_hdb->_gfx->loadTile(d->destGfxName);
 	}
 
-	warning("STUB: Play SND_POP");
+	g_hdb->_sound->playSound(SND_POP);
 	_dlvsInfo.animate = animate;
 	_dlvsInfo.delay1 = g_hdb->getTimeSlice() + 500;
 	_dlvsInfo.go1 = _dlvsInfo.go2 = _dlvsInfo.go3 = false;
@@ -714,7 +714,45 @@ void Window::drawDeliveries() {
 	DlvEnt *d;
 	static uint32 timer = g_hdb->getTimeSlice() + 300;
 
-	debug(9, "STUB: Add Crazy Sounds");
+	int crazySounds[kNumCrazy] = {
+		SND_GUI_INPUT,
+		SND_MAIL_PROCESS,
+		SND_MONKEY_OOHOOH,
+		SND_GET_GEM,
+		SND_MENU_ACCEPT,
+		SND_MENU_BACKOUT,
+		SND_MENU_SLIDER,
+		SND_DIALOG_CLOSE,
+		SND_POP,
+		SND_SPLASH,
+		SND_CHICKEN_AMBIENT,
+		SND_SWITCH_USE,
+		SND_BARREL_EXPLODE,
+		SND_BARREL_MELTING,
+		SND_MOVE_SELECTION,
+		SND_NOTICE,
+		SND_DIALOG_OPEN,
+		SND_TOUCHPLATE_CLICK,
+		SND_MBOT_HYEAH,
+		SND_MBOT_YEAH,
+		SND_MBOT_WHISTLE1,
+		SND_CLUB_MISS,
+		SND_CLUB_HIT_METAL,
+		SND_CLUB_HIT_FLESH,
+		SND_FROG_LICK,
+		SND_ROBOT_STUNNED,
+		SND_BRIDGE_EXTEND,
+		SND_BRIDGE_END,
+		SND_AIRLOCK_CLOSE,
+		SND_FART,
+		SND_FART2,
+		SND_GEM_THROW,
+		SND_INV_SELECT,
+		SND_INFOCOMP,
+		SND_CLOCK_BONK,
+		SND_GET_GOO,
+		SND_MANNY_CRASH
+	};
 
 	if (_infobarDimmed > 1)
 		return;
@@ -742,7 +780,7 @@ void Window::drawDeliveries() {
 					if (!_dlvsInfo.go2) {
 						_dlvsInfo.go2 = true;
 						_dlvsInfo.delay2 = g_hdb->getTimeSlice() + 500;
-						warning("STUB: Play crazy sound");
+						g_hdb->_sound->playSound(crazySounds[g_hdb->_rnd->getRandomNumber(kNumCrazy)]);
 					}
 				}
 			}
@@ -756,7 +794,7 @@ void Window::drawDeliveries() {
 					if (!_dlvsInfo.go3) {
 						_dlvsInfo.go3 = true;
 						_dlvsInfo.delay3 = g_hdb->getTimeSlice() + 500;
-						warning("STUB: Play crazy sound");
+						g_hdb->_sound->playSound(crazySounds[g_hdb->_rnd->getRandomNumber(kNumCrazy)]);
 					}
 				}
 			}
@@ -770,7 +808,7 @@ void Window::drawDeliveries() {
 					g_hdb->_gfx->drawText("to ");
 					g_hdb->_gfx->drawText(d->destTextName);
 
-					warning("STUB: Play crazy sound");
+					g_hdb->_sound->playSound(crazySounds[g_hdb->_rnd->getRandomNumber(kNumCrazy)]);
 					_dlvsInfo.animate = false;
 				}
 			}
@@ -823,7 +861,7 @@ void Window::drawDeliveries() {
 
 void Window::setSelectedDelivery(int which) {
 	_dlvsInfo.selected = which;
-	warning("STUB: Play SND_MENU_SLIDER");
+	g_hdb->_sound->playSound(SND_MENU_SLIDER);
 }
 
 void Window::checkDlvSelect(int x, int y) {


Commit: ce06f4eb9e0a516b370ea602318fd2eb49be9b43
    https://github.com/scummvm/scummvm/commit/ce06f4eb9e0a516b370ea602318fd2eb49be9b43
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:09+02:00

Commit Message:
HDB: Fix compilation

Changed paths:
    engines/hdb/ai-player.cpp


diff --git a/engines/hdb/ai-player.cpp b/engines/hdb/ai-player.cpp
index 5b7d979..323b308 100644
--- a/engines/hdb/ai-player.cpp
+++ b/engines/hdb/ai-player.cpp
@@ -1424,7 +1424,7 @@ void aiMagicEggUse(AIEntity *e) {
 		int	i = 0;
 		AIEntity *spawned = NULL;
 		while (aiEntList[i].type != END_AI_TYPES) {
-			if (!_stricmp(aiEntList[i].luaName, e->luaFuncAction)) {
+			if (!scumm_stricmp(aiEntList[i].luaName, e->luaFuncAction)) {
 				spawned = g_hdb->_ai->spawn(aiEntList[i].type, e->dir, e->tileX, e->tileY, NULL, NULL, NULL, DIR_NONE, e->level, 0, 0, 1);
 				break;
 			}


Commit: 734995512e354af0dac3ee5681372f283c7d375e
    https://github.com/scummvm/scummvm/commit/734995512e354af0dac3ee5681372f283c7d375e
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:09+02:00

Commit Message:
HDB: Added more script patches

Changed paths:
    engines/hdb/lua-script.cpp


diff --git a/engines/hdb/lua-script.cpp b/engines/hdb/lua-script.cpp
index 6b18b21..a42ca79 100644
--- a/engines/hdb/lua-script.cpp
+++ b/engines/hdb/lua-script.cpp
@@ -40,10 +40,12 @@ struct ScriptPatch {
 	{"GLOBAL_LUA", "if( dtable.counter < getn(dtable) ) then", "if( dtable.counter < #dtable ) then"},
 	{"GLOBAL_LUA", "if( getglobal( \"map\"..tostring(v1)..\"_complete\" ) ) then", "if( _G[\"map\"..tostring(v1)..\"_complete\"] ) then"},
 	{"GLOBAL_LUA", "closefunc = getglobal( npcdef.codename..\"_use\" )", "closefunc = _G[npcdef.codename..\"_use\"]"},
+	{"GLOBAL_LUA", "strsub(", "string.sub("}, // line 15
 	{"MAP00_LUA", "tempfunc = function() emptybed_use( %x, %y, %v1, %v2 ) end", "tempfunc = function() emptybed_use(x, y, v1, v2) end"},
 	{"MAP00_LUA", "if( getn( beds ) == 0 ) then", "if( #beds == 0 ) then"},
 	{"MAP01_LUA", "if( covert_index < getn(covert_dialog) ) then", "if( covert_index < #covert_dialog ) then"},
 	{"MAP01_LUA", "if( chiste_index < getn( chiste_dialog ) )then", "if( covert_index < #covert_dialog ) then"},
+	{"MAP01_LUA", "strsub(", "string.sub("}, // line 23
 	{NULL, NULL, NULL},
 };
 


Commit: 106a63aa81a17d9598936785b55d80641d6432de
    https://github.com/scummvm/scummvm/commit/106a63aa81a17d9598936785b55d80641d6432de
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:09+02:00

Commit Message:
HDB: Add LASTMAPNAME Lua variable

Changed paths:
    engines/hdb/hdb.cpp
    engines/hdb/hdb.h
    engines/hdb/lua-script.cpp


diff --git a/engines/hdb/hdb.cpp b/engines/hdb/hdb.cpp
index 978e85c..d4db1cf 100644
--- a/engines/hdb/hdb.cpp
+++ b/engines/hdb/hdb.cpp
@@ -76,6 +76,8 @@ bool HDBGame::init() {
 		Game Subsystem Initializations
 	*/
 
+	_lastMapname[0] = 0;
+
 	// Init fileMan
 
 	if (!_fileMan->openMPC(getGameFile())) {
diff --git a/engines/hdb/hdb.h b/engines/hdb/hdb.h
index c93cdf4..62c266e 100644
--- a/engines/hdb/hdb.h
+++ b/engines/hdb/hdb.h
@@ -189,6 +189,8 @@ public:
 		return _timeSlice - _prevTimeSlice;
 	}
 
+	char *lastMapname() { return _lastMapname; }
+
 	bool _gameShutdown;
 	Graphics::PixelFormat _format;
 
@@ -207,6 +209,8 @@ private:
 	int _actionMode; // 0 or 1
 	int _pauseFlag;
 
+	char _lastMapname[64];
+
 };
 
 extern HDBGame *g_hdb;
diff --git a/engines/hdb/lua-script.cpp b/engines/hdb/lua-script.cpp
index a42ca79..8e7083b 100644
--- a/engines/hdb/lua-script.cpp
+++ b/engines/hdb/lua-script.cpp
@@ -1346,10 +1346,9 @@ bool LuaScript::initScript(Common::SeekableReadStream *stream, const char *scrip
 		lua_setglobal(_state, luaGlobalValues[j].luaName);
 	}
 
-	/*
-		TODO: Set the last mapName as a global
-		after implementing the map-manager.
-	*/
+	// set the last mapname as a global
+	lua_pushstring(_state, g_hdb->lastMapname());
+	lua_setglobal(_state, "LASTMAP");
 
 	// Set the lowest printable line
 	lua_pushnumber(_state, 480 - 14);


Commit: af43070e150452c7876a6bc949c7ad36ae761508
    https://github.com/scummvm/scummvm/commit/af43070e150452c7876a6bc949c7ad36ae761508
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:09+02:00

Commit Message:
HDB: Implemented HDBGame::startMap()

Changed paths:
    engines/hdb/hdb.cpp
    engines/hdb/hdb.h


diff --git a/engines/hdb/hdb.cpp b/engines/hdb/hdb.cpp
index d4db1cf..6e19f1e 100644
--- a/engines/hdb/hdb.cpp
+++ b/engines/hdb/hdb.cpp
@@ -52,6 +52,8 @@ HDBGame::HDBGame(OSystem *syst, const ADGameDescription *gameDesc) : Engine(syst
 	_window = new Window;
 	_rnd = new Common::RandomSource("hdb");
 
+	_currentMapname[0] = _currentLuaName[0] = 0;
+
 	DebugMan.addDebugChannel(kDebugExample1, "Example1", "This is just an example to test");
 	DebugMan.addDebugChannel(kDebugExample2, "Example2", "This is also an example");
 }
@@ -145,6 +147,40 @@ void HDBGame::changeGameState() {
 	}
 }
 
+bool HDBGame::restartMap() {
+	if (!_currentMapname[0])
+		return false;
+
+	warning("STUB: HDBGame::restartMap()");
+
+	return true;
+}
+
+bool HDBGame::startMap(char *name) {
+	// save last mapname
+	strcpy(_lastMapname, _currentMapname);
+
+	// set current mapname
+	strcpy(_currentMapname, name);
+	strcat(_currentMapname, ".MSM");
+
+	// set current luaname
+	strcpy(_currentLuaName, name );
+	strcat(_currentLuaName, ".LUA");
+
+	restartMap();
+
+	//
+	// here is where we will be autosaving the start of level
+	// don't save cine intro/outro/etc...OR map30 (secret star map)
+	//
+	if (!scumm_strnicmp(name, "map", 3) && scumm_stricmp(name, "map30")) {
+		//_menu->fillSavegameSlots();
+		saveSlot(0);          // we ignore the slot parameter in everything else since we just keep saving...
+	}
+	return true;
+}
+
 void HDBGame::paint() {
 	switch (_gameState) {
 	case GAME_TITLE:
@@ -322,6 +358,12 @@ void HDBGame::setTargetXY(int x, int y) {
 	}
 }
 
+bool HDBGame::saveSlot(int slot) {
+	warning("STUB: HDBGame::saveSlot(%d)", slot);
+
+	return true;
+}
+
 // PLAYER is trying to use this entity
 void HDBGame::useEntity(AIEntity *e) {
 	warning("STUB: HDBGame::useEntity incomplete");
diff --git a/engines/hdb/hdb.h b/engines/hdb/hdb.h
index 62c266e..53ac40f 100644
--- a/engines/hdb/hdb.h
+++ b/engines/hdb/hdb.h
@@ -147,6 +147,12 @@ public:
 	bool init();
 
 	void start();
+
+	bool restartMap();
+	bool startMap(char *name);
+
+	bool saveSlot(int slot);
+
 	void setGameState(GameState gs) {
 		_gameState = gs;
 	}
@@ -209,8 +215,12 @@ private:
 	int _actionMode; // 0 or 1
 	int _pauseFlag;
 
+	char _currentMapname[64];
 	char _lastMapname[64];
 
+	char _currentLuaName[64];
+	char _lastLuaName[64];
+
 };
 
 extern HDBGame *g_hdb;


Commit: 34a3e1685bef4b57f10d4acdbf568a217315fa32
    https://github.com/scummvm/scummvm/commit/34a3e1685bef4b57f10d4acdbf568a217315fa32
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:09+02:00

Commit Message:
HDB: Added stub for Menu class

Changed paths:
  A engines/hdb/menu.cpp
  A engines/hdb/menu.h
    engines/hdb/hdb.cpp
    engines/hdb/hdb.h
    engines/hdb/module.mk
    engines/hdb/sound.cpp


diff --git a/engines/hdb/hdb.cpp b/engines/hdb/hdb.cpp
index 6e19f1e..0d10b50 100644
--- a/engines/hdb/hdb.cpp
+++ b/engines/hdb/hdb.cpp
@@ -32,6 +32,7 @@
 
 #include "hdb/hdb.h"
 #include "hdb/console.h"
+#include "hdb/menu.h"
 
 namespace HDB {
 
@@ -45,6 +46,7 @@ HDBGame::HDBGame(OSystem *syst, const ADGameDescription *gameDesc) : Engine(syst
 	_fileMan = new FileMan;
 	_gfx = new Gfx;
 	_lua = new LuaScript;
+	_menu = new Menu;
 	_map = new Map;
 	_ai = new AI;
 	_input = new Input;
@@ -175,7 +177,7 @@ bool HDBGame::startMap(char *name) {
 	// don't save cine intro/outro/etc...OR map30 (secret star map)
 	//
 	if (!scumm_strnicmp(name, "map", 3) && scumm_stricmp(name, "map30")) {
-		//_menu->fillSavegameSlots();
+		_menu->fillSavegameSlots();
 		saveSlot(0);          // we ignore the slot parameter in everything else since we just keep saving...
 	}
 	return true;
diff --git a/engines/hdb/hdb.h b/engines/hdb/hdb.h
index 53ac40f..b9247db 100644
--- a/engines/hdb/hdb.h
+++ b/engines/hdb/hdb.h
@@ -56,6 +56,8 @@ struct ADGameDescription;
 
 namespace HDB {
 
+class Menu;
+
 enum GameFeatures {
 	ADGF_TALKIE = 1 << 0
 };
@@ -136,6 +138,7 @@ public:
 	Map *_map;
 	AI *_ai;
 	Input *_input;
+	Menu *_menu;
 	Sound *_sound;
 	Window *_window;
 
diff --git a/engines/hdb/menu.cpp b/engines/hdb/menu.cpp
new file mode 100644
index 0000000..a707e84
--- /dev/null
+++ b/engines/hdb/menu.cpp
@@ -0,0 +1,37 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "hdb/hdb.h"
+#include "hdb/menu.h"
+
+namespace HDB {
+
+bool Menu::init() {
+	warning("STUB: Menu::init()");
+	return true;
+}
+
+void Menu::fillSavegameSlots() {
+	warning("STUB: PMenu::fillSavegameSlots()");
+}
+
+} // End of Namespace
diff --git a/engines/hdb/menu.h b/engines/hdb/menu.h
new file mode 100644
index 0000000..cd23b97
--- /dev/null
+++ b/engines/hdb/menu.h
@@ -0,0 +1,38 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef HDB_MENU_H
+#define HDB_MENU_H
+
+namespace HDB {
+
+class Menu {
+public:
+
+	bool init();
+
+	void fillSavegameSlots();
+};
+
+} // End of Namespace
+
+#endif // !HDB_SOUND_H
diff --git a/engines/hdb/module.mk b/engines/hdb/module.mk
index e6417b9..7fa8431 100644
--- a/engines/hdb/module.mk
+++ b/engines/hdb/module.mk
@@ -18,6 +18,7 @@ MODULE_OBJS := \
 	input.o \
 	lua-script.o \
 	map.o \
+	menu.o \
 	sound.o \
 	window.o
 
diff --git a/engines/hdb/sound.cpp b/engines/hdb/sound.cpp
index 12f64ad..4d39feb 100644
--- a/engines/hdb/sound.cpp
+++ b/engines/hdb/sound.cpp
@@ -25,6 +25,7 @@
 namespace HDB {
 
 bool Sound::init() {
+	warning("STUB: Sound::init()");
 	return true;
 }
 


Commit: 74eb242b5a0606a274b38e1fdc12b9b8fb908368
    https://github.com/scummvm/scummvm/commit/74eb242b5a0606a274b38e1fdc12b9b8fb908368
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:09+02:00

Commit Message:
HDB: Unstub HDBGame::restartMap()

Changed paths:
    engines/hdb/gfx.cpp
    engines/hdb/gfx.h
    engines/hdb/hdb.cpp
    engines/hdb/hdb.h
    engines/hdb/lua-script.cpp
    engines/hdb/lua-script.h
    engines/hdb/map.cpp
    engines/hdb/map.h
    engines/hdb/menu.cpp
    engines/hdb/menu.h
    engines/hdb/sound.cpp
    engines/hdb/sound.h


diff --git a/engines/hdb/gfx.cpp b/engines/hdb/gfx.cpp
index 3dfe644..bf9c43e 100644
--- a/engines/hdb/gfx.cpp
+++ b/engines/hdb/gfx.cpp
@@ -233,6 +233,10 @@ Tile *Gfx::getTile(int index) {
 	return _tLookupArray[index].tData;
 }
 
+void Gfx::emptyGfxCaches() {
+	warning("STUB: mptyGfxCaches()");
+}
+
 void Gfx::cacheTileSequence(int tileIndex, int count) {
 	for (int i = tileIndex; i < tileIndex + count; i++)
 		getTile(i);
@@ -462,6 +466,10 @@ void Gfx::drawSky() {
 	}
 }
 
+void Gfx::drawSnow() {
+	debug(9, "STUB: Gfx::drawSnow()");
+}
+
 int Gfx::animateTile(int tileIndex) {
 	return _tLookupArray[tileIndex].animIndex;
 }
diff --git a/engines/hdb/gfx.h b/engines/hdb/gfx.h
index d369edc..fb26fe4 100644
--- a/engines/hdb/gfx.h
+++ b/engines/hdb/gfx.h
@@ -107,6 +107,7 @@ public:
 	bool isFadeActive() { return _fadeInfo.active; }
 	bool isFadeStaying() { return _fadeInfo.stayFaded; }
 	void turnOffFade() { _fadeInfo.active = _fadeInfo.stayFaded = false; }
+	void turnOffSnow() { _snowInfo.active = false; }
 
 	Picture *loadPic(const char *picName);
 	Tile *loadTile(const char *tileName);
@@ -116,6 +117,8 @@ public:
 	int getTileIndex(const char *name);
 	Picture *getPicture(const char *name);
 
+	void emptyGfxCaches();
+
 	// Returns: true->Tile, false->Pic
 	bool selectGfxType(const char *name);
 	Tile *getTileGfx(const char *name, uint32 size);
@@ -128,6 +131,7 @@ public:
 	void draw3DStars();
 	void draw3DStarsLeft();
 	void drawSky();
+	void drawSnow();
 
 	int animateTile(int tileIndex);
 
@@ -162,6 +166,16 @@ private:
 		int curStep;
 	} _fadeInfo;
 
+#define MAX_SNOW                50                              // how many snowflakes onscreen
+#define MAX_SNOW_XV             12
+	struct {
+		bool    active;
+		double  x[MAX_SNOW];
+		double  y[MAX_SNOW];
+		double  yv[MAX_SNOW];
+		int     xvindex[MAX_SNOW];
+	} _snowInfo;
+
 	struct {
 		int x, y, speed;
 		uint16 color;
diff --git a/engines/hdb/hdb.cpp b/engines/hdb/hdb.cpp
index 0d10b50..fdbacec 100644
--- a/engines/hdb/hdb.cpp
+++ b/engines/hdb/hdb.cpp
@@ -56,6 +56,10 @@ HDBGame::HDBGame(OSystem *syst, const ADGameDescription *gameDesc) : Engine(syst
 
 	_currentMapname[0] = _currentLuaName[0] = 0;
 
+	_monkeystone7 = STARS_MONKEYSTONE_7_FAKE;
+	_monkeystone14 = STARS_MONKEYSTONE_14_FAKE;
+	_monkeystone21 = STARS_MONKEYSTONE_21_FAKE;
+
 	DebugMan.addDebugChannel(kDebugExample1, "Example1", "This is just an example to test");
 	DebugMan.addDebugChannel(kDebugExample2, "Example2", "This is also an example");
 }
@@ -153,7 +157,40 @@ bool HDBGame::restartMap() {
 	if (!_currentMapname[0])
 		return false;
 
-	warning("STUB: HDBGame::restartMap()");
+	_gfx->emptyGfxCaches();
+	_lua->callFunction("level_shutdown", 0);
+
+	_gfx->turnOffSnow();
+	_window->restartSystem();
+	_ai->restartSystem();
+	_lua->init();
+	_lua->loadLua(_currentLuaName);
+
+	_sound->markSoundCacheFreeable();
+	_map->restartSystem();
+
+	if (!_map->loadMap(_currentMapname))
+		return false;
+
+	_ai->initAnimInfo();
+
+	// if there are Secret Stars here, stick the variable in Lua
+	if (!_menu->_starWarp && getStarsMonkeystone7() == STARS_MONKEYSTONE_7)
+		_lua->setLuaGlobalValue("secretstars", 1);
+	if (_menu->_starWarp == 1 && getStarsMonkeystone14() == STARS_MONKEYSTONE_14)
+		_lua->setLuaGlobalValue("secretstars", 2);
+	if (_menu->_starWarp == 2 && getStarsMonkeystone21() == STARS_MONKEYSTONE_21)
+		_lua->setLuaGlobalValue("secretstars", 3);
+
+	_lua->callFunction("level_loaded", 0);
+	if (!_ai->cinematicsActive())
+		_gfx->turnOffFade();
+
+	// center the player on the screen
+	int x, y;
+
+	_ai->getPlayerXY(&x, &y);
+	_map->centerMapXY(x + 16, y + 16);
 
 	return true;
 }
diff --git a/engines/hdb/hdb.h b/engines/hdb/hdb.h
index b9247db..573f953 100644
--- a/engines/hdb/hdb.h
+++ b/engines/hdb/hdb.h
@@ -200,6 +200,17 @@ public:
 
 	char *lastMapname() { return _lastMapname; }
 
+	//
+	// monkeystone secret stars
+	//
+	int32 getStarsMonkeystone7() { return _monkeystone7; }
+	int32 getStarsMonkeystone14() { return _monkeystone14; }
+	int32 getStarsMonkeystone21() { return _monkeystone21; }
+
+	void setStarsMonkeystone7(int32 value) { _monkeystone7 = value; }
+	void setStarsMonkeystone14(int32 value) { _monkeystone14 = value; }
+	void setStarsMonkeystone21(int32 value) { _monkeystone21 = value; }
+
 	bool _gameShutdown;
 	Graphics::PixelFormat _format;
 
@@ -224,6 +235,10 @@ private:
 	char _currentLuaName[64];
 	char _lastLuaName[64];
 
+	int32 _monkeystone7;
+	int32 _monkeystone14;
+	int32 _monkeystone21;
+
 };
 
 extern HDBGame *g_hdb;
diff --git a/engines/hdb/lua-script.cpp b/engines/hdb/lua-script.cpp
index 8e7083b..eaf46ab 100644
--- a/engines/hdb/lua-script.cpp
+++ b/engines/hdb/lua-script.cpp
@@ -72,6 +72,20 @@ bool LuaScript::init() {
 	return true;
 }
 
+bool LuaScript::loadLua(char *name) {
+	warning("STUB: loadLua(%s)", name);
+
+	return true;
+}
+
+void LuaScript::setLuaGlobalValue(const char *name, int value) {
+	if (!_state)
+		return;
+
+	lua_pushnumber(_state, value);
+	lua_setglobal(_state, name);
+}
+
 /*
 	Called from Lua, this will pop into the menu
 */
diff --git a/engines/hdb/lua-script.h b/engines/hdb/lua-script.h
index 5cab8cb..4679d2c 100644
--- a/engines/hdb/lua-script.h
+++ b/engines/hdb/lua-script.h
@@ -42,6 +42,8 @@ public:
 	LuaScript();
 	~LuaScript();
 
+	bool loadLua(char *name);
+
 	bool init();
 	bool initScript(Common::SeekableReadStream *stream, const char *scriptName, int32 length);
 
@@ -58,6 +60,8 @@ public:
 
 	const char *getStringOffStack();
 
+	void setLuaGlobalValue(const char *name, int value);
+
 private:
 	lua_State *_state;
 	int _pcallErrorhandlerRegistryIndex;
diff --git a/engines/hdb/map.cpp b/engines/hdb/map.cpp
index ccad3b4..c34104c 100644
--- a/engines/hdb/map.cpp
+++ b/engines/hdb/map.cpp
@@ -68,6 +68,16 @@ int Map::loadTiles() {
 	return skyIndex;
 }
 
+void Map::restartSystem() {
+	warning("STUB: Map::restartSystem()");
+}
+
+bool Map::loadMap(char *name) {
+	warning("STUB: loadMap(%s)", name);
+
+	return true;
+}
+
 bool Map::load(Common::SeekableReadStream *stream) {
 	if (_mapLoaded) {
 		return false;
diff --git a/engines/hdb/map.h b/engines/hdb/map.h
index fcbd82e..3360e91 100644
--- a/engines/hdb/map.h
+++ b/engines/hdb/map.h
@@ -74,8 +74,11 @@ public:
 	Map();
 	~Map();
 
+	void restartSystem();
+
 	int loadTiles();
 	bool load(Common::SeekableReadStream *stream);
+	bool loadMap(char *name);
 	void draw();
 	void drawEnts();
 	void drawGratings();
diff --git a/engines/hdb/menu.cpp b/engines/hdb/menu.cpp
index a707e84..73c0eac 100644
--- a/engines/hdb/menu.cpp
+++ b/engines/hdb/menu.cpp
@@ -26,7 +26,10 @@
 namespace HDB {
 
 bool Menu::init() {
+	_starWarp = 0;
+
 	warning("STUB: Menu::init()");
+
 	return true;
 }
 
diff --git a/engines/hdb/menu.h b/engines/hdb/menu.h
index cd23b97..73e5a80 100644
--- a/engines/hdb/menu.h
+++ b/engines/hdb/menu.h
@@ -25,12 +25,21 @@
 
 namespace HDB {
 
+#define STARS_MONKEYSTONE_7			0xfe257d	// magic value in the config file for the unlocking of the Monkeystone secret #7
+#define STARS_MONKEYSTONE_7_FAKE	0x11887e	// fake value that means it hasn't been unlocked
+#define STARS_MONKEYSTONE_14		0x3341fe	// <same> for the Monkeystone #14
+#define STARS_MONKEYSTONE_14_FAKE	0x1cefd0	// fake value that means it hasn't been unlocked
+#define STARS_MONKEYSTONE_21		0x77ace3	// <same> for the Monkeystone #21
+#define STARS_MONKEYSTONE_21_FAKE	0x3548fe	// fake value that means it hasn't been unlocked
+
 class Menu {
 public:
 
 	bool init();
 
 	void fillSavegameSlots();
+
+	int _starWarp;
 };
 
 } // End of Namespace
diff --git a/engines/hdb/sound.cpp b/engines/hdb/sound.cpp
index 4d39feb..e37a6da 100644
--- a/engines/hdb/sound.cpp
+++ b/engines/hdb/sound.cpp
@@ -39,4 +39,8 @@ bool Sound::playVoice(int index, int actor) {
 	return true;
 }
 
+void Sound::markSoundCacheFreeable() {
+	warning("STUB: Sound::markSoundCacheFreeable() ");
+}
+
 } // End of Namespace
diff --git a/engines/hdb/sound.h b/engines/hdb/sound.h
index 1493ad2..f268309 100644
--- a/engines/hdb/sound.h
+++ b/engines/hdb/sound.h
@@ -1383,6 +1383,8 @@ public:
 
 	bool playSound(int index);
 	bool playVoice(int index, int actor);
+
+	void markSoundCacheFreeable();
 };
 
 } // End of Namespace


Commit: c3c8299962aaa335d4acb4ae39b772accf3cfff1
    https://github.com/scummvm/scummvm/commit/c3c8299962aaa335d4acb4ae39b772accf3cfff1
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:09+02:00

Commit Message:
HDB: Completed rendering pipeline

Changed paths:
    engines/hdb/hdb.cpp
    engines/hdb/hdb.h
    engines/hdb/menu.cpp
    engines/hdb/menu.h


diff --git a/engines/hdb/hdb.cpp b/engines/hdb/hdb.cpp
index fdbacec..3fefb28 100644
--- a/engines/hdb/hdb.cpp
+++ b/engines/hdb/hdb.cpp
@@ -55,6 +55,7 @@ HDBGame::HDBGame(OSystem *syst, const ADGameDescription *gameDesc) : Engine(syst
 	_rnd = new Common::RandomSource("hdb");
 
 	_currentMapname[0] = _currentLuaName[0] = 0;
+	_lastMapname[0] = _lastLuaName[0] = 0;
 
 	_monkeystone7 = STARS_MONKEYSTONE_7_FAKE;
 	_monkeystone14 = STARS_MONKEYSTONE_14_FAKE;
@@ -84,8 +85,6 @@ bool HDBGame::init() {
 		Game Subsystem Initializations
 	*/
 
-	_lastMapname[0] = 0;
-
 	// Init fileMan
 
 	if (!_fileMan->openMPC(getGameFile())) {
@@ -94,27 +93,30 @@ bool HDBGame::init() {
 	if (!_gfx->init()) {
 		error("Gfx::init: Couldn't initialize Gfx");
 	}
-	if (!_input->init()) {
-		error("Input::init: Couldn't initialize Input");
+	if (!_sound->init()) {
+		error("Window::init: Couldn't initialize Sound");
 	}
 	if (!_ai->init()) {
 		error("AI::init: Couldn't initialize AI");
 	}
-	if (!_lua->init()) {
-		error("LuaScript::init: Couldn't load the GLOBAL_LUA code.");
-	}
-	if (!_sound->init()) {
-		error("Window::init: Couldn't initialize Sound");
-	}
 	if (!_window->init()) {
 		error("Window::init: Couldn't initialize Window");
 	}
+	if (!_input->init()) {
+		error("Input::init: Couldn't initialize Input");
+	}
+	if (!_lua->init()) {
+		error("LuaScript::init: Couldn't load the GLOBAL_LUA code.");
+	}
+
+	_menu->init();
+
+	_changeLevel = false;
+	_changeMapname[0] = 0;
+	_loadInfo.active = _saveInfo.active = false;
 
-	// REMOVE: Putting this here since Menu hasn't been implemented yet.
-	// Defaults the game into Action Mode
-	setActionMode(1);
+	_menu->startTitle();
 
-	start();
 	_gameShutdown = false;
 	_pauseFlag = 0;
 	_systemInit = true;
@@ -122,11 +124,6 @@ bool HDBGame::init() {
 	return true;
 }
 
-void HDBGame::start() {
-	warning("REMOVE: _gameState initialized to GAME_PLAY");
-	_gameState = GAME_PLAY;
-}
-
 /*
 	Changes the current GameState to the next one.
 	Game State Transitions are deterministic: each state can
@@ -600,13 +597,32 @@ Common::Error HDBGame::run() {
 			_map->drawForegrounds();
 			_ai->animateTargets();
 
-			_window->drawDialogChoice();
 			_window->drawDialog();
-			_window->drawMessageBar();
+			_window->drawDialogChoice();
 			_window->drawInventory();
+			_window->drawMessageBar();
 			_window->drawDeliveries();
 			_window->drawTextOut();
 			_window->drawPause();
+
+			//_gfx->drawBonusStars();
+			_gfx->drawSnow();
+
+			if (_changeLevel == true) {
+				_changeLevel = false;
+				startMap(_changeMapname);
+			}
+
+			//
+			// should we save the game at this point?
+			//
+			if (_saveInfo.active == true) {
+				_sound->playSound(SND_VORTEX_SAVE);
+				_ai->stopEntity(e);
+				_menu->fillSavegameSlots();
+				saveSlot(_saveInfo.slot);
+				_saveInfo.active = false;
+			}
 		}
 
 		// Update Timer that's NOT used for in-game Timing
diff --git a/engines/hdb/hdb.h b/engines/hdb/hdb.h
index 573f953..33778b3 100644
--- a/engines/hdb/hdb.h
+++ b/engines/hdb/hdb.h
@@ -149,13 +149,26 @@ public:
 
 	bool init();
 
-	void start();
-
 	bool restartMap();
 	bool startMap(char *name);
 
+	void changeMap(char *name) {
+		strcpy(_changeMapname, name);
+		_changeLevel = true;
+	}
+
 	bool saveSlot(int slot);
 
+	void saveWhenReady(int slot) {
+		_saveInfo.active = true;
+		_saveInfo.slot = slot;
+	}
+
+	void loadWhenReady(int slot) {
+		_loadInfo.active = true;
+		_loadInfo.slot = slot;
+	}
+
 	void setGameState(GameState gs) {
 		_gameState = gs;
 	}
@@ -200,6 +213,11 @@ public:
 
 	char *lastMapname() { return _lastMapname; }
 
+	void changeLevel(char *name) {
+		strcpy(_changeMapname, name);
+		_changeLevel = true;
+	}
+
 	//
 	// monkeystone secret stars
 	//
@@ -239,6 +257,15 @@ private:
 	int32 _monkeystone14;
 	int32 _monkeystone21;
 
+	bool _changeLevel;
+	char _changeMapname[64];
+
+	struct {
+		bool active;
+		int  slot;
+	} _saveInfo, _loadInfo;
+
+
 };
 
 extern HDBGame *g_hdb;
diff --git a/engines/hdb/menu.cpp b/engines/hdb/menu.cpp
index 73c0eac..4b65a8b 100644
--- a/engines/hdb/menu.cpp
+++ b/engines/hdb/menu.cpp
@@ -33,6 +33,16 @@ bool Menu::init() {
 	return true;
 }
 
+void Menu::startTitle() {
+	// REMOVE: Putting this here since Menu hasn't been implemented yet.
+	// Defaults the game into Action Mode
+	g_hdb->setActionMode(1);
+	g_hdb->setGameState(GAME_PLAY);
+
+	warning("STUB: Menu::startTitle()");
+
+}
+
 void Menu::fillSavegameSlots() {
 	warning("STUB: PMenu::fillSavegameSlots()");
 }
diff --git a/engines/hdb/menu.h b/engines/hdb/menu.h
index 73e5a80..ebf1e5a 100644
--- a/engines/hdb/menu.h
+++ b/engines/hdb/menu.h
@@ -37,6 +37,8 @@ public:
 
 	bool init();
 
+	void startTitle();
+
 	void fillSavegameSlots();
 
 	int _starWarp;


Commit: 4baa1e4f20816c0546cf94b39c51611b1bec1f4a
    https://github.com/scummvm/scummvm/commit/4baa1e4f20816c0546cf94b39c51611b1bec1f4a
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:09+02:00

Commit Message:
HDB: Add isClosedDoor() and isOpenDoor()

Changed paths:
    engines/hdb/ai-use.cpp
    engines/hdb/ai.h


diff --git a/engines/hdb/ai-use.cpp b/engines/hdb/ai-use.cpp
index 10a8e4d..37951f9 100644
--- a/engines/hdb/ai-use.cpp
+++ b/engines/hdb/ai-use.cpp
@@ -24,6 +24,70 @@
 
 namespace HDB {
 
+bool AI::isClosedDoor(int x, int y) {
+	int tileIndex = g_hdb->_map->getMapBGTileIndex(x, y);
+
+	if ((tileIndex == _targetDoorN + 3) ||		// locked SILVER door?
+		(tileIndex == _targetDoorNv + 3) ||
+		(tileIndex == _targetDoorP + 3) ||		// locked BLUE door?
+		(tileIndex == _targetDoorPv + 3) ||
+		(tileIndex == _targetDoorS + 3) ||		// locked RED door?
+		(tileIndex == _targetDoorSv + 3) ||
+		(tileIndex == _targetDoor2N + 3) ||		// locked SILVER door?
+		(tileIndex == _targetDoor2Nv + 3) ||
+		(tileIndex == _targetDoor2P + 3) ||		// locked BLUE door?
+		(tileIndex == _targetDoor2Pv + 3) ||
+		(tileIndex == _targetDoor2S + 3) ||		// locked RED door?
+		(tileIndex == _targetDoor2Sv + 3) ||
+		(tileIndex == _target2DoorN + 3) ||		// locked SILVER door?
+		(tileIndex == _target2DoorNv + 3) ||
+		(tileIndex == _target2DoorP + 3) ||		// locked BLUE door?
+		(tileIndex == _target2DoorPv + 3) ||
+		(tileIndex == _target2DoorS + 3) ||		// locked RED door?
+		(tileIndex == _target2DoorSv + 3) ||
+		(tileIndex == _target3DoorN + 3) ||		// locked SILVER door?
+		(tileIndex == _target3DoorNv + 3) ||
+		(tileIndex == _target3DoorP + 3) ||		// locked BLUE door?
+		(tileIndex == _target3DoorPv + 3) ||
+		(tileIndex == _target3DoorS + 3) ||		// locked RED door?
+		(tileIndex == _target3DoorSv + 3) ||
+		(tileIndex == _blockpole + 3))			// blockpole UP?
+		return true;
+	return false;
+}
+
+bool AI::isOpenDoor(int x, int y) {
+	int tileIndex = g_hdb->_map->getMapBGTileIndex(x, y);
+
+	if ((tileIndex == _targetDoorN) ||		// open SILVER door?
+		(tileIndex == _targetDoorNv) ||
+		(tileIndex == _targetDoorP) ||		// open BLUE door?
+		(tileIndex == _targetDoorPv) ||
+		(tileIndex == _targetDoorS) ||		// open RED door?
+		(tileIndex == _targetDoorSv) ||
+		(tileIndex == _targetDoor2N) ||		// open SILVER door?
+		(tileIndex == _targetDoor2Nv) ||
+		(tileIndex == _targetDoor2P) ||		// open BLUE door?
+		(tileIndex == _targetDoor2Pv) ||
+		(tileIndex == _targetDoor2S) ||		// open RED door?
+		(tileIndex == _targetDoor2Sv) ||
+		(tileIndex == _target2DoorN) ||		// open SILVER door?
+		(tileIndex == _target2DoorNv) ||
+		(tileIndex == _target2DoorP) ||		// open BLUE door?
+		(tileIndex == _target2DoorPv) ||
+		(tileIndex == _target2DoorS) ||		// open RED door?
+		(tileIndex == _target2DoorSv) ||
+		(tileIndex == _target3DoorN) ||		// open SILVER door?
+		(tileIndex == _target3DoorNv) ||
+		(tileIndex == _target3DoorP) ||		// open BLUE door?
+		(tileIndex == _target3DoorPv) ||
+		(tileIndex == _target3DoorS) ||		// open RED door?
+		(tileIndex == _target3DoorSv) ||
+		(tileIndex == _blockpole))			// blockpole DOWN?
+		return true;
+	return false;
+}
+
 // Black Door Switch
 bool AI::useSwitch(AIEntity *e, int x, int y, int targetX, int targetY, int onTile) {
 	warning("STUB: Define useSwitch");
diff --git a/engines/hdb/ai.h b/engines/hdb/ai.h
index 80f7a71..afc25cb 100644
--- a/engines/hdb/ai.h
+++ b/engines/hdb/ai.h
@@ -1197,6 +1197,10 @@ private:
 
 	// Action Functions
 
+	// Checks for the existence of a closed/open door
+	bool isClosedDoor(int x, int y);
+	bool isOpenDoor(int x, int y);
+
 	// Black Door Switch
 	bool useSwitch(AIEntity *e, int x, int y, int targetX, int targetY, int onTile);
 	bool useSwitchOn(AIEntity *e, int x, int y, int targetX, int targetY, int offTile);


Commit: 10802c22fbe5bcadf32e2e1a974e39e75b599e8f
    https://github.com/scummvm/scummvm/commit/10802c22fbe5bcadf32e2e1a974e39e75b599e8f
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:09+02:00

Commit Message:
HDB: Add _bridges data

Changed paths:
    engines/hdb/ai-init.cpp
    engines/hdb/ai.h


diff --git a/engines/hdb/ai-init.cpp b/engines/hdb/ai-init.cpp
index f8fe0c2..1c22013 100644
--- a/engines/hdb/ai-init.cpp
+++ b/engines/hdb/ai-init.cpp
@@ -869,6 +869,10 @@ void AI::restartSystem() {
 	// Clear waypoints
 	memset(&_waypoints[0], 0, sizeof(_waypoints));
 	_numWaypoints = 0;
+
+	// Clear Bridges
+	memset(&_bridges[0], 0, sizeof(_bridges));
+	_numBridges = 0;
 }
 
 void AI::initAnimInfo() {
diff --git a/engines/hdb/ai.h b/engines/hdb/ai.h
index afc25cb..d64523f 100644
--- a/engines/hdb/ai.h
+++ b/engines/hdb/ai.h
@@ -40,6 +40,7 @@ enum {
 	kMaxAutoActions = 30,
 	kMaxLuaEnts = 50,
 	kMaxCallbacks = 20,
+	kMaxBridges = 10,
 	kDelay5Seconds = 5 * kGameFPS,
 	kPlayerMoveSpeed = 4,
 	kEnemyMoveSpeed = 2,
@@ -712,6 +713,15 @@ struct Callback {
 	Callback() : type(NO_FUNCTION), x(0), y(0), delay(0) {}
 };
 
+struct Bridge {
+	uint16 x, y;
+	AIDir dir;
+	uint16 delay;
+	uint16 anim;
+
+	Bridge() : x(0), y(0), dir(DIR_NONE), delay(0), anim(0) {}
+};
+
 struct CineCommand {
 	CineType cmdType;
 	double x, y;
@@ -1172,6 +1182,9 @@ public:
 
 	Callback _callbacks[kMaxCallbacks];
 
+	Bridge _bridges[kMaxBridges];
+	int _numBridges;
+
 	Common::Array<ArrowPath *> *_arrowPaths;
 	Common::Array<HereT *> *_hereList;
 	Common::Array<Trigger *> *_triggerList;


Commit: 73b7b830984025a8f5b877652cce758267be43ca
    https://github.com/scummvm/scummvm/commit/73b7b830984025a8f5b877652cce758267be43ca
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:09+02:00

Commit Message:
HDB: Add addBridgeExtend() and animateBridges()

Changed paths:
    engines/hdb/ai-lists.cpp
    engines/hdb/ai.h


diff --git a/engines/hdb/ai-lists.cpp b/engines/hdb/ai-lists.cpp
index 5126d14..4e6c876 100644
--- a/engines/hdb/ai-lists.cpp
+++ b/engines/hdb/ai-lists.cpp
@@ -136,6 +136,110 @@ void AI::animateTargets() {
 	}
 }
 
+void AI::addBridgeExtend(int x, int y, int bridgeType) {
+	if (_numBridges >= kMaxBridges)
+		return;
+
+	if (bridgeType == _targetBridgeU)
+		_bridges[_numBridges].dir = DIR_UP;
+	else if (bridgeType == _targetBridgeD)
+		_bridges[_numBridges].dir = DIR_DOWN;
+	else if (bridgeType == _targetBridgeL)
+		_bridges[_numBridges].dir = DIR_LEFT;
+	else if (bridgeType == _targetBridgeR)
+		_bridges[_numBridges].dir = DIR_RIGHT;
+
+	_bridges[_numBridges].delay = 5;
+	_bridges[_numBridges].x = x;
+	_bridges[_numBridges].y = y;
+	_bridges[_numBridges].anim = 0;
+
+	if (g_hdb->_map->onScreen(_bridges[_numBridges].x, _bridges[_numBridges].y))
+		g_hdb->_sound->playSound(SND_BRIDGE_START);
+
+	_numBridges++;
+}
+
+void AI::animateBridges() {
+	int	i, j, tileIndex, xv, yv;
+	uint32 flags;
+	bool done;
+
+	// out quick!
+	if (!_numBridges)
+		return;
+
+	for (i = 0; i < _numBridges; i++) {
+		if (_bridges[i].delay-- > 0)
+			continue;
+
+		_bridges[i].delay = 5;
+		done = false;
+		xv = yv = 0;
+
+		switch (_bridges[i].dir) {
+		case DIR_UP:
+			g_hdb->_map->setMapFGTileIndex(_bridges[i].x, _bridges[i].y, _targetBridgeU + _bridges[i].anim);
+			_bridges[i].anim++;
+			if (_bridges[i].anim > 2) {
+				g_hdb->_map->setMapFGTileIndex(_bridges[i].x, _bridges[i].y, _targetBridgeMidUD);
+				yv = -1;
+				done = true;
+			}
+			break;
+		case DIR_DOWN:
+			g_hdb->_map->setMapFGTileIndex(_bridges[i].x, _bridges[i].y, _targetBridgeD + _bridges[i].anim);
+			_bridges[i].anim++;
+			if (_bridges[i].anim > 2)
+			{
+				g_hdb->_map->setMapFGTileIndex(_bridges[i].x, _bridges[i].y, _targetBridgeMidUD);
+				yv = 1;
+				done = true;
+			}
+			break;
+		case DIR_LEFT:
+			g_hdb->_map->setMapFGTileIndex(_bridges[i].x, _bridges[i].y, _targetBridgeL + _bridges[i].anim);
+			_bridges[i].anim++;
+			if (_bridges[i].anim > 2)
+			{
+				g_hdb->_map->setMapFGTileIndex(_bridges[i].x, _bridges[i].y, _targetBridgeMidLR);
+				xv = -1;
+				done = true;
+			}
+			break;
+		case DIR_RIGHT:
+			g_hdb->_map->setMapFGTileIndex(_bridges[i].x, _bridges[i].y, _targetBridgeR + _bridges[i].anim);
+			_bridges[i].anim++;
+			if (_bridges[i].anim > 2)
+			{
+				g_hdb->_map->setMapFGTileIndex(_bridges[i].x, _bridges[i].y, _targetBridgeMidLR);
+				xv = 1;
+				done = true;
+			}
+			break;
+		}
+
+		// is this bridge done extending one chunk?
+		if (done == true)
+		{
+			if (g_hdb->_map->onScreen(_bridges[i].x, _bridges[i].y))
+				g_hdb->_sound->playSound(SND_BRIDGE_EXTEND);
+			_bridges[i].anim = 0;
+			_bridges[i].x += xv;
+			_bridges[i].y += yv;
+			tileIndex = g_hdb->_map->getMapFGTileIndex(_bridges[i].x, _bridges[i].y);
+			flags = g_hdb->_map->getMapBGTileFlags(_bridges[i].x, _bridges[i].y);
+			if (!flags || (flags & kFlagMetal) || tileIndex >= 0 || (flags & kFlagSolid)) {
+				if (g_hdb->_map->onScreen(_bridges[i].x, _bridges[i].y))
+					g_hdb->_sound->playSound(SND_BRIDGE_END);
+				for (j = 0; j < _numBridges - 1; j++)
+					memcpy(&_bridges[i], &_bridges[i + 1], sizeof(Bridge));
+				_numBridges--;
+			}
+		}
+	}
+}
+
 // Add an action location to the list of possible actions
 // Each action must be paired with another of the same number
 void AI::addToActionList(int actionIndex, int x, int y, char *luaFuncInt, char *luaFuncUse) {
diff --git a/engines/hdb/ai.h b/engines/hdb/ai.h
index d64523f..7a9b74f 100644
--- a/engines/hdb/ai.h
+++ b/engines/hdb/ai.h
@@ -813,6 +813,9 @@ public:
 	void addAnimateTarget(int x, int y, int start, int end, AnimSpeed speed, bool killAuto, bool inMap, const char *tileName);
 	void animateTargets();
 
+	void addBridgeExtend(int x, int y, int bridgeType);
+	void animateBridges();
+
 	AIEntity *playerCollision(int topBorder, int bottomBorder, int leftBorder, int rightBorder);
 	bool checkPlayerTileCollision(int x, int y);
 	bool checkPlayerCollision(int x, int y, int border);


Commit: 661ee3b104770ddb801af4aa2ab07df00c494eee
    https://github.com/scummvm/scummvm/commit/661ee3b104770ddb801af4aa2ab07df00c494eee
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:09+02:00

Commit Message:
HDB: Add useTarget()

Changed paths:
    engines/hdb/ai-use.cpp
    engines/hdb/ai.h


diff --git a/engines/hdb/ai-use.cpp b/engines/hdb/ai-use.cpp
index 37951f9..f63c608 100644
--- a/engines/hdb/ai-use.cpp
+++ b/engines/hdb/ai-use.cpp
@@ -88,6 +88,49 @@ bool AI::isOpenDoor(int x, int y) {
 	return false;
 }
 
+bool AI::useTarget(int x, int y, int targetX, int targetY, int newTile, int *worked) {
+	int tileIndex;
+
+	// open a locked door?
+	if (isClosedDoor(targetX, targetY)) {
+		tileIndex = g_hdb->_map->getMapBGTileIndex(targetX, targetY);
+
+		addAnimateTarget(targetX, targetY, tileIndex, tileIndex - 3, ANIM_SLOW, false, true, NULL);
+		g_hdb->_map->setMapBGTileIndex(x, y, newTile);
+		if (g_hdb->_map->onScreen(x, y))
+			g_hdb->_sound->playSound(SND_DOOR_OPEN_CLOSE);
+		*worked = 1;
+		return false;						// return FALSE because we need to be able to do it some more
+	}
+
+	// close an open door?
+	if (isOpenDoor(targetX, targetY)) {
+		tileIndex = g_hdb->_map->getMapBGTileIndex(targetX, targetY);
+
+		addAnimateTarget(targetX, targetY, tileIndex, tileIndex + 3, ANIM_SLOW, false, true, NULL);
+		g_hdb->_map->setMapBGTileIndex(x, y, newTile);
+		if (g_hdb->_map->onScreen(x, y))
+			g_hdb->_sound->playSound(SND_DOOR_OPEN_CLOSE);
+		*worked = 1;
+		return false;						// return FALSE because we need to be able to do it some more
+	}
+
+	// open up a bridge?
+	tileIndex = g_hdb->_map->getMapFGTileIndex(targetX, targetY);
+	if (tileIndex == _targetBridgeU ||
+		tileIndex == _targetBridgeD ||
+		tileIndex == _targetBridgeL ||
+		tileIndex == _targetBridgeR) {
+		addBridgeExtend(targetX, targetY, tileIndex);
+		g_hdb->_map->setMapBGTileIndex(x, y, newTile);
+		*worked = 1;
+		return true;						// return TRUE because we can't open it again
+	}
+
+	*worked = 0;
+	return false;
+}
+
 // Black Door Switch
 bool AI::useSwitch(AIEntity *e, int x, int y, int targetX, int targetY, int onTile) {
 	warning("STUB: Define useSwitch");
diff --git a/engines/hdb/ai.h b/engines/hdb/ai.h
index 7a9b74f..14495b3 100644
--- a/engines/hdb/ai.h
+++ b/engines/hdb/ai.h
@@ -1217,6 +1217,9 @@ private:
 	bool isClosedDoor(int x, int y);
 	bool isOpenDoor(int x, int y);
 
+	// MAIN FUNCTION : handles all animation of targeted tiles & changing the state of the "switch"
+	bool useTarget(int x, int y, int targetX, int targetY, int newTile, int *worked);
+
 	// Black Door Switch
 	bool useSwitch(AIEntity *e, int x, int y, int targetX, int targetY, int onTile);
 	bool useSwitchOn(AIEntity *e, int x, int y, int targetX, int targetY, int offTile);


Commit: e3ceb4dfbde8ccf9d0b5b9a584892d6b202f63f3
    https://github.com/scummvm/scummvm/commit/e3ceb4dfbde8ccf9d0b5b9a584892d6b202f63f3
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:09+02:00

Commit Message:
HDB: Add Switch functions

Changed paths:
    engines/hdb/ai-use.cpp


diff --git a/engines/hdb/ai-use.cpp b/engines/hdb/ai-use.cpp
index f63c608..fdbaaaf 100644
--- a/engines/hdb/ai-use.cpp
+++ b/engines/hdb/ai-use.cpp
@@ -133,29 +133,67 @@ bool AI::useTarget(int x, int y, int targetX, int targetY, int newTile, int *wor
 
 // Black Door Switch
 bool AI::useSwitch(AIEntity *e, int x, int y, int targetX, int targetY, int onTile) {
-	warning("STUB: Define useSwitch");
-	return false;
+	int worked;
+	if (g_hdb->_map->onScreen(x, y))
+		g_hdb->_sound->playSound(SND_SWITCH_USE);
+	return useTarget(x, y, targetX, targetY, onTile, &worked);
 }
 
 bool AI::useSwitchOn(AIEntity *e, int x, int y, int targetX, int targetY, int offTile) {
-	warning("STUB: Define useSwitchOn");
-	return false;
+	int worked;
+	if (g_hdb->_map->onScreen(x, y))
+		g_hdb->_sound->playSound(SND_SWITCH_USE);
+	return useTarget(x, y, targetX, targetY, offTile, &worked);
 }
 
 bool AI::useSwitch2(AIEntity *e, int x, int y, int targetX, int targetY) {
-	warning("STUB: Define useSwitch2");
-	return false;
+	int i = 10;
+	return true;
 }
 
 // Colored Keycard Switch
 bool AI::useLockedSwitch(AIEntity *e, int x, int y, int targetX, int targetY, int onTile, AIType item, const char *keyerror) {
-	warning("STUB: Define useLockedSwitch");
+	// is the PLAYER next to this thing?  No other entities are allowed to unlock anything!
+	if (abs(x - _player->tileX) > 1 || abs(y - _player->tileY) > 1)
+		return false;
+
+	int	amount = queryInventoryType(item);
+	int	worked;
+	bool rtn;
+
+	if (amount) {
+		rtn = useTarget(x, y, targetX, targetY, onTile, &worked);
+		if (worked) {
+			removeInvItemType(item, 1);
+			if (g_hdb->_map->onScreen(x, y))
+				g_hdb->_sound->playSound(SND_SWITCH_USE);
+		}
+		return rtn;
+	} else {
+		if (g_hdb->_map->onScreen(x, y))
+			g_hdb->_sound->playSound(SND_CELLHOLDER_USE_REJECT);
+		g_hdb->_window->openMessageBar(keyerror, 3);
+	}
 	return false;
 }
 
 bool AI::useLockedSwitchOn(AIEntity *e, int x, int y, int targetX, int targetY, int offTile, AIType item) {
-	warning("STUB: Define useLockedSwitchOn");
-	return false;
+	// is the PLAYER next to this thing?  No other entities are allowed to unlock anything!
+	if (abs(x - _player->tileX) > 1 || abs(y - _player->tileY) > 1)
+		return false;
+
+	int	worked;
+	bool rtn;
+	if (getInvAmount() == 10)
+		return false;
+
+	rtn = useTarget(x, y, targetX, targetY, offTile, &worked);
+	if (worked) {
+		addItemToInventory(item, 1, NULL, NULL, NULL);
+		if (g_hdb->_map->onScreen(x, y))
+			g_hdb->_sound->playSound(SND_SWITCH_USE);
+	}
+	return rtn;
 }
 
 // Purple Cell Holder Switch


Commit: c2c639cfc4de7860cf014f91edbc376513b86443
    https://github.com/scummvm/scummvm/commit/c2c639cfc4de7860cf014f91edbc376513b86443
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:09+02:00

Commit Message:
HDB: Add Cell Holder function

Changed paths:
    engines/hdb/ai-use.cpp


diff --git a/engines/hdb/ai-use.cpp b/engines/hdb/ai-use.cpp
index fdbaaaf..e2b3f9a 100644
--- a/engines/hdb/ai-use.cpp
+++ b/engines/hdb/ai-use.cpp
@@ -198,7 +198,29 @@ bool AI::useLockedSwitchOn(AIEntity *e, int x, int y, int targetX, int targetY,
 
 // Purple Cell Holder Switch
 bool AI::useCellHolder(AIEntity *e, int x, int y, int targetX, int targetY) {
-	warning("STUB: Define useCellHolder");
+	// is the PLAYER next to this thing?  No other entities are allowed to unlock anything!
+	if (abs(x - _player->tileX) > 1 || abs(y - _player->tileY) > 1)
+		return false;
+
+	int	amount = queryInventoryType(ITEM_CELL);
+	int	worked;
+	bool rtn;
+
+	if (amount) {
+		rtn = useTarget(x, y, targetX, targetY, _useHolderFull, &worked);
+		if (worked) {
+			removeInvItemType(ITEM_CELL, 1);
+			if (g_hdb->_map->onScreen(x, y))
+				g_hdb->_sound->playSound(SND_SWITCH_USE);
+		}
+		return rtn;
+	} else {
+		if (g_hdb->_map->onScreen(x, y))
+			g_hdb->_sound->playSound(SND_CELLHOLDER_USE_REJECT);
+	}
+
+	g_hdb->_window->openDialog("Locked!", -1, "I can't use that unless I have an Energy Cell.", 0, NULL);
+	g_hdb->_sound->playVoice(GUY_ENERGY_CELL, 0);
 	return false;
 }
 


Commit: e1d69ed3893a2ea67d238c2f09d49b181765ab46
    https://github.com/scummvm/scummvm/commit/e1d69ed3893a2ea67d238c2f09d49b181765ab46
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:09+02:00

Commit Message:
HDB: Add Touchplate functions

Changed paths:
    engines/hdb/ai-use.cpp


diff --git a/engines/hdb/ai-use.cpp b/engines/hdb/ai-use.cpp
index e2b3f9a..bca7315 100644
--- a/engines/hdb/ai-use.cpp
+++ b/engines/hdb/ai-use.cpp
@@ -226,12 +226,14 @@ bool AI::useCellHolder(AIEntity *e, int x, int y, int targetX, int targetY) {
 
 // Touchplate
 bool AI::useTouchplate(AIEntity *e, int x, int y, int targetX, int targetY, int type) {
-	warning("STUB: Define useTouchplate");
-	return false;
+	int worked;
+	g_hdb->_sound->playSound(SND_TOUCHPLATE_CLICK);
+	return useTarget(x, y, targetX, targetY, type, &worked);
 }
 bool AI::useTouchplateOn(AIEntity *e, int x, int y, int targetX, int targetY, int type) {
-	warning("STUB: Define useTouchplateOn");
-	return false;
+	int worked;
+	g_hdb->_sound->playSound(SND_TOUCHPLATE_CLICK);
+	return useTarget(x, y, targetX, targetY, type, &worked);
 }
 
 void callbackDoorOpenClose(int x, int y) {


Commit: eacc59bca9a22af15fffe809c3de383c0e144c38
    https://github.com/scummvm/scummvm/commit/eacc59bca9a22af15fffe809c3de383c0e144c38
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:09+02:00

Commit Message:
HDB: Add useDoorOpenCloseBot()

Changed paths:
    engines/hdb/ai-use.cpp


diff --git a/engines/hdb/ai-use.cpp b/engines/hdb/ai-use.cpp
index bca7315..f48b9e6 100644
--- a/engines/hdb/ai-use.cpp
+++ b/engines/hdb/ai-use.cpp
@@ -292,8 +292,19 @@ bool AI::useAutoDoorOpenClose(AIEntity *e, int x, int y) {
 
 // Any Type Door
 bool AI::useDoorOpenCloseBot(AIEntity *e, int x, int y) {
-	warning("STUB: Define useDoorOpenCloseBot");
-	return false;
+	int	tileIndex = g_hdb->_map->getMapBGTileIndex(x, y);
+
+	if (e == _player || e->type == AI_SLUG_ATTACK || e->type == AI_GEM_ATTACK) {
+		if (isClosedDoor(x, y))
+			g_hdb->_sound->playSound(SND_GUY_UHUH);
+		return false;
+	}
+
+	addAnimateTarget(x, y, tileIndex, tileIndex - 3, ANIM_SLOW, false, true, NULL);
+	//	AddCallback( CALLBACK_DOOR_OPEN_CLOSE, x, y, DELAY_5SECONDS / fs );
+	if (g_hdb->_map->onScreen(x, y))
+		g_hdb->_sound->playSound(SND_DOOR_OPEN_CLOSE);
+	return true;
 }
 
 } // End of Namespace


Commit: e97d425b8a70d4dac28291cb4262a37981db823a
    https://github.com/scummvm/scummvm/commit/e97d425b8a70d4dac28291cb4262a37981db823a
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:09+02:00

Commit Message:
HDB: Unstub printYouGotMsg call

Changed paths:
    engines/hdb/ai-inventory.cpp


diff --git a/engines/hdb/ai-inventory.cpp b/engines/hdb/ai-inventory.cpp
index 48ce48f..e9eb098 100644
--- a/engines/hdb/ai-inventory.cpp
+++ b/engines/hdb/ai-inventory.cpp
@@ -74,7 +74,7 @@ bool AI::addToInventory(AIEntity *e) {
 		warning("AI-INVENTORY: addToInventory: Unintended Type");
 	}
 
-	warning("STUB: addToInventory: Print a 'You Got' message");
+	printYouGotMsg(e->printedName);
 	removeEntity(e);
 	return true;
 }


Commit: 347dd30f784f7739da2a5ea29117851a7665e1ec
    https://github.com/scummvm/scummvm/commit/347dd30f784f7739da2a5ea29117851a7665e1ec
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:10+02:00

Commit Message:
HDB: Implement loadLua()

Changed paths:
    engines/hdb/hdb.cpp
    engines/hdb/lua-script.cpp
    engines/hdb/lua-script.h


diff --git a/engines/hdb/hdb.cpp b/engines/hdb/hdb.cpp
index 3fefb28..9eaf120 100644
--- a/engines/hdb/hdb.cpp
+++ b/engines/hdb/hdb.cpp
@@ -503,14 +503,7 @@ Common::Error HDBGame::run() {
 	tile->load(tileStream);
 #endif
 
-	Common::SeekableReadStream *luaStream = _fileMan->findFirstData("MAP00_LUA", TYPE_BINARY);
-	int32 luaLength = _fileMan->getLength("MAP00_LUA", TYPE_BINARY);
-	if (luaStream == NULL) {
-		debug("The MAP00_LUA MPC entry can't be found.");
-		return Common::kReadingFailed;
-	}
-
-	_lua->initScript(luaStream, "MAP00_LUA", luaLength);
+	_lua->loadLua("MAP00_LUA");
 
 	_lua->callFunction("level_loaded", 0);
 
diff --git a/engines/hdb/lua-script.cpp b/engines/hdb/lua-script.cpp
index eaf46ab..5c273e2 100644
--- a/engines/hdb/lua-script.cpp
+++ b/engines/hdb/lua-script.cpp
@@ -72,8 +72,16 @@ bool LuaScript::init() {
 	return true;
 }
 
-bool LuaScript::loadLua(char *name) {
-	warning("STUB: loadLua(%s)", name);
+bool LuaScript::loadLua(const char *name) {
+	Common::SeekableReadStream *luaStream = g_hdb->_fileMan->findFirstData(name, TYPE_BINARY);
+	int32 luaLength = g_hdb->_fileMan->getLength(name, TYPE_BINARY);
+	if (luaStream == NULL) {
+		warning("The %s MPC entry can't be found", name);
+
+		return false;
+	}
+
+	initScript(luaStream, name, luaLength);
 
 	return true;
 }
diff --git a/engines/hdb/lua-script.h b/engines/hdb/lua-script.h
index 4679d2c..6949deb 100644
--- a/engines/hdb/lua-script.h
+++ b/engines/hdb/lua-script.h
@@ -42,7 +42,7 @@ public:
 	LuaScript();
 	~LuaScript();
 
-	bool loadLua(char *name);
+	bool loadLua(const char *name);
 
 	bool init();
 	bool initScript(Common::SeekableReadStream *stream, const char *scriptName, int32 length);


Commit: 3eab2731cdf60574b9ecddb09b5a8ad4a02a566b
    https://github.com/scummvm/scummvm/commit/3eab2731cdf60574b9ecddb09b5a8ad4a02a566b
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:10+02:00

Commit Message:
HDB: Implement loadMap()

Changed paths:
    engines/hdb/file-manager.cpp
    engines/hdb/hdb.cpp
    engines/hdb/hdb.h
    engines/hdb/lua-script.cpp
    engines/hdb/map.cpp


diff --git a/engines/hdb/file-manager.cpp b/engines/hdb/file-manager.cpp
index 66543db..0bc22fb 100644
--- a/engines/hdb/file-manager.cpp
+++ b/engines/hdb/file-manager.cpp
@@ -96,23 +96,29 @@ Common::SeekableReadStream *FileMan::findFirstData(const char *string, DataType
 	Common::String fileString;
 	MPCEntry *file = NULL;
 
-	debug(4, "Looking for Data: '%s'", string);
+	char fname[128];
+	strcpy(fname, string);
+	char *pDest = strrchr(fname, '.');
+	if (pDest)
+		*pDest = '_';
+
+	debug(4, "Looking for Data: '%s' <- '%s'", fname, string);
 
 	// Find MPC Entry
 	for (MPCIterator it = _dir.begin(); it != _dir.end(); it++) {
 		fileString = (*it)->filename;
-		if (fileString.equals(string)) {
+		if (fileString.equals(fname)) {
 			if ((*it)->type == type) {
 				file = *it;
 				break;
 			} else {
-				debug(4, "Found Data but type mismatch: '%s', target: %d, found: %d", string, type, (*it)->type);
+				debug(4, "Found Data but type mismatch: '%s', target: %d, found: %d", fname, type, (*it)->type);
 			}
 		}
 	}
 
 	if (file == NULL) {
-		debug(4, "Couldn't find Data: '%s'", string);
+		debug(4, "Couldn't find Data: '%s'", fname);
 		return NULL;
 	}
 
@@ -130,10 +136,16 @@ int32 FileMan::getLength(const char *string, DataType type) {
 	Common::String fileString;
 	MPCEntry *file = NULL;
 
+	char fname[128];
+	strcpy(fname, string);
+	char *pDest = strrchr(fname, '.');
+	if (pDest)
+		*pDest = '_';
+
 	// Find MPC Entry
 	for (MPCIterator it = _dir.begin(); it != _dir.end(); it++) {
 		fileString = (*it)->filename;
-		if (fileString.contains(string)) {
+		if (fileString.contains(fname)) {
 			if ((*it)->type == type) {
 				file = *it;
 				break;
diff --git a/engines/hdb/hdb.cpp b/engines/hdb/hdb.cpp
index 9eaf120..1f2f58b 100644
--- a/engines/hdb/hdb.cpp
+++ b/engines/hdb/hdb.cpp
@@ -106,7 +106,7 @@ bool HDBGame::init() {
 		error("Input::init: Couldn't initialize Input");
 	}
 	if (!_lua->init()) {
-		error("LuaScript::init: Couldn't load the GLOBAL_LUA code.");
+		error("LuaScript::init: Couldn't load the GLOBAL.LUA code.");
 	}
 
 	_menu->init();
@@ -192,7 +192,7 @@ bool HDBGame::restartMap() {
 	return true;
 }
 
-bool HDBGame::startMap(char *name) {
+bool HDBGame::startMap(const char *name) {
 	// save last mapname
 	strcpy(_lastMapname, _currentMapname);
 
@@ -503,18 +503,7 @@ Common::Error HDBGame::run() {
 	tile->load(tileStream);
 #endif
 
-	_lua->loadLua("MAP00_LUA");
-
-	_lua->callFunction("level_loaded", 0);
-
-	Common::SeekableReadStream *mapStream = _fileMan->findFirstData("MAP00_MSM", TYPE_BINARY);
-	if (mapStream == NULL) {
-		debug("The MAP00_MSM MPC entry can't be found.");
-		return Common::kReadingFailed;
-	}
-
-	_map->load(mapStream);
-	_ai->initAnimInfo();
+	startMap("MAP00");
 
 	//_window->openDialog("Sgt. Filibuster", 0, "You address me as 'sarge' or 'sergeant' or get your snappin' teeth kicked in! Got me?", 0, NULL);
 
diff --git a/engines/hdb/hdb.h b/engines/hdb/hdb.h
index 33778b3..6d7490b 100644
--- a/engines/hdb/hdb.h
+++ b/engines/hdb/hdb.h
@@ -150,7 +150,7 @@ public:
 	bool init();
 
 	bool restartMap();
-	bool startMap(char *name);
+	bool startMap(const char *name);
 
 	void changeMap(char *name) {
 		strcpy(_changeMapname, name);
diff --git a/engines/hdb/lua-script.cpp b/engines/hdb/lua-script.cpp
index 5c273e2..4731136 100644
--- a/engines/hdb/lua-script.cpp
+++ b/engines/hdb/lua-script.cpp
@@ -30,22 +30,22 @@
 namespace HDB {
 
 struct ScriptPatch {
-	const char* scriptName;
-	const char* search;
-	const char* replace;
+	const char *scriptName;
+	const char *search;
+	const char *replace;
 } scriptPatches[] = {
-	{"GLOBAL_LUA", "for i,npc in npcs do", "for i,npc in pairs(npcs) do"},
-	{"GLOBAL_LUA", "setglobal( npcdef.codename..\"_init\", function() return NPC_Init( %npcdef ) end )", "_G[npcdef.codename .. \"_init\"] = function() return NPC_Init( npcdef ) end"},
-	{"GLOBAL_LUA", "setglobal( npcdef.codename..\"_use\", function(x, y, v1, v2) return NPC_Use( %npcdef, x, y, v1, v2 ) end )", "_G[npcdef.codename .. \"_use\"] = function(x, y, v1, v2) return NPC_Use( npcdef, x, y, v1, v2 ) end"},
-	{"GLOBAL_LUA", "if( dtable.counter < getn(dtable) ) then", "if( dtable.counter < #dtable ) then"},
-	{"GLOBAL_LUA", "if( getglobal( \"map\"..tostring(v1)..\"_complete\" ) ) then", "if( _G[\"map\"..tostring(v1)..\"_complete\"] ) then"},
-	{"GLOBAL_LUA", "closefunc = getglobal( npcdef.codename..\"_use\" )", "closefunc = _G[npcdef.codename..\"_use\"]"},
-	{"GLOBAL_LUA", "strsub(", "string.sub("}, // line 15
-	{"MAP00_LUA", "tempfunc = function() emptybed_use( %x, %y, %v1, %v2 ) end", "tempfunc = function() emptybed_use(x, y, v1, v2) end"},
-	{"MAP00_LUA", "if( getn( beds ) == 0 ) then", "if( #beds == 0 ) then"},
-	{"MAP01_LUA", "if( covert_index < getn(covert_dialog) ) then", "if( covert_index < #covert_dialog ) then"},
-	{"MAP01_LUA", "if( chiste_index < getn( chiste_dialog ) )then", "if( covert_index < #covert_dialog ) then"},
-	{"MAP01_LUA", "strsub(", "string.sub("}, // line 23
+	{"GLOBAL.LUA", "for i,npc in npcs do", "for i,npc in pairs(npcs) do"},
+	{"GLOBAL.LUA", "setglobal( npcdef.codename..\"_init\", function() return NPC_Init( %npcdef ) end )", "_G[npcdef.codename .. \"_init\"] = function() return NPC_Init( npcdef ) end"},
+	{"GLOBAL.LUA", "setglobal( npcdef.codename..\"_use\", function(x, y, v1, v2) return NPC_Use( %npcdef, x, y, v1, v2 ) end )", "_G[npcdef.codename .. \"_use\"] = function(x, y, v1, v2) return NPC_Use( npcdef, x, y, v1, v2 ) end"},
+	{"GLOBAL.LUA", "if( dtable.counter < getn(dtable) ) then", "if( dtable.counter < #dtable ) then"},
+	{"GLOBAL.LUA", "if( getglobal( \"map\"..tostring(v1)..\"_complete\" ) ) then", "if( _G[\"map\"..tostring(v1)..\"_complete\"] ) then"},
+	{"GLOBAL.LUA", "closefunc = getglobal( npcdef.codename..\"_use\" )", "closefunc = _G[npcdef.codename..\"_use\"]"},
+	{"GLOBAL.LUA", "strsub(", "string.sub("}, // line 15
+	{"MAP00.LUA", "tempfunc = function() emptybed_use( %x, %y, %v1, %v2 ) end", "tempfunc = function() emptybed_use(x, y, v1, v2) end"},
+	{"MAP00.LUA", "if( getn( beds ) == 0 ) then", "if( #beds == 0 ) then"},
+	{"MAP01.LUA", "if( covert_index < getn(covert_dialog) ) then", "if( covert_index < #covert_dialog ) then"},
+	{"MAP01.LUA", "if( chiste_index < getn( chiste_dialog ) )then", "if( covert_index < #covert_dialog ) then"},
+	{"MAP01.LUA", "strsub(", "string.sub("}, // line 23
 	{NULL, NULL, NULL},
 };
 
@@ -62,8 +62,8 @@ LuaScript::~LuaScript() {
 
 bool LuaScript::init() {
 	// Load Global Lua Code
-	_globalLuaStream = g_hdb->_fileMan->findFirstData("GLOBAL_LUA", TYPE_BINARY);
-	_globalLuaLength = g_hdb->_fileMan->getLength("GLOBAL_LUA", TYPE_BINARY);
+	_globalLuaStream = g_hdb->_fileMan->findFirstData("GLOBAL.LUA", TYPE_BINARY);
+	_globalLuaLength = g_hdb->_fileMan->getLength("GLOBAL.LUA", TYPE_BINARY);
 	if (_globalLuaStream == NULL || _globalLuaLength == 0) {
 		error("LuaScript::initScript: 'global code' failed to load");
 		return false;
@@ -1426,9 +1426,9 @@ bool LuaScript::initScript(Common::SeekableReadStream *stream, const char *scrip
 		lua_sethook(_state, debugHook, LUA_MASKCALL | LUA_MASKLINE, 0);
 	}
 
-	// Load GLOBAL_LUA and execute it
+	// Load GLOBAL.LUA and execute it
 
-	if (!executeMPC(_globalLuaStream, "global code", "GLOBAL_LUA", _globalLuaLength)) {
+	if (!executeMPC(_globalLuaStream, "global code", "GLOBAL.LUA", _globalLuaLength)) {
 		error("LuaScript::initScript: 'global code' failed to execute");
 		return false;
 	}
@@ -1640,17 +1640,22 @@ void LuaScript::stripComments(char *chunk) {
 	}
 }
 
-void LuaScript::addPatches(Common::String &chunk, const char* scriptName) {
+void LuaScript::addPatches(Common::String &chunk, const char *scriptName) {
 	ScriptPatch *patch = scriptPatches;
+	int applied = 0;
 
 	while (patch->scriptName) {
-		if (scriptName == patch->scriptName) {
+		if (!strcmp(scriptName, patch->scriptName)) {
 			Common::String searchString(patch->search);
 			Common::String replaceString(patch->replace);
 			Common::replace(chunk, searchString, replaceString);
+			applied++;
 		}
 		patch++;
 	}
+
+	if (applied)
+		debug(1, "Applied %d patches to %s", applied, scriptName);
 }
 
 void LuaScript::checkParameters(const char *func, int params) {
diff --git a/engines/hdb/map.cpp b/engines/hdb/map.cpp
index c34104c..ec5b57c 100644
--- a/engines/hdb/map.cpp
+++ b/engines/hdb/map.cpp
@@ -73,7 +73,13 @@ void Map::restartSystem() {
 }
 
 bool Map::loadMap(char *name) {
-	warning("STUB: loadMap(%s)", name);
+	Common::SeekableReadStream *mapStream = g_hdb->_fileMan->findFirstData(name, TYPE_BINARY);
+	if (mapStream == NULL) {
+		warning("The %s MPC entry can't be found", name);
+		return false;
+	}
+
+	load(mapStream);
 
 	return true;
 }


Commit: 1cd0a8d9368965eb77666a8d17ede2097a43655c
    https://github.com/scummvm/scummvm/commit/1cd0a8d9368965eb77666a8d17ede2097a43655c
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:10+02:00

Commit Message:
JANITORIAL: Fix formatting

Changed paths:
    engines/hdb/ai-lists.cpp


diff --git a/engines/hdb/ai-lists.cpp b/engines/hdb/ai-lists.cpp
index 4e6c876..2456812 100644
--- a/engines/hdb/ai-lists.cpp
+++ b/engines/hdb/ai-lists.cpp
@@ -190,8 +190,7 @@ void AI::animateBridges() {
 		case DIR_DOWN:
 			g_hdb->_map->setMapFGTileIndex(_bridges[i].x, _bridges[i].y, _targetBridgeD + _bridges[i].anim);
 			_bridges[i].anim++;
-			if (_bridges[i].anim > 2)
-			{
+			if (_bridges[i].anim > 2) {
 				g_hdb->_map->setMapFGTileIndex(_bridges[i].x, _bridges[i].y, _targetBridgeMidUD);
 				yv = 1;
 				done = true;
@@ -200,8 +199,7 @@ void AI::animateBridges() {
 		case DIR_LEFT:
 			g_hdb->_map->setMapFGTileIndex(_bridges[i].x, _bridges[i].y, _targetBridgeL + _bridges[i].anim);
 			_bridges[i].anim++;
-			if (_bridges[i].anim > 2)
-			{
+			if (_bridges[i].anim > 2) {
 				g_hdb->_map->setMapFGTileIndex(_bridges[i].x, _bridges[i].y, _targetBridgeMidLR);
 				xv = -1;
 				done = true;
@@ -210,8 +208,7 @@ void AI::animateBridges() {
 		case DIR_RIGHT:
 			g_hdb->_map->setMapFGTileIndex(_bridges[i].x, _bridges[i].y, _targetBridgeR + _bridges[i].anim);
 			_bridges[i].anim++;
-			if (_bridges[i].anim > 2)
-			{
+			if (_bridges[i].anim > 2) {
 				g_hdb->_map->setMapFGTileIndex(_bridges[i].x, _bridges[i].y, _targetBridgeMidLR);
 				xv = 1;
 				done = true;
@@ -220,8 +217,7 @@ void AI::animateBridges() {
 		}
 
 		// is this bridge done extending one chunk?
-		if (done == true)
-		{
+		if (done == true) {
 			if (g_hdb->_map->onScreen(_bridges[i].x, _bridges[i].y))
 				g_hdb->_sound->playSound(SND_BRIDGE_EXTEND);
 			_bridges[i].anim = 0;


Commit: ffe05e989b04f0d11e034e84a47cbbfe8d1597c6
    https://github.com/scummvm/scummvm/commit/ffe05e989b04f0d11e034e84a47cbbfe8d1597c6
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:10+02:00

Commit Message:
HDB: Add checkForTouchplate()

Changed paths:
    engines/hdb/ai-funcs.cpp
    engines/hdb/ai.h


diff --git a/engines/hdb/ai-funcs.cpp b/engines/hdb/ai-funcs.cpp
index f16c1f0..bc1e992 100644
--- a/engines/hdb/ai-funcs.cpp
+++ b/engines/hdb/ai-funcs.cpp
@@ -661,6 +661,13 @@ void AI::setLuaAnimFrame(const char *initName, AIState st, int frame) {
 	}
 }
 
+int AI::checkForTouchplate(int x, int y) {
+	int tileIndex = g_hdb->_map->getMapBGTileIndex(x, y);
+	if (tileIndex == _touchplateOff || tileIndex == _templeTouchpOff)
+		return tileIndex;
+	return 0;
+}
+
 void AI::removeEntity(AIEntity *e) {
 	_ents->erase(&e);
 }
diff --git a/engines/hdb/ai.h b/engines/hdb/ai.h
index 14495b3..22032f2 100644
--- a/engines/hdb/ai.h
+++ b/engines/hdb/ai.h
@@ -787,6 +787,7 @@ public:
 	void removeLuaEntity(const char *initName);
 	void animLuaEntity(const char *initName, AIState st);
 	void setLuaAnimFrame(const char *initName, AIState st, int frame);
+	int checkForTouchplate(int x, int y);
 	void removeEntity(AIEntity *e);
 	void setEntityGoal(AIEntity *e, int x, int y);
 	void initAllEnts();


Commit: 37b09c6e3d39347ab7f6ec1ca639c8220e4c736c
    https://github.com/scummvm/scummvm/commit/37b09c6e3d39347ab7f6ec1ca639c8220e4c736c
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:10+02:00

Commit Message:
HDB: Implement boot params.

To switch levels, run ./scummvm -b <levelnum> hdb-win

Changed paths:
    engines/hdb/hdb.cpp


diff --git a/engines/hdb/hdb.cpp b/engines/hdb/hdb.cpp
index 1f2f58b..3f2ca97 100644
--- a/engines/hdb/hdb.cpp
+++ b/engines/hdb/hdb.cpp
@@ -503,7 +503,19 @@ Common::Error HDBGame::run() {
 	tile->load(tileStream);
 #endif
 
-	startMap("MAP00");
+	if (ConfMan.hasKey("boot_param")) {
+		char mapname[10];
+		int level = ConfMan.getInt("boot_param");
+
+		if (level > 30 || level < 0)
+			level = 1;
+
+		snprintf(mapname, 10, "MAP%02d", level);
+
+		startMap(mapname);
+	} else {
+		startMap("MAP00");
+	}
 
 	//_window->openDialog("Sgt. Filibuster", 0, "You address me as 'sarge' or 'sergeant' or get your snappin' teeth kicked in! Got me?", 0, NULL);
 


Commit: 9369775b76951aeb3f24189c43b34bcadf9d897c
    https://github.com/scummvm/scummvm/commit/9369775b76951aeb3f24189c43b34bcadf9d897c
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:10+02:00

Commit Message:
HDB: Fix compilation

Changed paths:
    engines/hdb/ai-funcs.cpp
    engines/hdb/ai.h


diff --git a/engines/hdb/ai-funcs.cpp b/engines/hdb/ai-funcs.cpp
index bc1e992..ecd5e52 100644
--- a/engines/hdb/ai-funcs.cpp
+++ b/engines/hdb/ai-funcs.cpp
@@ -1870,13 +1870,6 @@ void AI::moveEnts() {
 	debug(9, "STUB: moveEnts: Laser Looping Sound Channel");
 }
 
-int AI::checkForTouchplate(int x, int y) {
-	int tileIndex = g_hdb->_map->getMapBGTileIndex(x, y);
-	if (tileIndex == _touchplateOff || tileIndex == _templeTouchpOff)
-		return tileIndex;
-	return 0;
-}
-
 bool AI::findPath(AIEntity *e) {
 	int x, y, xv = 0, yv = 0, max;
 	ArrowPath *here;
diff --git a/engines/hdb/ai.h b/engines/hdb/ai.h
index 22032f2..2e1d26e 100644
--- a/engines/hdb/ai.h
+++ b/engines/hdb/ai.h
@@ -806,7 +806,6 @@ public:
 
 	void moveEnts();
 
-	int checkForTouchplate(int x, int y);
 	bool findPath(AIEntity *e);
 	AIEntity *legalMove(int tileX, int tileY, int level, int *result);
 	AIEntity *legalMoveOverWater(int tileX, int tileY, int level, int *result);


Commit: 5e343d6591a64634dba614d27e8cef0b08ae41f9
    https://github.com/scummvm/scummvm/commit/5e343d6591a64634dba614d27e8cef0b08ae41f9
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:10+02:00

Commit Message:
HDB: Add checkForTouchplate call

Changed paths:
    engines/hdb/ai-funcs.cpp


diff --git a/engines/hdb/ai-funcs.cpp b/engines/hdb/ai-funcs.cpp
index ecd5e52..56239c8 100644
--- a/engines/hdb/ai-funcs.cpp
+++ b/engines/hdb/ai-funcs.cpp
@@ -2224,6 +2224,9 @@ void AI::movePlayer(uint16 buttons) {
 			case STATE_STANDRIGHT:
 				if (checkForTouchplate(nx, ny))
 					break;
+
+				if (checkForTouchplate(nx, ny))
+					break;
 				if (checkActionList(_player, nx, ny, true))
 					return;
 				if (checkAutoList(_player, nx, ny))


Commit: 9da57f1eb76ce20c3943070f618559ccdda57b2e
    https://github.com/scummvm/scummvm/commit/9da57f1eb76ce20c3943070f618559ccdda57b2e
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:10+02:00

Commit Message:
HDB: Add startMap lua function

Changed paths:
    engines/hdb/lua-script.cpp


diff --git a/engines/hdb/lua-script.cpp b/engines/hdb/lua-script.cpp
index 4731136..02bf16c 100644
--- a/engines/hdb/lua-script.cpp
+++ b/engines/hdb/lua-script.cpp
@@ -932,7 +932,13 @@ static int freeSound(lua_State *L) {
 }
 
 static int startMap(lua_State *L) {
-	warning("STUB: START MAP");
+	const char *string = lua_tostring(L, 1);
+
+	g_hdb->_lua->checkParameters("startMap", 1);
+
+	lua_pop(L, 1);
+	g_hdb->changeLevel((char *)string);
+
 	return 0;
 }
 


Commit: 478c10a1fb8516b16b6f3d40aba6f8c5385fc16a
    https://github.com/scummvm/scummvm/commit/478c10a1fb8516b16b6f3d40aba6f8c5385fc16a
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:10+02:00

Commit Message:
HDB: Unstub aiVortexianAction

Changed paths:
    engines/hdb/ai-player.cpp
    engines/hdb/ai.h


diff --git a/engines/hdb/ai-player.cpp b/engines/hdb/ai-player.cpp
index 323b308..599844b 100644
--- a/engines/hdb/ai-player.cpp
+++ b/engines/hdb/ai-player.cpp
@@ -1638,7 +1638,36 @@ void aiGooCupInit2(AIEntity *e) {
 }
 
 void aiVortexianAction(AIEntity *e) {
-	warning("STUB: AI: aiVortexianAction required");
+	// anim the alpha blending : down to 32, up to 180, back down...
+	e->value2 += e->value1;
+	if ((e->value2 & 0xff) > 128) {
+		e->value2 = (e->value2 & 0xff00) | 128;
+		e->value1 = -e->value1;
+	} else if ((e->value2 & 0xff) < 32) {
+		e->value2 = (e->value2 & 0xff00) | 32;
+		e->value1 = -e->value1;
+	}
+
+	// anim the shape
+	e->animFrame++;
+	if (e->animFrame >= e->standdownFrames) {
+		e->animFrame = 0;
+
+		// every 4th frame, check for player collision &
+		// do an autosave
+		AIEntity *p = g_hdb->_ai->getPlayer();
+		if (abs(p->x - e->x) < 4 && abs(p->y - e->y) < 4) {
+			if (!(e->value2 & 0xff00)) {
+				// let's make sure we don't autosave every frikken second!
+				e->value2 |= 0xff00;
+
+				g_hdb->saveWhenReady(kAutoSaveSlot);
+				g_hdb->_window->openMessageBar("Saving progress at Vortexian...", 1);
+			}
+		} else
+			e->value2 &= 0x00ff;
+	}
+	e->draw = e->standdownGfx[e->animFrame];
 }
 
 void aiVortexianUse(AIEntity *e) {
diff --git a/engines/hdb/ai.h b/engines/hdb/ai.h
index 2e1d26e..1a0f1d3 100644
--- a/engines/hdb/ai.h
+++ b/engines/hdb/ai.h
@@ -50,7 +50,9 @@ enum {
 	kRunToggleDelay = 2,
 	kMsgDelay = 3,
 	kYouGotX = -1,
-	kYouGotY = (kScreenHeight - 16)
+	kYouGotY = (kScreenHeight - 16),
+	kNumSaveSlots = 8,
+	kAutoSaveSlot = 0
 };
 
 enum AIType {


Commit: e319b120da08328b463f0d458875708705b19589
    https://github.com/scummvm/scummvm/commit/e319b120da08328b463f0d458875708705b19589
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:10+02:00

Commit Message:
HDB: Modify warning to debug output

Changed paths:
    engines/hdb/sound.cpp


diff --git a/engines/hdb/sound.cpp b/engines/hdb/sound.cpp
index e37a6da..1f4ec0a 100644
--- a/engines/hdb/sound.cpp
+++ b/engines/hdb/sound.cpp
@@ -30,7 +30,7 @@ bool Sound::init() {
 }
 
 bool Sound::playSound(int index) {
-	warning("STUB: Play Sound");
+	debug(9, "STUB: Play Sound");
 	return true;
 }
 


Commit: f35b63bc1351278dc5950f8867b0bcb997453fb6
    https://github.com/scummvm/scummvm/commit/f35b63bc1351278dc5950f8867b0bcb997453fb6
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:10+02:00

Commit Message:
HDB: Prevent crash when _skyClounds is empty.

Happens in MAP29

Changed paths:
    engines/hdb/gfx.cpp


diff --git a/engines/hdb/gfx.cpp b/engines/hdb/gfx.cpp
index bf9c43e..a17eab6 100644
--- a/engines/hdb/gfx.cpp
+++ b/engines/hdb/gfx.cpp
@@ -455,7 +455,8 @@ void Gfx::drawSky() {
 		static int offset = 0, wait = 0;
 		for (int j = -64; j < kScreenHeight; j += 64) {
 			for (int i = -64; i < kScreenWidth; i += 64) {
-				_skyClouds->draw(i + offset, j + offset);
+				if (_skyClouds)
+					_skyClouds->draw(i + offset, j + offset);
 			}
 		}
 		wait--;


Commit: fe9242f412dc66d30ed506021228c792fda99793
    https://github.com/scummvm/scummvm/commit/fe9242f412dc66d30ed506021228c792fda99793
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:10+02:00

Commit Message:
HDB: Implement safe version of removeEntity(). The previous one crashed

Changed paths:
    engines/hdb/ai-funcs.cpp


diff --git a/engines/hdb/ai-funcs.cpp b/engines/hdb/ai-funcs.cpp
index 56239c8..761f74d 100644
--- a/engines/hdb/ai-funcs.cpp
+++ b/engines/hdb/ai-funcs.cpp
@@ -669,7 +669,11 @@ int AI::checkForTouchplate(int x, int y) {
 }
 
 void AI::removeEntity(AIEntity *e) {
-	_ents->erase(&e);
+	for (int i = 0; i < _ents->size(); i++)
+		if (_ents->operator[](i) == e) {
+			_ents->remove_at(i);
+			return;
+		}
 }
 
 void AI::setEntityGoal(AIEntity *e, int x, int y) {


Commit: f832f66dd32a84f909c719ae6a1e62cf8743c691
    https://github.com/scummvm/scummvm/commit/f832f66dd32a84f909c719ae6a1e62cf8743c691
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:10+02:00

Commit Message:
HDB: Fix removeEntity to not manipulate pointers

Changed paths:
    engines/hdb/ai-funcs.cpp


diff --git a/engines/hdb/ai-funcs.cpp b/engines/hdb/ai-funcs.cpp
index 761f74d..08b72ee 100644
--- a/engines/hdb/ai-funcs.cpp
+++ b/engines/hdb/ai-funcs.cpp
@@ -669,7 +669,7 @@ int AI::checkForTouchplate(int x, int y) {
 }
 
 void AI::removeEntity(AIEntity *e) {
-	for (int i = 0; i < _ents->size(); i++)
+	for (uint i = 0; i < _ents->size(); i++)
 		if (_ents->operator[](i) == e) {
 			_ents->remove_at(i);
 			return;


Commit: eb388f9a50ed7456c0aae5c3f86fa20bc3746659
    https://github.com/scummvm/scummvm/commit/eb388f9a50ed7456c0aae5c3f86fa20bc3746659
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:10+02:00

Commit Message:
HDB: Remove invalid return statement

Changed paths:
    engines/hdb/ai-inventory.cpp


diff --git a/engines/hdb/ai-inventory.cpp b/engines/hdb/ai-inventory.cpp
index e9eb098..3dfea69 100644
--- a/engines/hdb/ai-inventory.cpp
+++ b/engines/hdb/ai-inventory.cpp
@@ -52,8 +52,7 @@ bool AI::addToInventory(AIEntity *e) {
 		removeEntity(e);
 		return true;
 	default:
-		warning("AI-INVENTORY: addToInventory: Unintended Type");
-		return false;
+		break;
 	}
 
 	if (_numInventory >= kMaxInventory) {


Commit: 95c36ed358fdfe598e2e0fae3c4757d22b541367
    https://github.com/scummvm/scummvm/commit/95c36ed358fdfe598e2e0fae3c4757d22b541367
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:10+02:00

Commit Message:
HDB: Add Pushing code

Changed paths:
    engines/hdb/ai.h
    engines/hdb/hdb.cpp


diff --git a/engines/hdb/ai.h b/engines/hdb/ai.h
index 1a0f1d3..adb6ee8 100644
--- a/engines/hdb/ai.h
+++ b/engines/hdb/ai.h
@@ -398,7 +398,7 @@ struct AIEntity {
 	AIDir		dir2;									// this is from TED
 
 	uint16		x, y;
-	uint16		drawXOff, drawYOff;					// might need a drawing offset
+	int16		drawXOff, drawYOff;					// might need a drawing offset
 	uint16		onScreen;								// FLAG: is this entity onscreen?
 	uint16		moveSpeed;								// movement speed of this entity
 	int16		xVel, yVel;								// movement values
diff --git a/engines/hdb/hdb.cpp b/engines/hdb/hdb.cpp
index 3f2ca97..4c48e06 100644
--- a/engines/hdb/hdb.cpp
+++ b/engines/hdb/hdb.cpp
@@ -448,12 +448,181 @@ void HDBGame::useEntity(AIEntity *e) {
 		}
 	}
 
-	/*
-		PUSHING
-		If its a pushable object, push it. Unless it's in/on water.
-	*/
+	// PUSHING
+	// If its a pushable object, push it. Unless it's in/on water.
 	if (e->type == AI_CRATE || e->type == AI_LIGHTBARREL || e->type == AI_BOOMBARREL || e->type == AI_MAGIC_EGG || e->type == AI_ICE_BLOCK || e->type == AI_FROGSTATUE || e->type == AI_DIVERTER) {
-		warning("STUB: HDBGame::useEntity PUSHING required");
+		int	xDir, yDir, chX, chY;
+		uint32 flags;
+		AIEntity *e2;
+
+		// if it's floating, don't touch!
+		if (e->state >= STATE_FLOATING && e->state <= STATE_FLOATRIGHT) {
+			g_hdb->_ai->lookAtEntity(e);
+			g_hdb->_ai->animGrabbing();
+			g_hdb->_window->openMessageBar("I can't lift that!", 1);
+			return;
+		}
+
+		xDir = yDir = 0;
+		if (p->tileX > e->tileX)
+			xDir = -2;
+		else if (p->tileX < e->tileX)
+			xDir = 2;
+
+		if (p->tileY > e->tileY)
+			yDir = -2;
+		else if (p->tileY < e->tileY)
+			yDir = 2;
+
+		// no diagonals allowed!
+		if (xDir && yDir)
+			return;
+
+		chX = p->tileX + xDir;
+		chY = p->tileY + yDir;
+
+		// are we going to push this over a sliding surface? (ok)
+		// are we going to push this into a blocking tile? (not ok)
+		if (e->level == 2) {
+			int	fg_flags = g_hdb->_map->getMapFGTileFlags(chX, chY);
+			if (fg_flags & kFlagSolid) {
+				g_hdb->_sound->playSound(SND_GUY_UHUH);
+				g_hdb->_ai->lookAtXY(chX, chY);
+				g_hdb->_ai->animGrabbing();
+				return;
+			}
+
+			flags = g_hdb->_map->getMapBGTileFlags(chX, chY);
+			if (((flags & kFlagSolid) == kFlagSolid) && !(fg_flags & kFlagGrating)) {
+				g_hdb->_sound->playSound(SND_GUY_UHUH);
+				g_hdb->_ai->lookAtXY(chX, chY);
+				g_hdb->_ai->animGrabbing();
+				return;
+			}
+		} else {
+			flags = g_hdb->_map->getMapBGTileFlags(chX, chY);
+			if (!(flags & kFlagSlide) && (flags & kFlagSolid)) {
+				g_hdb->_sound->playSound(SND_GUY_UHUH);
+				g_hdb->_ai->lookAtXY(chX, chY);
+				g_hdb->_ai->animGrabbing();
+				return;
+			}
+		}
+
+		// are we going to push this up the stairs? (not ok)
+		if (flags & kFlagStairBot) {
+			flags = g_hdb->_map->getMapBGTileFlags(e->tileX, e->tileY);
+			if (!(flags & kFlagStairTop)) {
+				g_hdb->_ai->lookAtEntity(e);
+				g_hdb->_ai->animGrabbing();
+				g_hdb->_sound->playSound(SND_GUY_UHUH);
+				return;
+			}
+		}
+
+		// is player trying to push across a dangerous floor (where the player would be ON the floor after the push)?
+		// don't allow it.
+		flags = g_hdb->_map->getMapBGTileFlags(p->tileX + (xDir >> 1), p->tileY + (yDir >> 1));
+		if (((flags & kFlagRadFloor) == kFlagRadFloor || (flags & kFlagPlasmaFloor) == kFlagPlasmaFloor) &&
+			false == g_hdb->_ai->checkFloating(p->tileX + (xDir >> 1), p->tileY + (yDir >> 1))) {
+			g_hdb->_ai->lookAtEntity(e);
+			g_hdb->_ai->animGrabbing();
+			g_hdb->_sound->playSound(SND_NOPUSH_SIZZLE);
+			return;
+		}
+
+		// are we going to push this into a gem?
+		// if it's a goodfairy, make it move!
+		e2 = g_hdb->_ai->findEntityIgnore(chX, chY, &g_hdb->_ai->_dummyLaser);
+		if (e2 && e2->type == ITEM_GEM_WHITE) {
+			g_hdb->_ai->addAnimateTarget(e2->x, e2->y, 0, 3, ANIM_NORMAL, false, false, GEM_FLASH);
+			g_hdb->_ai->removeEntity(e2);
+			g_hdb->_sound->playSound(SND_BRIDGE_END);
+			g_hdb->_ai->animGrabbing();
+			return;
+		}
+
+		// if so, is it a MELTED or FLOATING entity?  if so, that's cool...
+		if (e2) {
+			if (!g_hdb->_ai->checkFloating(e2->tileX, e2->tileY)) {
+				g_hdb->_ai->lookAtXY(chX, chY);
+				g_hdb->_ai->animGrabbing();
+				g_hdb->_sound->playSound(SND_GUY_UHUH);
+				return;
+			}
+		}
+
+		// are we trying to push this through a door? (teleporter!)
+		SingleTele info;
+		if (true == g_hdb->_ai->findTeleporterDest(chX, chY, &info)) {
+			g_hdb->_ai->lookAtXY(chX, chY);
+			g_hdb->_ai->animGrabbing();
+			g_hdb->_sound->playSound(SND_GUY_UHUH);
+			return;
+		}
+
+		// everything's clear - time to push!
+		// set goal for pushed object
+		if (e->type != AI_DIVERTER)
+			e->moveSpeed = kPushMoveSpeed;	// push DIVERTERS real fast
+		g_hdb->_ai->setEntityGoal(e, chX, chY);
+
+		// Diverters are very special - don't mess with their direction & state!
+		if (e->type == AI_DIVERTER) {
+			switch (e->dir2) {
+			case DIR_DOWN: e->state = STATE_DIVERTER_BL; break;
+			case DIR_UP: e->state = STATE_DIVERTER_BR; break;
+			case DIR_LEFT: e->state = STATE_DIVERTER_TL; break;
+			case DIR_RIGHT: e->state = STATE_DIVERTER_TR; break;
+			case DIR_NONE: break;
+			}
+		}
+
+		// set goal for player
+		if (xDir)
+			xDir = xDir >> 1;
+		if (yDir)
+			yDir = yDir >> 1;
+		if (e->type != AI_DIVERTER)			// push DIVERTERS real fast
+			p->moveSpeed = kPushMoveSpeed;
+		else
+			p->moveSpeed = kPlayerMoveSpeed;
+
+		g_hdb->_ai->setEntityGoal(p, p->tileX + xDir, p->tileY + yDir);
+
+		// need to set the state AFTER the SetEntityGoal!
+		switch (p->dir) {
+		case DIR_UP:	p->state = STATE_PUSHUP;	p->drawYOff = -10; break;
+		case DIR_DOWN:	p->state = STATE_PUSHDOWN;	p->drawYOff = 9; break;
+		case DIR_LEFT:	p->state = STATE_PUSHLEFT;	p->drawXOff = -10; break;
+		case DIR_RIGHT:	p->state = STATE_PUSHRIGHT; p->drawXOff = 10; break;
+		case DIR_NONE: break;
+		}
+
+		// if player is running, keep speed slow since we're pushing
+		if (g_hdb->_ai->playerRunning()) {
+			p->xVel = p->xVel >> 1;
+			p->yVel = p->yVel >> 1;
+		}
+
+		switch (e->type) {
+		case AI_CRATE:
+			g_hdb->_sound->playSound(SND_CRATE_SLIDE); break;
+		case AI_LIGHTBARREL:
+		case AI_FROGSTATUE:
+		case AI_ICE_BLOCK:
+			g_hdb->_sound->playSound(SND_LIGHT_SLIDE); break;
+		case AI_HEAVYBARREL:
+		case AI_MAGIC_EGG:
+		case AI_BOOMBARREL:
+			g_hdb->_sound->playSound(SND_HEAVY_SLIDE); break;
+		case AI_DIVERTER:
+			g_hdb->_sound->playSound(SND_PUSH_DIVERTER); break;
+		default:
+			break;
+		}
+
+		return;
 	}
 
 	// Look at Entity
@@ -468,7 +637,7 @@ void HDBGame::useEntity(AIEntity *e) {
 
 	// Can't push it - make a sound
 	if (e->type == AI_HEAVYBARREL) {
-		warning("STUB: HDBGame::useEntity Play HEAVYBARREL sound");
+		g_hdb->_sound->playSound(SND_GUY_UHUH);
 	}
 }
 


Commit: a48ee7d111cb0d2a096d091b13e374275d3ab139
    https://github.com/scummvm/scummvm/commit/a48ee7d111cb0d2a096d091b13e374275d3ab139
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:10+02:00

Commit Message:
HDB: Safer version of AI::moveEnts()

Changed paths:
    engines/hdb/ai-funcs.cpp


diff --git a/engines/hdb/ai-funcs.cpp b/engines/hdb/ai-funcs.cpp
index 08b72ee..e7cbfe9 100644
--- a/engines/hdb/ai-funcs.cpp
+++ b/engines/hdb/ai-funcs.cpp
@@ -1844,8 +1844,8 @@ void AI::moveEnts() {
 	}
 
 	// Call aiAction for all other Entities
-	for (Common::Array<AIEntity *>::iterator it = _ents->begin(); it != _ents->end(); it++) {
-		e = (*it);
+	for (int i = 0; i < _ents->size(); i++) {
+		e = _ents->operator[](i);
 		if (e->aiAction) {
 			// NPC Touchplate Counter
 			if (e != _player && e->touchpWait) {


Commit: 595187da81778b6dd3fdceb0155bd48fad99ea57
    https://github.com/scummvm/scummvm/commit/595187da81778b6dd3fdceb0155bd48fad99ea57
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:10+02:00

Commit Message:
HDB: Rewrote AI::killTrigger() to a safer variant

Changed paths:
    engines/hdb/ai-lists.cpp


diff --git a/engines/hdb/ai-lists.cpp b/engines/hdb/ai-lists.cpp
index 2456812..d2ddd4a 100644
--- a/engines/hdb/ai-lists.cpp
+++ b/engines/hdb/ai-lists.cpp
@@ -863,9 +863,11 @@ bool AI::checkTriggerList(char *entName, int x, int y) {
 }
 
 void AI::killTrigger(const char *id) {
-	for (Common::Array<Trigger *>::iterator it = _triggerList->begin(); it != _triggerList->end(); it++) {
-		if (!scumm_stricmp(id, (*it)->id))
-			_triggerList->erase(it);
+	for (uint i = 0; i < _triggerList->size(); i++) {
+		if (!scumm_stricmp(id, _triggerList->operator[](i)->id)) {
+			_triggerList->remove_at(i);
+			i--;
+		}
 	}
 }
 


Commit: 7e07602c25a42c0584cce2a98b47140cfa7ffc94
    https://github.com/scummvm/scummvm/commit/7e07602c25a42c0584cce2a98b47140cfa7ffc94
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:10+02:00

Commit Message:
HDB: Fix trigger launching

Changed paths:
    engines/hdb/ai-lists.cpp
    engines/hdb/lua-script.cpp


diff --git a/engines/hdb/ai-lists.cpp b/engines/hdb/ai-lists.cpp
index d2ddd4a..d6534cc 100644
--- a/engines/hdb/ai-lists.cpp
+++ b/engines/hdb/ai-lists.cpp
@@ -816,6 +816,8 @@ ArrowPath *AI::findArrowPath(int x, int y) {
 void AI::addToTriggerList(char *luaFuncInit, char *luaFuncUse, int x, int y, int value1, int value2, char *id) {
 	Trigger *t = new Trigger;
 
+	_triggerList->push_back(t);
+
 	strcpy(t->id, id);
 	t->x = x;
 	t->y = y;
diff --git a/engines/hdb/lua-script.cpp b/engines/hdb/lua-script.cpp
index 02bf16c..bffb785 100644
--- a/engines/hdb/lua-script.cpp
+++ b/engines/hdb/lua-script.cpp
@@ -1494,7 +1494,10 @@ void LuaScript::call(int args, int returns) {
 	if (!_systemInit)
 		return;
 
-	lua_call(_state, args, returns);
+	if (lua_pcall(_state, args, returns, -2)) {
+		error("An error occured while executing: %s.", lua_tostring(_state, -1));
+		lua_pop(_state, -1);
+	}
 }
 
 bool LuaScript::callFunction(const char *name, int returns) {


Commit: 92a4ff67feeb83755dcc271be65855593448eb34
    https://github.com/scummvm/scummvm/commit/92a4ff67feeb83755dcc271be65855593448eb34
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:10+02:00

Commit Message:
HDB: Implement cineSpawnEntity()

Changed paths:
    engines/hdb/ai-cinematic.cpp
    engines/hdb/ai.h
    engines/hdb/lua-script.cpp


diff --git a/engines/hdb/ai-cinematic.cpp b/engines/hdb/ai-cinematic.cpp
index 58287a8..d230ab3 100644
--- a/engines/hdb/ai-cinematic.cpp
+++ b/engines/hdb/ai-cinematic.cpp
@@ -348,6 +348,17 @@ void AI::processCines() {
 				complete = true;
 			}
 			break;
+		case C_SPAWNENTITY:
+		{
+			int x2, y2;
+			x2 = (int)_cine[i]->x2;
+			y2 = (int)_cine[i]->y2;
+			spawn((AIType)x2, (AIDir)y2, (int)_cine[i]->x, (int)_cine[i]->y, _cine[i]->title, _cine[i]->string,
+				_cine[i]->id, (AIDir)_cine[i]->start, (int)_cine[i]->end, (int)_cine[i]->delay, (int)_cine[i]->speed, 1);
+			complete = true;
+			break;
+		}
+		break;
 		case C_CLEAR_FG:
 			g_hdb->_map->setMapFGTileIndex((int)_cine[i]->x, (int)_cine[i]->y, -1);
 			g_hdb->_map->removeFGTileAnimation((int)_cine[i]->x, (int)_cine[i]->y);
@@ -576,6 +587,25 @@ void AI::cineEntityFace(const char *luaName, double dir) {
 	_cine.push_back(cmd);
 }
 
+void AI::cineSpawnEntity(AIType t, AIDir d, int x, int y, const char *func_init, const char *func_action,
+				const char *func_use, AIDir d2, int level, int value1, int value2) {
+	CineCommand *cmd = new CineCommand;
+	cmd->cmdType = C_SPAWNENTITY;
+	cmd->x2 = (double)t;
+	cmd->y2 = (double)d;
+	cmd->x = (double)x;
+	cmd->y = (double)y;
+	cmd->title = func_init;
+	cmd->string = func_action;
+	cmd->id = func_use;
+	cmd->start = (int)d2;
+	cmd->end = level;
+	cmd->delay = value1;
+	cmd->speed = value2;
+
+	_cine.push_back(cmd);
+}
+
 void AI::cineDialog(const char *title, const char *string, int seconds) {
 	CineCommand *cmd = new CineCommand;
 	cmd->title = title;
diff --git a/engines/hdb/ai.h b/engines/hdb/ai.h
index adb6ee8..78de3d4 100644
--- a/engines/hdb/ai.h
+++ b/engines/hdb/ai.h
@@ -942,6 +942,8 @@ public:
 	void cineWaitUntilDone();
 	void cineSetEntity(const char *entName, int x, int y, int level);
 	void cineMoveEntity(const char *entName, int x, int y, int level, int speed);
+	void cineSpawnEntity(AIType t, AIDir d, int x, int y, const char *func_init, const char *func_action,
+					const char *func_use, AIDir d2, int level, int value1, int value2);
 	void cineAnimEntity(const char *entName, AIState state, int loop);
 	void cineSetAnimFrame(const char *entName, AIState state, int frame);
 	void cineEntityFace(const char *luaName, double dir);
diff --git a/engines/hdb/lua-script.cpp b/engines/hdb/lua-script.cpp
index bffb785..e4d5f0e 100644
--- a/engines/hdb/lua-script.cpp
+++ b/engines/hdb/lua-script.cpp
@@ -362,7 +362,27 @@ static int cineMoveMaskedPic(lua_State *L) {
 }
 
 static int cineSpawnEntity(lua_State *L) {
-	warning("STUB: CINE SPAWN ENTITY");
+	double type = lua_tonumber( L, 1 );
+	double dir = lua_tonumber( L, 2 );
+	double x = lua_tonumber( L, 3 );
+	double y = lua_tonumber( L, 4 );
+	const char *func_init = lua_tostring( L, 5 );
+	const char *func_action = lua_tostring( L, 6 );
+	const char *func_use = lua_tostring( L, 7 );
+	double dir2 =  lua_tonumber( L, 8 );
+	double level =  lua_tonumber( L, 9 );
+	double value1 = lua_tonumber( L, 10 );
+	double value2 = lua_tonumber( L, 11 );
+
+	int t = (int) type;
+	int d = (int) dir;
+	int d2 = (int) dir2;
+
+	g_hdb->_lua->checkParameters("Cine_SpawnEntity", 11);
+
+	lua_pop(L, 11);
+	g_hdb->_ai->cineSpawnEntity((AIType)t, (AIDir)d, (int)x, (int)y, func_init, func_action, func_use,
+			(AIDir)d2, (int)level, (int)value1, (int)value2);
 	return 0;
 }
 


Commit: 9b6e83451fe5dc24801e6c6ea1bf0116b5b6fd7d
    https://github.com/scummvm/scummvm/commit/9b6e83451fe5dc24801e6c6ea1bf0116b5b6fd7d
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:10+02:00

Commit Message:
HDB: Add check for unknown size

Changed paths:
    engines/hdb/gfx.cpp
    engines/hdb/gfx.h


diff --git a/engines/hdb/gfx.cpp b/engines/hdb/gfx.cpp
index a17eab6..2f3e501 100644
--- a/engines/hdb/gfx.cpp
+++ b/engines/hdb/gfx.cpp
@@ -308,7 +308,7 @@ bool Gfx::selectGfxType(const char *name) {
 	return true;
 }
 
-Tile *Gfx::getTileGfx(const char *name, uint32 size) {
+Tile *Gfx::getTileGfx(const char *name, int32 size) {
 	// Try to find graphic
 	for (Common::Array<GfxCache *>::iterator it = _gfxCache->begin(); it != _gfxCache->end(); it++) {
 		if (Common::matchString((*it)->name, name)) {
@@ -328,6 +328,8 @@ Tile *Gfx::getTileGfx(const char *name, uint32 size) {
 	gfxTile->load(stream);
 
 	gc->tileGfx = gfxTile;
+	if (size == -1)
+		size = g_hdb->_fileMan->getLength(name, TYPE_TILE32);
 	gc->size = size;
 	gc->loaded = 1;
 
@@ -336,7 +338,7 @@ Tile *Gfx::getTileGfx(const char *name, uint32 size) {
 	return gc->tileGfx;
 }
 
-Picture *Gfx::getPicGfx(const char *name, uint32 size) {
+Picture *Gfx::getPicGfx(const char *name, int32 size) {
 	// Try to find graphic
 	for (Common::Array<GfxCache *>::iterator it = _gfxCache->begin(); it != _gfxCache->end(); it++) {
 		if (Common::matchString((*it)->name, name)) {
@@ -356,6 +358,8 @@ Picture *Gfx::getPicGfx(const char *name, uint32 size) {
 	gfxPic->load(stream);
 
 	gc->picGfx = gfxPic;
+	if (size == -1)
+		size = g_hdb->_fileMan->getLength(name, TYPE_PIC);
 	gc->size = size;
 	gc->loaded = 1;
 
diff --git a/engines/hdb/gfx.h b/engines/hdb/gfx.h
index fb26fe4..41277a1 100644
--- a/engines/hdb/gfx.h
+++ b/engines/hdb/gfx.h
@@ -121,8 +121,8 @@ public:
 
 	// Returns: true->Tile, false->Pic
 	bool selectGfxType(const char *name);
-	Tile *getTileGfx(const char *name, uint32 size);
-	Picture *getPicGfx(const char *name, uint32 size);
+	Tile *getTileGfx(const char *name, int32 size);
+	Picture *getPicGfx(const char *name, int32 size);
 
 	int isSky(int skyIndex);
 	void setSky(int skyIndex);


Commit: 1b2437900cd30b0d6b7626a9ff2e59e063598b01
    https://github.com/scummvm/scummvm/commit/1b2437900cd30b0d6b7626a9ff2e59e063598b01
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:10+02:00

Commit Message:
HDB: Do not declare AIEntity every frame

Changed paths:
    engines/hdb/hdb.cpp


diff --git a/engines/hdb/hdb.cpp b/engines/hdb/hdb.cpp
index 4c48e06..b9ae6c1 100644
--- a/engines/hdb/hdb.cpp
+++ b/engines/hdb/hdb.cpp
@@ -692,6 +692,8 @@ Common::Error HDBGame::run() {
 	lua->executeFile("test.lua");
 #endif
 
+	AIEntity *e;
+
 	while (!shouldQuit()) {
 
 		Common::Event event;
@@ -744,7 +746,7 @@ Common::Error HDBGame::run() {
 			_ai->processCines();
 			//_window->drawDialog();
 
-			AIEntity *e = _ai->getPlayer();
+			e = _ai->getPlayer();
 
 			if (e && e->level < 2)
 				_ai->drawWayPoints();


Commit: 1e5e8ed4ec734d9a3c9ed2e696a765b7d4e08898
    https://github.com/scummvm/scummvm/commit/1e5e8ed4ec734d9a3c9ed2e696a765b7d4e08898
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:10+02:00

Commit Message:
HDB: Unstub 'Cache graphics for Deliveries'

Changed paths:
    engines/hdb/ai-funcs.cpp


diff --git a/engines/hdb/ai-funcs.cpp b/engines/hdb/ai-funcs.cpp
index e7cbfe9..0b70b2f 100644
--- a/engines/hdb/ai-funcs.cpp
+++ b/engines/hdb/ai-funcs.cpp
@@ -728,7 +728,8 @@ void AI::initAllEnts() {
 		}
 	}
 
-	for (int i = 0; i < _numInventory; i++) {
+	int i;
+	for (i = 0; i < _numInventory; i++) {
 		AIEntity *temp = _inventory[i].ent;
 
 		// Clear out all ptrs in entity before writing
@@ -762,7 +763,10 @@ void AI::initAllEnts() {
 		cacheEntGfx(temp, false);
 	}
 
-	warning("STUB: initAllEnts: Cache graphics for Deliveries");
+	for (i = 0; i < _numDeliveries; i++) {
+		_deliveries[i].itemGfx = g_hdb->_gfx->getTileGfx(_deliveries[i].itemGfxName, -1);
+		_deliveries[i].destGfx = g_hdb->_gfx->getTileGfx(_deliveries[i].destGfxName, -1);
+	}
 	warning("STUB: initAllEnts: LaserScan required");
 }
 
@@ -1844,7 +1848,7 @@ void AI::moveEnts() {
 	}
 
 	// Call aiAction for all other Entities
-	for (int i = 0; i < _ents->size(); i++) {
+	for (uint i = 0; i < _ents->size(); i++) {
 		e = _ents->operator[](i);
 		if (e->aiAction) {
 			// NPC Touchplate Counter


Commit: 372cf8b734411f045c826e092b304f47800e9cfb
    https://github.com/scummvm/scummvm/commit/372cf8b734411f045c826e092b304f47800e9cfb
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:10+02:00

Commit Message:
HDB: Fix uninitized frame counters

Changed paths:
    engines/hdb/ai-init.cpp


diff --git a/engines/hdb/ai-init.cpp b/engines/hdb/ai-init.cpp
index 1c22013..426f549 100644
--- a/engines/hdb/ai-init.cpp
+++ b/engines/hdb/ai-init.cpp
@@ -816,6 +816,12 @@ void AI::restartSystem() {
 	memset(_slugLeftGfx, NULL, kMaxAnimFrames * sizeof(Tile *));
 	memset(_slugRightGfx, NULL, kMaxAnimFrames * sizeof(Tile *));
 
+	_horrible1Frames = _horrible2Frames = _horrible3Frames = _horrible4Frames = 0;
+	_plummetFrames = _dyingFrames = 0;
+	_pushdownFrames = _pushupFrames = _pushleftFrames = _pushrightFrames = 0;
+	_stunDownFrames = _stunUpFrames = _stunLeftFrames = _stunRightFrames = 0;
+	_slugDownFrames = _slugUpFrames = _slugLeftFrames = _slugRightFrames = 0;
+
 	if (_clubDownFrames) {
 		_clubDownFrames = 3;
 		_clubUpFrames = 3;


Commit: 85f37fd67a844e5b7942b910a852e7239fb6342f
    https://github.com/scummvm/scummvm/commit/85f37fd67a844e5b7942b910a852e7239fb6342f
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:10+02:00

Commit Message:
HDB: Hid noisy debug output

Changed paths:
    engines/hdb/ai-funcs.cpp


diff --git a/engines/hdb/ai-funcs.cpp b/engines/hdb/ai-funcs.cpp
index 0b70b2f..76493cc 100644
--- a/engines/hdb/ai-funcs.cpp
+++ b/engines/hdb/ai-funcs.cpp
@@ -882,15 +882,15 @@ void AI::animateEntity(AIEntity *e) {
 	uint64 flags;
 
 	// Move entity if player is not dead
-	debug(3, "Before animateEntity, e->x: %d, e->y: %d", e->x, e->y);
-	debug(3, "Before animateEntity, e->tileX: %d, e->tileY: %d", e->tileX, e->tileY);
+	debug(9, "Before animateEntity, e->x: %d, e->y: %d", e->x, e->y);
+	debug(9, "Before animateEntity, e->tileX: %d, e->tileY: %d", e->tileX, e->tileY);
 	if (!_playerDead) {
 		e->x += e->xVel;
 		e->y += e->yVel;
 		e->tileX = e->x / kTileWidth;
 		e->tileY = e->y / kTileHeight;
-		debug(3, "After animateEntity, e->x: %d, e->y: %d", e->x, e->y);
-		debug(3, "After animateEntity, e->tileX: %d, e->tileY: %d", e->tileX, e->tileY);
+		debug(9, "After animateEntity, e->x: %d, e->y: %d", e->x, e->y);
+		debug(9, "After animateEntity, e->tileX: %d, e->tileY: %d", e->tileX, e->tileY);
 	}
 
 	// For non-players, check for trigger being hit


Commit: 0a1ec9097c7ae8e6183ca16f612f693390a71adc
    https://github.com/scummvm/scummvm/commit/0a1ec9097c7ae8e6183ca16f612f693390a71adc
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:11+02:00

Commit Message:
HDB: Finish cineCleanup()

Changed paths:
    engines/hdb/ai-cinematic.cpp


diff --git a/engines/hdb/ai-cinematic.cpp b/engines/hdb/ai-cinematic.cpp
index d230ab3..340bedc 100644
--- a/engines/hdb/ai-cinematic.cpp
+++ b/engines/hdb/ai-cinematic.cpp
@@ -403,7 +403,7 @@ void AI::cineCleanup() {
 	_cameraLock = false;
 	_playerLock = false;
 	g_hdb->_window->setInfobarDark(0);
-	warning("STUB: DrawMan:: Set Pointer State");
+	g_hdb->_gfx->setPointerState(1);
 
 	int px, py;
 	getPlayerXY(&px, &py);


Commit: 375498e3522a0ca9838e2f3ff041f8ab9599528f
    https://github.com/scummvm/scummvm/commit/375498e3522a0ca9838e2f3ff041f8ab9599528f
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:11+02:00

Commit Message:
HDB: Fix cineAbort(), so it really removes the state machine program

Changed paths:
    engines/hdb/ai-cinematic.cpp


diff --git a/engines/hdb/ai-cinematic.cpp b/engines/hdb/ai-cinematic.cpp
index 340bedc..6656c93 100644
--- a/engines/hdb/ai-cinematic.cpp
+++ b/engines/hdb/ai-cinematic.cpp
@@ -416,6 +416,8 @@ void AI::cineAbort() {
 			_cine[0] = _cine[i];
 	}
 
+	_cine.resize(1);
+
 	g_hdb->_window->closeAll();
 
 	if (_player)


Commit: 71cff7f25614bd5909f751dd5efa3ba6de027478
    https://github.com/scummvm/scummvm/commit/71cff7f25614bd5909f751dd5efa3ba6de027478
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:11+02:00

Commit Message:
HDB: Fix AI::cineStart()

Changed paths:
    engines/hdb/ai-cinematic.cpp


diff --git a/engines/hdb/ai-cinematic.cpp b/engines/hdb/ai-cinematic.cpp
index 6656c93..42ce0c6 100644
--- a/engines/hdb/ai-cinematic.cpp
+++ b/engines/hdb/ai-cinematic.cpp
@@ -480,6 +480,8 @@ void AI::cineStart(bool abortable, const char *abortFunc) {
 	_cineActive = true;
 	_playerLock = false;
 	_cameraLock = false;
+
+	_cine.clear();
 }
 
 void AI::cineStop(const char *funcNext) {


Commit: 2d04954052bd28ba949f6d5e52eeba6cb373c5c5
    https://github.com/scummvm/scummvm/commit/2d04954052bd28ba949f6d5e52eeba6cb373c5c5
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:11+02:00

Commit Message:
HDB: Safer loops

Changed paths:
    engines/hdb/ai-funcs.cpp


diff --git a/engines/hdb/ai-funcs.cpp b/engines/hdb/ai-funcs.cpp
index 76493cc..ef32d51 100644
--- a/engines/hdb/ai-funcs.cpp
+++ b/engines/hdb/ai-funcs.cpp
@@ -625,9 +625,9 @@ void AI::removeLuaEntity(const char *initName) {
 	AIEntity *e;
 
 	for (uint i = 0; i < _ents->size(); i++) {
-		e = *(_ents->begin() + i);
+		e = _ents->operator[](i);
 		if (e->entityName && !scumm_stricmp(initName, e->entityName)) {
-			removeEntity(*(_ents->begin() + i));
+			removeEntity(e);
 			i--;
 		}
 	}
@@ -1640,8 +1640,8 @@ void AI::drawEnts(int x, int y, int w, int h) {
 	static uint32 stunTimer = g_hdb->getTimeSlice();
 
 	// Draw Floating Entities
-	for (Common::Array<AIEntity *>::iterator it = _floats->begin(); it != _floats->end(); it++) {
-		AIEntity *e = (*it);
+	for (uint i = 0; i < _floats->size(); i++) {
+		AIEntity *e = _floats->operator[](i);
 		if (e->aiDraw) {
 			e->aiDraw(e, x, y);
 		}
@@ -1656,8 +1656,8 @@ void AI::drawEnts(int x, int y, int w, int h) {
 	// Draw all other Ents
 	_numLevel2Ents = 0;
 
-	for (Common::Array<AIEntity *>::iterator it = _ents->begin(); it != _ents->end(); it++) {
-		AIEntity *e = (*it);
+	for (uint i = 0; i < _ents->size(); i++) {
+		AIEntity *e = _ents->operator[](i);
 		debugN(5, "AI::drawEnts: enity %s(%d) state %s(%d)...", AIType2Str(e->type), e->type, AIState2Str(e->state), e->state);
 
 		if (e->type == AI_LASER || e->type == AI_DIVERTER) {


Commit: 49cb33911e9cfa9250fb8737cc4adc8c9185f940
    https://github.com/scummvm/scummvm/commit/49cb33911e9cfa9250fb8737cc4adc8c9185f940
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:11+02:00

Commit Message:
HDB: Add playSoundEX()

Changed paths:
    engines/hdb/sound.cpp
    engines/hdb/sound.h


diff --git a/engines/hdb/sound.cpp b/engines/hdb/sound.cpp
index 1f4ec0a..92840e9 100644
--- a/engines/hdb/sound.cpp
+++ b/engines/hdb/sound.cpp
@@ -34,6 +34,11 @@ bool Sound::playSound(int index) {
 	return true;
 }
 
+bool Sound::playSoundEx(int index, int channel, bool loop) {
+	debug(9, "STUB: Play SoundEx");
+	return true;
+}
+
 bool Sound::playVoice(int index, int actor) {
 	warning("STUB: Play Voice");
 	return true;
diff --git a/engines/hdb/sound.h b/engines/hdb/sound.h
index f268309..c790ca9 100644
--- a/engines/hdb/sound.h
+++ b/engines/hdb/sound.h
@@ -25,6 +25,14 @@
 
 namespace HDB {
 
+enum {
+	kMaxSNDChannels = 32,
+	kSNDFrequency = 22050,
+	kLaserChannel = kMaxSNDChannels - 1,
+	kMusicChannel = kMaxSNDChannels - 2,
+	kVoiceChannel = kMaxSNDChannels - 5
+};
+
 enum SoundType {
 	SONG_NONE,
 	SND_GUI_INPUT,
@@ -1382,6 +1390,7 @@ public:
 	bool init();
 
 	bool playSound(int index);
+	bool playSoundEx(int index, int channel, bool loop);
 	bool playVoice(int index, int actor);
 
 	void markSoundCacheFreeable();


Commit: d70888269ed5dc5aacf55b5eacdacffcaa311f5c
    https://github.com/scummvm/scummvm/commit/d70888269ed5dc5aacf55b5eacdacffcaa311f5c
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:11+02:00

Commit Message:
HDB: Modify the return type of draw functions

Changed paths:
    engines/hdb/gfx.cpp
    engines/hdb/gfx.h


diff --git a/engines/hdb/gfx.cpp b/engines/hdb/gfx.cpp
index 2f3e501..36ec659 100644
--- a/engines/hdb/gfx.cpp
+++ b/engines/hdb/gfx.cpp
@@ -732,7 +732,7 @@ Graphics::Surface Picture::load(Common::SeekableReadStream *stream) {
 	return _surface;
 }
 
-void Picture::draw(int x, int y) {
+int Picture::draw(int x, int y) {
 	g_hdb->_gfx->_globalSurface.blitFrom(_surface, Common::Point(x, y));
 
 	Common::Rect clip(_surface.getBounds());
@@ -740,10 +740,12 @@ void Picture::draw(int x, int y) {
 	clip.clip(g_hdb->_gfx->_globalSurface.getBounds());
 	if (!clip.isEmpty()) {
 		g_system->copyRectToScreen(g_hdb->_gfx->_globalSurface.getBasePtr(clip.left, clip.top), g_hdb->_gfx->_globalSurface.pitch, clip.left, clip.top, clip.width(), clip.height());
+		return 1;
 	}
+	return 0;
 }
 
-void Picture::drawMasked(int x, int y) {
+int Picture::drawMasked(int x, int y) {
 	g_hdb->_gfx->_globalSurface.transBlitFrom(_surface, Common::Point(x, y), 0xf81f);
 
 	Common::Rect clip(_surface.getBounds());
@@ -751,7 +753,9 @@ void Picture::drawMasked(int x, int y) {
 	clip.clip(g_hdb->_gfx->_globalSurface.getBounds());
 	if (!clip.isEmpty()) {
 		g_system->copyRectToScreen(g_hdb->_gfx->_globalSurface.getBasePtr(clip.left, clip.top), g_hdb->_gfx->_globalSurface.pitch, clip.left, clip.top, clip.width(), clip.height());
+		return 1;
 	}
+	return 0;
 }
 
 Tile::Tile() : _flags(0), _name("") {
@@ -782,7 +786,7 @@ Graphics::Surface Tile::load(Common::SeekableReadStream *stream) {
 	return _surface;
 }
 
-void Tile::draw(int x, int y) {
+int Tile::draw(int x, int y) {
 	g_hdb->_gfx->_globalSurface.blitFrom(_surface, Common::Point(x, y));
 
 	Common::Rect clip(_surface.getBounds());
@@ -790,10 +794,12 @@ void Tile::draw(int x, int y) {
 	clip.clip(g_hdb->_gfx->_globalSurface.getBounds());
 	if (!clip.isEmpty()) {
 		g_system->copyRectToScreen(g_hdb->_gfx->_globalSurface.getBasePtr(clip.left, clip.top), g_hdb->_gfx->_globalSurface.pitch, clip.left, clip.top, clip.width(), clip.height());
+		return 1;
 	}
+	return 0;
 }
 
-void Tile::drawMasked(int x, int y) {
+int Tile::drawMasked(int x, int y) {
 	g_hdb->_gfx->_globalSurface.transBlitFrom(_surface, Common::Point(x, y), 0xf81f);
 
 	Common::Rect clip(_surface.getBounds());
@@ -801,7 +807,9 @@ void Tile::drawMasked(int x, int y) {
 	clip.clip(g_hdb->_gfx->_globalSurface.getBounds());
 	if (!clip.isEmpty()) {
 		g_system->copyRectToScreen(g_hdb->_gfx->_globalSurface.getBasePtr(clip.left, clip.top), g_hdb->_gfx->_globalSurface.pitch, clip.left, clip.top, clip.width(), clip.height());
+		return 1;
 	}
+	return 0;
 }
 
 }
diff --git a/engines/hdb/gfx.h b/engines/hdb/gfx.h
index 41277a1..849ae69 100644
--- a/engines/hdb/gfx.h
+++ b/engines/hdb/gfx.h
@@ -217,8 +217,8 @@ public:
 	~Picture();
 
 	Graphics::Surface load(Common::SeekableReadStream *stream);
-	void draw(int x, int y);
-	void drawMasked(int x, int y);
+	int draw(int x, int y);
+	int drawMasked(int x, int y);
 
 	uint _width, _height;
 
@@ -239,8 +239,8 @@ public:
 	~Tile();
 
 	Graphics::Surface load(Common::SeekableReadStream *stream);
-	void draw(int x, int y);
-	void drawMasked(int x, int y);
+	int draw(int x, int y);
+	int drawMasked(int x, int y);
 
 	uint32 _flags;
 


Commit: ac04002411d4094359c9f2722cecb41dd740d861
    https://github.com/scummvm/scummvm/commit/ac04002411d4094359c9f2722cecb41dd740d861
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:11+02:00

Commit Message:
HDB: Add Tile::free() and Picture::free()

Changed paths:
    engines/hdb/gfx.cpp
    engines/hdb/gfx.h


diff --git a/engines/hdb/gfx.cpp b/engines/hdb/gfx.cpp
index 36ec659..6c14f57 100644
--- a/engines/hdb/gfx.cpp
+++ b/engines/hdb/gfx.cpp
@@ -758,6 +758,10 @@ int Picture::drawMasked(int x, int y) {
 	return 0;
 }
 
+void Picture::free() {
+	_surface.free();
+}
+
 Tile::Tile() : _flags(0), _name("") {
 	_surface.create(32, 32, g_hdb->_format);
 }
@@ -812,4 +816,8 @@ int Tile::drawMasked(int x, int y) {
 	return 0;
 }
 
+void Tile::free() {
+	_surface.free();
+}
+
 }
diff --git a/engines/hdb/gfx.h b/engines/hdb/gfx.h
index 849ae69..83af1e4 100644
--- a/engines/hdb/gfx.h
+++ b/engines/hdb/gfx.h
@@ -219,6 +219,7 @@ public:
 	Graphics::Surface load(Common::SeekableReadStream *stream);
 	int draw(int x, int y);
 	int drawMasked(int x, int y);
+	void free();
 
 	uint _width, _height;
 
@@ -241,6 +242,7 @@ public:
 	Graphics::Surface load(Common::SeekableReadStream *stream);
 	int draw(int x, int y);
 	int drawMasked(int x, int y);
+	void free();
 
 	uint32 _flags;
 


Commit: c9c08476f16e7535da0bd8aff231f6ee6fa8a0db
    https://github.com/scummvm/scummvm/commit/c9c08476f16e7535da0bd8aff231f6ee6fa8a0db
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:11+02:00

Commit Message:
HDB: Add Gfx data

Changed paths:
    engines/hdb/ai-init.cpp
    engines/hdb/ai.h


diff --git a/engines/hdb/ai-init.cpp b/engines/hdb/ai-init.cpp
index 426f549..d6e2b3f 100644
--- a/engines/hdb/ai-init.cpp
+++ b/engines/hdb/ai-init.cpp
@@ -772,6 +772,19 @@ bool AI::init() {
 	_kcHolderBlackOff	= g_hdb->_gfx->getTileIndex("anim_t32_kcholder_black_off1");
 	_kcHolderBlackOn	= g_hdb->_gfx->getTileIndex("t32_kcholder_black_on");
 
+	// icepuff snowball
+	icepSnowballGfxDown = icepSnowballGfxLeft = icepSnowballGfxRight = NULL;
+
+	// Frogglick
+	tileFroglickMiddleUD = tileFroglickMiddleLR = NULL;
+	tileFroglickWiggleLeft[0] = tileFroglickWiggleRight[0] = NULL;
+
+	// Dragon
+	gfxDragonAsleep = NULL;
+
+	// laser beam
+	gfxLaserbeamUD[0] = gfxLaserbeamUD[1] = gfxLaserbeamLR[0] = gfxLaserbeamLR[1] = NULL;
+
 	_dummyPlayer.type = AI_GUY;
 	_dummyLaser.type = AI_LASERBEAM;
 	strcpy(_dummyPlayer.entityName, "Virtual Player");
@@ -834,6 +847,80 @@ void AI::restartSystem() {
 	memset(_clubLeftGfx, NULL, kMaxAnimFrames * sizeof(Tile *));
 	memset(_clubRightGfx, NULL, kMaxAnimFrames * sizeof(Tile *));
 
+	int i;
+	if (icepSnowballGfxDown) {
+		icepSnowballGfxDown->free();
+		icepSnowballGfxDown = NULL;
+	}
+	if (icepSnowballGfxLeft) {
+		icepSnowballGfxLeft->free();
+		icepSnowballGfxLeft = NULL;
+	}
+	if (icepSnowballGfxRight) {
+		icepSnowballGfxRight->free();
+		icepSnowballGfxRight = NULL;
+	}
+
+	if (tileFroglickMiddleUD) {
+		tileFroglickMiddleUD->free();
+		tileFroglickMiddleUD = NULL;
+	}
+	if (tileFroglickWiggleUD[0]) {
+		for (i = 0; i < 3; i++) {
+			tileFroglickWiggleUD[i]->free();
+			tileFroglickWiggleUD[i] = NULL;
+		}
+	}
+
+	if (tileFroglickMiddleLR) {
+		tileFroglickMiddleLR->free();
+		tileFroglickMiddleLR = NULL;
+	}
+	if (tileFroglickWiggleLeft[0]) {
+		for (i = 0; i < 3; i++) {
+			tileFroglickWiggleLeft[i]->free();
+			tileFroglickWiggleLeft[i] = NULL;
+		}
+	}
+	if (tileFroglickWiggleRight[0]) {
+		for (i = 0; i < 3; i++) {
+			tileFroglickWiggleRight[i]->free();
+			tileFroglickWiggleRight[i] = NULL;
+		}
+	}
+
+	// dragon!  see ya!
+	if (gfxDragonAsleep) {
+		gfxDragonAsleep->free();
+		gfxDragonAsleep = NULL;
+		gfxDragonFlap[0]->free();
+		gfxDragonFlap[1]->free();
+		gfxDragonFlap[0] = gfxDragonFlap[1] = NULL;
+		gfxDragonBreathe[0]->free();
+		gfxDragonBreathe[1]->free();
+		gfxDragonBreathe[2]->free();
+		gfxDragonBreathe[0] = gfxDragonBreathe[1] = gfxDragonBreathe[2] = NULL;
+	}
+
+	// laser beams
+	if (gfxLaserbeamUD[0]) {
+		for (i = 0; i < 4; i++) {
+			gfxLaserbeamUD[i]->free();
+			gfxLaserbeamUDTop[i]->free();
+			gfxLaserbeamUDBottom[i]->free();
+			gfxLaserbeamLR[i]->free();
+			gfxLaserbeamLRLeft[i]->free();
+			gfxLaserbeamLRRight[i]->free();
+
+			gfxLaserbeamUD[i] = NULL;
+			gfxLaserbeamUDTop[i] = NULL;
+			gfxLaserbeamUDBottom[i] = NULL;
+			gfxLaserbeamLR[i] = NULL;
+			gfxLaserbeamLRLeft[i] = NULL;
+			gfxLaserbeamLRRight[i] = NULL;
+		}
+	}
+
 	// Clear the Action list
 	memset(_actions, 0, sizeof(_actions));
 
diff --git a/engines/hdb/ai.h b/engines/hdb/ai.h
index 78de3d4..908bd51 100644
--- a/engines/hdb/ai.h
+++ b/engines/hdb/ai.h
@@ -766,6 +766,27 @@ struct CineBlit {
 	}
 #define spawnBlocking(x, y, level)	g_hdb->_ai->spawn(AI_NONE, DIR_NONE, x, y, NULL, NULL, NULL, DIR_NONE, level, 0, 0, 0)
 
+extern	Picture *icepSnowballGfxDown;		// ICEPUFF's snowball moving down
+extern	Picture *icepSnowballGfxLeft;		// ICEPUFF's snowball moving left
+extern	Picture *icepSnowballGfxRight;		// ICEPUFF's snowball moving right
+
+extern	Tile *tileFroglickMiddleUD;
+extern	Tile *tileFroglickWiggleUD[3];
+extern	Tile *tileFroglickMiddleLR;
+extern	Tile *tileFroglickWiggleLeft[3];
+extern	Tile *tileFroglickWiggleRight[3];
+
+extern	Picture *gfxDragonAsleep;
+extern	Picture *gfxDragonFlap[2];
+extern	Picture *gfxDragonBreathe[3];
+
+extern	Tile *gfxLaserbeamUD[4];
+extern	Tile *gfxLaserbeamUDTop[4];
+extern	Tile *gfxLaserbeamUDBottom[4];
+extern	Tile *gfxLaserbeamLR[4];
+extern	Tile *gfxLaserbeamLRLeft[4];
+extern	Tile *gfxLaserbeamLRRight[4];
+
 class AI {
 public:
 	AI();


Commit: d356756e6d2fd0802919987e120b4f55973e6a5d
    https://github.com/scummvm/scummvm/commit/d356756e6d2fd0802919987e120b4f55973e6a5d
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:11+02:00

Commit Message:
HDB: Add Diverter functions

Changed paths:
    engines/hdb/ai-bots.cpp


diff --git a/engines/hdb/ai-bots.cpp b/engines/hdb/ai-bots.cpp
index b6dfd23..2ce54b1 100644
--- a/engines/hdb/ai-bots.cpp
+++ b/engines/hdb/ai-bots.cpp
@@ -533,7 +533,12 @@ void aiPushBotAction(AIEntity *e) {
 				e1->state = e->state;
 				e1->moveSpeed = e->moveSpeed;
 				g_hdb->_ai->setEntityGoal(e1, nx2, ny2);
-				warning("STUB: aiPushBotAction: Switch Case for Sound");
+				switch (e1->type) {
+				case AI_CRATE: g_hdb->_sound->playSound(SND_CRATE_SLIDE); break;
+				case AI_HEAVYBARREL: case AI_BOOMBARREL: g_hdb->_sound->playSound(SND_HEAVY_SLIDE); break;
+				case AI_LIGHTBARREL: g_hdb->_sound->playSound(SND_LIGHT_SLIDE); break;
+				default: break;
+				}
 			} else {
 				if (e->onScreen)
 					g_hdb->_sound->playSound(SND_PUSHBOT_STRAIN);
@@ -1226,12 +1231,130 @@ void aiLaserDraw(AIEntity *e, int mx, int my) {
 	warning("STUB: AI: aiLaserDraw required");
 }
 
+void aiDiverterInit(AIEntity *e) {
+	e->aiDraw = aiDiverterDraw;
+	e->aiAction = aiDiverterAction;
+	e->moveSpeed = kPlayerMoveSpeed << 1;
+	e->dir2 = e->dir;
+}
+
+void aiDiverterInit2(AIEntity *e) {
+	e->movedownGfx[0] = e->standdownGfx[0];
+	e->moveupGfx[0] = e->standupGfx[0];
+	e->moveleftGfx[0] = e->standleftGfx[0];
+	e->moverightGfx[0] = e->standrightGfx[0];
+	e->movedownFrames =
+		e->moveupFrames =
+		e->moveleftFrames =
+		e->moverightFrames = 1;
+
+	// this is to handle loadgames...
+	AIDir d = e->dir2;
+	if (e->dir2 == DIR_NONE)
+		d = e->dir;
+	switch (d) {
+	case DIR_DOWN: e->state = STATE_DIVERTER_BL; e->draw = e->standdownGfx[0]; break;
+	case DIR_UP: e->state = STATE_DIVERTER_BR; e->draw = e->standupGfx[0]; break;
+	case DIR_LEFT: e->state = STATE_DIVERTER_TL; e->draw = e->standleftGfx[0]; break;
+	case DIR_RIGHT: e->state = STATE_DIVERTER_TR; e->draw = e->standrightGfx[0]; break;
+	case DIR_NONE: break;
+	}
+
+	warning("STUB: Set Laser Rescan to true");
+}
+
 void aiDiverterAction(AIEntity *e) {
 	warning("STUB: AI: aiDiverterAction required");
 }
 
 void aiDiverterDraw(AIEntity *e, int mx, int my) {
-	warning("STUB: AI: aiDiverterDraw required");
+	int		i;
+	if (!e->value1 && !e->value2)
+		return;
+
+	int	frame = e->movedownFrames & 3;
+	int onScreen = 0;
+	switch (e->dir2) {
+	case DIR_UP:
+		if (e->tileY == e->value1 && e->int2) {	// going down or right?
+			for (i = e->value1 + 1; i < e->value2; i++)
+				onScreen += gfxLaserbeamUD[frame]->drawMasked(e->x - mx, i * kTileHeight - my);
+			onScreen += gfxLaserbeamUDTop[frame]->drawMasked(e->x - mx, i * kTileHeight - my);
+			if (onScreen) {
+				g_hdb->_sound->playSoundEx(SND_LASER_LOOP, kLaserChannel, true);
+				warning("STUB: Set Laser onScreen to true");
+			}
+		} else {
+			for (i = e->value1 + 1; i < e->value2; i++)
+				onScreen += gfxLaserbeamLR[frame]->drawMasked(i * kTileWidth - mx, e->y - my);
+			onScreen += gfxLaserbeamLRLeft[frame]->drawMasked(i * kTileWidth - mx, e->y - my);
+			if (onScreen) {
+				g_hdb->_sound->playSoundEx(SND_LASER_LOOP, kLaserChannel, true);
+				warning("STUB: Set Laser onScreen to true");
+			}
+		}
+		break;
+	case DIR_DOWN:
+		if (e->tileY == e->value1 && e->int2) {	// going down or left?
+			for (i = e->value1 + 1; i < e->value2; i++)
+				onScreen += gfxLaserbeamUD[frame]->drawMasked(e->x - mx, i * kTileHeight - my);
+			onScreen += gfxLaserbeamUDTop[frame]->drawMasked(e->x - mx, i * kTileHeight - my);
+			if (onScreen) {
+				g_hdb->_sound->playSoundEx(SND_LASER_LOOP, kLaserChannel, true);
+				warning("STUB: Set Laser onscreen to true");
+			}
+		} else {
+			for (i = e->value1 - 1; i > e->value2; i--)
+				onScreen += gfxLaserbeamLR[frame]->drawMasked(i * kTileWidth - mx, e->y - my);
+			onScreen += gfxLaserbeamLRRight[frame]->drawMasked(i * kTileWidth - mx, e->y - my);
+			if (onScreen) {
+				g_hdb->_sound->playSoundEx(SND_LASER_LOOP, kLaserChannel, true);
+				warning("STUB: Set Laser onscreen to true");
+			}
+		}
+		break;
+	case DIR_LEFT:
+		if (e->tileY == e->value1 && e->int2) {	// going up or left?
+			for (i = e->value1 - 1; i > e->value2; i--)
+				onScreen += gfxLaserbeamUD[frame]->drawMasked(e->x - mx, i * kTileHeight - my);
+			onScreen += gfxLaserbeamUDBottom[frame]->drawMasked(e->x - mx, i * kTileHeight - my);
+			if (onScreen) {
+				g_hdb->_sound->playSoundEx(SND_LASER_LOOP, kLaserChannel, true);
+				warning("STUB: Set Laser onscreen to true");
+			}
+		} else {
+			for (i = e->value1 - 1; i > e->value2; i--)
+				onScreen += gfxLaserbeamLR[frame]->drawMasked(i * kTileWidth - mx, e->y - my);
+			onScreen += gfxLaserbeamLRRight[frame]->drawMasked(i * kTileWidth - mx, e->y - my);
+			if (onScreen) {
+				g_hdb->_sound->playSoundEx(SND_LASER_LOOP, kLaserChannel, true);
+				warning("STUB: Set Laser onscreen to true");
+			}
+		}
+		break;
+	case DIR_RIGHT:
+		if (e->tileY == e->value1 && e->int2) {	// going up or right?
+			for (i = e->value1 - 1; i > e->value2; i--)
+				onScreen += gfxLaserbeamUD[frame]->drawMasked(e->x - mx, i * kTileHeight - my);
+			onScreen += gfxLaserbeamUDBottom[frame]->drawMasked(e->x - mx, i * kTileHeight - my);
+			if (onScreen) {
+				g_hdb->_sound->playSoundEx(SND_LASER_LOOP, kLaserChannel, true);
+				warning("STUB: Set Laser onscreen to true");
+			}
+		} else {
+			for (i = e->value1 + 1; i < e->value2; i++)
+				onScreen += gfxLaserbeamLR[frame]->drawMasked(i * kTileWidth - mx, e->y - my);
+			onScreen += gfxLaserbeamLRLeft[frame]->drawMasked(i * kTileWidth - mx, e->y - my);
+			if (onScreen) {
+				g_hdb->_sound->playSoundEx(SND_LASER_LOOP, kLaserChannel, true);
+				warning("STUB: Set Laser onscreen to true");
+			}
+		}
+		break;
+	case DIR_NONE:
+		break;
+	}
+	e->movedownFrames++;
 }
 
 void aiMeerkatDraw(AIEntity *e, int mx, int my) {
@@ -1306,14 +1429,6 @@ void aiLaserInit2(AIEntity *e) {
 	warning("STUB: AI: aiLaserInit2 required");
 }
 
-void aiDiverterInit(AIEntity *e) {
-	warning("STUB: AI: aiDiverterInit required");
-}
-
-void aiDiverterInit2(AIEntity *e) {
-	warning("STUB: AI: aiDiverterInit2 required");
-}
-
 void aiMeerkatInit(AIEntity *e) {
 	warning("STUB: AI: aiMeerkatInit required");
 }


Commit: bcbe095ef8d172680318632c5d20ccf78b9c0e80
    https://github.com/scummvm/scummvm/commit/bcbe095ef8d172680318632c5d20ccf78b9c0e80
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:11+02:00

Commit Message:
HDB: Commet out non-compiling code

Changed paths:
    engines/hdb/ai-bots.cpp
    engines/hdb/ai-init.cpp
    engines/hdb/ai.h


diff --git a/engines/hdb/ai-bots.cpp b/engines/hdb/ai-bots.cpp
index 2ce54b1..f0b6f35 100644
--- a/engines/hdb/ai-bots.cpp
+++ b/engines/hdb/ai-bots.cpp
@@ -1268,6 +1268,10 @@ void aiDiverterAction(AIEntity *e) {
 }
 
 void aiDiverterDraw(AIEntity *e, int mx, int my) {
+}
+
+#if 0
+void aiDiverterDraw(AIEntity *e, int mx, int my) {
 	int		i;
 	if (!e->value1 && !e->value2)
 		return;
@@ -1356,6 +1360,8 @@ void aiDiverterDraw(AIEntity *e, int mx, int my) {
 	}
 	e->movedownFrames++;
 }
+#endif
+
 
 void aiMeerkatDraw(AIEntity *e, int mx, int my) {
 	warning("STUB: AI: aiMeerkatDraw required");
diff --git a/engines/hdb/ai-init.cpp b/engines/hdb/ai-init.cpp
index d6e2b3f..5e40823 100644
--- a/engines/hdb/ai-init.cpp
+++ b/engines/hdb/ai-init.cpp
@@ -772,6 +772,7 @@ bool AI::init() {
 	_kcHolderBlackOff	= g_hdb->_gfx->getTileIndex("anim_t32_kcholder_black_off1");
 	_kcHolderBlackOn	= g_hdb->_gfx->getTileIndex("t32_kcholder_black_on");
 
+#if 0
 	// icepuff snowball
 	icepSnowballGfxDown = icepSnowballGfxLeft = icepSnowballGfxRight = NULL;
 
@@ -784,6 +785,7 @@ bool AI::init() {
 
 	// laser beam
 	gfxLaserbeamUD[0] = gfxLaserbeamUD[1] = gfxLaserbeamLR[0] = gfxLaserbeamLR[1] = NULL;
+#endif
 
 	_dummyPlayer.type = AI_GUY;
 	_dummyLaser.type = AI_LASERBEAM;
@@ -847,6 +849,7 @@ void AI::restartSystem() {
 	memset(_clubLeftGfx, NULL, kMaxAnimFrames * sizeof(Tile *));
 	memset(_clubRightGfx, NULL, kMaxAnimFrames * sizeof(Tile *));
 
+#if 0
 	int i;
 	if (icepSnowballGfxDown) {
 		icepSnowballGfxDown->free();
@@ -920,6 +923,7 @@ void AI::restartSystem() {
 			gfxLaserbeamLRRight[i] = NULL;
 		}
 	}
+#endif
 
 	// Clear the Action list
 	memset(_actions, 0, sizeof(_actions));
diff --git a/engines/hdb/ai.h b/engines/hdb/ai.h
index 908bd51..e7cfd08 100644
--- a/engines/hdb/ai.h
+++ b/engines/hdb/ai.h
@@ -766,6 +766,7 @@ struct CineBlit {
 	}
 #define spawnBlocking(x, y, level)	g_hdb->_ai->spawn(AI_NONE, DIR_NONE, x, y, NULL, NULL, NULL, DIR_NONE, level, 0, 0, 0)
 
+#if 0
 extern	Picture *icepSnowballGfxDown;		// ICEPUFF's snowball moving down
 extern	Picture *icepSnowballGfxLeft;		// ICEPUFF's snowball moving left
 extern	Picture *icepSnowballGfxRight;		// ICEPUFF's snowball moving right
@@ -786,6 +787,7 @@ extern	Tile *gfxLaserbeamUDBottom[4];
 extern	Tile *gfxLaserbeamLR[4];
 extern	Tile *gfxLaserbeamLRLeft[4];
 extern	Tile *gfxLaserbeamLRRight[4];
+#endif
 
 class AI {
 public:


Commit: 64cd74d1b2c728696ce9e475dc6e883f1a48e1fe
    https://github.com/scummvm/scummvm/commit/64cd74d1b2c728696ce9e475dc6e883f1a48e1fe
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:11+02:00

Commit Message:
HDB: Add aiDiverterAction()

Changed paths:
    engines/hdb/ai-bots.cpp


diff --git a/engines/hdb/ai-bots.cpp b/engines/hdb/ai-bots.cpp
index f0b6f35..628a147 100644
--- a/engines/hdb/ai-bots.cpp
+++ b/engines/hdb/ai-bots.cpp
@@ -1264,7 +1264,19 @@ void aiDiverterInit2(AIEntity *e) {
 }
 
 void aiDiverterAction(AIEntity *e) {
-	warning("STUB: AI: aiDiverterAction required");
+	if (e->goalX) {
+		g_hdb->_ai->animateEntity(e);
+		warning("STUB: Set Laser Rescan to true");
+
+		// have to reset the state because we might have been moved...
+		switch (e->dir2) {
+		case DIR_DOWN: e->state = STATE_DIVERTER_BL; e->draw = e->standdownGfx[0]; break;
+		case DIR_UP: e->state = STATE_DIVERTER_BR; e->draw = e->standupGfx[0]; break;
+		case DIR_LEFT: e->state = STATE_DIVERTER_TL; e->draw = e->standleftGfx[0]; break;
+		case DIR_RIGHT: e->state = STATE_DIVERTER_TR; e->draw = e->standrightGfx[0]; break;
+		case DIR_NONE: break;
+		}
+	}
 }
 
 void aiDiverterDraw(AIEntity *e, int mx, int my) {


Commit: c67fb14640b5eaaabb45188537ad96295c8b77b9
    https://github.com/scummvm/scummvm/commit/c67fb14640b5eaaabb45188537ad96295c8b77b9
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:11+02:00

Commit Message:
HDB: Add getGemGfx()

Changed paths:
    engines/hdb/window.h


diff --git a/engines/hdb/window.h b/engines/hdb/window.h
index f2175d4..870d11d 100644
--- a/engines/hdb/window.h
+++ b/engines/hdb/window.h
@@ -222,6 +222,11 @@ public:
 		return (_textOutList.size());
 	}
 	void closeTextOut();
+
+	Tile *getGemGfx() {
+		return _gemGfx;
+	}
+
 private:
 
 	DialogInfo _dialogInfo;


Commit: 26c1c9440c8aac081fe9aa349934714a6089704d
    https://github.com/scummvm/scummvm/commit/26c1c9440c8aac081fe9aa349934714a6089704d
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:11+02:00

Commit Message:
HDB: Add Meerkat functions

Changed paths:
    engines/hdb/ai-bots.cpp


diff --git a/engines/hdb/ai-bots.cpp b/engines/hdb/ai-bots.cpp
index 628a147..a9af5eb 100644
--- a/engines/hdb/ai-bots.cpp
+++ b/engines/hdb/ai-bots.cpp
@@ -1374,17 +1374,186 @@ void aiDiverterDraw(AIEntity *e, int mx, int my) {
 }
 #endif
 
+void aiMeerkatInit(AIEntity *e) {
+	e->state = STATE_NONE;
+	e->sequence = 0;
+	if (e->value1 == 1) {
+		e->aiAction = aiMeerkatLookAround;
+		e->state = STATE_MEER_LOOK;
+	} else
+		e->aiAction = aiMeerkatAction;
+}
+
+void aiMeerkatInit2(AIEntity *e) {
+	//  hidden at the start!
+	e->draw = NULL;
+
+	// make the looking around cycle better...
+	e->movedownGfx[3] = e->movedownGfx[1];
+	e->movedownFrames++;
+}
 
 void aiMeerkatDraw(AIEntity *e, int mx, int my) {
-	warning("STUB: AI: aiMeerkatDraw required");
+	char word[3];
+	debug(9, "FIXME: Replace MaskedBlitting with AlphaMaskedBlitting");
+	g_hdb->_window->getGemGfx()->drawMasked(e->value1 - mx, e->value2 - my);
+	g_hdb->_gfx->setCursor(e->value1 + 12 - mx, e->value2 - 8 - my);
+	word[2] = 0;
+	if (!e->special1Frames) {
+		word[0] = '0';
+		word[1] = 0;
+	} else {
+		word[0] = '-';
+		word[1] = '0' + e->special1Frames;
+	}
+	g_hdb->_gfx->drawText(word);
 }
 
 void aiMeerkatAction(AIEntity *e) {
-	warning("STUB: AI: aiMeerkatAction required");
+	AIEntity *p = g_hdb->_ai->getPlayer();
+
+	switch (e->sequence) {
+		// waiting to see the player
+	case 0:
+		if ((abs(p->tileX - e->tileX) <= 1 && p->tileY == e->tileY) ||
+			(abs(p->tileY - e->tileY) <= 1 && p->tileX == e->tileX)) {
+			e->sequence = 1;
+			e->state = STATE_MEER_MOVE;
+			e->animFrame = 0;
+			e->animCycle = 1;
+			e->animDelay = e->animCycle;
+			if (e->onScreen)
+				g_hdb->_sound->playSound(SND_MEERKAT_WARNING);
+		}
+		break;
+		// time to show the mound for a sec...
+	case 1:
+		g_hdb->_ai->animateEntity(e);
+		if (!e->animFrame && e->animDelay == e->animCycle)
+			e->sequence++;
+		if (e->sequence == 2) {
+			e->state = STATE_MEER_APPEAR;
+			e->animFrame = 0;
+			e->animDelay = e->animCycle;
+			if (e->onScreen)
+				g_hdb->_sound->playSound(SND_MEERKAT_APPEAR);
+		}
+		break;
+
+		// pop outta the dirt!
+	case 2:
+		g_hdb->_ai->animateEntity(e);
+		// done w/sequence?
+		if (!e->animFrame && e->animDelay == e->animCycle) {
+			e->sequence++;
+			e->state = STATE_MEER_LOOK;
+			e->animFrame = 0;
+			e->animCycle = 2;
+			e->animDelay = e->animCycle;
+		}
+		break;
+
+		// looking around...... time to bite the player!?
+	case 3:
+	case 4:
+		g_hdb->_ai->animateEntity(e);
+		if (!e->animFrame && e->animDelay == e->animCycle) {
+			e->sequence++;
+			if (e->sequence == 5)
+				e->state = STATE_MEER_DISAPPEAR;
+		}
+		if (g_hdb->_ai->checkPlayerTileCollision(e->tileX, e->tileY)) {
+			e->state = STATE_MEER_BITE;
+			e->sequence = 6;
+			e->animFrame = 0;
+			e->animDelay = e->animCycle;
+			if (e->onScreen)
+				g_hdb->_sound->playSound(SND_MEERKAT_BITE);
+		}
+		break;
+
+		// going back underground!
+	case 5:
+		g_hdb->_ai->animateEntity(e);
+		if (!e->animFrame && e->animDelay == e->animCycle) {
+			e->sequence = 0;;
+			e->state = STATE_NONE;
+			e->draw = NULL;
+		}
+		break;
+
+		// biting the player right now!
+	case 6:
+		g_hdb->_ai->animateEntity(e);
+		// hit the player?
+		if (g_hdb->_ai->checkPlayerTileCollision(e->tileX, e->tileY)) {
+			g_hdb->_ai->stopEntity(p);
+			g_hdb->_ai->setPlayerLock(true);
+			e->sequence = 7;
+			p->moveSpeed <<= 1;
+			if (g_hdb->_ai->findEntity(p->tileX, p->tileY + 1))
+				g_hdb->_ai->setEntityGoal(p, p->tileX, p->tileY - 1);
+			else
+				g_hdb->_ai->setEntityGoal(p, p->tileX, p->tileY + 1);
+			e->aiDraw = aiMeerkatDraw;
+			e->value1 = e->x;
+			e->value2 = e->y;
+			e->blinkFrames = 0;		// index into movement table...
+
+			// figure # of gems to take
+			e->special1Frames = g_hdb->_rnd->getRandomNumber(5) + 1;
+			int	amt = g_hdb->_ai->getGemAmount();
+			if (amt - e->special1Frames < 0)
+				e->special1Frames = amt;
+
+			// if we're in Puzzle Mode and there's no gems left, give one back
+			if (!g_hdb->getActionMode() && !(e->special1Frames - amt) && e->special1Frames)
+				e->special1Frames--;
+
+			amt -= e->special1Frames;
+			g_hdb->_ai->setGemAmount(amt);
+		}
+		// go back to looking?
+		if (!e->animFrame && e->animDelay == e->animCycle) {
+			e->sequence = 3;
+			e->state = STATE_MEER_LOOK;
+			e->animFrame = 0;
+			e->animDelay = e->animCycle;
+		}
+		break;
+
+		// waiting for player to blast backward
+	case 7:
+		g_hdb->_ai->animateEntity(e);
+		if (!p->goalX) {
+			p->moveSpeed = kPlayerMoveSpeed;
+			g_hdb->_ai->setPlayerLock(false);
+			e->sequence = 5;
+			e->state = STATE_MEER_DISAPPEAR;
+			e->animFrame = 0;
+			e->animDelay = e->animCycle;
+		}
+		break;
+	}
+
+	// blasting a gem outta Guy?
+	if (e->value1) {
+		int	gem_xv[] = {0, 0,-2,-3,-4,-4,-3,-2,-2,-2,-2,-1,-1, 100};
+		int gem_yv[] = {-6,-5,-4,-3,-2,-1, 0, 0, 1, 2, 3, 4, 5, 100};
+
+		if (gem_xv[e->blinkFrames] == 100) {
+			e->value1 = 0;
+			e->aiDraw = NULL;
+			return;
+		}
+		e->value1 += gem_xv[e->blinkFrames];
+		e->value2 += gem_yv[e->blinkFrames];
+		e->blinkFrames++;
+	}
 }
 
 void aiMeerkatLookAround(AIEntity *e) {
-	warning("STUB: AI: aiMeerkatLookAround required");
+	g_hdb->_ai->animEntFrames(e);
 }
 
 void aiFatFrogAction(AIEntity *e) {
@@ -1447,14 +1616,6 @@ void aiLaserInit2(AIEntity *e) {
 	warning("STUB: AI: aiLaserInit2 required");
 }
 
-void aiMeerkatInit(AIEntity *e) {
-	warning("STUB: AI: aiMeerkatInit required");
-}
-
-void aiMeerkatInit2(AIEntity *e) {
-	warning("STUB: AI: aiMeerkatInit2 required");
-}
-
 void aiFatFrogInit(AIEntity *e) {
 	warning("STUB: AI: aiFatFrogInit required");
 }


Commit: 7a6a169422fd465e62ab64263976b77cb2ce4560
    https://github.com/scummvm/scummvm/commit/7a6a169422fd465e62ab64263976b77cb2ce4560
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:11+02:00

Commit Message:
HDB: Add _fairystones data

Changed paths:
    engines/hdb/ai.h


diff --git a/engines/hdb/ai.h b/engines/hdb/ai.h
index e7cfd08..3ac60ca 100644
--- a/engines/hdb/ai.h
+++ b/engines/hdb/ai.h
@@ -40,6 +40,7 @@ enum {
 	kMaxAutoActions = 30,
 	kMaxLuaEnts = 50,
 	kMaxCallbacks = 20,
+	kMaxFairystones = 5,
 	kMaxBridges = 10,
 	kDelay5Seconds = 5 * kGameFPS,
 	kPlayerMoveSpeed = 4,
@@ -715,6 +716,13 @@ struct Callback {
 	Callback() : type(NO_FUNCTION), x(0), y(0), delay(0) {}
 };
 
+struct Fairystone {
+	uint16 srcX, srcY;
+	uint16 destX, destY;
+
+	Fairystone() : srcX(0), srcY(0), destX(0), destY(0) {}
+};
+
 struct Bridge {
 	uint16 x, y;
 	AIDir dir;
@@ -1212,6 +1220,8 @@ public:
 
 	Callback _callbacks[kMaxCallbacks];
 
+	Fairystone _fairystones[kMaxFairystones];
+
 	Bridge _bridges[kMaxBridges];
 	int _numBridges;
 


Commit: 292ada30e344fbf9d8ba53a9f0bc264082d492b0
    https://github.com/scummvm/scummvm/commit/292ada30e344fbf9d8ba53a9f0bc264082d492b0
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:11+02:00

Commit Message:
HDB: Add _fairystones functions

Changed paths:
    engines/hdb/ai-lists.cpp
    engines/hdb/ai.h


diff --git a/engines/hdb/ai-lists.cpp b/engines/hdb/ai-lists.cpp
index d6534cc..890b943 100644
--- a/engines/hdb/ai-lists.cpp
+++ b/engines/hdb/ai-lists.cpp
@@ -236,6 +236,24 @@ void AI::animateBridges() {
 	}
 }
 
+void AI::addToFairystones(int index, int tileX, int tileY, int sourceOrDest) {
+	if (!sourceOrDest) {
+		_fairystones[index].srcX = tileX;
+		_fairystones[index].srcY = tileY;
+	} else {
+		_fairystones[index].destX = tileX;
+		_fairystones[index].destY = tileY;
+	}
+}
+
+int AI::checkFairystones(int tileX, int tileY) {
+	int i;
+	for (i = 0; i < kMaxFairystones; i++)
+		if (_fairystones[i].destX == tileX && _fairystones[i].destY == tileY)
+			return i;
+	return -1;
+}
+
 // Add an action location to the list of possible actions
 // Each action must be paired with another of the same number
 void AI::addToActionList(int actionIndex, int x, int y, char *luaFuncInt, char *luaFuncUse) {
diff --git a/engines/hdb/ai.h b/engines/hdb/ai.h
index 3ac60ca..f7d42e6 100644
--- a/engines/hdb/ai.h
+++ b/engines/hdb/ai.h
@@ -848,6 +848,12 @@ public:
 
 	void addBridgeExtend(int x, int y, int bridgeType);
 	void animateBridges();
+	void addToFairystones(int index, int tileX, int tileY, int sourceOrDest);
+	int checkFairystones(int tileX, int tileY);
+	void getFairystonesSrc(int index, int *tileX, int *tileY) {
+		*tileX = _fairystones[index].srcX;
+		*tileY = _fairystones[index].srcY;
+	}
 
 	AIEntity *playerCollision(int topBorder, int bottomBorder, int leftBorder, int rightBorder);
 	bool checkPlayerTileCollision(int x, int y);


Commit: 002f8edd48ad8fe01fce3ebb4e68362d6d023e82
    https://github.com/scummvm/scummvm/commit/002f8edd48ad8fe01fce3ebb4e68362d6d023e82
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:11+02:00

Commit Message:
HDB: Add GoodFairy functions

Changed paths:
    engines/hdb/ai-bots.cpp


diff --git a/engines/hdb/ai-bots.cpp b/engines/hdb/ai-bots.cpp
index a9af5eb..32d4587 100644
--- a/engines/hdb/ai-bots.cpp
+++ b/engines/hdb/ai-bots.cpp
@@ -1564,8 +1564,198 @@ void aiFatFrogTongueDraw(AIEntity *e, int mx, int my) {
 	warning("STUB: AI: aiFatFrogTongueDraw required");
 }
 
+void aiGoodFairyInit(AIEntity *e) {
+	e->aiAction = aiGoodFairyAction;
+	e->sequence = 20;
+	e->blinkFrames = e->goalX = 0;
+}
+
+void aiGoodFairyInit2(AIEntity *e) {
+	e->draw = g_hdb->_ai->getStandFrameDir(e);
+}
+
 void aiGoodFairyAction(AIEntity *e) {
-	warning("STUB: AI: aiGoodFairyAction required");
+	AIState state[5] = {STATE_NONE, STATE_MOVEUP, STATE_MOVEDOWN, STATE_MOVELEFT, STATE_MOVERIGHT};
+	int	xvAhead[5] = {9, 0, 0,-1, 1}, yvAhead[5] = {9,-1, 1, 0, 0};
+	int xv, yv;
+	int	result;
+	AIEntity *hit;
+
+	if (e->sequence) {
+		e->sequence--;
+
+		// look around...
+		switch (e->sequence) {
+		case 19:
+			e->state = STATE_MOVEDOWN;
+			break;
+		case 0:
+			{
+				// Create a GEM?
+				if (g_hdb->_rnd->getRandomNumber(100) > 98) {
+					int	spawnOK;
+
+					// spawn a gem in a random direction
+					int	d = g_hdb->_rnd->getRandomNumber(4) + 1;
+					xv = xvAhead[d];
+					yv = yvAhead[d];
+
+					e->sequence = 30;
+					e->state = STATE_MOVEDOWN;
+					// is something there already?
+					if ((g_hdb->_ai->findEntityType(AI_CRATE, e->tileX + xv, e->tileY + yv) != NULL) ||
+						(g_hdb->_ai->findEntityType(AI_LIGHTBARREL, e->tileX + xv, e->tileY + yv) != NULL))
+						return;
+					hit = g_hdb->_ai->legalMove(e->tileX + xv, e->tileY + yv, e->level, &spawnOK);
+					uint32 bg_flags = g_hdb->_map->getMapBGTileFlags(e->tileX + xv, e->tileY + yv);
+					if (hit || !spawnOK || (bg_flags & kFlagSpecial))
+						return;
+
+					g_hdb->_ai->spawn(ITEM_GEM_WHITE, e->dir, e->tileX + xv, e->tileY + yv, NULL, NULL, NULL, DIR_NONE, e->level, 0, 0, 1);
+					g_hdb->_ai->addAnimateTarget(e->x + xv * kTileWidth, e->y + yv * kTileHeight, 0, 3, ANIM_NORMAL, false, false, GEM_FLASH);
+					if (e->onScreen) {
+						g_hdb->_sound->playSound(SND_GET_GEM);
+						g_hdb->_sound->playSound(SND_GOOD_FAERIE_SPELL);
+					}
+					return;
+				}
+
+				int	tries = 4;
+				do {
+					// pick a random direction, then a random # of tiles in that direction
+					int	 rnd = g_hdb->_rnd->getRandomNumber(4) + 1;
+					AIDir d = (AIDir)rnd;
+					int	 walk = g_hdb->_rnd->getRandomNumber(5) + 1;
+					AIEntity *p = g_hdb->_ai->getPlayer();
+
+					// if player is within 3 tiles, move closer
+					if (abs(p->tileX - e->tileX) < 3 && abs(p->tileY - e->tileY) < 3) {
+						if (abs(p->tileX - e->tileX) > abs(p->tileY - e->tileY)) {
+						testx:
+							if (p->tileX != e->tileX) {
+								if (p->tileX < e->tileX)
+									d = DIR_LEFT;
+								else
+									d = DIR_RIGHT;
+							} else if (p->tileY != e->tileY)
+								goto testy;
+						} else {
+						testy:
+							if (p->tileY != e->tileY) {
+								if (p->tileY <= e->tileY)
+									d = DIR_UP;
+								else
+									d = DIR_DOWN;
+							} else if (p->tileX != e->tileX)
+								goto testx;
+						}
+					}
+
+					// special case: if player is exactly 2 tiles away, move out of the way
+					if (abs(p->tileX - e->tileX) == 2 && p->tileY == e->tileY) {
+						int	move_ok;
+						d = DIR_UP;
+						AIEntity *h = g_hdb->_ai->legalMoveOverWater(e->tileX, e->tileY - 1, e->level, &move_ok);
+						if (h || !move_ok)
+							d = DIR_DOWN;
+					} else if (abs(p->tileY - e->tileY) == 2 && p->tileX == e->tileX) {
+						int	move_ok;
+						d = DIR_LEFT;
+						AIEntity *h = g_hdb->_ai->legalMoveOverWater(e->tileX - 1, e->tileY, e->level, &move_ok);
+						if (h || !move_ok)
+							d = DIR_RIGHT;
+					}
+
+					e->dir = d;
+					e->state = state[d];
+					xv = xvAhead[d] * walk;
+					if (e->tileX + xv < 1)
+						xv = -e->tileX + 1;
+					if (e->tileX + xv > g_hdb->_map->_width)
+						xv = g_hdb->_map->_width - e->tileX - 1;
+
+					yv = yvAhead[d] * walk;
+					if (e->tileY + yv < 1)
+						yv = -e->tileY + 1;
+					if (e->tileY + yv > g_hdb->_map->_height)
+						yv = g_hdb->_map->_height - e->tileY - 1;
+
+					e->value1 = xvAhead[d];
+					e->value2 = yvAhead[d];
+					e->moveSpeed = kPlayerMoveSpeed;
+
+					// make sure we can move over water & white gems, but not fg_hdb->_ai->y blockers and solids
+					hit = g_hdb->_ai->legalMoveOverWater(e->tileX + e->value1, e->tileY + e->value2, e->level, &result);
+					if (hit && ((hit->type == ITEM_GEM_WHITE) || (hit->type == AI_GUY)))
+						hit = NULL;
+					uint32 bg_flags = g_hdb->_map->getMapBGTileFlags(e->tileX + e->value1, e->tileY + e->value2);
+					if (result && !hit && !(bg_flags & kFlagSpecial)) {
+						g_hdb->_ai->setEntityGoal(e, e->tileX + xv, e->tileY + yv);
+						if (e->onScreen && !g_hdb->_rnd->getRandomNumber(30))
+							g_hdb->_sound->playSound(SND_GOOD_FAERIE_AMBIENT);
+						g_hdb->_ai->animateEntity(e);
+						return;
+					}
+					tries--;		// don't lock the system if the fg_hdb->_ai->y is cornered
+				} while (!result && tries);
+
+				// couldn't find a place to move so just sit here for a sec & try agg_hdb->_ai->
+				e->dir = DIR_NONE;
+				e->state = STATE_MOVEDOWN;
+				e->sequence = 1;
+				e->value1 = e->value2 = e->xVel = e->yVel = 0;
+			}
+		}
+		g_hdb->_ai->animEntFrames(e);
+		return;
+	}
+
+	// in the process of moving around...
+	if (e->goalX) {
+		// did we run into a wall, entity, water, slime etc?
+		// if so, pick a new direction!
+		if (onEvenTile(e->x, e->y)) {
+
+			int	index;
+			// did we hit a Fg_hdb->_ai->YSTONE??? if so - teleport the thing at the other end to here!
+			index = g_hdb->_ai->checkFairystones(e->tileX, e->tileY);
+			if (index >= 0) {
+				int	sx, sy;
+				g_hdb->_ai->getFairystonesSrc(index, &sx, &sy);
+				hit = g_hdb->_ai->findEntity(sx, sy);
+				if (hit && (hit != g_hdb->_ai->getPlayer())) {
+					hit->tileX = e->tileX;
+					hit->tileY = e->tileY;
+					hit->x = hit->tileX * kTileWidth;
+					hit->y = hit->tileY * kTileHeight;
+					hit->goalX = hit->goalY = 0;
+					g_hdb->_ai->addAnimateTarget(e->x, e->y, 0, 7, ANIM_NORMAL, false, false, TELEPORT_FLASH);
+					g_hdb->_ai->addAnimateTarget(sx * kTileWidth, sy * kTileHeight, 0, 7, ANIM_NORMAL, false, false, TELEPORT_FLASH);
+					if (e->onScreen)
+						g_hdb->_sound->playSound(SND_TELEPORT);
+					if (hit->onScreen)
+						g_hdb->_sound->playSound(SND_TELEPORT);
+				}
+			}
+
+			// see if we're about to move to a bad spot, which means:
+			// (1) we're gonna hit a solid wall; ok to move over water/slime
+			// (2) ok to move thru white gems
+			// (3) cannot move thru SPECIAL flagged tiles (fg_hdb->_ai->y blockers)
+			hit = g_hdb->_ai->legalMoveOverWater(e->tileX + e->value1, e->tileY + e->value2, e->level, &result);
+			uint32 bg_flags = g_hdb->_map->getMapBGTileFlags(e->tileX + e->value1, e->tileY + e->value2);
+			if (!result || (hit && hit->type != ITEM_GEM_WHITE && hit->type != AI_GUY) || (bg_flags & kFlagSpecial)) {
+				g_hdb->_ai->stopEntity(e);
+				e->value1 = e->value2 = 0;
+				e->state = STATE_MOVEDOWN;
+				e->sequence = 20;
+				return;
+			}
+		}
+		g_hdb->_ai->animateEntity(e);
+	} else
+		// if not, start looking around!
+		e->sequence = 20;
 }
 
 void aiBadFairyAction(AIEntity *e) {
@@ -1624,18 +1814,6 @@ void aiFatFrogInit2(AIEntity *e) {
 	warning("STUB: AI: aiFatFrogInit2 required");
 }
 
-void aiGoodFairyInit(AIEntity *e) {
-	warning("STUB: AI: aiGoodFairyInit required");
-}
-
-void aiGoodFairyInit2(AIEntity *e) {
-	warning("STUB: AI: aiGoodFairyInit2 required");
-}
-
-void aiGoodFairyMoveaway(AIEntity *e) {
-	warning("STUB: AI: aiGoodFairyMoveaway required");
-}
-
 void aiBadFairyInit(AIEntity *e) {
 	warning("STUB: AI: aiBadFairyInit required");
 }


Commit: 60eb04f83341f6f45ed8b17b72c8ab1fe650bf6c
    https://github.com/scummvm/scummvm/commit/60eb04f83341f6f45ed8b17b72c8ab1fe650bf6c
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:11+02:00

Commit Message:
HDB: Unstub addtoFairystones calls

Changed paths:
    engines/hdb/map.cpp


diff --git a/engines/hdb/map.cpp b/engines/hdb/map.cpp
index ec5b57c..c99f3f2 100644
--- a/engines/hdb/map.cpp
+++ b/engines/hdb/map.cpp
@@ -596,7 +596,12 @@ bool Map::load(Common::SeekableReadStream *stream) {
 		case INFO_FAIRY_SRC3:
 		case INFO_FAIRY_SRC4:
 		case INFO_FAIRY_SRC5:
-			warning("STUB: Map::load: AddToFairystones(SRC) required");
+			g_hdb->_ai->addToFairystones(
+				aiInfo[_iconList[i].icon].type - INFO_FAIRY_SRC,
+				_iconList[i].x,
+				_iconList[i].y,
+				0
+			);
 			break;
 
 		case INFO_FAIRY_DEST:
@@ -604,7 +609,12 @@ bool Map::load(Common::SeekableReadStream *stream) {
 		case INFO_FAIRY_DEST3:
 		case INFO_FAIRY_DEST4:
 		case INFO_FAIRY_DEST5:
-			warning("STUB: Map::load: AddToFairystones(DEST) required");
+			g_hdb->_ai->addToFairystones(
+				aiInfo[_iconList[i].icon].type - INFO_FAIRY_DEST,
+				_iconList[i].x,
+				_iconList[i].y,
+				1
+			);
 			break;
 		}
 	}


Commit: 0751cedb08e9c357bfa6f696fa749ebc303b7cfa
    https://github.com/scummvm/scummvm/commit/0751cedb08e9c357bfa6f696fa749ebc303b7cfa
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:11+02:00

Commit Message:
HDB: Remove '#if 0' conditionals

Changed paths:
    engines/hdb/ai-bots.cpp
    engines/hdb/ai-init.cpp
    engines/hdb/ai.h


diff --git a/engines/hdb/ai-bots.cpp b/engines/hdb/ai-bots.cpp
index 32d4587..689c7af 100644
--- a/engines/hdb/ai-bots.cpp
+++ b/engines/hdb/ai-bots.cpp
@@ -1280,10 +1280,6 @@ void aiDiverterAction(AIEntity *e) {
 }
 
 void aiDiverterDraw(AIEntity *e, int mx, int my) {
-}
-
-#if 0
-void aiDiverterDraw(AIEntity *e, int mx, int my) {
 	int		i;
 	if (!e->value1 && !e->value2)
 		return;
@@ -1372,7 +1368,6 @@ void aiDiverterDraw(AIEntity *e, int mx, int my) {
 	}
 	e->movedownFrames++;
 }
-#endif
 
 void aiMeerkatInit(AIEntity *e) {
 	e->state = STATE_NONE;
diff --git a/engines/hdb/ai-init.cpp b/engines/hdb/ai-init.cpp
index 5e40823..d6e2b3f 100644
--- a/engines/hdb/ai-init.cpp
+++ b/engines/hdb/ai-init.cpp
@@ -772,7 +772,6 @@ bool AI::init() {
 	_kcHolderBlackOff	= g_hdb->_gfx->getTileIndex("anim_t32_kcholder_black_off1");
 	_kcHolderBlackOn	= g_hdb->_gfx->getTileIndex("t32_kcholder_black_on");
 
-#if 0
 	// icepuff snowball
 	icepSnowballGfxDown = icepSnowballGfxLeft = icepSnowballGfxRight = NULL;
 
@@ -785,7 +784,6 @@ bool AI::init() {
 
 	// laser beam
 	gfxLaserbeamUD[0] = gfxLaserbeamUD[1] = gfxLaserbeamLR[0] = gfxLaserbeamLR[1] = NULL;
-#endif
 
 	_dummyPlayer.type = AI_GUY;
 	_dummyLaser.type = AI_LASERBEAM;
@@ -849,7 +847,6 @@ void AI::restartSystem() {
 	memset(_clubLeftGfx, NULL, kMaxAnimFrames * sizeof(Tile *));
 	memset(_clubRightGfx, NULL, kMaxAnimFrames * sizeof(Tile *));
 
-#if 0
 	int i;
 	if (icepSnowballGfxDown) {
 		icepSnowballGfxDown->free();
@@ -923,7 +920,6 @@ void AI::restartSystem() {
 			gfxLaserbeamLRRight[i] = NULL;
 		}
 	}
-#endif
 
 	// Clear the Action list
 	memset(_actions, 0, sizeof(_actions));
diff --git a/engines/hdb/ai.h b/engines/hdb/ai.h
index f7d42e6..05a5a2d 100644
--- a/engines/hdb/ai.h
+++ b/engines/hdb/ai.h
@@ -774,7 +774,6 @@ struct CineBlit {
 	}
 #define spawnBlocking(x, y, level)	g_hdb->_ai->spawn(AI_NONE, DIR_NONE, x, y, NULL, NULL, NULL, DIR_NONE, level, 0, 0, 0)
 
-#if 0
 extern	Picture *icepSnowballGfxDown;		// ICEPUFF's snowball moving down
 extern	Picture *icepSnowballGfxLeft;		// ICEPUFF's snowball moving left
 extern	Picture *icepSnowballGfxRight;		// ICEPUFF's snowball moving right
@@ -795,7 +794,6 @@ extern	Tile *gfxLaserbeamUDBottom[4];
 extern	Tile *gfxLaserbeamLR[4];
 extern	Tile *gfxLaserbeamLRLeft[4];
 extern	Tile *gfxLaserbeamLRRight[4];
-#endif
 
 class AI {
 public:


Commit: ad8f85759576ca81993f9f143feaf5df8c2e714e
    https://github.com/scummvm/scummvm/commit/ad8f85759576ca81993f9f143feaf5df8c2e714e
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:11+02:00

Commit Message:
HDB: Move Bots gfx into _gfx

Changed paths:
    engines/hdb/ai-bots.cpp
    engines/hdb/ai-init.cpp
    engines/hdb/ai.h
    engines/hdb/gfx.h


diff --git a/engines/hdb/ai-bots.cpp b/engines/hdb/ai-bots.cpp
index 689c7af..7836bbf 100644
--- a/engines/hdb/ai-bots.cpp
+++ b/engines/hdb/ai-bots.cpp
@@ -1290,16 +1290,16 @@ void aiDiverterDraw(AIEntity *e, int mx, int my) {
 	case DIR_UP:
 		if (e->tileY == e->value1 && e->int2) {	// going down or right?
 			for (i = e->value1 + 1; i < e->value2; i++)
-				onScreen += gfxLaserbeamUD[frame]->drawMasked(e->x - mx, i * kTileHeight - my);
-			onScreen += gfxLaserbeamUDTop[frame]->drawMasked(e->x - mx, i * kTileHeight - my);
+				onScreen += g_hdb->_gfx->_gfxLaserbeamUD[frame]->drawMasked(e->x - mx, i * kTileHeight - my);
+			onScreen += g_hdb->_gfx->_gfxLaserbeamUDTop[frame]->drawMasked(e->x - mx, i * kTileHeight - my);
 			if (onScreen) {
 				g_hdb->_sound->playSoundEx(SND_LASER_LOOP, kLaserChannel, true);
 				warning("STUB: Set Laser onScreen to true");
 			}
 		} else {
 			for (i = e->value1 + 1; i < e->value2; i++)
-				onScreen += gfxLaserbeamLR[frame]->drawMasked(i * kTileWidth - mx, e->y - my);
-			onScreen += gfxLaserbeamLRLeft[frame]->drawMasked(i * kTileWidth - mx, e->y - my);
+				onScreen += g_hdb->_gfx->_gfxLaserbeamLR[frame]->drawMasked(i * kTileWidth - mx, e->y - my);
+			onScreen += g_hdb->_gfx->_gfxLaserbeamLRLeft[frame]->drawMasked(i * kTileWidth - mx, e->y - my);
 			if (onScreen) {
 				g_hdb->_sound->playSoundEx(SND_LASER_LOOP, kLaserChannel, true);
 				warning("STUB: Set Laser onScreen to true");
@@ -1309,16 +1309,16 @@ void aiDiverterDraw(AIEntity *e, int mx, int my) {
 	case DIR_DOWN:
 		if (e->tileY == e->value1 && e->int2) {	// going down or left?
 			for (i = e->value1 + 1; i < e->value2; i++)
-				onScreen += gfxLaserbeamUD[frame]->drawMasked(e->x - mx, i * kTileHeight - my);
-			onScreen += gfxLaserbeamUDTop[frame]->drawMasked(e->x - mx, i * kTileHeight - my);
+				onScreen += g_hdb->_gfx->_gfxLaserbeamUD[frame]->drawMasked(e->x - mx, i * kTileHeight - my);
+			onScreen += g_hdb->_gfx->_gfxLaserbeamUDTop[frame]->drawMasked(e->x - mx, i * kTileHeight - my);
 			if (onScreen) {
 				g_hdb->_sound->playSoundEx(SND_LASER_LOOP, kLaserChannel, true);
 				warning("STUB: Set Laser onscreen to true");
 			}
 		} else {
 			for (i = e->value1 - 1; i > e->value2; i--)
-				onScreen += gfxLaserbeamLR[frame]->drawMasked(i * kTileWidth - mx, e->y - my);
-			onScreen += gfxLaserbeamLRRight[frame]->drawMasked(i * kTileWidth - mx, e->y - my);
+				onScreen += g_hdb->_gfx->_gfxLaserbeamLR[frame]->drawMasked(i * kTileWidth - mx, e->y - my);
+			onScreen += g_hdb->_gfx->_gfxLaserbeamLRRight[frame]->drawMasked(i * kTileWidth - mx, e->y - my);
 			if (onScreen) {
 				g_hdb->_sound->playSoundEx(SND_LASER_LOOP, kLaserChannel, true);
 				warning("STUB: Set Laser onscreen to true");
@@ -1328,16 +1328,16 @@ void aiDiverterDraw(AIEntity *e, int mx, int my) {
 	case DIR_LEFT:
 		if (e->tileY == e->value1 && e->int2) {	// going up or left?
 			for (i = e->value1 - 1; i > e->value2; i--)
-				onScreen += gfxLaserbeamUD[frame]->drawMasked(e->x - mx, i * kTileHeight - my);
-			onScreen += gfxLaserbeamUDBottom[frame]->drawMasked(e->x - mx, i * kTileHeight - my);
+				onScreen += g_hdb->_gfx->_gfxLaserbeamUD[frame]->drawMasked(e->x - mx, i * kTileHeight - my);
+			onScreen += g_hdb->_gfx->_gfxLaserbeamUDBottom[frame]->drawMasked(e->x - mx, i * kTileHeight - my);
 			if (onScreen) {
 				g_hdb->_sound->playSoundEx(SND_LASER_LOOP, kLaserChannel, true);
 				warning("STUB: Set Laser onscreen to true");
 			}
 		} else {
 			for (i = e->value1 - 1; i > e->value2; i--)
-				onScreen += gfxLaserbeamLR[frame]->drawMasked(i * kTileWidth - mx, e->y - my);
-			onScreen += gfxLaserbeamLRRight[frame]->drawMasked(i * kTileWidth - mx, e->y - my);
+				onScreen += g_hdb->_gfx->_gfxLaserbeamLR[frame]->drawMasked(i * kTileWidth - mx, e->y - my);
+			onScreen += g_hdb->_gfx->_gfxLaserbeamLRRight[frame]->drawMasked(i * kTileWidth - mx, e->y - my);
 			if (onScreen) {
 				g_hdb->_sound->playSoundEx(SND_LASER_LOOP, kLaserChannel, true);
 				warning("STUB: Set Laser onscreen to true");
@@ -1347,16 +1347,16 @@ void aiDiverterDraw(AIEntity *e, int mx, int my) {
 	case DIR_RIGHT:
 		if (e->tileY == e->value1 && e->int2) {	// going up or right?
 			for (i = e->value1 - 1; i > e->value2; i--)
-				onScreen += gfxLaserbeamUD[frame]->drawMasked(e->x - mx, i * kTileHeight - my);
-			onScreen += gfxLaserbeamUDBottom[frame]->drawMasked(e->x - mx, i * kTileHeight - my);
+				onScreen += g_hdb->_gfx->_gfxLaserbeamUD[frame]->drawMasked(e->x - mx, i * kTileHeight - my);
+			onScreen += g_hdb->_gfx->_gfxLaserbeamUDBottom[frame]->drawMasked(e->x - mx, i * kTileHeight - my);
 			if (onScreen) {
 				g_hdb->_sound->playSoundEx(SND_LASER_LOOP, kLaserChannel, true);
 				warning("STUB: Set Laser onscreen to true");
 			}
 		} else {
 			for (i = e->value1 + 1; i < e->value2; i++)
-				onScreen += gfxLaserbeamLR[frame]->drawMasked(i * kTileWidth - mx, e->y - my);
-			onScreen += gfxLaserbeamLRLeft[frame]->drawMasked(i * kTileWidth - mx, e->y - my);
+				onScreen += g_hdb->_gfx->_gfxLaserbeamLR[frame]->drawMasked(i * kTileWidth - mx, e->y - my);
+			onScreen += g_hdb->_gfx->_gfxLaserbeamLRLeft[frame]->drawMasked(i * kTileWidth - mx, e->y - my);
 			if (onScreen) {
 				g_hdb->_sound->playSoundEx(SND_LASER_LOOP, kLaserChannel, true);
 				warning("STUB: Set Laser onscreen to true");
diff --git a/engines/hdb/ai-init.cpp b/engines/hdb/ai-init.cpp
index d6e2b3f..29b5ec1 100644
--- a/engines/hdb/ai-init.cpp
+++ b/engines/hdb/ai-init.cpp
@@ -773,17 +773,19 @@ bool AI::init() {
 	_kcHolderBlackOn	= g_hdb->_gfx->getTileIndex("t32_kcholder_black_on");
 
 	// icepuff snowball
-	icepSnowballGfxDown = icepSnowballGfxLeft = icepSnowballGfxRight = NULL;
+	g_hdb->_gfx->_icepSnowballGfxDown = g_hdb->_gfx->_icepSnowballGfxLeft = 
+		g_hdb->_gfx->_icepSnowballGfxRight = NULL;
 
 	// Frogglick
-	tileFroglickMiddleUD = tileFroglickMiddleLR = NULL;
-	tileFroglickWiggleLeft[0] = tileFroglickWiggleRight[0] = NULL;
+	g_hdb->_gfx->_tileFroglickMiddleUD = g_hdb->_gfx->_tileFroglickMiddleLR = NULL;
+	g_hdb->_gfx->_tileFroglickWiggleLeft[0] = g_hdb->_gfx->_tileFroglickWiggleRight[0] = NULL;
 
 	// Dragon
-	gfxDragonAsleep = NULL;
+	g_hdb->_gfx->_gfxDragonAsleep = NULL;
 
 	// laser beam
-	gfxLaserbeamUD[0] = gfxLaserbeamUD[1] = gfxLaserbeamLR[0] = gfxLaserbeamLR[1] = NULL;
+	g_hdb->_gfx->_gfxLaserbeamUD[0] = g_hdb->_gfx->_gfxLaserbeamUD[1] = 
+		g_hdb->_gfx->_gfxLaserbeamLR[0] = g_hdb->_gfx->_gfxLaserbeamLR[1] = NULL;
 
 	_dummyPlayer.type = AI_GUY;
 	_dummyLaser.type = AI_LASERBEAM;
@@ -848,76 +850,77 @@ void AI::restartSystem() {
 	memset(_clubRightGfx, NULL, kMaxAnimFrames * sizeof(Tile *));
 
 	int i;
-	if (icepSnowballGfxDown) {
-		icepSnowballGfxDown->free();
-		icepSnowballGfxDown = NULL;
+	if (g_hdb->_gfx->_icepSnowballGfxDown) {
+		g_hdb->_gfx->_icepSnowballGfxDown->free();
+		g_hdb->_gfx->_icepSnowballGfxDown = NULL;
 	}
-	if (icepSnowballGfxLeft) {
-		icepSnowballGfxLeft->free();
-		icepSnowballGfxLeft = NULL;
+	if (g_hdb->_gfx->_icepSnowballGfxLeft) {
+		g_hdb->_gfx->_icepSnowballGfxLeft->free();
+		g_hdb->_gfx->_icepSnowballGfxLeft = NULL;
 	}
-	if (icepSnowballGfxRight) {
-		icepSnowballGfxRight->free();
-		icepSnowballGfxRight = NULL;
+	if (g_hdb->_gfx->_icepSnowballGfxRight) {
+		g_hdb->_gfx->_icepSnowballGfxRight->free();
+		g_hdb->_gfx->_icepSnowballGfxRight = NULL;
 	}
 
-	if (tileFroglickMiddleUD) {
-		tileFroglickMiddleUD->free();
-		tileFroglickMiddleUD = NULL;
+	if (g_hdb->_gfx->_tileFroglickMiddleUD) {
+		g_hdb->_gfx->_tileFroglickMiddleUD->free();
+		g_hdb->_gfx->_tileFroglickMiddleUD = NULL;
 	}
-	if (tileFroglickWiggleUD[0]) {
+	if (g_hdb->_gfx->_tileFroglickWiggleUD[0]) {
 		for (i = 0; i < 3; i++) {
-			tileFroglickWiggleUD[i]->free();
-			tileFroglickWiggleUD[i] = NULL;
+			g_hdb->_gfx->_tileFroglickWiggleUD[i]->free();
+			g_hdb->_gfx->_tileFroglickWiggleUD[i] = NULL;
 		}
 	}
 
-	if (tileFroglickMiddleLR) {
-		tileFroglickMiddleLR->free();
-		tileFroglickMiddleLR = NULL;
+	if (g_hdb->_gfx->_tileFroglickMiddleLR) {
+		g_hdb->_gfx->_tileFroglickMiddleLR->free();
+		g_hdb->_gfx->_tileFroglickMiddleLR = NULL;
 	}
-	if (tileFroglickWiggleLeft[0]) {
+	if (g_hdb->_gfx->_tileFroglickWiggleLeft[0]) {
 		for (i = 0; i < 3; i++) {
-			tileFroglickWiggleLeft[i]->free();
-			tileFroglickWiggleLeft[i] = NULL;
+			g_hdb->_gfx->_tileFroglickWiggleLeft[i]->free();
+			g_hdb->_gfx->_tileFroglickWiggleLeft[i] = NULL;
 		}
 	}
-	if (tileFroglickWiggleRight[0]) {
+	if (g_hdb->_gfx->_tileFroglickWiggleRight[0]) {
 		for (i = 0; i < 3; i++) {
-			tileFroglickWiggleRight[i]->free();
-			tileFroglickWiggleRight[i] = NULL;
+			g_hdb->_gfx->_tileFroglickWiggleRight[i]->free();
+			g_hdb->_gfx->_tileFroglickWiggleRight[i] = NULL;
 		}
 	}
 
 	// dragon!  see ya!
-	if (gfxDragonAsleep) {
-		gfxDragonAsleep->free();
-		gfxDragonAsleep = NULL;
-		gfxDragonFlap[0]->free();
-		gfxDragonFlap[1]->free();
-		gfxDragonFlap[0] = gfxDragonFlap[1] = NULL;
-		gfxDragonBreathe[0]->free();
-		gfxDragonBreathe[1]->free();
-		gfxDragonBreathe[2]->free();
-		gfxDragonBreathe[0] = gfxDragonBreathe[1] = gfxDragonBreathe[2] = NULL;
+	if (g_hdb->_gfx->_gfxDragonAsleep) {
+		g_hdb->_gfx->_gfxDragonAsleep->free();
+		g_hdb->_gfx->_gfxDragonAsleep = NULL;
+		g_hdb->_gfx->_gfxDragonFlap[0]->free();
+		g_hdb->_gfx->_gfxDragonFlap[1]->free();
+		g_hdb->_gfx->_gfxDragonFlap[0] = g_hdb->_gfx->_gfxDragonFlap[1] = NULL;
+		g_hdb->_gfx->_gfxDragonBreathe[0]->free();
+		g_hdb->_gfx->_gfxDragonBreathe[1]->free();
+		g_hdb->_gfx->_gfxDragonBreathe[2]->free();
+		g_hdb->_gfx->_gfxDragonBreathe[0] = g_hdb->_gfx->_gfxDragonBreathe[1] = 
+			g_hdb->_gfx->_gfxDragonBreathe[2] = NULL;
 	}
 
 	// laser beams
-	if (gfxLaserbeamUD[0]) {
+	if (g_hdb->_gfx->_gfxLaserbeamUD[0]) {
 		for (i = 0; i < 4; i++) {
-			gfxLaserbeamUD[i]->free();
-			gfxLaserbeamUDTop[i]->free();
-			gfxLaserbeamUDBottom[i]->free();
-			gfxLaserbeamLR[i]->free();
-			gfxLaserbeamLRLeft[i]->free();
-			gfxLaserbeamLRRight[i]->free();
-
-			gfxLaserbeamUD[i] = NULL;
-			gfxLaserbeamUDTop[i] = NULL;
-			gfxLaserbeamUDBottom[i] = NULL;
-			gfxLaserbeamLR[i] = NULL;
-			gfxLaserbeamLRLeft[i] = NULL;
-			gfxLaserbeamLRRight[i] = NULL;
+			g_hdb->_gfx->_gfxLaserbeamUD[i]->free();
+			g_hdb->_gfx->_gfxLaserbeamUDTop[i]->free();
+			g_hdb->_gfx->_gfxLaserbeamUDBottom[i]->free();
+			g_hdb->_gfx->_gfxLaserbeamLR[i]->free();
+			g_hdb->_gfx->_gfxLaserbeamLRLeft[i]->free();
+			g_hdb->_gfx->_gfxLaserbeamLRRight[i]->free();
+
+			g_hdb->_gfx->_gfxLaserbeamUD[i] = NULL;
+			g_hdb->_gfx->_gfxLaserbeamUDTop[i] = NULL;
+			g_hdb->_gfx->_gfxLaserbeamUDBottom[i] = NULL;
+			g_hdb->_gfx->_gfxLaserbeamLR[i] = NULL;
+			g_hdb->_gfx->_gfxLaserbeamLRLeft[i] = NULL;
+			g_hdb->_gfx->_gfxLaserbeamLRRight[i] = NULL;
 		}
 	}
 
diff --git a/engines/hdb/ai.h b/engines/hdb/ai.h
index 05a5a2d..3850180 100644
--- a/engines/hdb/ai.h
+++ b/engines/hdb/ai.h
@@ -774,27 +774,6 @@ struct CineBlit {
 	}
 #define spawnBlocking(x, y, level)	g_hdb->_ai->spawn(AI_NONE, DIR_NONE, x, y, NULL, NULL, NULL, DIR_NONE, level, 0, 0, 0)
 
-extern	Picture *icepSnowballGfxDown;		// ICEPUFF's snowball moving down
-extern	Picture *icepSnowballGfxLeft;		// ICEPUFF's snowball moving left
-extern	Picture *icepSnowballGfxRight;		// ICEPUFF's snowball moving right
-
-extern	Tile *tileFroglickMiddleUD;
-extern	Tile *tileFroglickWiggleUD[3];
-extern	Tile *tileFroglickMiddleLR;
-extern	Tile *tileFroglickWiggleLeft[3];
-extern	Tile *tileFroglickWiggleRight[3];
-
-extern	Picture *gfxDragonAsleep;
-extern	Picture *gfxDragonFlap[2];
-extern	Picture *gfxDragonBreathe[3];
-
-extern	Tile *gfxLaserbeamUD[4];
-extern	Tile *gfxLaserbeamUDTop[4];
-extern	Tile *gfxLaserbeamUDBottom[4];
-extern	Tile *gfxLaserbeamLR[4];
-extern	Tile *gfxLaserbeamLRLeft[4];
-extern	Tile *gfxLaserbeamLRRight[4];
-
 class AI {
 public:
 	AI();
diff --git a/engines/hdb/gfx.h b/engines/hdb/gfx.h
index 83af1e4..dbd3786 100644
--- a/engines/hdb/gfx.h
+++ b/engines/hdb/gfx.h
@@ -148,6 +148,29 @@ public:
 	void setCursor(int x, int y);
 	void getCursor(int *x, int *y);
 
+	// Some Gfx
+
+	Picture *_icepSnowballGfxDown;		// ICEPUFF's snowball moving down
+	Picture *_icepSnowballGfxLeft;		// ICEPUFF's snowball moving left
+	Picture *_icepSnowballGfxRight;		// ICEPUFF's snowball moving right
+
+	Tile *_tileFroglickMiddleUD;
+	Tile *_tileFroglickWiggleUD[3];
+	Tile *_tileFroglickMiddleLR;
+	Tile *_tileFroglickWiggleLeft[3];
+	Tile *_tileFroglickWiggleRight[3];
+
+	Picture *_gfxDragonAsleep;
+	Picture *_gfxDragonFlap[2];
+	Picture *_gfxDragonBreathe[3];
+
+	Tile *_gfxLaserbeamUD[4];
+	Tile *_gfxLaserbeamUDTop[4];
+	Tile *_gfxLaserbeamUDBottom[4];
+	Tile *_gfxLaserbeamLR[4];
+	Tile *_gfxLaserbeamLRLeft[4];
+	Tile *_gfxLaserbeamLRRight[4];
+
 private:
 	int _numTiles;
 	TileLookup *_tLookupArray;


Commit: 5ed21d12df2c548d4cc7e214715a3c7c307c528a
    https://github.com/scummvm/scummvm/commit/5ed21d12df2c548d4cc7e214715a3c7c307c528a
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:11+02:00

Commit Message:
HDB: Move Bots gfx into _ai class

Changed paths:
    engines/hdb/ai-bots.cpp
    engines/hdb/ai-init.cpp
    engines/hdb/ai.h
    engines/hdb/gfx.h


diff --git a/engines/hdb/ai-bots.cpp b/engines/hdb/ai-bots.cpp
index 7836bbf..aa80e85 100644
--- a/engines/hdb/ai-bots.cpp
+++ b/engines/hdb/ai-bots.cpp
@@ -1290,16 +1290,16 @@ void aiDiverterDraw(AIEntity *e, int mx, int my) {
 	case DIR_UP:
 		if (e->tileY == e->value1 && e->int2) {	// going down or right?
 			for (i = e->value1 + 1; i < e->value2; i++)
-				onScreen += g_hdb->_gfx->_gfxLaserbeamUD[frame]->drawMasked(e->x - mx, i * kTileHeight - my);
-			onScreen += g_hdb->_gfx->_gfxLaserbeamUDTop[frame]->drawMasked(e->x - mx, i * kTileHeight - my);
+				onScreen += g_hdb->_ai->_gfxLaserbeamUD[frame]->drawMasked(e->x - mx, i * kTileHeight - my);
+			onScreen += g_hdb->_ai->_gfxLaserbeamUDTop[frame]->drawMasked(e->x - mx, i * kTileHeight - my);
 			if (onScreen) {
 				g_hdb->_sound->playSoundEx(SND_LASER_LOOP, kLaserChannel, true);
 				warning("STUB: Set Laser onScreen to true");
 			}
 		} else {
 			for (i = e->value1 + 1; i < e->value2; i++)
-				onScreen += g_hdb->_gfx->_gfxLaserbeamLR[frame]->drawMasked(i * kTileWidth - mx, e->y - my);
-			onScreen += g_hdb->_gfx->_gfxLaserbeamLRLeft[frame]->drawMasked(i * kTileWidth - mx, e->y - my);
+				onScreen += g_hdb->_ai->_gfxLaserbeamLR[frame]->drawMasked(i * kTileWidth - mx, e->y - my);
+			onScreen += g_hdb->_ai->_gfxLaserbeamLRLeft[frame]->drawMasked(i * kTileWidth - mx, e->y - my);
 			if (onScreen) {
 				g_hdb->_sound->playSoundEx(SND_LASER_LOOP, kLaserChannel, true);
 				warning("STUB: Set Laser onScreen to true");
@@ -1309,16 +1309,16 @@ void aiDiverterDraw(AIEntity *e, int mx, int my) {
 	case DIR_DOWN:
 		if (e->tileY == e->value1 && e->int2) {	// going down or left?
 			for (i = e->value1 + 1; i < e->value2; i++)
-				onScreen += g_hdb->_gfx->_gfxLaserbeamUD[frame]->drawMasked(e->x - mx, i * kTileHeight - my);
-			onScreen += g_hdb->_gfx->_gfxLaserbeamUDTop[frame]->drawMasked(e->x - mx, i * kTileHeight - my);
+				onScreen += g_hdb->_ai->_gfxLaserbeamUD[frame]->drawMasked(e->x - mx, i * kTileHeight - my);
+			onScreen += g_hdb->_ai->_gfxLaserbeamUDTop[frame]->drawMasked(e->x - mx, i * kTileHeight - my);
 			if (onScreen) {
 				g_hdb->_sound->playSoundEx(SND_LASER_LOOP, kLaserChannel, true);
 				warning("STUB: Set Laser onscreen to true");
 			}
 		} else {
 			for (i = e->value1 - 1; i > e->value2; i--)
-				onScreen += g_hdb->_gfx->_gfxLaserbeamLR[frame]->drawMasked(i * kTileWidth - mx, e->y - my);
-			onScreen += g_hdb->_gfx->_gfxLaserbeamLRRight[frame]->drawMasked(i * kTileWidth - mx, e->y - my);
+				onScreen += g_hdb->_ai->_gfxLaserbeamLR[frame]->drawMasked(i * kTileWidth - mx, e->y - my);
+			onScreen += g_hdb->_ai->_gfxLaserbeamLRRight[frame]->drawMasked(i * kTileWidth - mx, e->y - my);
 			if (onScreen) {
 				g_hdb->_sound->playSoundEx(SND_LASER_LOOP, kLaserChannel, true);
 				warning("STUB: Set Laser onscreen to true");
@@ -1328,16 +1328,16 @@ void aiDiverterDraw(AIEntity *e, int mx, int my) {
 	case DIR_LEFT:
 		if (e->tileY == e->value1 && e->int2) {	// going up or left?
 			for (i = e->value1 - 1; i > e->value2; i--)
-				onScreen += g_hdb->_gfx->_gfxLaserbeamUD[frame]->drawMasked(e->x - mx, i * kTileHeight - my);
-			onScreen += g_hdb->_gfx->_gfxLaserbeamUDBottom[frame]->drawMasked(e->x - mx, i * kTileHeight - my);
+				onScreen += g_hdb->_ai->_gfxLaserbeamUD[frame]->drawMasked(e->x - mx, i * kTileHeight - my);
+			onScreen += g_hdb->_ai->_gfxLaserbeamUDBottom[frame]->drawMasked(e->x - mx, i * kTileHeight - my);
 			if (onScreen) {
 				g_hdb->_sound->playSoundEx(SND_LASER_LOOP, kLaserChannel, true);
 				warning("STUB: Set Laser onscreen to true");
 			}
 		} else {
 			for (i = e->value1 - 1; i > e->value2; i--)
-				onScreen += g_hdb->_gfx->_gfxLaserbeamLR[frame]->drawMasked(i * kTileWidth - mx, e->y - my);
-			onScreen += g_hdb->_gfx->_gfxLaserbeamLRRight[frame]->drawMasked(i * kTileWidth - mx, e->y - my);
+				onScreen += g_hdb->_ai->_gfxLaserbeamLR[frame]->drawMasked(i * kTileWidth - mx, e->y - my);
+			onScreen += g_hdb->_ai->_gfxLaserbeamLRRight[frame]->drawMasked(i * kTileWidth - mx, e->y - my);
 			if (onScreen) {
 				g_hdb->_sound->playSoundEx(SND_LASER_LOOP, kLaserChannel, true);
 				warning("STUB: Set Laser onscreen to true");
@@ -1347,16 +1347,16 @@ void aiDiverterDraw(AIEntity *e, int mx, int my) {
 	case DIR_RIGHT:
 		if (e->tileY == e->value1 && e->int2) {	// going up or right?
 			for (i = e->value1 - 1; i > e->value2; i--)
-				onScreen += g_hdb->_gfx->_gfxLaserbeamUD[frame]->drawMasked(e->x - mx, i * kTileHeight - my);
-			onScreen += g_hdb->_gfx->_gfxLaserbeamUDBottom[frame]->drawMasked(e->x - mx, i * kTileHeight - my);
+				onScreen += g_hdb->_ai->_gfxLaserbeamUD[frame]->drawMasked(e->x - mx, i * kTileHeight - my);
+			onScreen += g_hdb->_ai->_gfxLaserbeamUDBottom[frame]->drawMasked(e->x - mx, i * kTileHeight - my);
 			if (onScreen) {
 				g_hdb->_sound->playSoundEx(SND_LASER_LOOP, kLaserChannel, true);
 				warning("STUB: Set Laser onscreen to true");
 			}
 		} else {
 			for (i = e->value1 + 1; i < e->value2; i++)
-				onScreen += g_hdb->_gfx->_gfxLaserbeamLR[frame]->drawMasked(i * kTileWidth - mx, e->y - my);
-			onScreen += g_hdb->_gfx->_gfxLaserbeamLRLeft[frame]->drawMasked(i * kTileWidth - mx, e->y - my);
+				onScreen += g_hdb->_ai->_gfxLaserbeamLR[frame]->drawMasked(i * kTileWidth - mx, e->y - my);
+			onScreen += g_hdb->_ai->_gfxLaserbeamLRLeft[frame]->drawMasked(i * kTileWidth - mx, e->y - my);
 			if (onScreen) {
 				g_hdb->_sound->playSoundEx(SND_LASER_LOOP, kLaserChannel, true);
 				warning("STUB: Set Laser onscreen to true");
diff --git a/engines/hdb/ai-init.cpp b/engines/hdb/ai-init.cpp
index 29b5ec1..c19037f 100644
--- a/engines/hdb/ai-init.cpp
+++ b/engines/hdb/ai-init.cpp
@@ -773,19 +773,18 @@ bool AI::init() {
 	_kcHolderBlackOn	= g_hdb->_gfx->getTileIndex("t32_kcholder_black_on");
 
 	// icepuff snowball
-	g_hdb->_gfx->_icepSnowballGfxDown = g_hdb->_gfx->_icepSnowballGfxLeft = 
-		g_hdb->_gfx->_icepSnowballGfxRight = NULL;
+	_icepSnowballGfxDown = _icepSnowballGfxLeft = 
+		_icepSnowballGfxRight = NULL;
 
 	// Frogglick
-	g_hdb->_gfx->_tileFroglickMiddleUD = g_hdb->_gfx->_tileFroglickMiddleLR = NULL;
-	g_hdb->_gfx->_tileFroglickWiggleLeft[0] = g_hdb->_gfx->_tileFroglickWiggleRight[0] = NULL;
+	_tileFroglickMiddleUD = _tileFroglickMiddleLR = NULL;
+	_tileFroglickWiggleLeft[0] = _tileFroglickWiggleRight[0] = NULL;
 
 	// Dragon
-	g_hdb->_gfx->_gfxDragonAsleep = NULL;
+	_gfxDragonAsleep = NULL;
 
 	// laser beam
-	g_hdb->_gfx->_gfxLaserbeamUD[0] = g_hdb->_gfx->_gfxLaserbeamUD[1] = 
-		g_hdb->_gfx->_gfxLaserbeamLR[0] = g_hdb->_gfx->_gfxLaserbeamLR[1] = NULL;
+	_gfxLaserbeamUD[0] = _gfxLaserbeamUD[1] = _gfxLaserbeamLR[0] = _gfxLaserbeamLR[1] = NULL;
 
 	_dummyPlayer.type = AI_GUY;
 	_dummyLaser.type = AI_LASERBEAM;
@@ -850,77 +849,77 @@ void AI::restartSystem() {
 	memset(_clubRightGfx, NULL, kMaxAnimFrames * sizeof(Tile *));
 
 	int i;
-	if (g_hdb->_gfx->_icepSnowballGfxDown) {
-		g_hdb->_gfx->_icepSnowballGfxDown->free();
-		g_hdb->_gfx->_icepSnowballGfxDown = NULL;
+	if (_icepSnowballGfxDown) {
+		_icepSnowballGfxDown->free();
+		_icepSnowballGfxDown = NULL;
 	}
-	if (g_hdb->_gfx->_icepSnowballGfxLeft) {
-		g_hdb->_gfx->_icepSnowballGfxLeft->free();
-		g_hdb->_gfx->_icepSnowballGfxLeft = NULL;
+	if (_icepSnowballGfxLeft) {
+		_icepSnowballGfxLeft->free();
+		_icepSnowballGfxLeft = NULL;
 	}
-	if (g_hdb->_gfx->_icepSnowballGfxRight) {
-		g_hdb->_gfx->_icepSnowballGfxRight->free();
-		g_hdb->_gfx->_icepSnowballGfxRight = NULL;
+	if (_icepSnowballGfxRight) {
+		_icepSnowballGfxRight->free();
+		_icepSnowballGfxRight = NULL;
 	}
 
-	if (g_hdb->_gfx->_tileFroglickMiddleUD) {
-		g_hdb->_gfx->_tileFroglickMiddleUD->free();
-		g_hdb->_gfx->_tileFroglickMiddleUD = NULL;
+	if (_tileFroglickMiddleUD) {
+		_tileFroglickMiddleUD->free();
+		_tileFroglickMiddleUD = NULL;
 	}
-	if (g_hdb->_gfx->_tileFroglickWiggleUD[0]) {
+	if (_tileFroglickWiggleUD[0]) {
 		for (i = 0; i < 3; i++) {
-			g_hdb->_gfx->_tileFroglickWiggleUD[i]->free();
-			g_hdb->_gfx->_tileFroglickWiggleUD[i] = NULL;
+			_tileFroglickWiggleUD[i]->free();
+			_tileFroglickWiggleUD[i] = NULL;
 		}
 	}
 
-	if (g_hdb->_gfx->_tileFroglickMiddleLR) {
-		g_hdb->_gfx->_tileFroglickMiddleLR->free();
-		g_hdb->_gfx->_tileFroglickMiddleLR = NULL;
+	if (_tileFroglickMiddleLR) {
+		_tileFroglickMiddleLR->free();
+		_tileFroglickMiddleLR = NULL;
 	}
-	if (g_hdb->_gfx->_tileFroglickWiggleLeft[0]) {
+	if (_tileFroglickWiggleLeft[0]) {
 		for (i = 0; i < 3; i++) {
-			g_hdb->_gfx->_tileFroglickWiggleLeft[i]->free();
-			g_hdb->_gfx->_tileFroglickWiggleLeft[i] = NULL;
+			_tileFroglickWiggleLeft[i]->free();
+			_tileFroglickWiggleLeft[i] = NULL;
 		}
 	}
-	if (g_hdb->_gfx->_tileFroglickWiggleRight[0]) {
+	if (_tileFroglickWiggleRight[0]) {
 		for (i = 0; i < 3; i++) {
-			g_hdb->_gfx->_tileFroglickWiggleRight[i]->free();
-			g_hdb->_gfx->_tileFroglickWiggleRight[i] = NULL;
+			_tileFroglickWiggleRight[i]->free();
+			_tileFroglickWiggleRight[i] = NULL;
 		}
 	}
 
 	// dragon!  see ya!
-	if (g_hdb->_gfx->_gfxDragonAsleep) {
-		g_hdb->_gfx->_gfxDragonAsleep->free();
-		g_hdb->_gfx->_gfxDragonAsleep = NULL;
-		g_hdb->_gfx->_gfxDragonFlap[0]->free();
-		g_hdb->_gfx->_gfxDragonFlap[1]->free();
-		g_hdb->_gfx->_gfxDragonFlap[0] = g_hdb->_gfx->_gfxDragonFlap[1] = NULL;
-		g_hdb->_gfx->_gfxDragonBreathe[0]->free();
-		g_hdb->_gfx->_gfxDragonBreathe[1]->free();
-		g_hdb->_gfx->_gfxDragonBreathe[2]->free();
-		g_hdb->_gfx->_gfxDragonBreathe[0] = g_hdb->_gfx->_gfxDragonBreathe[1] = 
-			g_hdb->_gfx->_gfxDragonBreathe[2] = NULL;
+	if (_gfxDragonAsleep) {
+		_gfxDragonAsleep->free();
+		_gfxDragonAsleep = NULL;
+		_gfxDragonFlap[0]->free();
+		_gfxDragonFlap[1]->free();
+		_gfxDragonFlap[0] = _gfxDragonFlap[1] = NULL;
+		_gfxDragonBreathe[0]->free();
+		_gfxDragonBreathe[1]->free();
+		_gfxDragonBreathe[2]->free();
+		_gfxDragonBreathe[0] = _gfxDragonBreathe[1] = 
+			_gfxDragonBreathe[2] = NULL;
 	}
 
 	// laser beams
-	if (g_hdb->_gfx->_gfxLaserbeamUD[0]) {
+	if (_gfxLaserbeamUD[0]) {
 		for (i = 0; i < 4; i++) {
-			g_hdb->_gfx->_gfxLaserbeamUD[i]->free();
-			g_hdb->_gfx->_gfxLaserbeamUDTop[i]->free();
-			g_hdb->_gfx->_gfxLaserbeamUDBottom[i]->free();
-			g_hdb->_gfx->_gfxLaserbeamLR[i]->free();
-			g_hdb->_gfx->_gfxLaserbeamLRLeft[i]->free();
-			g_hdb->_gfx->_gfxLaserbeamLRRight[i]->free();
-
-			g_hdb->_gfx->_gfxLaserbeamUD[i] = NULL;
-			g_hdb->_gfx->_gfxLaserbeamUDTop[i] = NULL;
-			g_hdb->_gfx->_gfxLaserbeamUDBottom[i] = NULL;
-			g_hdb->_gfx->_gfxLaserbeamLR[i] = NULL;
-			g_hdb->_gfx->_gfxLaserbeamLRLeft[i] = NULL;
-			g_hdb->_gfx->_gfxLaserbeamLRRight[i] = NULL;
+			_gfxLaserbeamUD[i]->free();
+			_gfxLaserbeamUDTop[i]->free();
+			_gfxLaserbeamUDBottom[i]->free();
+			_gfxLaserbeamLR[i]->free();
+			_gfxLaserbeamLRLeft[i]->free();
+			_gfxLaserbeamLRRight[i]->free();
+
+			_gfxLaserbeamUD[i] = NULL;
+			_gfxLaserbeamUDTop[i] = NULL;
+			_gfxLaserbeamUDBottom[i] = NULL;
+			_gfxLaserbeamLR[i] = NULL;
+			_gfxLaserbeamLRLeft[i] = NULL;
+			_gfxLaserbeamLRRight[i] = NULL;
 		}
 	}
 
diff --git a/engines/hdb/ai.h b/engines/hdb/ai.h
index 3850180..f37bb81 100644
--- a/engines/hdb/ai.h
+++ b/engines/hdb/ai.h
@@ -1229,6 +1229,29 @@ public:
 	int _stunAnim;
 	uint32 _stunTimer;
 
+	// Bots Gfx
+
+	Picture *_icepSnowballGfxDown;		// ICEPUFF's snowball moving down
+	Picture *_icepSnowballGfxLeft;		// ICEPUFF's snowball moving left
+	Picture *_icepSnowballGfxRight;		// ICEPUFF's snowball moving right
+
+	Tile *_tileFroglickMiddleUD;
+	Tile *_tileFroglickWiggleUD[3];
+	Tile *_tileFroglickMiddleLR;
+	Tile *_tileFroglickWiggleLeft[3];
+	Tile *_tileFroglickWiggleRight[3];
+
+	Picture *_gfxDragonAsleep;
+	Picture *_gfxDragonFlap[2];
+	Picture *_gfxDragonBreathe[3];
+
+	Tile *_gfxLaserbeamUD[4];
+	Tile *_gfxLaserbeamUDTop[4];
+	Tile *_gfxLaserbeamUDBottom[4];
+	Tile *_gfxLaserbeamLR[4];
+	Tile *_gfxLaserbeamLRLeft[4];
+	Tile *_gfxLaserbeamLRRight[4];
+
 private:
 
 	// Action Functions
diff --git a/engines/hdb/gfx.h b/engines/hdb/gfx.h
index dbd3786..83af1e4 100644
--- a/engines/hdb/gfx.h
+++ b/engines/hdb/gfx.h
@@ -148,29 +148,6 @@ public:
 	void setCursor(int x, int y);
 	void getCursor(int *x, int *y);
 
-	// Some Gfx
-
-	Picture *_icepSnowballGfxDown;		// ICEPUFF's snowball moving down
-	Picture *_icepSnowballGfxLeft;		// ICEPUFF's snowball moving left
-	Picture *_icepSnowballGfxRight;		// ICEPUFF's snowball moving right
-
-	Tile *_tileFroglickMiddleUD;
-	Tile *_tileFroglickWiggleUD[3];
-	Tile *_tileFroglickMiddleLR;
-	Tile *_tileFroglickWiggleLeft[3];
-	Tile *_tileFroglickWiggleRight[3];
-
-	Picture *_gfxDragonAsleep;
-	Picture *_gfxDragonFlap[2];
-	Picture *_gfxDragonBreathe[3];
-
-	Tile *_gfxLaserbeamUD[4];
-	Tile *_gfxLaserbeamUDTop[4];
-	Tile *_gfxLaserbeamUDBottom[4];
-	Tile *_gfxLaserbeamLR[4];
-	Tile *_gfxLaserbeamLRLeft[4];
-	Tile *_gfxLaserbeamLRRight[4];
-
 private:
 	int _numTiles;
 	TileLookup *_tLookupArray;


Commit: 97d702f8917e4ae20114237f19653d3894f31708
    https://github.com/scummvm/scummvm/commit/97d702f8917e4ae20114237f19653d3894f31708
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:11+02:00

Commit Message:
HDB: Add Gate Puddles

Changed paths:
    engines/hdb/ai-init.cpp
    engines/hdb/ai.h


diff --git a/engines/hdb/ai-init.cpp b/engines/hdb/ai-init.cpp
index c19037f..e203ed5 100644
--- a/engines/hdb/ai-init.cpp
+++ b/engines/hdb/ai-init.cpp
@@ -968,6 +968,9 @@ void AI::restartSystem() {
 	// Clear Bridges
 	memset(&_bridges[0], 0, sizeof(_bridges));
 	_numBridges = 0;
+
+	// No Gate Puddles
+	_gatePuddles = 0;
 }
 
 void AI::initAnimInfo() {
diff --git a/engines/hdb/ai.h b/engines/hdb/ai.h
index f37bb81..5930638 100644
--- a/engines/hdb/ai.h
+++ b/engines/hdb/ai.h
@@ -41,6 +41,7 @@ enum {
 	kMaxLuaEnts = 50,
 	kMaxCallbacks = 20,
 	kMaxFairystones = 5,
+	kMaxGatePuddles = 8,
 	kMaxBridges = 10,
 	kDelay5Seconds = 5 * kGameFPS,
 	kPlayerMoveSpeed = 4,
@@ -1032,6 +1033,15 @@ public:
 	}
 	bool completeDelivery(const char *id);
 
+	// Gate Puddles
+	int _gatePuddles;
+	void addGatePuddle(int amount) {
+		_gatePuddles += amount;
+	}
+	int getGatePuddles() {
+		return _gatePuddles;
+	}
+
 	// Player Variables
 	bool _playerDead;
 	bool _playerInvisible;	// While on RailRider for example


Commit: c3f409d0c959472d6c158ee17c91ce1e77945dba
    https://github.com/scummvm/scummvm/commit/c3f409d0c959472d6c158ee17c91ce1e77945dba
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:12+02:00

Commit Message:
HDB: Add BadFairy functions

Changed paths:
    engines/hdb/ai-bots.cpp


diff --git a/engines/hdb/ai-bots.cpp b/engines/hdb/ai-bots.cpp
index aa80e85..780cb12 100644
--- a/engines/hdb/ai-bots.cpp
+++ b/engines/hdb/ai-bots.cpp
@@ -1753,8 +1753,131 @@ void aiGoodFairyAction(AIEntity *e) {
 		e->sequence = 20;
 }
 
+void aiBadFairyInit(AIEntity *e) {
+	e->aiAction = aiBadFairyAction;
+	e->sequence = 20;
+	e->blinkFrames = e->goalX = 0;
+}
+
+void aiBadFairyInit2(AIEntity *e) {
+	e->draw = g_hdb->_ai->getStandFrameDir(e);
+}
+
 void aiBadFairyAction(AIEntity *e) {
-	warning("STUB: AI: aiBadFairyAction required");
+	AIState	state[5] = {STATE_NONE, STATE_MOVEUP, STATE_MOVEDOWN, STATE_MOVELEFT, STATE_MOVERIGHT};
+	int	xvAhead[5] = {9, 0, 0,-1, 1}, yvAhead[5] = {9,-1, 1, 0, 0};
+	int xv, yv;
+	int	result;
+	AIEntity *hit;
+
+	if (e->sequence) {
+		e->sequence--;
+
+		// look around...
+		switch (e->sequence) {
+		case 19:
+			e->state = STATE_MOVEDOWN;
+			break;
+		case 0:
+			{
+				// Create a GATE PUDDLE?
+				if (e->onScreen && (g_hdb->_rnd->getRandomNumber(100) > 90) && g_hdb->getActionMode() && (g_hdb->_ai->getGatePuddles() < kMaxGatePuddles)) {
+					AIDir opposite[] = {DIR_NONE, DIR_DOWN, DIR_UP, DIR_RIGHT, DIR_LEFT};
+
+					if (e->onScreen)
+						g_hdb->_sound->playSound(SND_BADFAIRY_SPELL);
+
+					e->sequence = 30;
+					e->state = STATE_MOVEUP;
+					g_hdb->_ai->spawn(AI_GATEPUDDLE, opposite[e->dir], e->tileX, e->tileY, NULL, NULL, NULL, DIR_NONE, e->level, 0, 0, 1);
+					g_hdb->_ai->addAnimateTarget(e->x, e->y, 0, 7, ANIM_NORMAL, false, false, TELEPORT_FLASH);
+					g_hdb->_ai->addGatePuddle(1);
+					if (e->onScreen)
+						g_hdb->_sound->playSound(SND_GATEPUDDLE_SPAWN);
+					return;
+				}
+
+				int	tries = 4;
+				do {
+					// pick a random direction, then a random # of tiles in that direction
+					int	rnd = g_hdb->_rnd->getRandomNumber(4) + 1;
+					AIDir d = (AIDir)rnd;
+					int	walk = g_hdb->_rnd->getRandomNumber(5) + 1;
+					AIEntity *p = g_hdb->_ai->getPlayer();
+
+					e->dir = d;
+					e->state = state[d];
+					xv = xvAhead[d] * walk;
+					if (e->tileX + xv < 1)
+						xv = -e->tileX + 1;
+					if (e->tileX + xv > g_hdb->_map->_width)
+						xv = g_hdb->_map->_width - e->tileX - 1;
+
+					yv = yvAhead[d] * walk;
+					if (e->tileY + yv < 1)
+						yv = -e->tileY + 1;
+					if (e->tileY + yv > g_hdb->_map->_height)
+						yv = g_hdb->_map->_height - e->tileY - 1;
+
+					e->value1 = xvAhead[d];
+					e->value2 = yvAhead[d];
+					e->moveSpeed = kPlayerMoveSpeed;
+					if (!g_hdb->getActionMode())
+						e->moveSpeed >>= 1;
+
+					hit = g_hdb->_ai->legalMoveOverWater(e->tileX + e->value1, e->tileY + e->value2, e->level, &result);
+					uint32 bg_flags = g_hdb->_map->getMapBGTileFlags(e->tileX + e->value1, e->tileY + e->value2);
+					if (hit == p && !g_hdb->_ai->playerDead()) {
+						g_hdb->_ai->killPlayer(DEATH_FRIED);
+						hit = NULL;
+					}
+
+					if (!hit && result && !(bg_flags & kFlagSpecial)) {
+						g_hdb->_ai->setEntityGoal(e, e->tileX + xv, e->tileY + yv);
+						g_hdb->_ai->animateEntity(e);
+						if (e->onScreen && !g_hdb->_rnd->getRandomNumber(20))
+							g_hdb->_sound->playSound(SND_BADFAIRY_AMBIENT);
+						return;
+					}
+					tries--;		// don't lock the system if the player gets the fairy cornered
+				} while (!result && tries);
+
+				// couldn't find a place to move so just sit here for a sec & try again
+				e->dir = DIR_NONE;
+				e->state = STATE_MOVEDOWN;
+				e->sequence = 1;
+				e->value1 = e->value2 = e->xVel = e->yVel = 0;
+			}
+		}
+		g_hdb->_ai->animEntFrames(e);
+		return;
+	}
+
+	// in the process of moving around...
+	if (e->goalX) {
+		// hit the player?
+		if (hitPlayer(e->x, e->y)) {
+			g_hdb->_ai->killPlayer(DEATH_FRIED);
+			g_hdb->_sound->playSound(SND_MBOT_DEATH);
+			return;
+		}
+
+		// did we run into a wall, entity, water, slime etc?
+		// if so, pick a new direction!
+		if (onEvenTile(e->x, e->y)) {
+			hit = g_hdb->_ai->legalMoveOverWater(e->tileX + e->value1, e->tileY + e->value2, e->level, &result);
+			uint32 bg_flags = g_hdb->_map->getMapBGTileFlags(e->tileX + e->value1, e->tileY + e->value2);
+			if (!result || (hit && hit->type != AI_GUY) || (bg_flags & kFlagSpecial)) {
+				g_hdb->_ai->stopEntity(e);
+				e->state = STATE_MOVEDOWN;
+				e->sequence = 20;
+				return;
+			}
+		}
+		g_hdb->_ai->animateEntity(e);
+	} else
+		// if not, start looking around!
+		e->sequence = 20;
 }
 
 void aiGatePuddleAction(AIEntity *e) {
@@ -1809,14 +1932,6 @@ void aiFatFrogInit2(AIEntity *e) {
 	warning("STUB: AI: aiFatFrogInit2 required");
 }
 
-void aiBadFairyInit(AIEntity *e) {
-	warning("STUB: AI: aiBadFairyInit required");
-}
-
-void aiBadFairyInit2(AIEntity *e) {
-	warning("STUB: AI: aiBadFairyInit2 required");
-}
-
 void aiGatePuddleInit(AIEntity *e) {
 	warning("STUB: AI: aiGatePuddleInit required");
 }


Commit: de017b0ce96b85a1e30c7c8d49e5399712d9c3d1
    https://github.com/scummvm/scummvm/commit/de017b0ce96b85a1e30c7c8d49e5399712d9c3d1
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:12+02:00

Commit Message:
HDB: Add PanicZone data and functions

Changed paths:
    engines/hdb/gfx.cpp
    engines/hdb/gfx.h
    engines/hdb/window.cpp
    engines/hdb/window.h


diff --git a/engines/hdb/gfx.cpp b/engines/hdb/gfx.cpp
index 6c14f57..d4315a0 100644
--- a/engines/hdb/gfx.cpp
+++ b/engines/hdb/gfx.cpp
@@ -721,9 +721,9 @@ Graphics::Surface Picture::load(Common::SeekableReadStream *stream) {
 
 	uint16 *ptr;
 
-	for (uint y = 0; y < _height; y++) {
+	for (int y = 0; y < _height; y++) {
 		ptr = (uint16 *)_surface.getBasePtr(0, y);
-		for (uint x = 0; x < _width; x++) {
+		for (int x = 0; x < _width; x++) {
 			*ptr = TO_LE_16(stream->readUint16LE());
 			ptr++;
 		}
diff --git a/engines/hdb/gfx.h b/engines/hdb/gfx.h
index 83af1e4..ae7927d 100644
--- a/engines/hdb/gfx.h
+++ b/engines/hdb/gfx.h
@@ -221,7 +221,7 @@ public:
 	int drawMasked(int x, int y);
 	void free();
 
-	uint _width, _height;
+	int _width, _height;
 
 	char *getName() { return _name; }
 
diff --git a/engines/hdb/window.cpp b/engines/hdb/window.cpp
index 71e16e9..d78ea00 100644
--- a/engines/hdb/window.cpp
+++ b/engines/hdb/window.cpp
@@ -109,7 +109,7 @@ void Window::drawPause() {
 		_gfxPausePlaque->drawMasked(480 / 2 - _gfxPausePlaque->_width / 2, kPauseY);
 }
 
-void Window::checkPause(uint x, uint y) {
+void Window::checkPause(int x, int y) {
 	if (x >= 480 / 2 - _gfxPausePlaque->_width / 2 && 480 / 2 + _gfxPausePlaque->_width / 2 > x && y >= kPauseY && y < kPauseY + _gfxPausePlaque->_height) {
 		g_hdb->togglePause();
 		g_hdb->_sound->playSound(SND_POP);
@@ -882,6 +882,131 @@ void Window::checkDlvSelect(int x, int y) {
 	}
 }
 
+void Window::loadPanicZoneGfx() {
+	_pzInfo.gfxPanic = g_hdb->_gfx->loadPic(PANIC_PANIC);
+	_pzInfo.gfxZone	= g_hdb->_gfx->loadPic(PANIC_ZONE);
+	_pzInfo.gfxFace[0] = g_hdb->_gfx->loadPic(PANIC_POINTER1);
+	_pzInfo.gfxFace[1] = g_hdb->_gfx->loadPic(PANIC_POINTER2);
+	_pzInfo.gfxNumber[0] = g_hdb->_gfx->loadPic(PANIC_NUM0);
+	_pzInfo.gfxNumber[1] = g_hdb->_gfx->loadPic(PANIC_NUM1);
+	_pzInfo.gfxNumber[2] = g_hdb->_gfx->loadPic(PANIC_NUM2);
+	_pzInfo.gfxNumber[3] = g_hdb->_gfx->loadPic(PANIC_NUM3);
+	_pzInfo.gfxNumber[4] = g_hdb->_gfx->loadPic(PANIC_NUM4);
+	_pzInfo.gfxNumber[5] = g_hdb->_gfx->loadPic(PANIC_NUM5);
+	_pzInfo.gfxNumber[6] = g_hdb->_gfx->loadPic(PANIC_NUM6);
+	_pzInfo.gfxNumber[7] = g_hdb->_gfx->loadPic(PANIC_NUM7);
+	_pzInfo.gfxNumber[8] = g_hdb->_gfx->loadPic(PANIC_NUM8);
+	_pzInfo.gfxNumber[9] = g_hdb->_gfx->loadPic(PANIC_NUM9);
+}
+
+void Window::drawPanicZone() {
+	int xx, yy;
+
+	if (!_pzInfo.active)
+		return;
+
+	switch (_pzInfo.sequence) {
+		// Wait before displaying PANIC ZONE
+	case PANICZONE_TIMER:
+		_pzInfo.timer--;
+		if (!_pzInfo.timer) {
+			_pzInfo.sequence++;
+			g_hdb->_sound->playSound(SND_PANIC);
+		}
+		break;
+
+		// Move PANIC ZONE to screen center
+	case PANICZONE_START:
+		xx = g_hdb->_rnd->getRandomNumber(10) - 5;
+		yy = g_hdb->_rnd->getRandomNumber(10) - 5;
+		_pzInfo.x1 += _pzInfo.xv;
+		_pzInfo.y1++;
+		_pzInfo.x2 += _pzInfo.yv;
+		_pzInfo.y2--;
+		if (_pzInfo.x1 > kPanicXStop) {
+			_pzInfo.timer = 30;
+			_pzInfo.sequence++;
+		}
+		_pzInfo.gfxPanic->drawMasked(_pzInfo.x1 + xx, _pzInfo.y1 + yy);
+		_pzInfo.gfxZone->drawMasked(_pzInfo.x2 + yy, _pzInfo.y2 + xx);
+		break;
+
+	case PANICZONE_TITLESTOP:
+		xx = g_hdb->_rnd->getRandomNumber(10) - 5;
+		yy = g_hdb->_rnd->getRandomNumber(10) - 5;
+		_pzInfo.gfxPanic->drawMasked(_pzInfo.x1 + xx, _pzInfo.y1 + yy);
+		_pzInfo.gfxZone->drawMasked(_pzInfo.x2 + yy, _pzInfo.y2 + xx);
+		_pzInfo.timer--;
+		if (!_pzInfo.timer) {
+			_pzInfo.sequence++;
+		}
+		break;
+
+	case PANICZONE_BLASTOFF:
+		xx = g_hdb->_rnd->getRandomNumber(10) - 5;
+		yy = g_hdb->_rnd->getRandomNumber(10) - 5;
+		_pzInfo.y1 -= 10;
+		_pzInfo.y2 += 10;
+		_pzInfo.gfxPanic->drawMasked(_pzInfo.x1 + xx, _pzInfo.y1 + yy);
+		_pzInfo.gfxZone->drawMasked(_pzInfo.x2 + yy, _pzInfo.y2 + xx);
+		if (_pzInfo.y1 < -_pzInfo.gfxPanic->_height &&
+			_pzInfo.y2 > kScreenHeight) {
+			g_hdb->_sound->playSound(SND_PANIC_COUNT);
+			_pzInfo.sequence++;
+			_pzInfo.timer = 30 + g_hdb->getTime();
+		}
+		break;
+
+	case PANICZONE_COUNTDOWN:
+		{
+			static int last_seconds = 0, seconds = 0;
+			_pzInfo.gfxFace[seconds & 1]->drawMasked(kPanicZoneFaceX, kPanicZoneFaceY);
+
+			// make knocking timer sound
+			if (last_seconds != seconds)
+				g_hdb->_sound->playSound(SND_PANIC_COUNT);
+
+			last_seconds = seconds;
+			seconds = _pzInfo.timer - g_hdb->getTime();
+			if (seconds >= 10) {
+				_pzInfo.gfxNumber[seconds / 10]->drawMasked(kPanicZoneFaceX, kPanicZoneFaceY + 32);
+				_pzInfo.gfxNumber[seconds % 10]->drawMasked(kPanicZoneFaceX + 16, kPanicZoneFaceY + 32);
+			} else
+				_pzInfo.gfxNumber[seconds]->drawMasked(kPanicZoneFaceX + 8, kPanicZoneFaceY + 32);
+
+			// time until death!
+			if (!seconds) {
+				// dead
+				g_hdb->_ai->killPlayer(DEATH_PANICZONE);
+				_pzInfo.active = false;
+				return;
+			}
+		}
+	break;
+	}
+}
+
+void Window::startPanicZone() {
+	_pzInfo.active = true;
+	_pzInfo.sequence = PANICZONE_TIMER;
+
+	// load PANIC ZONE gfx if they aren't loaded
+	if (!_pzInfo.gfxPanic)
+		loadPanicZoneGfx();
+
+	_pzInfo.x1 = -(_pzInfo.gfxPanic->_width + 5);
+	_pzInfo.y1 = (kScreenHeight / 4) - (_pzInfo.gfxPanic->_height >> 1);
+	_pzInfo.x2 = 480 + (_pzInfo.gfxZone->_width >> 1);
+	_pzInfo.y2 = (kScreenHeight / 4) * 3 - (_pzInfo.gfxZone->_height >> 1);
+	_pzInfo.xv = 10;			// horizontal speed
+	_pzInfo.yv = -12;			// vertical speed
+	_pzInfo.timer = 30;			// 30 seconds to get out!
+}
+
+void Window::stopPanicZone() {
+	_pzInfo.active = false;
+}
+
 void Window::textOut(const char *text, int x, int y, int timer) {
 	TOut *t = new TOut;
 
diff --git a/engines/hdb/window.h b/engines/hdb/window.h
index 870d11d..1615dea 100644
--- a/engines/hdb/window.h
+++ b/engines/hdb/window.h
@@ -40,11 +40,24 @@ enum {
 	kDlvItemSpaceY = (kTileHeight * 2 + 16),
 	kDlvItemPerLine = 3,
 	kDlvItemTextY = (kScreenHeight - 30),
+	kPanicXStop = 480 / 3,
+	kPanicZoneFaceX = 480 - 32,
+	kPanicZoneFaceY = 5,
 	kNumCrazy = 37,
 	kTextOutCenterX = ((kScreenWidth - kTileWidth * 5) / 2),
 	kPauseY = (kScreenHeight / 2 - 64)
 };
 
+enum PZValue {
+	PANICZONE_TIMER,
+	PANICZONE_START,
+	PANICZONE_TITLESTOP,
+	PANICZONE_BLASTOFF,
+	PANICZONE_COUNTDOWN,
+
+	PANICZONE_END
+};
+
 struct DialogInfo {
 	char		title[64];				// TITLE string
 	int			tileIndex;					// this is for a character picture
@@ -126,7 +139,29 @@ struct DlvsInfo {
 	uint32 delay1, delay2, delay3;
 	bool go1, go2, go3;
 
-	DlvsInfo() : x(0), y(0), width(0), height(0), active(false), selected(0), animate(false), delay1(0), delay2(0), delay3(0), go1(false), go2(false), go3(false) {}
+	DlvsInfo() : x(0), y(0), width(0), height(0), active(false), selected(0), 
+		animate(false), delay1(0), delay2(0), delay3(0), go1(false), go2(false), go3(false) {}
+};
+
+struct PanicZone {
+	bool active;
+	int sequence;
+	int timer;
+	int x1, y1;
+	int x2, y2;
+	int xv, yv;		// for both
+	int numberTime;
+	int numberTimeMaster;
+	int numberValue;
+	Picture *gfxPanic, *gfxZone;
+	Picture *gfxFace[2];
+	Picture *gfxNumber[10];
+
+	PanicZone() : active(false), sequence(0), timer(0), x1(0), y1(0), x2(0), y2(0), xv(0), yv(0),
+		numberTime(0), numberTimeMaster(0), numberValue(0), gfxPanic(NULL), gfxZone(NULL) {
+		memset(&gfxFace, 0, sizeof(gfxFace));
+		memset(&gfxNumber, 0, sizeof(gfxNumber));
+	}
 };
 
 struct TOut {
@@ -150,7 +185,7 @@ public:
 
 	// Pause Functions
 	void drawPause();
-	void checkPause(uint x, uint y);
+	void checkPause(int x, int y);
 
 	// Dialog Functions
 
@@ -214,6 +249,15 @@ public:
 	}
 	void checkDlvSelect(int x, int y);
 
+	// Panic Zone Functions
+	void loadPanicZoneGfx();
+	void drawPanicZone();
+	void startPanicZone();
+	void stopPanicZone();
+	bool inPanicZone() {
+		return _pzInfo.active;
+	}
+
 	// TextOut functions
 	void textOut(const char *text, int x, int y, int timer);
 	void centerTextOut(const char *text, int y, int timer);
@@ -240,6 +284,8 @@ private:
 	Common::Array<TOut *> _textOutList;
 	DlvsInfo _dlvsInfo;
 
+	PanicZone _pzInfo, _tempPzInfo;
+
 	char _msgQueueStr[kMaxMsgQueue][128];
 	int _msgQueueWait[kMaxMsgQueue];
 	int _numMsgQueue;


Commit: 8d4dea4bc385bf251f2315c34aa293dcce84f8ac
    https://github.com/scummvm/scummvm/commit/8d4dea4bc385bf251f2315c34aa293dcce84f8ac
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:12+02:00

Commit Message:
HDB: Add GatePuddle functions

Changed paths:
    engines/hdb/ai-bots.cpp


diff --git a/engines/hdb/ai-bots.cpp b/engines/hdb/ai-bots.cpp
index 780cb12..b66dad0 100644
--- a/engines/hdb/ai-bots.cpp
+++ b/engines/hdb/ai-bots.cpp
@@ -1880,8 +1880,126 @@ void aiBadFairyAction(AIEntity *e) {
 		e->sequence = 20;
 }
 
+void aiGatePuddleInit(AIEntity *e) {
+	e->aiAction = aiGatePuddleAction;
+	e->value1 = 50;
+}
+
+void aiGatePuddleInit2(AIEntity *e) {
+}
+
 void aiGatePuddleAction(AIEntity *e) {
-	warning("STUB: AI: aiGatePuddleAction required");
+	int	xva[5] = {9, 0, 0,-1, 1}, yva[5] = {9,-1, 1, 0, 0};
+	AIEntity *p = g_hdb->_ai->getPlayer();
+
+	if (e->goalX) {
+		g_hdb->_ai->animateEntity(e);
+		if (hitPlayer(e->x, e->y)) {
+			int		i;
+			for (i = 0; i < kMaxTeleporters; i++) {
+				if (g_hdb->_ai->_teleporters[i].anim1 == 2) {	// PANIC ZONE?
+					p->tileX = g_hdb->_ai->_teleporters[i].x1;
+					p->tileY = g_hdb->_ai->_teleporters[i].y1;
+					p->x = p->tileX * kTileWidth;
+					p->y = p->tileY * kTileHeight;
+					p->xVel = p->yVel = 0;
+					p->goalX = p->goalY = 0;
+					p->animFrame = 0;
+					p->drawXOff = p->drawYOff = 0;
+					p->dir = g_hdb->_ai->_teleporters[i].dir1;
+					p->level = g_hdb->_ai->_teleporters[i].level1;
+					g_hdb->_ai->addAnimateTarget(p->x, p->y, 0, 7, ANIM_NORMAL, false, false, TELEPORT_FLASH);
+					g_hdb->_sound->playSound(SND_TELEPORT);
+					g_hdb->_ai->clearWaypoints();
+					g_hdb->_window->startPanicZone();
+					g_hdb->_map->centerMapXY(p->x + 16, p->y + 16);
+					switch (p->dir) {
+					case DIR_UP:
+						g_hdb->_ai->setEntityGoal(p, p->tileX, p->tileY - 1);
+						break;
+					case DIR_DOWN:
+						g_hdb->_ai->setEntityGoal(p, p->tileX, p->tileY + 1);
+						break;
+					case DIR_LEFT:
+						g_hdb->_ai->setEntityGoal(p, p->tileX - 1, p->tileY);
+						break;
+					case DIR_RIGHT:
+						g_hdb->_ai->setEntityGoal(p, p->tileX + 1, p->tileY);
+						break;
+					case DIR_NONE:
+						break;
+					}
+					g_hdb->_ai->_playerEmerging = true;
+					break;
+				} else if (g_hdb->_ai->_teleporters[i].anim2 == 2) {	// PANIC ZONE?
+					p->tileX = g_hdb->_ai->_teleporters[i].x2;
+					p->tileY = g_hdb->_ai->_teleporters[i].y2;
+					p->x = p->tileX * kTileWidth;
+					p->y = p->tileY * kTileHeight;
+					p->xVel = p->yVel = 0;
+					p->goalX = p->goalY = 0;
+					p->animFrame = 0;
+					p->drawXOff = p->drawYOff = 0;
+					p->dir = g_hdb->_ai->_teleporters[i].dir2;
+					p->level = g_hdb->_ai->_teleporters[i].level2;
+					g_hdb->_ai->addAnimateTarget(p->x, p->y, 0, 7, ANIM_NORMAL, false, false, TELEPORT_FLASH);
+					g_hdb->_sound->playSound(SND_TELEPORT);
+					g_hdb->_ai->clearWaypoints();
+					g_hdb->_window->startPanicZone();
+					g_hdb->_map->centerMapXY(p->x + 16, p->y + 16);
+					switch (p->dir) {
+					case DIR_UP:
+						g_hdb->_ai->setEntityGoal(p, p->tileX, p->tileY - 1);
+						break;
+					case DIR_DOWN:
+						g_hdb->_ai->setEntityGoal(p, p->tileX, p->tileY + 1);
+						break;
+					case DIR_LEFT:
+						g_hdb->_ai->setEntityGoal(p, p->tileX - 1, p->tileY);
+						break;
+					case DIR_RIGHT:
+						g_hdb->_ai->setEntityGoal(p, p->tileX + 1, p->tileY);
+						break;
+					}
+					g_hdb->_ai->_playerEmerging = true;
+					break;
+				}
+			}
+		}
+	} else {
+		int rnd = g_hdb->_rnd->getRandomNumber(4) + 1;
+		int move_ok = 0, nx, ny;
+
+		e->dir = (AIDir)rnd;
+		nx = e->tileX + xva[e->dir];
+		ny = e->tileY + yva[e->dir];
+		AIEntity *hit = g_hdb->_ai->legalMoveOverWater(nx, ny, e->level, &move_ok);
+		if (hit == p)
+			hit = NULL;
+
+		if (!hit && move_ok) {
+			uint32	bg_flags = g_hdb->_map->getMapBGTileFlags(nx, ny);
+			// Gate Puddles can't go over METAL!!! It's in their genes...
+			if (!(bg_flags & kFlagMetal)) {
+				if (e->onScreen)
+					g_hdb->_sound->playSound(SND_GATEPUDDLE_AMBIENT);
+
+				g_hdb->_ai->setEntityGoal(e, nx, ny);
+				e->state = STATE_MOVEDOWN;
+				g_hdb->_ai->animateEntity(e);
+			}
+		}
+
+		// can only move 50 spaces or collisions
+		e->value1--;
+		if (!e->value1) {
+			g_hdb->_ai->addGatePuddle(-1);
+			g_hdb->_ai->addAnimateTarget(e->x, e->y, 0, 7, ANIM_NORMAL, false, false, TELEPORT_FLASH);
+			if (e->onScreen)
+				g_hdb->_sound->playSound(SND_GATEPUDDLE_DISSIPATE);
+			g_hdb->_ai->removeEntity(e);
+		}
+	}
 }
 
 void aiIcePuffSnowballAction(AIEntity *e) {
@@ -1932,14 +2050,6 @@ void aiFatFrogInit2(AIEntity *e) {
 	warning("STUB: AI: aiFatFrogInit2 required");
 }
 
-void aiGatePuddleInit(AIEntity *e) {
-	warning("STUB: AI: aiGatePuddleInit required");
-}
-
-void aiGatePuddleInit2(AIEntity *e) {
-	warning("STUB: AI: aiGatePuddleInit2 required");
-}
-
 void aiIcePuffInit(AIEntity *e) {
 	warning("STUB: AI: aiIcePuffInit required");
 }


Commit: f7be3c5e28b6d6f17ac3088100f2dab74cc4ca97
    https://github.com/scummvm/scummvm/commit/f7be3c5e28b6d6f17ac3088100f2dab74cc4ca97
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:12+02:00

Commit Message:
HDB: Add missing initialization data

Changed paths:
    engines/hdb/ai-init.cpp


diff --git a/engines/hdb/ai-init.cpp b/engines/hdb/ai-init.cpp
index e203ed5..075096c 100644
--- a/engines/hdb/ai-init.cpp
+++ b/engines/hdb/ai-init.cpp
@@ -778,7 +778,7 @@ bool AI::init() {
 
 	// Frogglick
 	_tileFroglickMiddleUD = _tileFroglickMiddleLR = NULL;
-	_tileFroglickWiggleLeft[0] = _tileFroglickWiggleRight[0] = NULL;
+	_tileFroglickWiggleUD[0] = _tileFroglickWiggleLeft[0] = _tileFroglickWiggleRight[0] = NULL;
 
 	// Dragon
 	_gfxDragonAsleep = NULL;


Commit: ff7de3179a87daee71628562100bd0572a128140
    https://github.com/scummvm/scummvm/commit/ff7de3179a87daee71628562100bd0572a128140
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:12+02:00

Commit Message:
HDB: Add icePuff functions

Changed paths:
    engines/hdb/ai-bots.cpp


diff --git a/engines/hdb/ai-bots.cpp b/engines/hdb/ai-bots.cpp
index b66dad0..daee785 100644
--- a/engines/hdb/ai-bots.cpp
+++ b/engines/hdb/ai-bots.cpp
@@ -2002,16 +2002,224 @@ void aiGatePuddleAction(AIEntity *e) {
 	}
 }
 
+void aiIcePuffSnowballInit(AIEntity *e) {
+	// which direction are we throwing in? Load the graphic if we need to
+	switch (e->dir) {
+	case DIR_DOWN:
+		e->value1 = e->x + 12;
+		e->value2 = e->y + 32;
+		break;
+	case DIR_LEFT:
+		e->value1 = e->x - 4;
+		e->value2 = e->y + 16;
+		break;
+	case DIR_RIGHT:
+		e->value1 = e->x + 32;
+		e->value2 = e->y + 16;
+		break;
+	default:
+		break;
+	}
+	e->aiDraw = aiIcePuffSnowballDraw;
+}
+
 void aiIcePuffSnowballAction(AIEntity *e) {
-	warning("STUB: AI: aiIcePuffSnowballAction required");
+	int	result, speed;
+	AIEntity *hit = NULL;
+
+	// check for hit BEFORE moving so snowball is closer to object
+	// NOTE: Need to do logic in this draw routine just in case the ICEPUFF gets stunned!
+	hit = g_hdb->_ai->legalMoveOverWater(e->value1 / kTileWidth, e->value2 / kTileHeight, e->level, &result);
+	if (hit && hit->type == AI_GUY && !g_hdb->_ai->playerDead()) {
+		g_hdb->_ai->killPlayer(DEATH_NORMAL);
+		g_hdb->_ai->addAnimateTarget(hit->x, hit->y, 0, 3, ANIM_NORMAL, false, false, GROUP_WATER_SPLASH_SIT);
+		result = 0; // fall thru...
+	}
+
+	// hit something solid - kill the snowball
+	if (!result) {
+		e->dir2 = DIR_NONE;
+		e->aiDraw = NULL;
+		return;
+	}
+
+	speed = kPlayerMoveSpeed;
+	if (!g_hdb->getActionMode())
+		speed >>= 1;
+
+	switch (e->dir2) {
+	case DIR_DOWN:  e->value2 += speed; break;
+	case DIR_LEFT:  e->value1 -= speed; break;
+	case DIR_RIGHT: e->value1 += speed; break;
+	default: break;
+	}
 }
 
 void aiIcePuffSnowballDraw(AIEntity *e, int mx, int my) {
-	warning("STUB: AI: aiIcePuffSnowballDraw required");
+	// did we throw a snowball?  make it move!
+	if (e->dir2 != DIR_NONE)
+		aiIcePuffSnowballAction(e);
+
+	switch (e->dir2) {
+	case DIR_DOWN:
+		if (!g_hdb->_ai->_icepSnowballGfxDown)
+			g_hdb->_ai->_icepSnowballGfxDown = g_hdb->_gfx->loadPic(ICEPUFF_SNOWBALL_DOWN);
+		g_hdb->_ai->_icepSnowballGfxDown->drawMasked(e->value1 - mx, e->value2 - my);
+		break;
+	case DIR_LEFT:
+		if (!g_hdb->_ai->_icepSnowballGfxLeft)
+			g_hdb->_ai->_icepSnowballGfxLeft = g_hdb->_gfx->loadPic(ICEPUFF_SNOWBALL_LEFT);
+		g_hdb->_ai->_icepSnowballGfxLeft->drawMasked(e->value1 - mx, e->value2 - my);
+		break;
+	case DIR_RIGHT:
+		if (!g_hdb->_ai->_icepSnowballGfxRight)
+			g_hdb->_ai->_icepSnowballGfxRight = g_hdb->_gfx->loadPic(ICEPUFF_SNOWBALL_RIGHT);
+		g_hdb->_ai->_icepSnowballGfxRight->drawMasked(e->value1 - mx, e->value2 - my);
+		break;
+	default:
+		break;
+	}
+}
+
+void aiIcePuffInit(AIEntity *e) {
+	// PEEK - but no head up yet
+	e->sequence = 30;				// timed sequence for peeking
+	e->state = STATE_ICEP_PEEK;			// start in PEEK mode
+	e->dir2 = DIR_NONE;					// no snowball out
+	e->aiAction = aiIcePuffAction;
+}
+
+void aiIcePuffInit2(AIEntity *e) {
+	e->draw = e->blinkGfx[3];	// empty frame
 }
 
 void aiIcePuffAction(AIEntity *e) {
-	warning("STUB: AI: aiIcePuffAction required");
+	AIEntity *p = g_hdb->_ai->getPlayer();
+
+	switch (e->state) {
+	case STATE_ICEP_PEEK:
+		e->sequence--;
+		switch (e->sequence) {
+		case 20: e->draw = e->blinkGfx[0]; break;	// underground
+		case 16: e->draw = e->blinkGfx[1]; break;	// peek - looking
+		case 12: e->draw = e->blinkGfx[2]; break;	// peek - blinking
+		case  8: e->draw = e->blinkGfx[1]; break;	// peek - looking
+		case  4: e->draw = e->blinkGfx[0]; break;	// peek - looking
+		case  3: 
+			if (e->onScreen && !g_hdb->_rnd->getRandomNumber(6)) 
+				g_hdb->_sound->playSound(SND_ICEPUFF_WARNING); 
+			break;
+		case  0: e->draw = e->blinkGfx[3];			// underground
+			e->sequence = 30;
+			break;
+		}
+
+		// can we see the player? (and no snowball is out)
+		if (e->sequence <= 20 && !g_hdb->_ai->playerDead() && e->onScreen) {
+			if (p->tileX == e->tileX && p->tileY > e->tileY && e->dir2 == DIR_NONE) {
+				e->dir = DIR_DOWN;
+				e->state = STATE_ICEP_APPEAR;
+				e->animFrame = 0;
+				if (e->onScreen)
+					g_hdb->_sound->playSound(SND_ICEPUFF_APPEAR);
+			} else if (p->tileY == e->tileY && e->dir2 == DIR_NONE) {
+				p->tileX < e->tileX ? e->dir = DIR_LEFT : e->dir = DIR_RIGHT;
+				e->state = STATE_ICEP_APPEAR;
+				e->animFrame = 0;
+				if (e->onScreen)
+					g_hdb->_sound->playSound(SND_ICEPUFF_APPEAR);
+			}
+		}
+		break;
+
+	case STATE_ICEP_APPEAR:
+		e->draw = e->standupGfx[e->animFrame];
+
+		// cycle animation frames
+		if (e->animDelay-- > 0)
+			return;
+		e->animDelay = e->animCycle;
+
+		e->animFrame++;
+		if (e->animFrame == e->standupFrames) {
+			e->animFrame = 0;
+			switch (e->dir) {
+			case DIR_DOWN: e->state = STATE_ICEP_THROWDOWN; g_hdb->_sound->playSound(SND_ICEPUFF_THROW); break;
+			case DIR_LEFT: e->state = STATE_ICEP_THROWLEFT;g_hdb->_sound->playSound(SND_ICEPUFF_THROW);  break;
+			case DIR_RIGHT: e->state = STATE_ICEP_THROWRIGHT; g_hdb->_sound->playSound(SND_ICEPUFF_THROW); break;
+			default: break;
+			}
+		}
+		break;
+
+	case STATE_ICEP_THROWDOWN:
+		e->draw = e->standdownGfx[e->animFrame];
+
+		// cycle animation frames
+		if (e->animDelay-- > 0)
+			return;
+		e->animDelay = e->animCycle;
+
+		e->animFrame++;
+		if (e->animFrame == e->standdownFrames && e->state != STATE_ICEP_DISAPPEAR) {
+			e->dir2 = e->dir;				// dir2 = direction snowball is moving
+			aiIcePuffSnowballInit(e);	// throw it!
+			e->animFrame = 0;
+			e->state = STATE_ICEP_DISAPPEAR;
+		} else if (e->animFrame == e->special1Frames) {
+			e->state = STATE_ICEP_PEEK;
+			e->draw = e->blinkGfx[3];
+			e->sequence = g_hdb->_rnd->getRandomNumber(100) + 30;
+		}
+		break;
+
+	case STATE_ICEP_THROWLEFT:
+		e->draw = e->standleftGfx[e->animFrame];
+
+		// cycle animation frames
+		if (e->animDelay-- > 0)
+			return;
+		e->animDelay = e->animCycle;
+
+		e->animFrame++;
+		if (e->animFrame == e->standdownFrames && e->state != STATE_ICEP_DISAPPEAR) {
+			e->dir2 = e->dir;				// dir2 = direction snowball is moving
+			aiIcePuffSnowballInit(e);	// throw it!
+			e->animFrame = 0;
+			e->state = STATE_ICEP_DISAPPEAR;
+		} else if (e->animFrame == e->special1Frames) {
+			e->state = STATE_ICEP_PEEK;
+			e->draw = e->blinkGfx[3];
+			e->sequence = g_hdb->_rnd->getRandomNumber(100) + 30;
+		}
+		break;
+
+	case STATE_ICEP_THROWRIGHT:
+		e->draw = e->standrightGfx[e->animFrame];
+
+		// cycle animation frames
+		if (e->animDelay-- > 0)
+			return;
+		e->animDelay = e->animCycle;
+
+		e->animFrame++;
+		if (e->animFrame == e->standdownFrames && e->state != STATE_ICEP_DISAPPEAR) {
+			e->dir2 = e->dir;				// dir2 = direction snowball is moving
+			aiIcePuffSnowballInit(e);	// throw it!
+			e->animFrame = 0;
+			e->state = STATE_ICEP_DISAPPEAR;
+		} else if (e->animFrame == e->special1Frames) {
+			e->state = STATE_ICEP_PEEK;
+			e->draw = e->blinkGfx[3];
+			e->sequence = g_hdb->_rnd->getRandomNumber(100) + 30;
+		}
+		break;
+
+	case STATE_ICEP_DISAPPEAR:
+		e->draw = e->special1Gfx[e->animFrame];
+	default:
+		break;
+	}
 }
 
 void aiBuzzflyAction(AIEntity *e) {
@@ -2050,14 +2258,6 @@ void aiFatFrogInit2(AIEntity *e) {
 	warning("STUB: AI: aiFatFrogInit2 required");
 }
 
-void aiIcePuffInit(AIEntity *e) {
-	warning("STUB: AI: aiIcePuffInit required");
-}
-
-void aiIcePuffInit2(AIEntity *e) {
-	warning("STUB: AI: aiIcePuffInit2 required");
-}
-
 void aiBuzzflyInit(AIEntity *e) {
 	warning("STUB: AI: aiBuzzflyInit required");
 }


Commit: b8a2ed94c66bff79419326c78d2b89c2d474fa46
    https://github.com/scummvm/scummvm/commit/b8a2ed94c66bff79419326c78d2b89c2d474fa46
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:12+02:00

Commit Message:
HDB: Add BuzzFly code

Changed paths:
    engines/hdb/ai-bots.cpp


diff --git a/engines/hdb/ai-bots.cpp b/engines/hdb/ai-bots.cpp
index daee785..a64e230 100644
--- a/engines/hdb/ai-bots.cpp
+++ b/engines/hdb/ai-bots.cpp
@@ -2222,8 +2222,65 @@ void aiIcePuffAction(AIEntity *e) {
 	}
 }
 
+void aiBuzzflyInit(AIEntity *e) {
+	e->aiAction = aiBuzzflyAction;
+	e->sequence = 0;
+
+	g_hdb->_ai->findPath(e);
+}
+
+void aiBuzzflyInit2(AIEntity *e) {
+	int		i;
+	e->draw = g_hdb->_ai->getStandFrameDir(e);
+	for (i = 0; i < e->movedownFrames; i++)
+	{
+		e->standdownGfx[i] = e->movedownGfx[i];
+		e->standupGfx[i] = e->moveupGfx[i];
+		e->standleftGfx[i] = e->moveleftGfx[i];
+		e->standrightGfx[i] = e->moverightGfx[i];
+	}
+	e->standdownFrames = e->movedownFrames;
+	e->standupFrames = e->moveupFrames;
+	e->standleftFrames = e->moveleftFrames;
+	e->standrightFrames = e->moverightFrames;
+}
+
 void aiBuzzflyAction(AIEntity *e) {
-	warning("STUB: AI: aiBuzzflyAction required");
+	if (!e->goalX) {
+		switch (e->sequence) {
+		case 0:
+		case 1:
+		case 2:
+		case 3:
+		case 4:
+			if (!e->animFrame && e->animDelay == e->animCycle)
+				e->sequence++;
+
+			e->draw = e->standdownGfx[e->animFrame];
+
+			// cycle animation frames
+			if (e->animDelay-- > 0)
+				return;
+			e->animDelay = e->animCycle;
+			e->animFrame++;
+			if (e->animFrame == e->standdownFrames)
+				e->animFrame = 0;
+
+			break;
+
+		case 5:
+			g_hdb->_ai->findPath(e);
+			if (e->onScreen)
+				g_hdb->_sound->playSound(SND_BUZZFLY_FLY);
+			e->sequence = 0;
+		}
+	} else {
+		g_hdb->_ai->animateEntity(e);
+		if (g_hdb->_ai->checkPlayerCollision(e->x, e->y, 6) && !g_hdb->_ai->playerDead()) {
+			g_hdb->_sound->playSound(SND_BUZZFLY_STING);
+			g_hdb->_ai->killPlayer(DEATH_GRABBED);
+		}
+	}
 }
 
 void aiDragonAction(AIEntity *e) {
@@ -2258,14 +2315,6 @@ void aiFatFrogInit2(AIEntity *e) {
 	warning("STUB: AI: aiFatFrogInit2 required");
 }
 
-void aiBuzzflyInit(AIEntity *e) {
-	warning("STUB: AI: aiBuzzflyInit required");
-}
-
-void aiBuzzflyInit2(AIEntity *e) {
-	warning("STUB: AI: aiBuzzflyInit2 required");
-}
-
 void aiDragonInit(AIEntity *e) {
 	warning("STUB: AI: aiDragonInit required");
 }


Commit: 1b924b23b9e699dcc56edf9560fec8d7780d1de3
    https://github.com/scummvm/scummvm/commit/1b924b23b9e699dcc56edf9560fec8d7780d1de3
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:12+02:00

Commit Message:
HDB: Add Dragon functions

Changed paths:
    engines/hdb/ai-bots.cpp


diff --git a/engines/hdb/ai-bots.cpp b/engines/hdb/ai-bots.cpp
index a64e230..f9f6486 100644
--- a/engines/hdb/ai-bots.cpp
+++ b/engines/hdb/ai-bots.cpp
@@ -2283,12 +2283,202 @@ void aiBuzzflyAction(AIEntity *e) {
 	}
 }
 
+void aiDragonInit(AIEntity *e) {
+	AIEntity *block;
+
+	e->state = STATE_STANDDOWN;
+	e->sequence = 0;	// 0 = sleeping
+	e->aiAction = aiDragonAction;
+	e->aiDraw = aiDragonDraw;
+	e->animCycle = 10;		// time between flaps
+
+	// need to save the dragon's coords and type in the blocking entity for gem-hit-blocking detection
+	block = spawnBlocking(e->tileX - 1, e->tileY, e->level);
+	block->value1 = (int)AI_DRAGON;
+	sprintf(block->luaFuncUse, "%03d%03d", e->tileX, e->tileY);
+	block = spawnBlocking(e->tileX + 1, e->tileY, e->level);
+	block->value1 = (int)AI_DRAGON;
+	sprintf(block->luaFuncUse, "%03d%03d", e->tileX, e->tileY);
+	block = spawnBlocking(e->tileX - 1, e->tileY - 1, e->level);
+	block->value1 = (int)AI_DRAGON;
+	sprintf(block->luaFuncUse, "%03d%03d", e->tileX, e->tileY);
+	block = spawnBlocking(e->tileX + 1, e->tileY - 1, e->level);
+	block->value1 = (int)AI_DRAGON;
+	sprintf(block->luaFuncUse, "%03d%03d", e->tileX, e->tileY);
+	block = spawnBlocking(e->tileX - 1, e->tileY - 2, e->level);
+	block->value1 = (int)AI_DRAGON;
+	sprintf(block->luaFuncUse, "%03d%03d", e->tileX, e->tileY);
+	block = spawnBlocking(e->tileX + 1, e->tileY - 2, e->level);
+	block->value1 = (int)AI_DRAGON;
+	sprintf(block->luaFuncUse, "%03d%03d", e->tileX, e->tileY);
+}
+
+void aiDragonInit2(AIEntity *e) {
+	e->draw = NULL;
+	if (!g_hdb->_ai->_gfxDragonAsleep) {
+		g_hdb->_ai->_gfxDragonAsleep = g_hdb->_gfx->loadPic(DRAGON_ASLEEP);
+		g_hdb->_ai->_gfxDragonFlap[0] = g_hdb->_gfx->loadPic(DRAGON_FLAP1);
+		g_hdb->_ai->_gfxDragonFlap[1] = g_hdb->_gfx->loadPic(DRAGON_FLAP2);
+		g_hdb->_ai->_gfxDragonBreathe[0] = g_hdb->_gfx->loadPic(DRAGON_BREATHE_START);
+		g_hdb->_ai->_gfxDragonBreathe[1] = g_hdb->_gfx->loadPic(DRAGON_BREATHING_1);
+		g_hdb->_ai->_gfxDragonBreathe[2] = g_hdb->_gfx->loadPic(DRAGON_BREATHING_2);
+	}
+}
+
+void aiDragonWake(AIEntity *e) {
+	e->sequence = 1;	// woke up, start flapping and breathing!
+	e->animFrame = 0;
+	e->animDelay = e->animCycle;
+}
+
+void aiDragonUse(AIEntity *e) {
+	aiDragonWake(e);
+}
+
 void aiDragonAction(AIEntity *e) {
-	warning("STUB: AI: aiDragonAction required");
+	AIEntity *p = g_hdb->_ai->getPlayer();
+
+	switch (e->sequence) {
+		// Sleeping, waiting for the player to wake him up
+	case 0:
+		if (e->onScreen &&
+			p->tileX >= e->tileX - 1 &&
+			p->tileX <= e->tileX + 1 &&
+			p->tileY <= e->tileY + 1 &&
+			p->tileY >= e->tileY - 3) {
+			if ((p->state >= STATE_ATK_CLUB_UP &&
+				p->state <= STATE_ATK_SLUG_RIGHT) || g_hdb->_window->inPanicZone()) {
+				aiDragonWake(e);
+				if (e->onScreen)
+					g_hdb->_sound->playSound(SND_DRAGON_WAKE);
+			}
+		}
+		break;
+
+		// Woke up - flapping wings 3 times!
+	case 1:
+		e->animDelay--;
+
+		if (e->animDelay < 1) {
+			if (e->onScreen)
+				g_hdb->_sound->playSound(SND_DRAGON_WAKE);
+			e->animDelay = e->animCycle;
+			e->animFrame++;
+			if (e->animFrame >= 8) {
+				e->animFrame = 0;
+				e->sequence = 2;
+				e->animCycle = 2;
+			}
+		}
+		break;
+
+		// Start breathing fire!
+	case 2:
+		e->animDelay--;
+
+		if (e->onScreen)
+			g_hdb->_sound->playSound(SND_DRAGON_BREATHEFIRE);
+		if (e->animDelay < 1) {
+			e->animDelay = e->animCycle;
+			e->animFrame++;
+			if (e->animFrame >= 1) {
+				e->animFrame = 0;
+				e->sequence = 3;
+				e->animCycle = 2;		// time between flaps
+			}
+		}
+
+		break;
+
+		// Breathing fire!
+	case 3:
+		{
+			if (hitPlayer(e->x, e->y + 32)) {
+				g_hdb->_ai->killPlayer(DEATH_FRIED);
+				return;
+			}
+
+			// whatever entity is in front of the dragon is gettin' USED!
+			AIEntity *hit = g_hdb->_ai->findEntity(e->tileX, e->tileY + 1);
+			if (hit) {
+				switch (hit->type) {
+				case AI_CHICKEN:
+					g_hdb->_ai->addAnimateTarget(hit->tileX * kTileWidth, hit->tileY * kTileHeight, 0, 2, ANIM_NORMAL, false, false, GROUP_ENT_CHICKEN_DIE);
+					g_hdb->_sound->playSound(SND_CHICKEN_DEATH);
+					g_hdb->_ai->removeEntity(hit);
+					e->sequence = 4;
+					break;
+				case AI_MAGIC_EGG:
+				case AI_ICE_BLOCK:
+					aiMagicEggUse(hit);
+					break;
+				default:
+					if (hit->aiUse)
+						hit->aiUse(hit);
+					if (hit->luaFuncUse[0])
+						g_hdb->_lua->callFunction(hit->luaFuncUse, 0);
+				}
+			}
+
+			e->animDelay--;
+
+			if (e->animDelay < 1) {
+				if (e->onScreen && !(e->animFrame & 7))
+					g_hdb->_sound->playSound(SND_DRAGON_BREATHEFIRE);
+
+				e->animDelay = e->animCycle;
+				e->animFrame++;
+				if (e->animFrame >= 30) {
+					e->animFrame = 0;
+					e->sequence = 4;
+					e->animCycle = 10;		// time between flaps
+				}
+			}
+		}
+
+		break;
+
+	// Done burning - flapping wings 3 times
+	case 4:
+		e->animDelay--;
+
+		if (e->animDelay < 1) {
+			e->animDelay = e->animCycle;
+			e->animFrame++;
+			if (e->animFrame >= 8) {
+				e->animFrame = 0;
+				e->sequence = 0;
+				if (e->onScreen)
+					g_hdb->_sound->playSound(SND_DRAGON_FALLASLEEP);
+			}
+		}
+		break;
+	}
 }
 
 void aiDragonDraw(AIEntity *e, int mx, int my) {
-	warning("STUB: AI: aiDragonDraw required");
+	switch (e->sequence) {
+		// sleeping
+	case 0:
+		g_hdb->_ai->_gfxDragonAsleep->drawMasked(e->x - 32 - mx, e->y - 96 - my);
+		break;
+		// flapping 3 times
+	case 1:
+		g_hdb->_ai->_gfxDragonFlap[e->animFrame & 1]->drawMasked(e->x - 32 - mx, e->y - 96 - my);
+		break;
+		// start breathing (very short)
+	case 2:
+		g_hdb->_ai->_gfxDragonBreathe[0]->drawMasked(e->x - 32 - mx, e->y - 96 - my);
+		break;
+		// breathing
+	case 3:
+		g_hdb->_ai->_gfxDragonBreathe[(e->animFrame & 1) + 1]->drawMasked(e->x - 32 - mx, e->y - 96 - my);
+		break;
+		// flapping 3 times
+	case 4:
+		g_hdb->_ai->_gfxDragonBreathe[e->animFrame & 1]->drawMasked(e->x - 32 - mx, e->y - 96 - my);
+		break;
+	}
 }
 
 void aiListenBotInit(AIEntity *e) {
@@ -2315,20 +2505,4 @@ void aiFatFrogInit2(AIEntity *e) {
 	warning("STUB: AI: aiFatFrogInit2 required");
 }
 
-void aiDragonInit(AIEntity *e) {
-	warning("STUB: AI: aiDragonInit required");
-}
-
-void aiDragonInit2(AIEntity *e) {
-	warning("STUB: AI: aiDragonInit2 required");
-}
-
-void aiDragonWake(AIEntity *e) {
-	warning("STUB: AI: aiDragonWake required");
-}
-
-void aiDragonUse(AIEntity *e) {
-	warning("STUB: AI: aiDragonUse required");
-}
-
 } // End of Namespace


Commit: 03f1a137865dc99de5d433ce90ddf19b154b3547
    https://github.com/scummvm/scummvm/commit/03f1a137865dc99de5d433ce90ddf19b154b3547
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:12+02:00

Commit Message:
HDB: Simplify executeChunk() function

Changed paths:
    engines/hdb/lua-script.cpp
    engines/hdb/lua-script.h


diff --git a/engines/hdb/lua-script.cpp b/engines/hdb/lua-script.cpp
index e4d5f0e..7da2bd9 100644
--- a/engines/hdb/lua-script.cpp
+++ b/engines/hdb/lua-script.cpp
@@ -1576,7 +1576,7 @@ bool LuaScript::executeMPC(Common::SeekableReadStream *stream, const char *name,
 
 	addPatches(chunkString, scriptName);
 
-	if (!executeChunk(chunkString, chunkString.size(), name)) {
+	if (!executeChunk(chunkString, name)) {
 		delete[] chunk;
 
 		return false;
@@ -1610,7 +1610,7 @@ bool LuaScript::executeFile(const Common::String &filename) {
 
 	addPatches(fileDataString, filename.c_str());
 
-	if (!executeChunk(fileDataString, fileDataString.size(), filename)) {
+	if (!executeChunk(fileDataString, filename)) {
 		delete[] fileData;
 		delete file;
 
@@ -1623,14 +1623,14 @@ bool LuaScript::executeFile(const Common::String &filename) {
 	return true;
 }
 
-bool LuaScript::executeChunk(Common::String &chunk, uint chunkSize, const Common::String &chunkName) const {
+bool LuaScript::executeChunk(Common::String &chunk, const Common::String &chunkName) const {
 
 	if (!_systemInit) {
 		return false;
 	}
 
 	// Compile Chunk
-	if (luaL_loadbuffer(_state, chunk.c_str(), chunkSize, chunkName.c_str())) {
+	if (luaL_loadbuffer(_state, chunk.c_str(), chunk.size(), chunkName.c_str())) {
 		error("Couldn't compile \"%s\": %s", chunkName.c_str(), lua_tostring(_state, -1));
 		lua_pop(_state, -1);
 
diff --git a/engines/hdb/lua-script.h b/engines/hdb/lua-script.h
index 6949deb..92574d2 100644
--- a/engines/hdb/lua-script.h
+++ b/engines/hdb/lua-script.h
@@ -71,7 +71,7 @@ private:
 	bool _systemInit;
 
 	bool registerExtensions();
-	bool executeChunk(Common::String &chunk, uint chunkSize, const Common::String &chunkName) const;
+	bool executeChunk(Common::String &chunk, const Common::String &chunkName) const;
 	void stripComments(char *chunk);
 	void addPatches(Common::String &chunk, const char *scriptName);
 };


Commit: 10df2d85dc013a9d7cbd5f68a21b4b59daada50b
    https://github.com/scummvm/scummvm/commit/10df2d85dc013a9d7cbd5f68a21b4b59daada50b
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:12+02:00

Commit Message:
HDB: Fix warning

Changed paths:
    engines/hdb/hdb.h
    engines/hdb/lua-script.cpp


diff --git a/engines/hdb/hdb.h b/engines/hdb/hdb.h
index 6d7490b..e936498 100644
--- a/engines/hdb/hdb.h
+++ b/engines/hdb/hdb.h
@@ -213,7 +213,7 @@ public:
 
 	char *lastMapname() { return _lastMapname; }
 
-	void changeLevel(char *name) {
+	void changeLevel(const char *name) {
 		strcpy(_changeMapname, name);
 		_changeLevel = true;
 	}
diff --git a/engines/hdb/lua-script.cpp b/engines/hdb/lua-script.cpp
index 7da2bd9..50c1551 100644
--- a/engines/hdb/lua-script.cpp
+++ b/engines/hdb/lua-script.cpp
@@ -957,7 +957,7 @@ static int startMap(lua_State *L) {
 	g_hdb->_lua->checkParameters("startMap", 1);
 
 	lua_pop(L, 1);
-	g_hdb->changeLevel((char *)string);
+	g_hdb->changeLevel(string);
 
 	return 0;
 }


Commit: 5f8e3fab2cba60d04f4748936cbe31b0b273ed57
    https://github.com/scummvm/scummvm/commit/5f8e3fab2cba60d04f4748936cbe31b0b273ed57
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:12+02:00

Commit Message:
HDB: Fix warning

Changed paths:
    engines/hdb/ai-lists.cpp


diff --git a/engines/hdb/ai-lists.cpp b/engines/hdb/ai-lists.cpp
index 890b943..53084dd 100644
--- a/engines/hdb/ai-lists.cpp
+++ b/engines/hdb/ai-lists.cpp
@@ -214,6 +214,8 @@ void AI::animateBridges() {
 				done = true;
 			}
 			break;
+		case DIR_NONE:
+			break;
 		}
 
 		// is this bridge done extending one chunk?


Commit: 9a0e685f0e76ceca6d525e81ea167483472af73a
    https://github.com/scummvm/scummvm/commit/9a0e685f0e76ceca6d525e81ea167483472af73a
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:12+02:00

Commit Message:
HDB: Fix warnings

Changed paths:
    engines/hdb/ai-use.cpp
    engines/hdb/window.cpp


diff --git a/engines/hdb/ai-use.cpp b/engines/hdb/ai-use.cpp
index f48b9e6..806491f 100644
--- a/engines/hdb/ai-use.cpp
+++ b/engines/hdb/ai-use.cpp
@@ -147,7 +147,7 @@ bool AI::useSwitchOn(AIEntity *e, int x, int y, int targetX, int targetY, int of
 }
 
 bool AI::useSwitch2(AIEntity *e, int x, int y, int targetX, int targetY) {
-	int i = 10;
+	// int i = 10; // unused
 	return true;
 }
 
diff --git a/engines/hdb/window.cpp b/engines/hdb/window.cpp
index d78ea00..7637ffc 100644
--- a/engines/hdb/window.cpp
+++ b/engines/hdb/window.cpp
@@ -590,7 +590,7 @@ void Window::closeMsg() {
 
 void Window::drawInventory() {
 	int baseX, drawX, drawY;
-	static uint32 timer = g_hdb->getTimeSlice() + 300;
+	// static uint32 timer = g_hdb->getTimeSlice() + 300; // unused
 	AIEntity *e, *sel;
 	char string[8];
 	int gems, mstones;
@@ -712,7 +712,7 @@ void Window::openDeliveries(bool animate) {
 void Window::drawDeliveries() {
 	int baseX, drawX, drawY;
 	DlvEnt *d;
-	static uint32 timer = g_hdb->getTimeSlice() + 300;
+	//static uint32 timer = g_hdb->getTimeSlice() + 300; //unused
 
 	int crazySounds[kNumCrazy] = {
 		SND_GUI_INPUT,


Commit: 6feed893deb1262e6e0c74ed1aece2306aa62241
    https://github.com/scummvm/scummvm/commit/6feed893deb1262e6e0c74ed1aece2306aa62241
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:12+02:00

Commit Message:
HDB: Fix warning

Changed paths:
    engines/hdb/ai-bots.cpp


diff --git a/engines/hdb/ai-bots.cpp b/engines/hdb/ai-bots.cpp
index f9f6486..95d11f0 100644
--- a/engines/hdb/ai-bots.cpp
+++ b/engines/hdb/ai-bots.cpp
@@ -1960,6 +1960,8 @@ void aiGatePuddleAction(AIEntity *e) {
 					case DIR_RIGHT:
 						g_hdb->_ai->setEntityGoal(p, p->tileX + 1, p->tileY);
 						break;
+					case DIR_NONE:
+						break;
 					}
 					g_hdb->_ai->_playerEmerging = true;
 					break;
@@ -2105,9 +2107,9 @@ void aiIcePuffAction(AIEntity *e) {
 		case 12: e->draw = e->blinkGfx[2]; break;	// peek - blinking
 		case  8: e->draw = e->blinkGfx[1]; break;	// peek - looking
 		case  4: e->draw = e->blinkGfx[0]; break;	// peek - looking
-		case  3: 
-			if (e->onScreen && !g_hdb->_rnd->getRandomNumber(6)) 
-				g_hdb->_sound->playSound(SND_ICEPUFF_WARNING); 
+		case  3:
+			if (e->onScreen && !g_hdb->_rnd->getRandomNumber(6))
+				g_hdb->_sound->playSound(SND_ICEPUFF_WARNING);
 			break;
 		case  0: e->draw = e->blinkGfx[3];			// underground
 			e->sequence = 30;


Commit: 73be5db12ecb4d83afa8c4a4248a9f857a470de3
    https://github.com/scummvm/scummvm/commit/73be5db12ecb4d83afa8c4a4248a9f857a470de3
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:12+02:00

Commit Message:
HDB: Attempt to implement hot patches

Changed paths:
    engines/hdb/hdb.cpp
    engines/hdb/lua-script.h


diff --git a/engines/hdb/hdb.cpp b/engines/hdb/hdb.cpp
index b9ae6c1..054ae22 100644
--- a/engines/hdb/hdb.cpp
+++ b/engines/hdb/hdb.cpp
@@ -163,6 +163,13 @@ bool HDBGame::restartMap() {
 	_lua->init();
 	_lua->loadLua(_currentLuaName);
 
+	// Cheat/workarounds
+	if (!strcmp(_currentLuaName, "MAP00.LUA")) {
+		Common::String patch("KillTrigger( \"mannyquest\" )");
+
+		_lua->executeChunk(patch, "MAP00 patch");
+	}
+
 	_sound->markSoundCacheFreeable();
 	_map->restartSystem();
 
diff --git a/engines/hdb/lua-script.h b/engines/hdb/lua-script.h
index 92574d2..4f2ffd2 100644
--- a/engines/hdb/lua-script.h
+++ b/engines/hdb/lua-script.h
@@ -56,6 +56,7 @@ public:
 
 	bool executeMPC(Common::SeekableReadStream *stream, const char *name, const char *scriptName, int32 length);
 	bool executeFile(const Common::String &filename);
+	bool executeChunk(Common::String &chunk, const Common::String &chunkName) const;
 	void checkParameters(const char *func, int params);
 
 	const char *getStringOffStack();
@@ -71,7 +72,6 @@ private:
 	bool _systemInit;
 
 	bool registerExtensions();
-	bool executeChunk(Common::String &chunk, const Common::String &chunkName) const;
 	void stripComments(char *chunk);
 	void addPatches(Common::String &chunk, const char *scriptName);
 };


Commit: a29e3b96980150c8195b6f727df1758644695632
    https://github.com/scummvm/scummvm/commit/a29e3b96980150c8195b6f727df1758644695632
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:12+02:00

Commit Message:
HDB: Proper place for the cheat patches. And wrap them into a define

We need to apply them after the map has been loaded, not before

Changed paths:
    engines/hdb/hdb.cpp


diff --git a/engines/hdb/hdb.cpp b/engines/hdb/hdb.cpp
index 054ae22..92d2939 100644
--- a/engines/hdb/hdb.cpp
+++ b/engines/hdb/hdb.cpp
@@ -34,6 +34,8 @@
 #include "hdb/console.h"
 #include "hdb/menu.h"
 
+#define CHEAT_PATCHES 1
+
 namespace HDB {
 
 HDBGame* g_hdb;
@@ -163,13 +165,6 @@ bool HDBGame::restartMap() {
 	_lua->init();
 	_lua->loadLua(_currentLuaName);
 
-	// Cheat/workarounds
-	if (!strcmp(_currentLuaName, "MAP00.LUA")) {
-		Common::String patch("KillTrigger( \"mannyquest\" )");
-
-		_lua->executeChunk(patch, "MAP00 patch");
-	}
-
 	_sound->markSoundCacheFreeable();
 	_map->restartSystem();
 
@@ -178,6 +173,15 @@ bool HDBGame::restartMap() {
 
 	_ai->initAnimInfo();
 
+	// Cheat/workarounds
+#if CHEAT_PATCHES
+	if (!strcmp(_currentLuaName, "MAP00.LUA")) {
+		Common::String patch("KillTrigger( \"mannyquest\" )");
+
+		_lua->executeChunk(patch, "MAP00 patch");
+	}
+#endif
+
 	// if there are Secret Stars here, stick the variable in Lua
 	if (!_menu->_starWarp && getStarsMonkeystone7() == STARS_MONKEYSTONE_7)
 		_lua->setLuaGlobalValue("secretstars", 1);


Commit: 20f7bf6df8d80c2b2ebbec8ce833844f8aa9cf6a
    https://github.com/scummvm/scummvm/commit/20f7bf6df8d80c2b2ebbec8ce833844f8aa9cf6a
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:12+02:00

Commit Message:
HDB: Add FatFrog functions

Changed paths:
    engines/hdb/ai-bots.cpp


diff --git a/engines/hdb/ai-bots.cpp b/engines/hdb/ai-bots.cpp
index 95d11f0..9d6b18a 100644
--- a/engines/hdb/ai-bots.cpp
+++ b/engines/hdb/ai-bots.cpp
@@ -1551,12 +1551,335 @@ void aiMeerkatLookAround(AIEntity *e) {
 	g_hdb->_ai->animEntFrames(e);
 }
 
+void aiFatFrogInit(AIEntity *e) {
+	e->aiAction = aiFatFrogAction;
+}
+
+void aiFatFrogInit2(AIEntity *e) {
+	e->draw = g_hdb->_ai->getStandFrameDir(e);
+	// load tongue tiles
+	switch (e->dir) {
+	case DIR_DOWN:
+		if (!g_hdb->_ai->_tileFroglickMiddleUD) {
+			g_hdb->_ai->_tileFroglickMiddleLR = g_hdb->_gfx->loadTile(TILE_FFTONGUE_UD_MIDDLE);
+			g_hdb->_ai->_tileFroglickWiggleUD[0] = g_hdb->_gfx->loadTile(TILE_FFTONGUE_UD_WIGGLE_L);
+			g_hdb->_ai->_tileFroglickWiggleUD[1] = g_hdb->_gfx->loadTile(TILE_FFTONGUE_UD_WIGGLE_M);
+			g_hdb->_ai->_tileFroglickWiggleUD[2] = g_hdb->_gfx->loadTile(TILE_FFTONGUE_UD_WIGGLE_R);
+		}
+		e->state = STATE_STANDDOWN;
+		break;
+	case DIR_LEFT:
+		if (!g_hdb->_ai->_tileFroglickMiddleLR)
+			g_hdb->_ai->_tileFroglickMiddleLR = g_hdb->_gfx->loadTile(TILE_FFTONGUE_LR_MIDDLE);
+
+		if (!g_hdb->_ai->_tileFroglickWiggleLeft[0]) {
+			g_hdb->_ai->_tileFroglickWiggleLeft[0] = g_hdb->_gfx->loadTile(TILE_FFTONGUE_L_WIGGLE_U);
+			g_hdb->_ai->_tileFroglickWiggleLeft[1] = g_hdb->_gfx->loadTile(TILE_FFTONGUE_L_WIGGLE_M);
+			g_hdb->_ai->_tileFroglickWiggleLeft[2] = g_hdb->_gfx->loadTile(TILE_FFTONGUE_L_WIGGLE_D);
+		}
+		e->state = STATE_STANDLEFT;
+		break;
+	case DIR_RIGHT:
+		if (!g_hdb->_ai->_tileFroglickMiddleLR)
+			g_hdb->_ai->_tileFroglickMiddleLR = g_hdb->_gfx->loadTile(TILE_FFTONGUE_LR_MIDDLE);
+
+		if (!g_hdb->_ai->_tileFroglickWiggleRight[0]) {
+			g_hdb->_ai->_tileFroglickWiggleRight[0] = g_hdb->_gfx->loadTile(TILE_FFTONGUE_R_WIGGLE_U);
+			g_hdb->_ai->_tileFroglickWiggleRight[1] = g_hdb->_gfx->loadTile(TILE_FFTONGUE_R_WIGGLE_M);
+			g_hdb->_ai->_tileFroglickWiggleRight[2] = g_hdb->_gfx->loadTile(TILE_FFTONGUE_R_WIGGLE_D);
+		}
+		e->state = STATE_STANDRIGHT;
+		break;
+	default:
+		break;
+	}
+}
+
 void aiFatFrogAction(AIEntity *e) {
-	warning("STUB: AI: aiFatFrogAction required");
+	AIEntity *p = g_hdb->_ai->getPlayer();
+
+	switch (e->state) {
+		//-------------------------------------------------------------------
+		// WAITING TO ATTACK
+		//-------------------------------------------------------------------
+	case STATE_STANDDOWN:
+		e->draw = e->standdownGfx[e->animFrame];
+		// is player within 2 tiles below fatfrog?
+		if (p->tileX == e->tileX && p->tileY - e->tileY < 3 && p->tileY > e->tileY) {
+			e->state = STATE_LICKDOWN;
+			e->animDelay = e->animCycle << 2;
+			e->animFrame = 0;
+		}
+		// cycle animation frames
+		if (e->animDelay-- > 0)
+			return;
+		e->animDelay = e->animCycle << 2;
+		e->animFrame++;
+		if (e->animFrame == e->standdownFrames)
+			e->animFrame = 0;
+		if (!g_hdb->_rnd->getRandomNumber(30) && e->onScreen)
+			g_hdb->_sound->playSound(SND_FROG_RIBBIT1);
+		break;
+
+	case STATE_STANDLEFT:
+		e->draw = e->standleftGfx[e->animFrame];
+		// is player within 2 tiles below fatfrog?
+		if (p->tileY == e->tileY && e->tileX - p->tileX < 3 && p->tileX < e->tileX) {
+			e->state = STATE_LICKLEFT;
+			e->animDelay = e->animCycle << 2;
+			e->animFrame = 0;
+		}
+		// cycle animation frames
+		if (e->animDelay-- > 0)
+			return;
+		e->animDelay = e->animCycle << 2;
+		e->animFrame++;
+		if (e->animFrame == e->standleftFrames)
+			e->animFrame = 0;
+		if (!g_hdb->_rnd->getRandomNumber(30) && e->onScreen)
+			g_hdb->_sound->playSound(SND_FROG_RIBBIT2);
+		break;
+
+	case STATE_STANDRIGHT:
+		e->draw = e->standrightGfx[e->animFrame];
+		// is player within 2 tiles below fatfrog?
+		if (p->tileY == e->tileY && p->tileX - e->tileX < 3 && p->tileX > e->tileX) {
+			e->state = STATE_LICKRIGHT;
+			e->animDelay = e->animCycle << 2;
+			e->animFrame = 0;
+		}
+		// cycle animation frames
+		if (e->animDelay-- > 0)
+			return;
+		e->animDelay = e->animCycle << 2;
+		e->animFrame++;
+		if (e->animFrame == e->standrightFrames)
+			e->animFrame = 0;
+		if (!g_hdb->_rnd->getRandomNumber(30) && e->onScreen)
+			g_hdb->_sound->playSound(SND_FROG_RIBBIT2);
+		break;
+
+		//-------------------------------------------------------------------
+		// LICK ATTACK
+		//-------------------------------------------------------------------
+	case STATE_LICKDOWN:
+		e->draw = e->movedownGfx[e->animFrame];
+		// ready to start licking?
+		if (e->animFrame == e->movedownFrames - 1 && !e->value1) {
+			e->value1 = 1;
+			e->aiDraw = aiFatFrogTongueDraw;
+			g_hdb->_sound->playSound(SND_FROG_LICK);
+		} else if (e->animFrame == e->movedownFrames - 1 && e->value1) {
+			// animate licking
+
+			// check player death
+			if (((p->tileX == e->tileX && p->tileY == e->tileY + 1) ||					// in front of frog + 1 tile!?
+				(e->value1 > 3 && p->tileX == e->tileX && p->tileY < e->tileY + 3)) &&	// in front of frog + 2 tiles!?
+				g_hdb->_ai->playerDead() == false)
+				g_hdb->_ai->killPlayer(DEATH_NORMAL);
+
+			e->value1++;
+			if (e->value1 == 14) {
+				e->animFrame = e->value1 = 0;
+				e->aiDraw = NULL;
+				e->state = STATE_STANDDOWN;
+			}
+		} else {
+			// animate pre-licking
+			// cycle animation frames
+			if (e->animDelay-- > 0)
+				return;
+			e->animDelay = e->animCycle;
+			e->animFrame++;
+		}
+		break;
+
+	case STATE_LICKLEFT:
+		e->draw = e->moveleftGfx[e->animFrame];
+		// ready to start licking?
+		if (e->animFrame == e->moveleftFrames - 1 && !e->value1) {
+			e->value1 = 1;
+			e->aiDraw = aiFatFrogTongueDraw;
+			g_hdb->_sound->playSound(SND_FROG_LICK);
+		} else if (e->animFrame == e->moveleftFrames - 1 && e->value1) {
+			// animate licking
+
+			// check player death
+			if (((p->tileY == e->tileY && p->tileX == e->tileX - 1) ||					// in front of frog + 1 tile!?
+				(e->value1 > 3 && p->tileY == e->tileY && p->tileX > e->tileX - 3)) &&	// in front of frog + 2 tiles!?
+				g_hdb->_ai->playerDead() == false)
+				g_hdb->_ai->killPlayer(DEATH_NORMAL);
+
+			e->value1++;
+			if (e->value1 == 14) {
+				e->animFrame = e->value1 = 0;
+				e->aiDraw = NULL;
+				e->state = STATE_STANDLEFT;
+			}
+		} else {
+			// animate pre-licking
+			// cycle animation frames
+			if (e->animDelay-- > 0)
+				return;
+			e->animDelay = e->animCycle;
+			e->animFrame++;
+		}
+		break;
+
+	case STATE_LICKRIGHT:
+		e->draw = e->moverightGfx[e->animFrame];
+		// ready to start licking?
+		if (e->animFrame == e->moverightFrames - 1 && !e->value1) {
+			e->value1 = 1;
+			e->aiDraw = aiFatFrogTongueDraw;
+			g_hdb->_sound->playSound(SND_FROG_LICK);
+		} else if (e->animFrame == e->moverightFrames - 1 && e->value1) {
+			// animate licking
+			// check player death
+			//
+			if (((p->tileY == e->tileY && p->tileX == e->tileX + 1) ||					// in front of frog + 1 tile!?
+				(e->value1 > 3 && p->tileY == e->tileY && p->tileX < e->tileX + 3)) &&	// in front of frog + 2 tiles!?
+				g_hdb->_ai->playerDead() == false)
+				g_hdb->_ai->killPlayer(DEATH_NORMAL);
+
+			e->value1++;
+			if (e->value1 == 14) {
+				e->animFrame = e->value1 = 0;
+				e->aiDraw = NULL;
+				e->state = STATE_STANDRIGHT;
+			}
+		} else {
+			// animate pre-licking
+			// cycle animation frames
+			if (e->animDelay-- > 0)
+				return;
+			e->animDelay = e->animCycle;
+			e->animFrame++;
+		}
+		break;
+	}
 }
 
 void aiFatFrogTongueDraw(AIEntity *e, int mx, int my) {
-	warning("STUB: AI: aiFatFrogTongueDraw required");
+	int	nx, ny;
+
+	switch (e->state) {
+	case STATE_LICKDOWN:
+		switch (e->value1) {
+		case 1:
+		case 2:
+		case 3:
+		case 13:
+		case 14:
+			nx = e->x;
+			ny = e->y + 32;
+			g_hdb->_ai->_tileFroglickWiggleUD[1]->drawMasked(nx - mx, ny - my);
+			break;
+		case 4:
+		case 7:
+		case 10:
+			nx = e->x;
+			ny = e->y + 32;
+			g_hdb->_ai->_tileFroglickMiddleUD->drawMasked(nx - mx, ny - my);
+			g_hdb->_ai->_tileFroglickWiggleUD[0]->drawMasked(nx - mx, ny + 32 - my);
+			break;
+		case 5:
+		case 8:
+		case 11:
+			nx = e->x;
+			ny = e->y + 32;
+			g_hdb->_ai->_tileFroglickMiddleUD->drawMasked(nx - mx, ny - my);
+			g_hdb->_ai->_tileFroglickWiggleUD[1]->drawMasked(nx - mx, ny + 32 - my);
+			break;
+		case 6:
+		case 9:
+		case 12:
+			nx = e->x;
+			ny = e->y + 32;
+			g_hdb->_ai->_tileFroglickMiddleUD->drawMasked(nx - mx, ny - my);
+			g_hdb->_ai->_tileFroglickWiggleUD[2]->drawMasked(nx - mx, ny + 32 - my);
+			break;
+		}
+		break;
+
+	case STATE_LICKLEFT:
+		switch (e->value1) {
+		case 1:
+		case 2:
+		case 3:
+		case 13:
+		case 14:
+			nx = e->x - 32;
+			ny = e->y;
+			g_hdb->_ai->_tileFroglickWiggleLeft[1]->drawMasked(nx - mx, ny - my);
+			break;
+		case 4:
+		case 7:
+		case 10:
+			nx = e->x - 32;
+			ny = e->y;
+			g_hdb->_ai->_tileFroglickMiddleLR->drawMasked(nx - mx, ny - my);
+			g_hdb->_ai->_tileFroglickWiggleLeft[0]->drawMasked(nx - 32 - mx, ny - my);
+			break;
+		case 5:
+		case 8:
+		case 11:
+			nx = e->x - 32;
+			ny = e->y;
+			g_hdb->_ai->_tileFroglickMiddleLR->drawMasked(nx - mx, ny - my);
+			g_hdb->_ai->_tileFroglickWiggleLeft[1]->drawMasked(nx - 32 - mx, ny - my);
+			break;
+		case 6:
+		case 9:
+		case 12:
+			nx = e->x - 32;
+			ny = e->y;
+			g_hdb->_ai->_tileFroglickMiddleLR->drawMasked(nx - mx, ny - my);
+			g_hdb->_ai->_tileFroglickWiggleLeft[2]->drawMasked(nx - 32 - mx, ny - my);
+			break;
+		}
+		break;
+
+	case STATE_LICKRIGHT:
+		switch (e->value1) {
+		case 1:
+		case 2:
+		case 3:
+		case 13:
+		case 14:
+			nx = e->x + 32;
+			ny = e->y;
+			g_hdb->_ai->_tileFroglickWiggleRight[1]->drawMasked(nx - 32 - mx, ny - my);
+			break;
+		case 4:
+		case 7:
+		case 10:
+			nx = e->x + 32;
+			ny = e->y;
+			g_hdb->_ai->_tileFroglickMiddleLR->drawMasked(nx - mx, ny - my);
+			g_hdb->_ai->_tileFroglickWiggleRight[0]->drawMasked(nx + 32 - mx, ny - my);
+			break;
+		case 5:
+		case 8:
+		case 11:
+			nx = e->x + 32;
+			ny = e->y;
+			g_hdb->_ai->_tileFroglickMiddleLR->drawMasked(nx - mx, ny - my);
+			g_hdb->_ai->_tileFroglickWiggleRight[1]->drawMasked(nx + 32 - mx, ny - my);
+			break;
+		case 6:
+		case 9:
+		case 12:
+			nx = e->x + 32;
+			ny = e->y;
+			g_hdb->_ai->_tileFroglickMiddleLR->drawMasked(nx - mx, ny - my);
+			g_hdb->_ai->_tileFroglickWiggleRight[2]->drawMasked(nx + 32 - mx, ny - my);
+			break;
+		}
+		break;
+	default:
+		break;
+	}
 }
 
 void aiGoodFairyInit(AIEntity *e) {
@@ -2483,14 +2806,6 @@ void aiDragonDraw(AIEntity *e, int mx, int my) {
 	}
 }
 
-void aiListenBotInit(AIEntity *e) {
-	warning("STUB: AI: aiListenBotInit required");
-}
-
-void aiListenBotInit2(AIEntity *e) {
-	warning("STUB: AI: aiListenBotInit2 required");
-}
-
 void aiLaserInit(AIEntity *e) {
 	warning("STUB: AI: aiLaserInit required");
 }
@@ -2499,12 +2814,4 @@ void aiLaserInit2(AIEntity *e) {
 	warning("STUB: AI: aiLaserInit2 required");
 }
 
-void aiFatFrogInit(AIEntity *e) {
-	warning("STUB: AI: aiFatFrogInit required");
-}
-
-void aiFatFrogInit2(AIEntity *e) {
-	warning("STUB: AI: aiFatFrogInit2 required");
-}
-
 } // End of Namespace


Commit: 68431702c87cfba224b3736447b6de07c20b37e1
    https://github.com/scummvm/scummvm/commit/68431702c87cfba224b3736447b6de07c20b37e1
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:12+02:00

Commit Message:
HDB: Add stopChannel()

Changed paths:
    engines/hdb/sound.cpp
    engines/hdb/sound.h


diff --git a/engines/hdb/sound.cpp b/engines/hdb/sound.cpp
index 92840e9..5f5cf86 100644
--- a/engines/hdb/sound.cpp
+++ b/engines/hdb/sound.cpp
@@ -44,6 +44,11 @@ bool Sound::playVoice(int index, int actor) {
 	return true;
 }
 
+bool Sound::stopChannel(int channel) {
+	debug(9, "STUB: Stop Channel");
+	return true;
+}
+
 void Sound::markSoundCacheFreeable() {
 	warning("STUB: Sound::markSoundCacheFreeable() ");
 }
diff --git a/engines/hdb/sound.h b/engines/hdb/sound.h
index c790ca9..2fc677b 100644
--- a/engines/hdb/sound.h
+++ b/engines/hdb/sound.h
@@ -1392,6 +1392,7 @@ public:
 	bool playSound(int index);
 	bool playSoundEx(int index, int channel, bool loop);
 	bool playVoice(int index, int actor);
+	bool stopChannel(int channel);
 
 	void markSoundCacheFreeable();
 };


Commit: ab06602332b3a10029127656dbc23471c3237f3e
    https://github.com/scummvm/scummvm/commit/ab06602332b3a10029127656dbc23471c3237f3e
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:12+02:00

Commit Message:
HDB: Add clearDiverters()

Changed paths:
    engines/hdb/ai-funcs.cpp
    engines/hdb/ai.h


diff --git a/engines/hdb/ai-funcs.cpp b/engines/hdb/ai-funcs.cpp
index ef32d51..ed5183f 100644
--- a/engines/hdb/ai-funcs.cpp
+++ b/engines/hdb/ai-funcs.cpp
@@ -2033,6 +2033,16 @@ bool AI::checkPlayerCollision(int x, int y, int border) {
 	return (x > (_player->x - 32 + border) && x < (_player->x - 32 - border) && y >(_player->y - 32 + border) && y < (_player->y - 32 - border));
 }
 
+void AI::clearDiverters() {
+	AIEntity *e;
+
+	for (uint i = 0; i < _ents->size(); i++) {
+		e = _ents->operator[](i);
+		if (e->type == AI_DIVERTER)
+			e->value1 = e->value2 = 0;
+	}
+}
+
 void AI::floatEntity(AIEntity *e, AIState state) {
 	for (Common::Array<AIEntity *>::iterator it = _ents->begin(); it != _ents->end(); it++) {
 		if (e == *it) {
diff --git a/engines/hdb/ai.h b/engines/hdb/ai.h
index 5930638..098b4d3 100644
--- a/engines/hdb/ai.h
+++ b/engines/hdb/ai.h
@@ -836,6 +836,7 @@ public:
 	AIEntity *playerCollision(int topBorder, int bottomBorder, int leftBorder, int rightBorder);
 	bool checkPlayerTileCollision(int x, int y);
 	bool checkPlayerCollision(int x, int y, int border);
+	void clearDiverters();
 
 	// List functions
 	void addToActionList(int actionIndex, int x, int y, char *funcLuaInit, char *funcLuaUse);


Commit: 22ca561f4af1d524ab5519903e49f743020b48a4
    https://github.com/scummvm/scummvm/commit/22ca561f4af1d524ab5519903e49f743020b48a4
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:12+02:00

Commit Message:
HDB: Add _laserRescan and _laserOnScreen

Changed paths:
    engines/hdb/ai-bots.cpp
    engines/hdb/ai-funcs.cpp
    engines/hdb/ai-init.cpp
    engines/hdb/ai.h


diff --git a/engines/hdb/ai-bots.cpp b/engines/hdb/ai-bots.cpp
index 9d6b18a..0f553b0 100644
--- a/engines/hdb/ai-bots.cpp
+++ b/engines/hdb/ai-bots.cpp
@@ -1260,13 +1260,13 @@ void aiDiverterInit2(AIEntity *e) {
 	case DIR_NONE: break;
 	}
 
-	warning("STUB: Set Laser Rescan to true");
+	g_hdb->_ai->_laserRescan = true;
 }
 
 void aiDiverterAction(AIEntity *e) {
 	if (e->goalX) {
 		g_hdb->_ai->animateEntity(e);
-		warning("STUB: Set Laser Rescan to true");
+		g_hdb->_ai->_laserRescan = true;
 
 		// have to reset the state because we might have been moved...
 		switch (e->dir2) {
@@ -1294,7 +1294,7 @@ void aiDiverterDraw(AIEntity *e, int mx, int my) {
 			onScreen += g_hdb->_ai->_gfxLaserbeamUDTop[frame]->drawMasked(e->x - mx, i * kTileHeight - my);
 			if (onScreen) {
 				g_hdb->_sound->playSoundEx(SND_LASER_LOOP, kLaserChannel, true);
-				warning("STUB: Set Laser onScreen to true");
+				g_hdb->_ai->_laserOnScreen = true;
 			}
 		} else {
 			for (i = e->value1 + 1; i < e->value2; i++)
@@ -1302,7 +1302,7 @@ void aiDiverterDraw(AIEntity *e, int mx, int my) {
 			onScreen += g_hdb->_ai->_gfxLaserbeamLRLeft[frame]->drawMasked(i * kTileWidth - mx, e->y - my);
 			if (onScreen) {
 				g_hdb->_sound->playSoundEx(SND_LASER_LOOP, kLaserChannel, true);
-				warning("STUB: Set Laser onScreen to true");
+				g_hdb->_ai->_laserOnScreen = true;
 			}
 		}
 		break;
@@ -1313,7 +1313,7 @@ void aiDiverterDraw(AIEntity *e, int mx, int my) {
 			onScreen += g_hdb->_ai->_gfxLaserbeamUDTop[frame]->drawMasked(e->x - mx, i * kTileHeight - my);
 			if (onScreen) {
 				g_hdb->_sound->playSoundEx(SND_LASER_LOOP, kLaserChannel, true);
-				warning("STUB: Set Laser onscreen to true");
+				g_hdb->_ai->_laserOnScreen = true;
 			}
 		} else {
 			for (i = e->value1 - 1; i > e->value2; i--)
@@ -1321,7 +1321,7 @@ void aiDiverterDraw(AIEntity *e, int mx, int my) {
 			onScreen += g_hdb->_ai->_gfxLaserbeamLRRight[frame]->drawMasked(i * kTileWidth - mx, e->y - my);
 			if (onScreen) {
 				g_hdb->_sound->playSoundEx(SND_LASER_LOOP, kLaserChannel, true);
-				warning("STUB: Set Laser onscreen to true");
+				g_hdb->_ai->_laserOnScreen = true;
 			}
 		}
 		break;
@@ -1332,7 +1332,7 @@ void aiDiverterDraw(AIEntity *e, int mx, int my) {
 			onScreen += g_hdb->_ai->_gfxLaserbeamUDBottom[frame]->drawMasked(e->x - mx, i * kTileHeight - my);
 			if (onScreen) {
 				g_hdb->_sound->playSoundEx(SND_LASER_LOOP, kLaserChannel, true);
-				warning("STUB: Set Laser onscreen to true");
+				g_hdb->_ai->_laserOnScreen = true;
 			}
 		} else {
 			for (i = e->value1 - 1; i > e->value2; i--)
@@ -1340,7 +1340,7 @@ void aiDiverterDraw(AIEntity *e, int mx, int my) {
 			onScreen += g_hdb->_ai->_gfxLaserbeamLRRight[frame]->drawMasked(i * kTileWidth - mx, e->y - my);
 			if (onScreen) {
 				g_hdb->_sound->playSoundEx(SND_LASER_LOOP, kLaserChannel, true);
-				warning("STUB: Set Laser onscreen to true");
+				g_hdb->_ai->_laserOnScreen = true;
 			}
 		}
 		break;
@@ -1351,7 +1351,7 @@ void aiDiverterDraw(AIEntity *e, int mx, int my) {
 			onScreen += g_hdb->_ai->_gfxLaserbeamUDBottom[frame]->drawMasked(e->x - mx, i * kTileHeight - my);
 			if (onScreen) {
 				g_hdb->_sound->playSoundEx(SND_LASER_LOOP, kLaserChannel, true);
-				warning("STUB: Set Laser onscreen to true");
+				g_hdb->_ai->_laserOnScreen = true;
 			}
 		} else {
 			for (i = e->value1 + 1; i < e->value2; i++)
@@ -1359,7 +1359,7 @@ void aiDiverterDraw(AIEntity *e, int mx, int my) {
 			onScreen += g_hdb->_ai->_gfxLaserbeamLRLeft[frame]->drawMasked(i * kTileWidth - mx, e->y - my);
 			if (onScreen) {
 				g_hdb->_sound->playSoundEx(SND_LASER_LOOP, kLaserChannel, true);
-				warning("STUB: Set Laser onscreen to true");
+				g_hdb->_ai->_laserOnScreen = true;
 			}
 		}
 		break;
diff --git a/engines/hdb/ai-funcs.cpp b/engines/hdb/ai-funcs.cpp
index ed5183f..fd44017 100644
--- a/engines/hdb/ai-funcs.cpp
+++ b/engines/hdb/ai-funcs.cpp
@@ -923,7 +923,7 @@ void AI::animateEntity(AIEntity *e) {
 					e->touchpWait = kPlayerTouchPWait;
 				}
 			}
-			warning("STUB: animateEntity: Set laser_rescan to true");
+			_laserRescan = true;
 			break;
 		default:
 			debug(9, "animateEntity: Unintended Type");
@@ -1157,7 +1157,8 @@ void AI::animateEntity(AIEntity *e) {
 			case AI_MAGIC_EGG:
 			case AI_ICE_BLOCK:
 			case AI_DIVERTER:
-				warning("STUB: animateEntity: Set _laserRescan to true");
+				if (g_hdb->_map->laserBeamExist(e->tileX, e->tileY))
+					_laserRescan = true;
 				break;
 			default:
 				debug(9, "animateEntity: Unintended State");
diff --git a/engines/hdb/ai-init.cpp b/engines/hdb/ai-init.cpp
index 075096c..85fd370 100644
--- a/engines/hdb/ai-init.cpp
+++ b/engines/hdb/ai-init.cpp
@@ -786,6 +786,9 @@ bool AI::init() {
 	// laser beam
 	_gfxLaserbeamUD[0] = _gfxLaserbeamUD[1] = _gfxLaserbeamLR[0] = _gfxLaserbeamLR[1] = NULL;
 
+	_laserRescan = false;
+	_laserOnScreen = false;
+
 	_dummyPlayer.type = AI_GUY;
 	_dummyLaser.type = AI_LASERBEAM;
 	strcpy(_dummyPlayer.entityName, "Virtual Player");
diff --git a/engines/hdb/ai.h b/engines/hdb/ai.h
index 098b4d3..be55122 100644
--- a/engines/hdb/ai.h
+++ b/engines/hdb/ai.h
@@ -1209,6 +1209,9 @@ public:
 
 	TeleInfo _teleporters[kMaxTeleporters];
 	int _numTeleporters;
+	// Virtual Player
+	AIEntity _dummyPlayer, _dummyLaser;
+	bool _laserRescan, _laserOnScreen;
 
 	AutoAction _autoActions[kMaxAutoActions];
 
@@ -1223,9 +1226,6 @@ public:
 	Common::Array<HereT *> *_hereList;
 	Common::Array<Trigger *> *_triggerList;
 
-	// Virtual Player
-	AIEntity _dummyPlayer, _dummyLaser;
-
 	char _youGotBuffer[32];	// For printing the text of entities that are removed
 
 	// Cinematic Variables


Commit: 48546f3c8d24babf477c05671ec384706ab23654
    https://github.com/scummvm/scummvm/commit/48546f3c8d24babf477c05671ec384706ab23654
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:12+02:00

Commit Message:
HDB: Add laserScan()

Changed paths:
    engines/hdb/ai-funcs.cpp
    engines/hdb/ai.h


diff --git a/engines/hdb/ai-funcs.cpp b/engines/hdb/ai-funcs.cpp
index fd44017..266a71c 100644
--- a/engines/hdb/ai-funcs.cpp
+++ b/engines/hdb/ai-funcs.cpp
@@ -2044,6 +2044,19 @@ void AI::clearDiverters() {
 	}
 }
 
+void AI::laserScan() {
+	AIEntity *e;
+
+	clearDiverters();
+	g_hdb->_map->clearLaserBeams();
+
+	for (uint i = 0; i < _ents->size(); i++) {
+		e = _ents->operator[](i);
+		if (e->type == AI_LASER)
+			aiLaserAction(e);
+	}
+}
+
 void AI::floatEntity(AIEntity *e, AIState state) {
 	for (Common::Array<AIEntity *>::iterator it = _ents->begin(); it != _ents->end(); it++) {
 		if (e == *it) {
diff --git a/engines/hdb/ai.h b/engines/hdb/ai.h
index be55122..44e4f69 100644
--- a/engines/hdb/ai.h
+++ b/engines/hdb/ai.h
@@ -837,6 +837,7 @@ public:
 	bool checkPlayerTileCollision(int x, int y);
 	bool checkPlayerCollision(int x, int y, int border);
 	void clearDiverters();
+	void laserScan();
 
 	// List functions
 	void addToActionList(int actionIndex, int x, int y, char *funcLuaInit, char *funcLuaUse);


Commit: a27faf35b43ae19c679eb9e927aee0736b158b3a
    https://github.com/scummvm/scummvm/commit/a27faf35b43ae19c679eb9e927aee0736b158b3a
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:12+02:00

Commit Message:
HDB: Add Laser related stubs

Changed paths:
    engines/hdb/ai-funcs.cpp


diff --git a/engines/hdb/ai-funcs.cpp b/engines/hdb/ai-funcs.cpp
index 266a71c..9e95b73 100644
--- a/engines/hdb/ai-funcs.cpp
+++ b/engines/hdb/ai-funcs.cpp
@@ -1835,6 +1835,7 @@ void AI::entityFace(const char *luaName, int dir) {
 
 void AI::moveEnts() {
 	static int frameDelay = kAnimFrameDelay;
+	static int startLaserSound = false;
 	AIEntity *e;
 
 	if (frameDelay-- > 0)
@@ -1875,8 +1876,19 @@ void AI::moveEnts() {
 		}
 	}
 
-	debug(9, "STUB: moveEnts: Laser Rescan");
-	debug(9, "STUB: moveEnts: Laser Looping Sound Channel");
+	// if lasers need to rescan, do it here only
+	if (_laserRescan) {
+		_laserRescan = false;
+		laserScan();
+	}
+
+	// handle the constant laser looping sound channel
+	if (_laserOnScreen)
+		startLaserSound = true;
+	if (!_laserOnScreen && startLaserSound) {
+		startLaserSound = 0;
+		g_hdb->_sound->stopChannel(kLaserChannel);
+	}
 }
 
 bool AI::findPath(AIEntity *e) {


Commit: 7bf9cc945cfce45ed058c96a80a3b981e977148d
    https://github.com/scummvm/scummvm/commit/7bf9cc945cfce45ed058c96a80a3b981e977148d
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:12+02:00

Commit Message:
HDB: Add Laser functions

Changed paths:
    engines/hdb/ai-bots.cpp


diff --git a/engines/hdb/ai-bots.cpp b/engines/hdb/ai-bots.cpp
index 0f553b0..2168395 100644
--- a/engines/hdb/ai-bots.cpp
+++ b/engines/hdb/ai-bots.cpp
@@ -1223,12 +1223,214 @@ void aiDeadEyeAction(AIEntity *e) {
 		e->sequence = 64;
 }
 
+void aiLaserInit(AIEntity *e) {
+	e->aiDraw = aiLaserDraw;
+	e->value1 = e->value2 = 0;		// start & end of laser beam
+}
+
+void aiLaserInit2(AIEntity *e) {
+	e->draw = g_hdb->_ai->getStandFrameDir(e);
+	if (!g_hdb->_ai->_gfxLaserbeamUD[0]) {
+		char name[64];
+		int	i;
+		for (i = 0; i < 4; i++) {
+			sprintf(name, FORCEFIELD_UD"0%d", i + 1);
+			g_hdb->_ai->_gfxLaserbeamUD[i] = g_hdb->_gfx->loadTile(name);
+			sprintf(name, FORCESPLASH_TOP"0%d", i + 1);
+			g_hdb->_ai->_gfxLaserbeamUDTop[i] = g_hdb->_gfx->loadTile(name);
+			sprintf(name, FORCESPLASH_BTM"0%d", i + 1);
+			g_hdb->_ai->_gfxLaserbeamUDBottom[i] = g_hdb->_gfx->loadTile(name);
+			sprintf(name, FORCEFIELD_LR"0%d", i + 1);
+			g_hdb->_ai->_gfxLaserbeamLR[i] = g_hdb->_gfx->loadTile(name);
+			sprintf(name, FORCESPLASH_LEFT"0%d", i + 1);
+			g_hdb->_ai->_gfxLaserbeamLRLeft[i] = g_hdb->_gfx->loadTile(name);
+			sprintf(name, FORCESPLASH_RIGHT"0%d", i + 1);
+			g_hdb->_ai->_gfxLaserbeamLRRight[i] = g_hdb->_gfx->loadTile(name);
+		}
+	}
+}
+
 void aiLaserAction(AIEntity *e) {
-	warning("STUB: AI: aiLaserAction required");
+	int	xva[] = {9,0,0,-1,1}, yva[] = {9,-1,1,0,0};
+	int	nx, ny, moveOK;
+	AIEntity *hit;
+
+	hit = e;
+	do {
+		if (hit->type != AI_DIVERTER) {
+			hit->int1 = xva[hit->dir];
+			hit->int2 = yva[hit->dir];
+
+			nx = hit->tileX;
+			ny = hit->tileY;
+			if (hit->dir == DIR_UP || hit->dir == DIR_DOWN)
+				hit->value1 = ny;
+			else
+				hit->value1 = nx;
+		} else {
+			nx = hit->tileX;
+			ny = hit->tileY;
+			// diverter is on y-plane?
+			if (hit->tileX == e->tileX) {
+				hit->value1 = nx;
+				hit->int2 = 0;
+				switch (hit->dir2) {
+				case DIR_UP: hit->int1 = 1; break;
+				case DIR_DOWN: hit->int1 = -1; break;
+				case DIR_LEFT: hit->int1 = -1; break;
+				case DIR_RIGHT: hit->int1 = 1; break;
+				case DIR_NONE: break;
+				}
+			} else {
+				// diverter is on x-plane
+				hit->value1 = ny;
+				hit->int1 = 0;
+				switch (hit->dir2) {
+				case DIR_UP: hit->int2 = 1; break;
+				case DIR_DOWN: hit->int2 = 1; break;
+				case DIR_LEFT: hit->int2 = -1; break;
+				case DIR_RIGHT: hit->int2 = -1; break;
+				case DIR_NONE: break;
+				}
+			}
+		}
+		e = hit;
+
+		//
+		// scan for all legal moves
+		//
+		do {
+			nx += e->int1;
+			ny += e->int2;
+			hit = g_hdb->_ai->legalMoveOverWater(nx, ny, e->level, &moveOK);
+			g_hdb->_map->setLaserBeam(nx, ny, 1);
+			if (hit && hit->type != AI_LASERBEAM) {
+				//
+				// hit player = death
+				//
+				if (hit == g_hdb->_ai->getPlayer() && onEvenTile(hit->x, hit->y) && !g_hdb->_ai->playerDead())
+					g_hdb->_ai->killPlayer(DEATH_FRIED);
+				else if (hit->type == AI_BOOMBARREL && hit->state != STATE_EXPLODING && onEvenTile(hit->x, hit->y)) {
+					// hit BOOM BARREL = explodes
+
+					aiBarrelExplode(hit);
+					aiBarrelBlowup(hit, nx, ny);
+				} else if (hit->type == AI_LIGHTBARREL || hit->type == AI_HEAVYBARREL || hit->type == AI_CRATE) {
+					// hit LIGHT/HEAVY BARREL = blocking
+					moveOK = 0;
+				} else if (hit->type == AI_DIVERTER) {
+					// hit a diverter?
+					moveOK = 0;
+				} else if (onEvenTile(hit->x, hit->y) && hit != g_hdb->_ai->getPlayer()) {
+					switch (hit->type) {
+					case AI_VORTEXIAN:		// cannot kill Vortexians!
+						continue;
+
+					case AI_BOOMBARREL:
+						if (hit->state == STATE_EXPLODING)
+							continue;
+						break;
+					case AI_LASER:
+						g_hdb->_ai->_laserRescan = true;
+						break;
+
+					case ITEM_KEYCARD_WHITE:
+					case ITEM_KEYCARD_BLUE:
+					case ITEM_KEYCARD_RED:
+					case ITEM_KEYCARD_GREEN:
+					case ITEM_KEYCARD_PURPLE:
+					case ITEM_KEYCARD_BLACK:
+					case ITEM_CABKEY:
+						g_hdb->_window->centerTextOut("CARD DESTROYED!", 306, 5 * 60);
+						g_hdb->_sound->playSound(SND_QUEST_FAILED);
+						break;
+					default:
+						break;
+					}
+					g_hdb->_ai->removeEntity(hit);
+					g_hdb->_ai->addAnimateTarget(nx * kTileWidth,
+						ny * kTileHeight, 0, 3, ANIM_NORMAL, false, false, GROUP_EXPLOSION_BOOM_SIT);
+					g_hdb->_sound->playSound(SND_BARREL_EXPLODE);
+				}
+			}
+		} while (moveOK);
+
+		if (e->int2) {
+			e->value2 = ny;
+			// check for hitting the BACK of a Diverter.  It stops the laser.
+			if (hit && hit->type == AI_DIVERTER) {
+				if (e->int2 < 0 && hit->state != STATE_DIVERTER_BL && hit->state != STATE_DIVERTER_BR)
+					hit = NULL;
+				else if (e->int2 > 0 && hit->state != STATE_DIVERTER_TL && hit->state != STATE_DIVERTER_TR)
+					hit = NULL;
+			}
+		} else {
+			e->value2 = nx;
+			// check for hitting the BACK of a Diverter.  It stops the laser.
+			if (hit && hit->type == AI_DIVERTER) {
+				if (e->int1 < 0 && hit->state != STATE_DIVERTER_BR && hit->state != STATE_DIVERTER_TR)
+					hit = NULL;
+				else if (e->int1 > 0 && hit->state != STATE_DIVERTER_TL && hit->state != STATE_DIVERTER_BL)
+					hit = NULL;
+			}
+		}
+	} while (hit && hit->type == AI_DIVERTER);
 }
 
 void aiLaserDraw(AIEntity *e, int mx, int my) {
-	warning("STUB: AI: aiLaserDraw required");
+	int	i;
+	int	frame = e->movedownFrames & 3;
+	int onScreen = 0;
+
+	switch (e->dir) {
+	case DIR_UP:
+	{
+		for (i = e->value1 - 1; i > e->value2; i--)
+			onScreen += g_hdb->_ai->_gfxLaserbeamUD[frame]->drawMasked(e->x - mx, i*kTileWidth - my);
+		onScreen += g_hdb->_ai->_gfxLaserbeamUDBottom[frame & 3]->drawMasked(e->x - mx, i*kTileWidth - my);
+		if (onScreen) {
+			g_hdb->_sound->playSoundEx(SND_LASER_LOOP, kLaserChannel, true);
+			g_hdb->_ai->_laserOnScreen = true;
+		}
+	}
+		break;
+	case DIR_DOWN:
+	{
+		for (i = e->value1 + 1; i < e->value2; i++)
+			onScreen += g_hdb->_ai->_gfxLaserbeamUD[frame]->drawMasked(e->x - mx, i*kTileWidth - my);
+		onScreen += g_hdb->_ai->_gfxLaserbeamUDBottom[frame]->drawMasked(e->x - mx, i*kTileWidth - my);
+		if (onScreen) {
+			g_hdb->_sound->playSoundEx(SND_LASER_LOOP, kLaserChannel, true);
+			g_hdb->_ai->_laserOnScreen = true;
+		}
+	}
+		break;
+	case DIR_LEFT:
+	{
+		for (i = e->value1 - 1; i > e->value2; i--)
+			onScreen += g_hdb->_ai->_gfxLaserbeamLR[frame]->drawMasked(i*kTileWidth - mx, e->y - my);
+		onScreen += g_hdb->_ai->_gfxLaserbeamLRRight[frame]->drawMasked(i*kTileWidth - mx, e->y - my);
+		if (onScreen) {
+			g_hdb->_sound->playSoundEx(SND_LASER_LOOP, kLaserChannel, true);
+			g_hdb->_ai->_laserOnScreen = true;
+		}
+	}
+		break;
+	case DIR_RIGHT:
+	{
+		for (i = e->value1 + 1; i < e->value2; i++)
+			onScreen += g_hdb->_ai->_gfxLaserbeamLR[frame]->drawMasked(i*kTileWidth - mx, e->y - my);
+		onScreen += g_hdb->_ai->_gfxLaserbeamLRLeft[frame]->drawMasked(i*kTileWidth - mx, e->y - my);
+		if (onScreen) {
+			g_hdb->_sound->playSoundEx(SND_LASER_LOOP, kLaserChannel, true);
+			g_hdb->_ai->_laserOnScreen = true;
+		}
+	}
+		break;
+	default:
+		break;
+	}
+	e->movedownFrames++;
 }
 
 void aiDiverterInit(AIEntity *e) {
@@ -2806,12 +3008,4 @@ void aiDragonDraw(AIEntity *e, int mx, int my) {
 	}
 }
 
-void aiLaserInit(AIEntity *e) {
-	warning("STUB: AI: aiLaserInit required");
-}
-
-void aiLaserInit2(AIEntity *e) {
-	warning("STUB: AI: aiLaserInit2 required");
-}
-
 } // End of Namespace


Commit: 0d2f2f2bf7ff8bc8df8198a3e4634cab430437f4
    https://github.com/scummvm/scummvm/commit/0d2f2f2bf7ff8bc8df8198a3e4634cab430437f4
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:13+02:00

Commit Message:
HDB: Fix enity lists, and warn on missing files

Changed paths:
    engines/hdb/ai-funcs.cpp
    engines/hdb/ai-init.cpp


diff --git a/engines/hdb/ai-funcs.cpp b/engines/hdb/ai-funcs.cpp
index 9e95b73..bdbf997 100644
--- a/engines/hdb/ai-funcs.cpp
+++ b/engines/hdb/ai-funcs.cpp
@@ -98,6 +98,9 @@ bool AI::cacheEntGfx(AIEntity *e, bool init) {
 				Common::Array<const char *> *gfxFiles = g_hdb->_fileMan->findFiles(list[j].name, TYPE_TILE32);
 				uint32 size;
 
+				if (gfxFiles->size() == 0)
+					warning("AI::cacheEntGfx: no files for %s", list[j].name);
+
 				for (Common::Array<const char *>::iterator it = gfxFiles->begin(); it != gfxFiles->end(); it++) {
 					size = g_hdb->_fileMan->getLength((*it), TYPE_TILE32);
 
diff --git a/engines/hdb/ai-init.cpp b/engines/hdb/ai-init.cpp
index 85fd370..ede8b8e 100644
--- a/engines/hdb/ai-init.cpp
+++ b/engines/hdb/ai-init.cpp
@@ -35,43 +35,43 @@ AIStateDef none[] = {
 };
 
 AIStateDef guy[] = {
-	{ STATE_BLINK,		"ent_guy_blink" },
-	{ STATE_STANDDOWN,	"ent_guy_standdown" },
-	{ STATE_STANDUP,	"ent_guy_standup" },
-	{ STATE_STANDLEFT,	"ent_guy_standleft" },
-	{ STATE_STANDRIGHT,	"ent_guy_standright" },
-	{ STATE_MOVEDOWN,	"ent_guy_walkdown" },
-	{ STATE_MOVEUP,		"ent_guy_walkup" },
-	{ STATE_MOVELEFT,	"ent_guy_walkleft" },
-	{ STATE_MOVERIGHT,	"ent_guy_walkright" },
-	{ STATE_PUSHDOWN,	"ent_guy_pushdown" },
-	{ STATE_PUSHUP,		"ent_guy_pushup" },
-	{ STATE_PUSHLEFT,	"ent_guy_pushleft" },
-	{ STATE_PUSHRIGHT,	"ent_guy_pushright" },
-	{ STATE_GRABDOWN,	"ent_guy_getdown" },
-	{ STATE_GRABUP,		"ent_guy_getup" },
-	{ STATE_GRABLEFT,	"ent_guy_getleft" },
-	{ STATE_GRABRIGHT,	"ent_guy_getright" },
-	{ STATE_PLUMMET,		"ent_guy_plummet" },
-	{ STATE_ATK_STUN_DOWN,	"ent_guy_stundown" },
-	{ STATE_ATK_STUN_UP,	"ent_guy_stunup" },
-	{ STATE_ATK_STUN_LEFT,	"ent_guy_stunleft" },
-	{ STATE_ATK_STUN_RIGHT,	"ent_guy_stunright" },
-	{ STATE_ATK_SLUG_DOWN,	"ent_guy_slingdown" },
-	{ STATE_ATK_SLUG_UP,	"ent_guy_slingup" },
-	{ STATE_ATK_SLUG_LEFT,	"ent_guy_slingleft" },
-	{ STATE_ATK_SLUG_RIGHT,	"ent_guy_slingright" },
-	{ STATE_DYING,		"ent_guy_die" },
-	{ STATE_HORRIBLE1,	"ent_guy_horrible1" },
-	{ STATE_HORRIBLE2,	"ent_guy_horrible2" },
-	{ STATE_HORRIBLE3,	"ent_guy_horrible3" },
-	{ STATE_HORRIBLE4,	"ent_guy_horrible4" },
-	{ STATE_GOODJOB,	"ent_guy_goodjob" },
-	{ STATE_ENDSTATES, "" }
+	{ STATE_BLINK,          GROUP_ENT_GUY_BLINK },
+	{ STATE_STANDDOWN,      GROUP_ENT_GUY_STANDDOWN },
+	{ STATE_STANDUP,        GROUP_ENT_GUY_STANDUP },
+	{ STATE_STANDLEFT,      GROUP_ENT_GUY_STANDLEFT },
+	{ STATE_STANDRIGHT,     GROUP_ENT_GUY_STANDRIGHT },
+	{ STATE_MOVEDOWN,       GROUP_ENT_GUY_WALKDOWN },
+	{ STATE_MOVEUP,         GROUP_ENT_GUY_WALKUP },
+	{ STATE_MOVELEFT,       GROUP_ENT_GUY_WALKLEFT },
+	{ STATE_MOVERIGHT,      GROUP_ENT_GUY_WALKRIGHT },
+	{ STATE_PUSHDOWN,       GROUP_ENT_GUY_PUSHDOWN },
+	{ STATE_PUSHUP,         GROUP_ENT_GUY_PUSHUP },
+	{ STATE_PUSHLEFT,       GROUP_ENT_GUY_PUSHLEFT },
+	{ STATE_PUSHRIGHT,      GROUP_ENT_GUY_PUSHRIGHT },
+	{ STATE_GRABDOWN,       GROUP_ENT_GUY_GETDOWN },
+	{ STATE_GRABUP,         GROUP_ENT_GUY_GETUP },
+	{ STATE_GRABLEFT,       GROUP_ENT_GUY_GETLEFT },
+	{ STATE_GRABRIGHT,      GROUP_ENT_GUY_GETRIGHT },
+	{ STATE_PLUMMET,        GROUP_ENT_GUY_PLUMMET },
+	{ STATE_ATK_STUN_DOWN,  GROUP_ENT_GUY_STUNDOWN },
+	{ STATE_ATK_STUN_UP,    GROUP_ENT_GUY_STUNUP },
+	{ STATE_ATK_STUN_LEFT,  GROUP_ENT_GUY_STUNLEFT },
+	{ STATE_ATK_STUN_RIGHT, GROUP_ENT_GUY_STUNRIGHT },
+	{ STATE_ATK_SLUG_DOWN,  GROUP_ENT_GUY_SLINGDOWN },
+	{ STATE_ATK_SLUG_UP,    GROUP_ENT_GUY_SLINGUP },
+	{ STATE_ATK_SLUG_LEFT,  GROUP_ENT_GUY_SLINGLEFT },
+	{ STATE_ATK_SLUG_RIGHT, GROUP_ENT_GUY_SLINGRIGHT },
+	{ STATE_DYING,          GROUP_ENT_GUY_DIE },
+	{ STATE_HORRIBLE1,      GROUP_ENT_GUY_HORRIBLE1 },
+	{ STATE_HORRIBLE2,      GROUP_ENT_GUY_HORRIBLE2 },
+	{ STATE_HORRIBLE3,      GROUP_ENT_GUY_HORRIBLE3 },
+	{ STATE_HORRIBLE4,      GROUP_ENT_GUY_HORRIBLE4 },
+	{ STATE_GOODJOB,        GROUP_ENT_GUY_GOODJOB },
+	{ STATE_ENDSTATES, "" }                            // end of list indicator
 };
 
 AIStateDef gemAttack[] = {
-	{ STATE_MOVEDOWN, "ent_gem_white_sit" },
+	{ STATE_MOVEDOWN,       GROUP_ENT_GEM_WHITE_SIT },
 	{ STATE_ENDSTATES, "" }
 };
 
@@ -80,224 +80,225 @@ AIStateDef slugAttack[] = {
 };
 
 AIStateDef dolly[] = {
-	{ STATE_MOVEDOWN,	"ent_sergeant_walkdown" },
-	{ STATE_MOVEUP,		"ent_sergeant_walkup" },
-	{ STATE_MOVELEFT,	"ent_sergeant_walkleft" },
-	{ STATE_MOVERIGHT,	"ent_sergeant_walkright" },
-	{ STATE_DOLLYUSERIGHT, "ent_sergeant_userright" },
-	{ STATE_KISSRIGHT,	"ent_sergeant_kissright" },
-	{ STATE_KISSLEFT,	"ent_sergeant_kissleft" },
-	{ STATE_ANGRY,		"ent_sergeant_angry"},
-	{ STATE_LAUGH,		"ent_sergeant_laugh" },
-	{ STATE_PANIC,		"ent_sergeant_panic" },
+	{ STATE_MOVEDOWN,       GROUP_ENT_DOLLY_WALKDOWN },
+	{ STATE_MOVEUP,         GROUP_ENT_DOLLY_WALKUP },
+	{ STATE_MOVELEFT,       GROUP_ENT_DOLLY_WALKLEFT },
+	{ STATE_MOVERIGHT,      GROUP_ENT_DOLLY_WALKRIGHT },
+	{ STATE_DOLLYUSERIGHT, GROUP_ENT_DOLLY_USERIGHT },
+	{ STATE_KISSRIGHT,      GROUP_ENT_DOLLY_KISSRIGHT },
+	{ STATE_KISSLEFT,       GROUP_ENT_DOLLY_KISSLEFT },
+	{ STATE_ANGRY,          GROUP_ENT_DOLLY_ANGRY },
+	{ STATE_LAUGH,          GROUP_ENT_DOLLY_LAUGH },
+	{ STATE_PANIC,          GROUP_ENT_DOLLY_PANIC },
 	{ STATE_ENDSTATES, "" }
 };
 
 AIStateDef sergeant[] = {
-	{ STATE_STANDDOWN,	"ent_sergeant_standdown" },
-	{ STATE_STANDUP,	"ent_sergeant_standup" },
-	{ STATE_STANDLEFT,	"ent_sergeant_standleft" },
-	{ STATE_STANDRIGHT,	"ent_sergeant_standright" },
-	{ STATE_YELL,		"ent_sergeant_yell" },
-	{ STATE_MOVEDOWN,	"ent_sergeant_walkdown" },
-	{ STATE_MOVEUP,		"ent_sergeant_walkup" },
-	{ STATE_MOVELEFT,	"ent_sergeant_walkleft" },
-	{ STATE_MOVERIGHT,	"ent_sergeant_walkright" },
+	{ STATE_STANDDOWN,      GROUP_ENT_SERGEANT_STANDDOWN },
+	{ STATE_STANDUP,        GROUP_ENT_SERGEANT_STANDUP },
+	{ STATE_STANDLEFT,      GROUP_ENT_SERGEANT_STANDLEFT },
+	{ STATE_STANDRIGHT,     GROUP_ENT_SERGEANT_STANDRIGHT },
+	{ STATE_YELL,           GROUP_ENT_SERGEANT_YELL },
+	{ STATE_MOVEDOWN,       GROUP_ENT_SERGEANT_WALKDOWN },
+	{ STATE_MOVEUP,         GROUP_ENT_SERGEANT_WALKUP },
+	{ STATE_MOVELEFT,       GROUP_ENT_SERGEANT_WALKLEFT },
+	{ STATE_MOVERIGHT,      GROUP_ENT_SERGEANT_WALKRIGHT },
 	{ STATE_ENDSTATES, "" }
 };
 
 AIStateDef spacedude[] = {
-	{ STATE_MOVEDOWN,	"ent_spacedude_walkdown" },
-	{ STATE_MOVEUP,		"ent_spacedude_walkup" },
-	{ STATE_MOVELEFT,	"ent_spacedude_walkleft" },
-	{ STATE_MOVERIGHT,	"ent_spacedude_walkright" },
+	{ STATE_MOVEDOWN,       GROUP_ENT_SPACEDUDE_WALKDOWN },
+	{ STATE_MOVEUP,         GROUP_ENT_SPACEDUDE_WALKUP },
+	{ STATE_MOVELEFT,       GROUP_ENT_SPACEDUDE_WALKLEFT },
+	{ STATE_MOVERIGHT,      GROUP_ENT_SPACEDUDE_WALKRIGHT },
 	{ STATE_ENDSTATES, "" }
 };
 
 AIStateDef chicken[] = {
-	{ STATE_STANDDOWN,	"ent_chicken_standdown" },
-	{ STATE_STANDUP,		"ent_chicken_standup" },
-	{ STATE_STANDLEFT,	"ent_chicken_standleft" },
-	{ STATE_STANDRIGHT,	"ent_chicken_standright" },
-	{ STATE_MOVEDOWN,	"ent_chicken_walkdown" },
-	{ STATE_MOVEUP,		"ent_chicken_walkup" },
-	{ STATE_MOVELEFT,	"ent_chicken_walkleft" },
-	{ STATE_MOVERIGHT,	"ent_chicken_walkright" },
+	{ STATE_STANDDOWN,      GROUP_ENT_CHICKEN_STANDDOWN },
+	{ STATE_STANDUP,        GROUP_ENT_CHICKEN_STANDUP },
+	{ STATE_STANDLEFT,      GROUP_ENT_CHICKEN_STANDLEFT },
+	{ STATE_STANDRIGHT,     GROUP_ENT_CHICKEN_STANDRIGHT },
+	{ STATE_MOVEDOWN,       GROUP_ENT_CHICKEN_WALKDOWN },
+	{ STATE_MOVEUP,         GROUP_ENT_CHICKEN_WALKUP },
+	{ STATE_MOVELEFT,       GROUP_ENT_CHICKEN_WALKLEFT },
+	{ STATE_MOVERIGHT,      GROUP_ENT_CHICKEN_WALKRIGHT },
 	{ STATE_ENDSTATES, "" }
 };
 
 AIStateDef vortexian[] = {
-	{ STATE_STANDDOWN, "ent_vortexian_standdown" },
+	{ STATE_STANDDOWN,      GROUP_ENT_VORTEXIAN_STANDDOWN },
 	{ STATE_ENDSTATES, "" }
 };
 
 AIStateDef maintBot[] = {
-	{ STATE_STANDDOWN,	"ent_maintbot_standdown" },
-	{ STATE_STANDUP,	"ent_maintbot_standup" },
-	{ STATE_STANDLEFT,	"ent_maintbot_standleft" },
-	{ STATE_STANDRIGHT,	"ent_maintbot_standright" },
-	{ STATE_MOVEDOWN,	"ent_maintbot_walkdown" },
-	{ STATE_MOVEUP,		"ent_maintbot_walkup" },
-	{ STATE_MOVELEFT,	"ent_maintbot_walkleft" },
-	{ STATE_MOVERIGHT,	"ent_maintbot_walkright" },
-	{ STATE_USEDOWN,	"ent_maintbot_usedown" },
-	{ STATE_USEUP,		"ent_maintbot_useup" },
-	{ STATE_USELEFT,	"ent_maintbot_useleft" },
-	{ STATE_USERIGHT,	"ent_maintbot_useright" },
+	{ STATE_STANDDOWN,      GROUP_ENT_MAINTBOT_STANDDOWN },
+	{ STATE_STANDUP,        GROUP_ENT_MAINTBOT_STANDUP },
+	{ STATE_STANDLEFT,      GROUP_ENT_MAINTBOT_STANDLEFT },
+	{ STATE_STANDRIGHT,     GROUP_ENT_MAINTBOT_STANDRIGHT },
+	{ STATE_MOVEDOWN,       GROUP_ENT_MAINTBOT_WALKDOWN },
+	{ STATE_MOVEUP,         GROUP_ENT_MAINTBOT_WALKUP },
+	{ STATE_MOVELEFT,       GROUP_ENT_MAINTBOT_WALKLEFT },
+	{ STATE_MOVERIGHT,      GROUP_ENT_MAINTBOT_WALKRIGHT },
+	{ STATE_USEDOWN,        GROUP_ENT_MAINTBOT_USEDOWN },
+	{ STATE_USEUP,          GROUP_ENT_MAINTBOT_USEUP },
+	{ STATE_USELEFT,        GROUP_ENT_MAINTBOT_USELEFT },
+	{ STATE_USERIGHT,       GROUP_ENT_MAINTBOT_USERIGHT },
 	{ STATE_ENDSTATES, "" }
 };
 
 AIStateDef scientist[] = {
-	{ STATE_BLINK,		"ent_scientist_blink" },
-	{ STATE_STANDDOWN,	"ent_scientist_standdown" },
-	{ STATE_STANDUP,	"ent_scientist_standup" },
-	{ STATE_STANDLEFT,	"ent_scientist_standleft" },
-	{ STATE_STANDRIGHT,	"ent_scientist_standright" },
-	{ STATE_MOVEDOWN,	"ent_scientist_walkdown" },
-	{ STATE_MOVEUP,		"ent_scientist_walkup" },
-	{ STATE_MOVELEFT,	"ent_scientist_walkleft" },
-	{ STATE_MOVERIGHT,	"ent_scientist_walkright" },
+	{ STATE_BLINK,          GROUP_ENT_SCIENTIST_BLINK },
+	{ STATE_STANDDOWN,      GROUP_ENT_SCIENTIST_STANDDOWN },
+	{ STATE_STANDUP,        GROUP_ENT_SCIENTIST_STANDUP },
+	{ STATE_STANDLEFT,      GROUP_ENT_SCIENTIST_STANDLEFT },
+	{ STATE_STANDRIGHT,     GROUP_ENT_SCIENTIST_STANDRIGHT },
+	{ STATE_MOVEDOWN,       GROUP_ENT_SCIENTIST_WALKDOWN },
+	{ STATE_MOVEUP,         GROUP_ENT_SCIENTIST_WALKUP },
+	{ STATE_MOVELEFT,       GROUP_ENT_SCIENTIST_WALKLEFT },
+	{ STATE_MOVERIGHT,      GROUP_ENT_SCIENTIST_WALKRIGHT },
 	{ STATE_ENDSTATES, "" }
 };
 
 AIStateDef worker[] = {
-	{ STATE_BLINK,		"ent_worker_blink" },
-	{ STATE_STANDDOWN,	"ent_worker_standdown" },
-	{ STATE_STANDUP,	"ent_worker_standup" },
-	{ STATE_STANDLEFT,	"ent_worker_standleft" },
-	{ STATE_STANDRIGHT,	"ent_worker_standright" },
-	{ STATE_MOVEDOWN,	"ent_worker_walkdown" },
-	{ STATE_MOVEUP,		"ent_worker_walkup" },
-	{ STATE_MOVELEFT,	"ent_worker_walkleft" },
-	{ STATE_MOVERIGHT,	"ent_worker_walkright" },
+	{ STATE_BLINK,          GROUP_ENT_WORKER_BLINK },
+	{ STATE_STANDDOWN,      GROUP_ENT_WORKER_STANDDOWN },
+	{ STATE_STANDUP,        GROUP_ENT_WORKER_STANDUP },
+	{ STATE_STANDLEFT,      GROUP_ENT_WORKER_STANDLEFT },
+	{ STATE_STANDRIGHT,     GROUP_ENT_WORKER_STANDRIGHT },
+	{ STATE_MOVEDOWN,       GROUP_ENT_WORKER_WALKDOWN },
+	{ STATE_MOVEUP,         GROUP_ENT_WORKER_WALKUP },
+	{ STATE_MOVELEFT,       GROUP_ENT_WORKER_WALKLEFT },
+	{ STATE_MOVERIGHT,      GROUP_ENT_WORKER_WALKRIGHT },
 	{ STATE_ENDSTATES, "" }
 };
 
 AIStateDef deadWorker[] = {
-	{ STATE_STANDDOWN, "ent_dead_worker_sit" },
+	{ STATE_STANDDOWN,      GROUP_ENT_DEAD_WORKER_SIT },
 	{ STATE_ENDSTATES, "" }
 };
 
 AIStateDef accountant[] = {
-	{ STATE_STANDDOWN,	"ent_accountant_standdown" },
-	{ STATE_STANDUP,	"ent_accountant_standup" },
-	{ STATE_STANDLEFT,	"ent_accountant_standleft" },
-	{ STATE_STANDRIGHT,	"ent_accountant_standright" },
+	{ STATE_STANDDOWN,      GROUP_ENT_ACCOUNTANT_STANDDOWN },
+	{ STATE_STANDUP,        GROUP_ENT_ACCOUNTANT_STANDUP },
+	{ STATE_STANDLEFT,      GROUP_ENT_ACCOUNTANT_STANDLEFT },
+	{ STATE_STANDRIGHT,     GROUP_ENT_ACCOUNTANT_STANDRIGHT },
 	{ STATE_ENDSTATES, "" }
 };
 
 // Enemies
 
 AIStateDef pushBot[] = {
-	{ STATE_MOVEDOWN,	"ent_pushbot_walkdown" },
-	{ STATE_MOVEUP,		"ent_pushbot_walkup" },
-	{ STATE_MOVELEFT,	"ent_pushbot_walkleft" },
-	{ STATE_MOVERIGHT,	"ent_pushbot_walkright" },
+	{ STATE_MOVEDOWN,       GROUP_ENT_PUSHBOT_WALKDOWN },
+	{ STATE_MOVEUP,         GROUP_ENT_PUSHBOT_WALKUP },
+	{ STATE_MOVELEFT,       GROUP_ENT_PUSHBOT_WALKLEFT },
+	{ STATE_MOVERIGHT,      GROUP_ENT_PUSHBOT_WALKRIGHT },
 	{ STATE_ENDSTATES, "" }
 };
 
 AIStateDef rightBot[] = {
-	{ STATE_MOVEDOWN,	"ent_rightbot_walkdown" },
-	{ STATE_MOVEUP,		"ent_rightbot_walkup" },
-	{ STATE_MOVELEFT,	"ent_rightbot_walkleft" },
-	{ STATE_MOVERIGHT,	"ent_rightbot_walkright" },
+	{ STATE_MOVEDOWN,       GROUP_ENT_RIGHTBOT_WALKDOWN },
+	{ STATE_MOVEUP,         GROUP_ENT_RIGHTBOT_WALKUP },
+	{ STATE_MOVELEFT,       GROUP_ENT_RIGHTBOT_WALKLEFT },
+	{ STATE_MOVERIGHT,      GROUP_ENT_RIGHTBOT_WALKRIGHT },
 	{ STATE_ENDSTATES, "" }
 };
 
 AIStateDef omniBot[] = {
-	{ STATE_MOVEDOWN,	"ent_omnibot_walkdown" },
-	{ STATE_MOVEUP,		"ent_omnibot_walkup" },
-	{ STATE_MOVELEFT,	"ent_omnibot_walkleft" },
-	{ STATE_MOVERIGHT,	"ent_omnibot_walkright" },
+	{ STATE_MOVEDOWN,       GROUP_ENT_OMNIBOT_WALKDOWN },
+	{ STATE_MOVEUP,         GROUP_ENT_OMNIBOT_WALKUP },
+	{ STATE_MOVELEFT,       GROUP_ENT_OMNIBOT_WALKLEFT },
+	{ STATE_MOVERIGHT,      GROUP_ENT_OMNIBOT_WALKRIGHT },
 	{ STATE_ENDSTATES, "" }
 };
 
 AIStateDef laser[] = {
-	{ STATE_STANDDOWN,	"ent_laser_down" },
-	{ STATE_STANDUP,	"ent_laser_up" },
-	{ STATE_STANDLEFT,	"ent_laser_left" },
-	{ STATE_STANDRIGHT,	"ent_laser_right" },
+	{ STATE_STANDRIGHT,     GROUP_ENT_LASER_RIGHT },
+	{ STATE_STANDLEFT,      GROUP_ENT_LASER_LEFT },
+	{ STATE_STANDUP,        GROUP_ENT_LASER_UP },
+	{ STATE_STANDDOWN,      GROUP_ENT_LASER_DOWN },
 	{ STATE_ENDSTATES, "" }
 };
 
 AIStateDef diverter[] = {
-	{ STATE_DIVERTER_BL,	"ent_deflectorbl_sit" },
-	{ STATE_DIVERTER_BR,	"ent_deflectorbr_sit" },
-	{ STATE_DIVERTER_TL,	"ent_deflectortl_sit" },
-	{ STATE_DIVERTER_TR,	"ent_deflectortr_sit" },
+	{ STATE_DIVERTER_BL,    GROUP_ENT_DEFLECTORBL_SIT },
+	{ STATE_DIVERTER_BR,    GROUP_ENT_DEFLECTORBR_SIT },
+	{ STATE_DIVERTER_TL,    GROUP_ENT_DEFLECTORTL_SIT },
+	{ STATE_DIVERTER_TR,    GROUP_ENT_DEFLECTORTR_SIT },
 	{ STATE_ENDSTATES, "" }
 };
 
 AIStateDef turnBot[] = {
-	{ STATE_MOVEDOWN,	"ent_turnbot_walkdown" },
-	{ STATE_MOVEUP,		"ent_turnbot_walkup" },
-	{ STATE_MOVELEFT,	"ent_turnbot_walkleft" },
-	{ STATE_MOVERIGHT,	"ent_turnbot_walkright" },
+	{ STATE_MOVEDOWN,       GROUP_ENT_TURNBOT_WALKDOWN },
+	{ STATE_MOVEUP,         GROUP_ENT_TURNBOT_WALKUP },
+	{ STATE_MOVELEFT,       GROUP_ENT_TURNBOT_WALKLEFT },
+	{ STATE_MOVERIGHT,      GROUP_ENT_TURNBOT_WALKRIGHT },
 	{ STATE_ENDSTATES, "" }
 };
 
 AIStateDef deadEye[] = {
-	{ STATE_MOVEDOWN,	"ent_deadeye_walkdown" },
-	{ STATE_MOVEUP,		"ent_deadeye_walkup" },
-	{ STATE_MOVELEFT,	"ent_deadeye_walkleft" },
-	{ STATE_MOVERIGHT,	"ent_deadeye_walkright" },
+	{ STATE_MOVEDOWN,       GROUP_ENT_DEADEYE_WALKDOWN },
+	{ STATE_MOVEUP,         GROUP_ENT_DEADEYE_WALKUP },
+	{ STATE_MOVELEFT,       GROUP_ENT_DEADEYE_WALKLEFT },
+	{ STATE_MOVERIGHT,      GROUP_ENT_DEADEYE_WALKRIGHT },
 	{ STATE_ENDSTATES, "" }
 };
 
 AIStateDef meerkat[] = {
-	{ STATE_MEER_MOVE,		"ent_meerkat_dirtmove" },
-	{ STATE_MEER_APPEAR,	"ent_meerkat_appear" },
-	{ STATE_MEER_BITE,		"ent_meerkat_bite" },
-	{ STATE_MEER_DISAPPEAR, "ent_meerkat_disappear" },
-	{ STATE_MEER_LOOK,		"ent_meerkat_look" },
+	{ STATE_MEER_MOVE,      GROUP_ENT_MEERKAT_DIRTMOVE },
+	{ STATE_MEER_APPEAR,    GROUP_ENT_MEERKAT_APPEAR },
+	{ STATE_MEER_BITE,      GROUP_ENT_MEERKAT_BITE },
+	{ STATE_MEER_DISAPPEAR, GROUP_ENT_MEERKAT_DISAPPEAR },
+	{ STATE_MEER_LOOK,      GROUP_ENT_MEERKAT_LOOK },
+	{ STATE_ENDSTATES, "" }
 };
 
 AIStateDef goodFairy[] = {
-	{ STATE_MOVEDOWN,	"ent_goodfairy_walkdown" },
-	{ STATE_MOVEUP,		"ent_goodfairy_walkup" },
-	{ STATE_MOVELEFT,	"ent_goodfairy_walkleft" },
-	{ STATE_MOVERIGHT,	"ent_goodfairy_walkright" },
+	{ STATE_MOVEDOWN,       GROUP_ENT_GOODFAIRY_WALKDOWN },
+	{ STATE_MOVEUP,         GROUP_ENT_GOODFAIRY_WALKUP },
+	{ STATE_MOVELEFT,       GROUP_ENT_GOODFAIRY_WALKLEFT },
+	{ STATE_MOVERIGHT,      GROUP_ENT_GOODFAIRY_WALKRIGHT },
 	{ STATE_ENDSTATES, "" }
 };
 
 AIStateDef badFairy[] = {
-	{ STATE_MOVEDOWN,	"ent_badfairy_walkdown" },
-	{ STATE_MOVEUP,		"ent_badfairy_walkup" },
-	{ STATE_MOVELEFT,	"ent_badfairy_walkleft" },
-	{ STATE_MOVERIGHT,	"ent_badfairy_walkright" },
+	{ STATE_MOVEDOWN,       GROUP_ENT_BADFAIRY_WALKDOWN },
+	{ STATE_MOVEUP,         GROUP_ENT_BADFAIRY_WALKUP },
+	{ STATE_MOVELEFT,       GROUP_ENT_BADFAIRY_WALKLEFT },
+	{ STATE_MOVERIGHT,      GROUP_ENT_BADFAIRY_WALKRIGHT },
 	{ STATE_ENDSTATES, "" }
 };
 
 AIStateDef gatePuddle[] = {
-	{ STATE_MOVEDOWN, "ent_gatepuddle_standdown"},
+	{ STATE_MOVEDOWN,       GROUP_ENT_GATEPUDDLE_STANDDOWN },
 	{ STATE_ENDSTATES, "" }
 };
 
 AIStateDef icePuff[] = {
-	{ STATE_ICEP_PEEK,			"ent_icepuff_peek" },
-	{ STATE_ICEP_APPEAR,		"ent_icepuff_appear" },
-	{ STATE_ICEP_THROWDOWN,		"ent_icepuff_throwdown" },
-	{ STATE_ICEP_THROWRIGHT,	"ent_icepuff_throwright" },
-	{ STATE_ICEP_THROWLEFT,		"ent_icepuff_throwleft" },
-	{ STATE_ICEP_DISAPPEAR,		"ent_icepuff_disappear" },
+	{ STATE_ICEP_PEEK,      GROUP_ENT_ICEPUFF_PEEK },
+	{ STATE_ICEP_APPEAR,    GROUP_ENT_ICEPUFF_APPEAR },
+	{ STATE_ICEP_THROWDOWN, GROUP_ENT_ICEPUFF_THROWDOWN },
+	{ STATE_ICEP_THROWRIGHT,GROUP_ENT_ICEPUFF_THROWRIGHT },
+	{ STATE_ICEP_THROWLEFT, GROUP_ENT_ICEPUFF_THROWLEFT },
+	{ STATE_ICEP_DISAPPEAR, GROUP_ENT_ICEPUFF_DISAPPEAR },
 	{ STATE_ENDSTATES, "" }
 };
 
 AIStateDef buzzfly[] = {
-	{ STATE_MOVEDOWN,	"ent_buzzfly_walkdown" },
-	{ STATE_MOVEUP,		"ent_buzzfly_walkup" },
-	{ STATE_MOVELEFT,	"ent_buzzfly_walkleft" },
-	{ STATE_MOVERIGHT,	"ent_buzzfly_walkright" },
+	{ STATE_MOVEDOWN,      GROUP_ENT_BUZZFLY_WALKDOWN },
+	{ STATE_MOVEUP,        GROUP_ENT_BUZZFLY_WALKUP },
+	{ STATE_MOVELEFT,      GROUP_ENT_BUZZFLY_WALKLEFT },
+	{ STATE_MOVERIGHT,     GROUP_ENT_BUZZFLY_WALKRIGHT },
 	{ STATE_ENDSTATES, "" }
 };
 
 AIStateDef fatFrog[] = {
-	{ STATE_STANDDOWN,	"ent_fatfrog_standdown" },
-	{ STATE_STANDLEFT,	"ent_fatfrog_standleft" },
-	{ STATE_STANDRIGHT,	"ent_fatfrog_standright" },
-	{ STATE_LICKDOWN,	"ent_fatfrog_lickdown" },
-	{ STATE_LICKLEFT,	"ent_fatfrog_lickleft" },
-	{ STATE_LICKRIGHT,	"ent_fatfrog_lickright" },
+	{ STATE_STANDDOWN,              GROUP_ENT_FATFROG_STANDDOWN },
+	{ STATE_STANDLEFT,              GROUP_ENT_FATFROG_STANDLEFT },
+	{ STATE_STANDRIGHT,             GROUP_ENT_FATFROG_STANDRIGHT },
+	{ STATE_LICKDOWN,               GROUP_ENT_FATFROG_LICKDOWN },
+	{ STATE_LICKLEFT,               GROUP_ENT_FATFROG_LICKLEFT },
+	{ STATE_LICKRIGHT,              GROUP_ENT_FATFROG_LICKRIGHT },
 	{ STATE_ENDSTATES, "" }
 };
 
@@ -305,272 +306,276 @@ AIStateDef dragon[] = {
 	{ STATE_ENDSTATES, "" }
 };
 
+// These are in the demo
+
 AIStateDef omniBotMissile[] = {
-	{ STATE_MOVEDOWN, "ent_omnibot_missile"},
+	{ STATE_MOVEDOWN,       GROUP_ENT_OMNIBOT_MISSILE },
 	{ STATE_ENDSTATES, "" }
 };
 
 AIStateDef fourFirer[] = {
-	{ STATE_STANDDOWN,	"ent_four_laser_down" },
-	{ STATE_STANDUP,	"ent_four_laser_up" },
-	{ STATE_STANDLEFT,	"ent_four_laser_left" },
-	{ STATE_STANDRIGHT,	"ent_four_laser_right" },
+	{ STATE_STANDDOWN,      GROUP_ENT_FOUR_LASER_DOWN },
+	{ STATE_STANDUP,        GROUP_ENT_FOUR_LASER_UP },
+	{ STATE_STANDLEFT,      GROUP_ENT_FOUR_LASER_LEFT },
+	{ STATE_STANDRIGHT,     GROUP_ENT_FOUR_LASER_RIGHT },
 	{ STATE_ENDSTATES, "" }
 };
 
 AIStateDef railRider[] = {
-	{ STATE_STANDDOWN,	"ent_railrider_standdown" },
-	{ STATE_STANDUP,	"ent_railrider_standup" },
-	{ STATE_MOVEDOWN,	"ent_railrider_walkdown" },
-	{ STATE_MOVEUP,		"ent_railrider_walkup" },
-	{ STATE_MOVELEFT,	"ent_railrider_walkleft" },
-	{ STATE_MOVERIGHT,	"ent_railrider_walkright" },
+	{ STATE_STANDDOWN,      GROUP_ENT_RAILRIDER_STANDDOWN },
+	{ STATE_STANDUP,        GROUP_ENT_RAILRIDER_STANDUP },
+	{ STATE_MOVEDOWN,       GROUP_ENT_RAILRIDER_WALKDOWN },
+	{ STATE_MOVEUP,         GROUP_ENT_RAILRIDER_WALKUP },
+	{ STATE_MOVELEFT,       GROUP_ENT_RAILRIDER_WALKLEFT },
+	{ STATE_MOVERIGHT,      GROUP_ENT_RAILRIDER_WALKRIGHT },
 	{ STATE_ENDSTATES, "" }
 };
 
 AIStateDef shockBot[] = {
-	{ STATE_MOVEDOWN, "ent_shockbot_walk" },
-	{ STATE_SHOCKING, "ent_shock_spark_sit" },
+	{ STATE_MOVEDOWN,       GROUP_ENT_SHOCKBOT_WALK },
+	{ STATE_SHOCKING,       GROUP_SHOCK_SPARK_SIT },
 	{ STATE_ENDSTATES, "" }
 };
 
 // Pushables
 
 AIStateDef crate[] = {
-	{ STATE_STANDDOWN,	"ent_crate_sit" },
-	{ STATE_FLOATING,	"ent_crate_float" },
+	{ STATE_STANDDOWN,      GROUP_ENT_CRATE_SIT },
+	{ STATE_FLOATING,       GROUP_ENT_CRATE_FLOAT },
 	{ STATE_ENDSTATES, "" }
 };
 
 AIStateDef barrelLight[] = {
-	{ STATE_STANDDOWN,	"ent_barrel_light_sit" },
-	{ STATE_FLOATING,	"ent_barrel_light_float" },
-	{ STATE_MELTED,		"ent_barrel_light_melt" },
+	{ STATE_FLOATING,       GROUP_ENT_BARREL_LIGHT_FLOAT },
+	{ STATE_MELTED,         GROUP_ENT_BARREL_LIGHT_MELT },
+	{ STATE_STANDDOWN,      GROUP_ENT_BARREL_LIGHT_SIT },
 	{ STATE_ENDSTATES, "" }
 };
 
 AIStateDef barrelHeavy[] = {
-	{ STATE_STANDDOWN,	"ent_barrel_heavy_sit" },
-	{ STATE_FLOATING,	"ent_barrel_heavy_float" },
-	{ STATE_MELTED,		"ent_barrel_heavy_melt" },
+	{ STATE_FLOATING,       GROUP_ENT_BARREL_HEAVY_FLOAT },
+	{ STATE_MELTED,         GROUP_ENT_BARREL_HEAVY_MELT },
+	{ STATE_STANDDOWN,      GROUP_ENT_BARREL_HEAVY_SIT },
 	{ STATE_ENDSTATES, "" }
 };
 
 AIStateDef barrelExplode[] = {
-	{ STATE_STANDDOWN,	"ent_barrel_explode_sit" },
-	{ STATE_EXPLODING,	"explosion_boom_sit" },
+	{ STATE_EXPLODING,      GROUP_EXPLOSION_BOOM_SIT },
+	{ STATE_STANDDOWN,      GROUP_ENT_BARREL_EXPLODE_SIT },
 	{ STATE_ENDSTATES, "" }
 };
 
 AIStateDef frogStatue[] = {
-	{ STATE_STANDDOWN,	"ent_frogstatue_sit" },
+	{ STATE_STANDDOWN,      GROUP_ENT_FROGSTATUE_SIT },
 	{ STATE_ENDSTATES, "" }
 };
 
 // Weapons
 
 AIStateDef club[] = {
-	{ STATE_STANDDOWN,	"ent_club_sit" },
+	{ STATE_STANDDOWN,      GROUP_ENT_CLUB_SIT },
 	{ STATE_ENDSTATES, "" }
 };
+
 AIStateDef roboStunner[] = {
-	{ STATE_STANDDOWN,	"ent_robostunner_sit" },
+	{ STATE_STANDDOWN,      GROUP_ENT_ROBOSTUNNER_SIT },
 	{ STATE_ENDSTATES, "" }
 };
+
 AIStateDef slugSlinger[] = {
-	{ STATE_STANDDOWN,	"ent_slugslinger_sit" },
+	{ STATE_STANDDOWN,      GROUP_ENT_SLUGSLINGER_SIT },
 	{ STATE_ENDSTATES, "" }
 };
 
 // Items
 
 AIStateDef itemChicken[] = {
-	{ STATE_STANDDOWN, "ent_chicken_standdown" },
+	{ STATE_STANDDOWN,      GROUP_ENT_CHICKEN_STANDDOWN },
 	{ STATE_ENDSTATES, "" }
 };
 
 AIStateDef envelopeWhite[] = {
-	{ STATE_STANDDOWN, "ent_envelope_white_sit" },
+	{ STATE_STANDDOWN,      GROUP_ENT_ENVELOPE_WHITE_SIT },
 	{ STATE_ENDSTATES, "" }
 };
 
 AIStateDef envelopeBlue[] = {
-	{ STATE_STANDDOWN, "ent_envelope_blue_sit" },
+	{ STATE_STANDDOWN,      GROUP_ENT_ENVELOPE_BLUE_SIT },
 	{ STATE_ENDSTATES, "" }
 };
 
 AIStateDef envelopeRed[] = {
-	{ STATE_STANDDOWN, "ent_envelope_red_sit" },
-	{ STATE_ENDSTATES, "" }
-};
-
-AIStateDef envelopeGreen[] = {
-	{ STATE_STANDDOWN, "ent_envelope_green_sit" },
+	{ STATE_STANDDOWN,      GROUP_ENT_ENVELOPE_RED_SIT },
 	{ STATE_ENDSTATES, "" }
 };
 
 AIStateDef transceiver[] = {
-	{ STATE_STANDDOWN, "ent_transceiver_sit" },
+	{ STATE_STANDDOWN,      GROUP_ENT_TRANSCEIVER_SIT },
 	{ STATE_ENDSTATES, "" }
 };
 
 AIStateDef cell[] = {
-	{ STATE_STANDDOWN, "ent_cell_sit" },
+	{ STATE_STANDDOWN,      GROUP_ENT_CELL_SIT },
 	{ STATE_ENDSTATES, "" }
 };
 
 AIStateDef gooCup[] = {
-	{ STATE_STANDDOWN, "ent_goo_cup_sit" },
+	{ STATE_STANDDOWN,      GROUP_ENT_GOO_CUP_SIT },
 	{ STATE_ENDSTATES, "" }
 };
 
 AIStateDef gemWhite[] = {
-	{ STATE_STANDDOWN, "ent_gem_white_sit" },
+	{ STATE_STANDDOWN,      GROUP_ENT_GEM_WHITE_SIT },
 	{ STATE_ENDSTATES, "" }
 };
 
-AIStateDef gemBlue[] = {
-	{ STATE_STANDDOWN, "ent_gem_blue_sit" },
-	{ STATE_ENDSTATES, "" }
-};
-
-AIStateDef gemRed[] = {
-	{ STATE_STANDDOWN, "ent_gem_red_sit" },
-	{ STATE_ENDSTATES, "" }
-};
-
-AIStateDef gemGreen[] = {
-	{ STATE_STANDDOWN, "ent_gem_green_sit" },
+AIStateDef cabKey[] = {
+	{ STATE_STANDDOWN, "ent_cabkey_sit" },
 	{ STATE_ENDSTATES, "" }
 };
 
-AIStateDef cabKey[] = {
-	{ STATE_STANDDOWN, "ent_cabkey_sit" },
+AIStateDef envelopeGreen[] = {
+	{ STATE_STANDDOWN,      GROUP_ENT_ENVELOPE_GREEN_SIT },
 	{ STATE_ENDSTATES, "" }
 };
 
 AIStateDef teaCup[] = {
-	{ STATE_STANDDOWN, "ent_teacup_sit" },
+	{ STATE_STANDDOWN,      GROUP_ENT_TEACUP_SIT },
 	{ STATE_ENDSTATES, "" }
 };
 
 AIStateDef cookie[] = {
-	{ STATE_STANDDOWN, "ent_cookie_sit" },
+	{ STATE_STANDDOWN,      GROUP_ENT_COOKIE_SIT },
 	{ STATE_ENDSTATES, "" }
 };
 
 AIStateDef burger[] = {
-	{ STATE_STANDDOWN, "ent_burger_sit" },
+	{ STATE_STANDDOWN,      GROUP_ENT_BURGER_SIT },
 	{ STATE_ENDSTATES, "" }
 };
 
 AIStateDef pda[] = {
-	{ STATE_STANDDOWN, "ent_pda_sit" },
+	{ STATE_STANDDOWN,      GROUP_ENT_PDA_SIT },
 	{ STATE_ENDSTATES, "" }
 };
 
 AIStateDef book[] = {
-	{ STATE_STANDDOWN, "ent_book_sit" },
+	{ STATE_STANDDOWN,      GROUP_ENT_BOOK_SIT },
 	{ STATE_ENDSTATES, "" }
 };
 
 AIStateDef clipboard[] = {
-	{ STATE_STANDDOWN, "ent_clipboard_sit" },
+	{ STATE_STANDDOWN,      GROUP_ENT_CLIPBOARD_SIT },
 	{ STATE_ENDSTATES, "" }
 };
 
 AIStateDef note[] = {
-	{ STATE_STANDDOWN, "ent_note_sit" },
+	{ STATE_STANDDOWN,      GROUP_ENT_NOTE_SIT },
 	{ STATE_ENDSTATES, "" }
 };
 
 AIStateDef keycardWhite[] = {
-	{ STATE_STANDDOWN, "ent_keycard_white_sit" },
+	{ STATE_STANDDOWN,      GROUP_ENT_KEYCARD_WHITE_SIT },
 	{ STATE_ENDSTATES, "" }
 };
 
 AIStateDef keycardBlue[] = {
-	{ STATE_STANDDOWN, "ent_keycard_blue_sit" },
+	{ STATE_STANDDOWN,      GROUP_ENT_KEYCARD_BLUE_SIT },
 	{ STATE_ENDSTATES, "" }
 };
 
 AIStateDef keycardRed[] = {
-	{ STATE_STANDDOWN, "ent_keycard_red_sit" },
+	{ STATE_STANDDOWN,      GROUP_ENT_KEYCARD_RED_SIT },
 	{ STATE_ENDSTATES, "" }
 };
 
 AIStateDef keycardGreen[] = {
-	{ STATE_STANDDOWN, "ent_keycard_green_sit" },
+	{ STATE_STANDDOWN,      GROUP_ENT_KEYCARD_GREEN_SIT },
 	{ STATE_ENDSTATES, "" }
 };
 
 AIStateDef keycardPurple[] = {
-	{ STATE_STANDDOWN, "ent_keycard_purple_sit" },
+	{ STATE_STANDDOWN,      GROUP_ENT_KEYCARD_PURPLE_SIT },
 	{ STATE_ENDSTATES, "" }
 };
 
 AIStateDef keycardBlack[] = {
-	{ STATE_STANDDOWN, "ent_keycard_black_sit" },
+	{ STATE_STANDDOWN,      GROUP_ENT_KEYCARD_BLACK_SIT },
 	{ STATE_ENDSTATES, "" }
 };
 
 AIStateDef magicEgg[] = {
-	{ STATE_STANDDOWN, "ent_magic_egg_sit" },
+	{ STATE_STANDDOWN,      GROUP_ENT_MAGIC_EGG_SIT },
 	{ STATE_ENDSTATES, "" }
 };
 
 AIStateDef iceBlock[] = {
-	{ STATE_STANDDOWN, "ent_ice_block_sit" },
+	{ STATE_STANDDOWN,      GROUP_ENT_ICE_BLOCK_SIT },
+	{ STATE_ENDSTATES, "" }
+};
+
+AIStateDef gemBlue[] = {
+	{ STATE_STANDDOWN,      GROUP_ENT_GEM_BLUE_SIT },
+	{ STATE_ENDSTATES, "" }
+};
+
+AIStateDef gemRed[] = {
+	{ STATE_STANDDOWN,      GROUP_ENT_GEM_RED_SIT },
+	{ STATE_ENDSTATES, "" }
+};
+
+AIStateDef gemGreen[] = {
+	{ STATE_STANDDOWN,      GROUP_ENT_GEM_GREEN_SIT },
 	{ STATE_ENDSTATES, "" }
 };
 
 AIStateDef dollyTool1[] = {
-	{ STATE_STANDDOWN, "ent_dolly_tool1_sit" },
+	{ STATE_STANDDOWN,      GROUP_ENT_DOLLY_TOOL1_SIT },
 	{ STATE_ENDSTATES, "" }
 };
 
 AIStateDef dollyTool2[] = {
-	{ STATE_STANDDOWN, "ent_dolly_tool2_sit" },
+	{ STATE_STANDDOWN,      GROUP_ENT_DOLLY_TOOL2_SIT },
 	{ STATE_ENDSTATES, "" }
 };
 
 AIStateDef dollyTool3[] = {
-	{ STATE_STANDDOWN, "ent_dolly_tool3_sit" },
+	{ STATE_STANDDOWN,      GROUP_ENT_DOLLY_TOOL3_SIT },
 	{ STATE_ENDSTATES, "" }
 };
 
 AIStateDef dollyTool4[] = {
-	{ STATE_STANDDOWN, "ent_dolly_tool4_sit" },
+	{ STATE_STANDDOWN,      GROUP_ENT_DOLLY_TOOL4_SIT },
 	{ STATE_ENDSTATES, "" }
 };
 
 AIStateDef seed[] = {
-	{ STATE_STANDDOWN, "ent_seed_sit" },
+	{ STATE_STANDDOWN,      GROUP_ENT_SEED_SIT },
 	{ STATE_ENDSTATES, "" }
 };
 
 AIStateDef soda[] = {
-	{ STATE_STANDDOWN, "ent_soda_sit" },
+	{ STATE_STANDDOWN,      GROUP_ENT_SODA_SIT },
 	{ STATE_ENDSTATES, "" }
 };
 
 AIStateDef router[] = {
-	{ STATE_STANDDOWN, "ent_router_sit" },
+	{ STATE_STANDDOWN,      GROUP_ENT_ROUTER_SIT },
 	{ STATE_ENDSTATES, "" }
 };
 
 AIStateDef slicer[] = {
-	{ STATE_STANDDOWN, "ent_slicer_sit" },
+	{ STATE_STANDDOWN,      GROUP_ENT_SLICER_SIT },
 	{ STATE_ENDSTATES, "" }
 };
 
 AIStateDef package[] = {
-	{ STATE_STANDDOWN, "ent_package_sit" },
+	{ STATE_STANDDOWN,      GROUP_ENT_PACKAGE_SIT },
 	{ STATE_ENDSTATES, "" }
 };
 
 AIStateDef monkeystone[] = {
-	{ STATE_STANDDOWN, "ent_monkeystone_sit" },
+	{ STATE_STANDDOWN,      GROUP_ENT_MONKEYSTONE_SIT },
 	{ STATE_ENDSTATES, "" }
 };
 
@@ -773,7 +778,7 @@ bool AI::init() {
 	_kcHolderBlackOn	= g_hdb->_gfx->getTileIndex("t32_kcholder_black_on");
 
 	// icepuff snowball
-	_icepSnowballGfxDown = _icepSnowballGfxLeft = 
+	_icepSnowballGfxDown = _icepSnowballGfxLeft =
 		_icepSnowballGfxRight = NULL;
 
 	// Frogglick
@@ -903,7 +908,7 @@ void AI::restartSystem() {
 		_gfxDragonBreathe[0]->free();
 		_gfxDragonBreathe[1]->free();
 		_gfxDragonBreathe[2]->free();
-		_gfxDragonBreathe[0] = _gfxDragonBreathe[1] = 
+		_gfxDragonBreathe[0] = _gfxDragonBreathe[1] =
 			_gfxDragonBreathe[2] = NULL;
 	}
 


Commit: 7caca5d2d099fd7b8e16779c8531ba5c8b5afe79
    https://github.com/scummvm/scummvm/commit/7caca5d2d099fd7b8e16779c8531ba5c8b5afe79
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:13+02:00

Commit Message:
HDB: Unstub the '#if 0' functions

Changed paths:
    engines/hdb/ai-player.cpp


diff --git a/engines/hdb/ai-player.cpp b/engines/hdb/ai-player.cpp
index 599844b..6f3ba61 100644
--- a/engines/hdb/ai-player.cpp
+++ b/engines/hdb/ai-player.cpp
@@ -286,7 +286,6 @@ void aiPlayerAction(AIEntity *e) {
 					warning("STUB: Play MetalorFlesh SND");
 					break;
 				default:
-					warning("aiPlayerAction: DIR_NONE found");
 					break;
 				}
 			}
@@ -1492,9 +1491,11 @@ void aiPdaInit2(AIEntity *e) {
 	e->draw = e->standdownGfx[0];
 }
 
+#if 0
 void aiCellUse(AIEntity *e) {
-	warning("STUB: AI: aiCellUse required");
+	g_hdb->_window->openMessageBar("You got the Energy Cell!", kMsgDelay);
 }
+#endif
 
 void aiCellInit2(AIEntity *e) {
 	e->draw = e->standdownGfx[0];
@@ -1549,7 +1550,7 @@ void aiTransceiverAction(AIEntity *e) {
 
 #if 0
 void aiTransceiverUse(AIEntity *e) {
-	warning("STUB: AI: aiTransceiverUse required");
+	g_hdb->_window->openMessageBar("You got the Transceiver!", kMsgDelay);
 }
 #endif
 


Commit: 0ca3f5bd7fd12657182a1cc75e93ba93f6e677f0
    https://github.com/scummvm/scummvm/commit/0ca3f5bd7fd12657182a1cc75e93ba93f6e677f0
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:13+02:00

Commit Message:
HDB: Add Bots splitter-comments

Changed paths:
    engines/hdb/ai-bots.cpp


diff --git a/engines/hdb/ai-bots.cpp b/engines/hdb/ai-bots.cpp
index 2168395..fafeadc 100644
--- a/engines/hdb/ai-bots.cpp
+++ b/engines/hdb/ai-bots.cpp
@@ -24,6 +24,13 @@
 
 namespace HDB {
 
+//-------------------------------------------------------------------
+//
+//	OMNIBOT : This guy moves on a path and if he sees the player
+//		directly ahead, he will shoot at him
+//
+//-------------------------------------------------------------------
+
 void aiOmniBotInit(AIEntity *e) {
 	if (e->value1 == 1)
 		e->aiAction = aiOmniBotMove;
@@ -129,6 +136,13 @@ void aiOmniBotAction(AIEntity *e) {
 		e->sequence--;
 }
 
+//-------------------------------------------------------------------
+//
+//	OMNIBOT MISSILE : Used by the FOURFIRER and OMNIBOT, this deadly
+//		missile flies through the air, killing anything it hits
+//
+//-------------------------------------------------------------------
+
 void aiOmniBotMissileInit(AIEntity *e) {
 	e->state = STATE_MOVEDOWN;
 	e->aiAction = aiOmniBotMissileAction;
@@ -169,6 +183,13 @@ void aiOmniBotMissileAction(AIEntity *e) {
 		}
 }
 
+//-------------------------------------------------------------------
+//
+//	TURNBOT : Moves straight ahead until it hits a wall, then turns
+//		right and continues.
+//
+//-------------------------------------------------------------------
+
 void aiTurnBotInit(AIEntity *e) {
 	e->aiAction = aiTurnBotAction;
 }
@@ -220,6 +241,13 @@ void aiTurnBotAction(AIEntity *e) {
 		g_hdb->_ai->killPlayer(DEATH_NORMAL);
 }
 
+//-------------------------------------------------------------------
+//
+//	SHOCKBOT : Moves on a path, electrifying all tiles surrounding it
+//		that are METAL.  Will pause when changing directions.
+//
+//-------------------------------------------------------------------
+
 void aiShockBotInit(AIEntity *e) {
 	g_hdb->_ai->findPath(e);
 	e->aiAction = aiShockBotAction;
@@ -291,6 +319,14 @@ void aiShockBotShock(AIEntity *e, int mx, int my) {
 	}
 }
 
+//-------------------------------------------------------------------
+//
+//	RIGHTBOT
+//
+//	Rules: Follows the right-hand wall.  That's it!
+//
+//-------------------------------------------------------------------
+
 void aiRightBotInit(AIEntity *e) {
 	e->moveSpeed = kPlayerMoveSpeed;
 	if (!g_hdb->getActionMode())
@@ -468,6 +504,15 @@ void aiRightBotAction(AIEntity *e) {
 	}
 }
 
+//-------------------------------------------------------------------
+//
+//	PUSHBOT : Very simple, this guy goes forward and pushes anything in his
+//		path all the way until it can't go any further.  Then, he turns 180
+//		degress and comes back until he can't go any further.  Then... he
+//		turns 180 degrees and does it all over again!
+//
+//-------------------------------------------------------------------
+
 void aiPushBotInit(AIEntity *e) {
 	if (e->value1 != 1)
 		e->aiAction = aiPushBotAction;
@@ -566,6 +611,13 @@ void aiPushBotAction(AIEntity *e) {
 	}
 }
 
+//-------------------------------------------------------------------
+//
+//	RAILRIDER : crazy green goopy dude -- he gives you rides on his
+//		special track!
+//
+//-------------------------------------------------------------------
+
 void aiRailRiderInit(AIEntity *e) {
 	if (e->type == AI_RAILRIDER_ON) {
 		// On the tracks already - spawn RED arrow
@@ -804,6 +856,13 @@ void aiRailRiderOnAction(AIEntity *e) {
 	}
 }
 
+//-------------------------------------------------------------------
+//
+//	MAINTBOT : This little fella likes to cause trouble!  He just jubs
+//		around the map and looks for stuff to press.  Touch him and you die.
+//
+//-------------------------------------------------------------------
+
 void aiMaintBotInit(AIEntity *e) {
 	// value1 field determines whether the "MMM!" sound plays
 	// 1 means NO
@@ -962,6 +1021,13 @@ void aiMaintBotAction(AIEntity *e) {
 	}
 }
 
+//-------------------------------------------------------------------
+//
+//	FOURFIRER : This bot turns and fires in the direction it's facing,
+//		but only if the player is visible
+//
+//-------------------------------------------------------------------
+
 void aiFourFirerInit(AIEntity *e) {
 	e->value1 = 0;
 	e->aiAction = aiFourFirerAction;
@@ -1032,6 +1098,14 @@ void aiFourFirerAction(AIEntity *e) {
 	}
 }
 
+//-------------------------------------------------------------------
+//
+//	DEADEYE : Crazy attack dog with Chompie(tm) sounds!  Will sit in one spot
+//		looking around, then run in a random direction and distance.  If, while
+//		scanning, Deadeye sees the player, he goes nuts and attacks!
+//
+//-------------------------------------------------------------------
+
 void aiDeadEyeInit(AIEntity *e) {
 	e->sequence = 64;
 	e->blinkFrames = e->goalX = 0;
@@ -1223,6 +1297,12 @@ void aiDeadEyeAction(AIEntity *e) {
 		e->sequence = 64;
 }
 
+//-------------------------------------------------------------------
+//
+//	LASER
+//
+//-------------------------------------------------------------------
+
 void aiLaserInit(AIEntity *e) {
 	e->aiDraw = aiLaserDraw;
 	e->value1 = e->value2 = 0;		// start & end of laser beam
@@ -1433,6 +1513,12 @@ void aiLaserDraw(AIEntity *e, int mx, int my) {
 	e->movedownFrames++;
 }
 
+//-------------------------------------------------------------------
+//
+//	DIVERTER
+//
+//-------------------------------------------------------------------
+
 void aiDiverterInit(AIEntity *e) {
 	e->aiDraw = aiDiverterDraw;
 	e->aiAction = aiDiverterAction;
@@ -1571,6 +1657,13 @@ void aiDiverterDraw(AIEntity *e, int mx, int my) {
 	e->movedownFrames++;
 }
 
+//-------------------------------------------------------------------
+//
+//	MEERKAT : nutty little groundhog dude that will bite Guy if he's on
+//		his mound.  That blows 1-5 gems outta Guy!
+//
+//-------------------------------------------------------------------
+
 void aiMeerkatInit(AIEntity *e) {
 	e->state = STATE_NONE;
 	e->sequence = 0;
@@ -1753,6 +1846,13 @@ void aiMeerkatLookAround(AIEntity *e) {
 	g_hdb->_ai->animEntFrames(e);
 }
 
+//-------------------------------------------------------------------
+//
+//	FATFROG : Just sits in place and blasts out his tongue if you're 
+//		within range.
+//
+//-------------------------------------------------------------------
+
 void aiFatFrogInit(AIEntity *e) {
 	e->aiAction = aiFatFrogAction;
 }
@@ -2084,6 +2184,12 @@ void aiFatFrogTongueDraw(AIEntity *e, int mx, int my) {
 	}
 }
 
+//-------------------------------------------------------------------
+//
+//	GOODFAIRY
+//
+//-------------------------------------------------------------------
+
 void aiGoodFairyInit(AIEntity *e) {
 	e->aiAction = aiGoodFairyAction;
 	e->sequence = 20;
@@ -2278,6 +2384,12 @@ void aiGoodFairyAction(AIEntity *e) {
 		e->sequence = 20;
 }
 
+//-------------------------------------------------------------------
+//
+//	BADFAIRY
+//
+//-------------------------------------------------------------------
+
 void aiBadFairyInit(AIEntity *e) {
 	e->aiAction = aiBadFairyAction;
 	e->sequence = 20;
@@ -2405,6 +2517,12 @@ void aiBadFairyAction(AIEntity *e) {
 		e->sequence = 20;
 }
 
+//-------------------------------------------------------------------
+//
+//	BADFAIRY's GATE PUDDLE!
+//
+//-------------------------------------------------------------------
+
 void aiGatePuddleInit(AIEntity *e) {
 	e->aiAction = aiGatePuddleAction;
 	e->value1 = 50;
@@ -2529,6 +2647,19 @@ void aiGatePuddleAction(AIEntity *e) {
 	}
 }
 
+//-------------------------------------------------------------------
+//
+//	ICEPUFF : Little icy dude peeks out of the ground and pops up and
+//		throws a snowball at you if he sees you....then he blasts back
+//		into the snow and hides for a while....
+//
+// Variables used specially:
+//	value1, value2	: x,y of snowball
+//	dir2			: direction of snowball. DIR_NONE = no snowball
+//	sequence	: timer for peeking
+//
+//-------------------------------------------------------------------
+
 void aiIcePuffSnowballInit(AIEntity *e) {
 	// which direction are we throwing in? Load the graphic if we need to
 	switch (e->dir) {
@@ -2749,6 +2880,13 @@ void aiIcePuffAction(AIEntity *e) {
 	}
 }
 
+//-------------------------------------------------------------------
+//
+//	BUZZFLY : Simply flies around on paths.... kills you if you touch him.
+//		He pauses at corners, too.
+//
+//-------------------------------------------------------------------
+
 void aiBuzzflyInit(AIEntity *e) {
 	e->aiAction = aiBuzzflyAction;
 	e->sequence = 0;
@@ -2810,6 +2948,12 @@ void aiBuzzflyAction(AIEntity *e) {
 	}
 }
 
+//-------------------------------------------------------------------
+//
+//	DRAGON
+//
+//-------------------------------------------------------------------
+
 void aiDragonInit(AIEntity *e) {
 	AIEntity *block;
 


Commit: 74675ba2d542ebe2ab8a4ffbe2d4d7c4cf25e56b
    https://github.com/scummvm/scummvm/commit/74675ba2d542ebe2ab8a4ffbe2d4d7c4cf25e56b
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:13+02:00

Commit Message:
HDB: Fix type warning

Changed paths:
    engines/hdb/ai.h


diff --git a/engines/hdb/ai.h b/engines/hdb/ai.h
index 44e4f69..7c7c28e 100644
--- a/engines/hdb/ai.h
+++ b/engines/hdb/ai.h
@@ -418,13 +418,13 @@ struct AIEntity {
 
 	union {
 		uint16 blinkFrames;
-		uint16 int1;
+		int16 int1;
 	};
 	Tile *blinkGfx[kMaxAnimFrames];
 
 	union {
 		uint16 special1Frames;
-		uint16 int2;
+		int16 int2;
 	};
 	Tile *special1Gfx[kMaxAnimFrames];
 


Commit: aed071e5a0eb15980db09d95c220d7d08ebffaad
    https://github.com/scummvm/scummvm/commit/aed071e5a0eb15980db09d95c220d7d08ebffaad
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:13+02:00

Commit Message:
HDB: Add stubbed getMusicVolume()

Changed paths:
    engines/hdb/sound.h


diff --git a/engines/hdb/sound.h b/engines/hdb/sound.h
index 2fc677b..65c61f2 100644
--- a/engines/hdb/sound.h
+++ b/engines/hdb/sound.h
@@ -1388,6 +1388,10 @@ class Sound {
 public:
 
 	bool init();
+	int getMusicVolume() {
+		debug(9, "STUB: Add Music System Variables");
+		return 1;
+	}
 
 	bool playSound(int index);
 	bool playSoundEx(int index, int channel, bool loop);


Commit: 267ddc8358c8b5ddd2034cadfaaf1b7c97a83ff8
    https://github.com/scummvm/scummvm/commit/267ddc8358c8b5ddd2034cadfaaf1b7c97a83ff8
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:13+02:00

Commit Message:
HDB: Add turnOnSnow()

Changed paths:
    engines/hdb/gfx.cpp
    engines/hdb/gfx.h


diff --git a/engines/hdb/gfx.cpp b/engines/hdb/gfx.cpp
index d4315a0..3fdba2e 100644
--- a/engines/hdb/gfx.cpp
+++ b/engines/hdb/gfx.cpp
@@ -192,6 +192,17 @@ void Gfx::updateFade() {
 	debug(9, "STUB: Gfx::updateFade incomplete");
 }
 
+void Gfx::turnOnSnow() {
+	int		i;
+	_snowInfo.active = true;
+	for (i = 0; i < MAX_SNOW; i++) {
+		_snowInfo.x[i] = g_hdb->_rnd->getRandomNumber(kScreenWidth);
+		_snowInfo.y[i] = g_hdb->_rnd->getRandomNumber(kScreenHeight);
+		_snowInfo.yv[i] = g_hdb->_rnd->getRandomNumber(3) + 1;
+		_snowInfo.xvindex[i] = g_hdb->_rnd->getRandomNumber(MAX_SNOW_XV);
+	}
+}
+
 Picture *Gfx::loadPic(const char *picName) {
 	Picture *pic = new Picture;
 	Common::SeekableReadStream *stream = g_hdb->_fileMan->findFirstData(picName, TYPE_PIC);
diff --git a/engines/hdb/gfx.h b/engines/hdb/gfx.h
index ae7927d..597bf7f 100644
--- a/engines/hdb/gfx.h
+++ b/engines/hdb/gfx.h
@@ -107,6 +107,7 @@ public:
 	bool isFadeActive() { return _fadeInfo.active; }
 	bool isFadeStaying() { return _fadeInfo.stayFaded; }
 	void turnOffFade() { _fadeInfo.active = _fadeInfo.stayFaded = false; }
+	void turnOnSnow();
 	void turnOffSnow() { _snowInfo.active = false; }
 
 	Picture *loadPic(const char *picName);


Commit: 0dff3cd8e66ac2d5e3e8284fe6ea4186aea506ee
    https://github.com/scummvm/scummvm/commit/0dff3cd8e66ac2d5e3e8284fe6ea4186aea506ee
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:13+02:00

Commit Message:
HDB: Unstub Lua Snow functions

Changed paths:
    engines/hdb/lua-script.cpp


diff --git a/engines/hdb/lua-script.cpp b/engines/hdb/lua-script.cpp
index 50c1551..49915d6 100644
--- a/engines/hdb/lua-script.cpp
+++ b/engines/hdb/lua-script.cpp
@@ -1003,12 +1003,12 @@ static int centerTextOut(lua_State *L) {
 }
 
 static int turnOnSnow(lua_State *L) {
-	warning("STUB: TURN ON SNOW");
+	g_hdb->_gfx->turnOnSnow();
 	return 0;
 }
 
 static int turnOffSnow(lua_State *L) {
-	warning("STUB: TURN OFF SNOW");
+	g_hdb->_gfx->turnOffSnow();
 	return 0;
 }
 


Commit: ebea69eceb2cb8ae823a702b484b9a29f91f3858
    https://github.com/scummvm/scummvm/commit/ebea69eceb2cb8ae823a702b484b9a29f91f3858
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:13+02:00

Commit Message:
HDB: Unstub lasers and more

Changed paths:
    engines/hdb/ai-funcs.cpp


diff --git a/engines/hdb/ai-funcs.cpp b/engines/hdb/ai-funcs.cpp
index bdbf997..56b021a 100644
--- a/engines/hdb/ai-funcs.cpp
+++ b/engines/hdb/ai-funcs.cpp
@@ -529,7 +529,9 @@ AIEntity *AI::findEntity(int x, int y) {
 		}
 	}
 
-	warning("STUB: findEntity: Check for Laser");
+	if (g_hdb->_map->laserBeamExist(x, y))
+		return &_dummyLaser;
+
 	return NULL;
 }
 
@@ -546,7 +548,9 @@ AIEntity *AI::findEntityIgnore(int x, int y, AIEntity *ignore) {
 		}
 	}
 
-	warning("STUB: findEntityIgnore: Check for Laser");
+	if (g_hdb->_map->laserBeamExist(x, y) && ignore->type != AI_LASERBEAM)
+		return &_dummyLaser;
+
 	return NULL;
 }
 
@@ -563,7 +567,9 @@ AIEntity *AI::findEntityType(AIType type, int x, int y) {
 		}
 	}
 
-	warning("STUB: findEntityType: Check for Laser");
+	if (g_hdb->_map->laserBeamExist(x, y) && type == AI_LASERBEAM)
+		return &_dummyLaser;
+
 	return NULL;
 }
 
@@ -770,7 +776,9 @@ void AI::initAllEnts() {
 		_deliveries[i].itemGfx = g_hdb->_gfx->getTileGfx(_deliveries[i].itemGfxName, -1);
 		_deliveries[i].destGfx = g_hdb->_gfx->getTileGfx(_deliveries[i].destGfxName, -1);
 	}
-	warning("STUB: initAllEnts: LaserScan required");
+
+	// do a quick LaserScan to fill the laserbeam matrix!
+	laserScan();
 }
 
 void AI::killPlayer(Death method) {
@@ -783,7 +791,9 @@ void AI::killPlayer(Death method) {
 	_playerInvisible = false;
 	_playerDead = true;
 
-	warning("STUB: killPlayer: Close Dialogs");
+	g_hdb->_window->closeDialog();
+	g_hdb->_window->closeDialogChoice();
+	g_hdb->_window->stopPanicZone();
 
 	switch (method) {
 	case DEATH_NORMAL:
@@ -817,7 +827,9 @@ void AI::killPlayer(Death method) {
 		break;
 	}
 
-	warning("STUB: killPlayer: Stop Music");
+	// sound.StopMusic();
+	if (!g_hdb->_sound->getMusicVolume())
+		g_hdb->_sound->playSound(SND_TRY_AGAIN);
 }
 
 void AI::stunEnemy(AIEntity *e, int time) {


Commit: a2c9c83b8392b850cec2839adf6367ca7186581b
    https://github.com/scummvm/scummvm/commit/a2c9c83b8392b850cec2839adf6367ca7186581b
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:13+02:00

Commit Message:
HDB: Unstub Window function calls

Changed paths:
    engines/hdb/ai-inventory.cpp
    engines/hdb/input.cpp


diff --git a/engines/hdb/ai-inventory.cpp b/engines/hdb/ai-inventory.cpp
index 3dfea69..ef67c73 100644
--- a/engines/hdb/ai-inventory.cpp
+++ b/engines/hdb/ai-inventory.cpp
@@ -56,7 +56,7 @@ bool AI::addToInventory(AIEntity *e) {
 	}
 
 	if (_numInventory >= kMaxInventory) {
-		warning("STUB: addToInventory: Inventory full message");
+		g_hdb->_window->openMessageBar("Your inventory is full.", 5);
 		return false;
 	}
 
diff --git a/engines/hdb/input.cpp b/engines/hdb/input.cpp
index 2c527e6..9762910 100644
--- a/engines/hdb/input.cpp
+++ b/engines/hdb/input.cpp
@@ -250,7 +250,7 @@ void Input::updateMouseButtons(int l, int m, int r) {
 		if (_mouseX > (kScreenWidth - 32 * 5) && _mouseY < 240) {
 			g_hdb->_window->checkInvSelect(_mouseX, _mouseY);
 		} else if (_mouseX > (kScreenWidth - 32 * 5) && _mouseY >= 240) {
-			warning("STUB: updateMouseButtons: checkDeliveriesSelect() required");
+			g_hdb->_window->checkDlvSelect(_mouseX, _mouseY);
 		} else {
 			if (g_hdb->getPause() && g_hdb->getGameState() == GAME_PLAY) {
 				g_hdb->_window->checkPause(_mouseX, _mouseY);


Commit: 373106f896908c32060c13c3e084b16a0033c61a
    https://github.com/scummvm/scummvm/commit/373106f896908c32060c13c3e084b16a0033c61a
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:13+02:00

Commit Message:
HDB: Add cineStartMap()

Changed paths:
    engines/hdb/ai-cinematic.cpp
    engines/hdb/ai.h
    engines/hdb/hdb.h


diff --git a/engines/hdb/ai-cinematic.cpp b/engines/hdb/ai-cinematic.cpp
index 42ce0c6..8f42a59 100644
--- a/engines/hdb/ai-cinematic.cpp
+++ b/engines/hdb/ai-cinematic.cpp
@@ -104,6 +104,22 @@ void AI::processCines() {
 			if (func[0])
 				g_hdb->_lua->callFunction(func, 0);
 			break;
+		case C_STARTMAP:
+			cineFreeGfx();			// free all gfx alloc'ed during cine
+			_cineActive = false;
+			_playerLock = false;
+			_cameraLock = false;
+			g_hdb->_window->setInfobarDark(0);
+			g_hdb->_gfx->setPointerState(1);
+			_cine.resize(0);
+			_numCineFreeList = 0;
+			_numCineBlitList = 0;
+			// if cine is aborted and an abort function was specified, call it
+			if (_cineAborted && _cineAbortFunc)
+				g_hdb->_lua->callFunction(_cineAbortFunc, 0);
+			g_hdb->changeMap(_cine[i]->title);
+			return;
+			break;
 		case C_LOCKPLAYER:
 			_playerLock = true;
 			complete = true;
@@ -491,6 +507,13 @@ void AI::cineStop(const char *funcNext) {
 	_cine.push_back(cmd);
 }
 
+void AI::cineStartMap(const char *mapName) {
+	CineCommand *cmd = new CineCommand;
+	cmd->cmdType = C_STARTMAP;
+	cmd->title = mapName;
+	_cine.push_back(cmd);
+}
+
 void AI::cineLockPlayer() {
 	CineCommand *cmd = new CineCommand;
 	cmd->cmdType = C_LOCKPLAYER;
diff --git a/engines/hdb/ai.h b/engines/hdb/ai.h
index 7c7c28e..be7a530 100644
--- a/engines/hdb/ai.h
+++ b/engines/hdb/ai.h
@@ -950,6 +950,7 @@ public:
 	void cineFreeGfx();
 	void cineStart(bool abortable, const char *abortFunc);
 	void cineStop(const char *funcNext);
+	void cineStartMap(const char *mapName);
 	void cineLockPlayer();
 	void cineUnlockPlayer();
 	void cineSetCamera(int x, int y);
diff --git a/engines/hdb/hdb.h b/engines/hdb/hdb.h
index e936498..3444fbf 100644
--- a/engines/hdb/hdb.h
+++ b/engines/hdb/hdb.h
@@ -152,7 +152,7 @@ public:
 	bool restartMap();
 	bool startMap(const char *name);
 
-	void changeMap(char *name) {
+	void changeMap(const char *name) {
 		strcpy(_changeMapname, name);
 		_changeLevel = true;
 	}


Commit: f6a3eac4972bd64c4e2c81c801a4924d892aeddd
    https://github.com/scummvm/scummvm/commit/f6a3eac4972bd64c4e2c81c801a4924d892aeddd
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:13+02:00

Commit Message:
HDB: Add cineStartMap() Lua function

Changed paths:
    engines/hdb/lua-script.cpp


diff --git a/engines/hdb/lua-script.cpp b/engines/hdb/lua-script.cpp
index 49915d6..0c713ec 100644
--- a/engines/hdb/lua-script.cpp
+++ b/engines/hdb/lua-script.cpp
@@ -173,7 +173,14 @@ static int cineFadeOutWhite(lua_State *L) {
 }
 
 static int cineStartMap(lua_State *L) {
-	warning("STUB: CINE START MAP");
+	const char *mapName = lua_tostring(L, 1);
+
+	g_hdb->_lua->checkParameters("cineStartMap", 1);
+
+	lua_pop(L, 1);
+
+	g_hdb->_ai->cineStartMap(mapName);
+
 	return 0;
 }
 


Commit: 9b48e15b8eb1d1e140e46af377ee5d874dc3ad81
    https://github.com/scummvm/scummvm/commit/9b48e15b8eb1d1e140e46af377ee5d874dc3ad81
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:13+02:00

Commit Message:
HDB: Add cinePlayVoice() and cinePlaySound()

Changed paths:
    engines/hdb/ai-cinematic.cpp
    engines/hdb/ai.h


diff --git a/engines/hdb/ai-cinematic.cpp b/engines/hdb/ai-cinematic.cpp
index 8f42a59..e5062a8 100644
--- a/engines/hdb/ai-cinematic.cpp
+++ b/engines/hdb/ai-cinematic.cpp
@@ -348,6 +348,14 @@ void AI::processCines() {
 			}
 			complete = true;
 			break;
+		case C_PLAYSOUND:
+			g_hdb->_sound->playSound((int)_cine[i]->start);
+			complete = true;
+			break;
+		case C_PLAYVOICE:
+			g_hdb->_sound->playVoice((int)_cine[i]->x, (int)_cine[i]->y);
+			complete = true;
+			break;
 		case C_FADEIN:
 			if (!_cine[i]->start) {
 				g_hdb->_gfx->setFade(true, (bool)_cine[i]->end, _cine[i]->speed);
@@ -695,6 +703,21 @@ void AI::cineUse(const char *entName) {
 	_cine.push_back(cmd);
 }
 
+void AI::cinePlaySound(int index) {
+	CineCommand *cmd = new CineCommand;
+	cmd->start = index;
+	cmd->cmdType = C_PLAYSOUND;
+	_cine.push_back(cmd);
+}
+
+void AI::cinePlayVoice(int index, int actor) {
+	CineCommand *cmd = new CineCommand;
+	cmd->x = index;
+	cmd->y = actor;
+	cmd->cmdType = C_PLAYVOICE;
+	_cine.push_back(cmd);
+}
+
 void AI::cineFadeIn(bool isBlack, int steps) {
 	CineCommand *cmd = new CineCommand;
 	cmd->speed = steps;
diff --git a/engines/hdb/ai.h b/engines/hdb/ai.h
index be7a530..02a9288 100644
--- a/engines/hdb/ai.h
+++ b/engines/hdb/ai.h
@@ -970,6 +970,8 @@ public:
 	void cineCenterTextOut(const char *text, int y, int timer);
 	void cineMoveMaskedPic(const char *id, const char *pic, int x1, int y1, int x2, int y2, int speed);
 	void cineUse(const char *entName);
+	void cinePlaySound(int index);
+	void cinePlayVoice(int index, int actor);
 	void cineFadeIn(bool isBlack, int steps);
 	void cineFadeOut(bool isBlack, int steps);
 	void cineClearForeground(int x, int y);


Commit: f89015a90d3ce14fde272bc9653aa9cb8f3ec054
    https://github.com/scummvm/scummvm/commit/f89015a90d3ce14fde272bc9653aa9cb8f3ec054
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:13+02:00

Commit Message:
HDB: Add Lua functions for _sound

Changed paths:
    engines/hdb/lua-script.cpp


diff --git a/engines/hdb/lua-script.cpp b/engines/hdb/lua-script.cpp
index 0c713ec..7c9664f 100644
--- a/engines/hdb/lua-script.cpp
+++ b/engines/hdb/lua-script.cpp
@@ -241,12 +241,25 @@ static int cineWaitUntilDone(lua_State *L) {
 }
 
 static int cinePlaySound(lua_State *L) {
-	warning("STUB: CINE PLAY SOUND");
+	double index = lua_tonumber(L, 1);
+
+	g_hdb->_lua->checkParameters("cinePlaySound", 1);
+
+	lua_pop(L, 1);
+
+	g_hdb->_ai->cinePlaySound((int)index);
 	return 0;
 }
 
 static int cinePlayVoice(lua_State *L) {
-	warning("STUB: CINE PLAY VOICE");
+	double	index = lua_tonumber(L, 1);
+	double	actor = lua_tonumber(L, 2);
+
+	g_hdb->_lua->checkParameters("cinePlayVoice", 2);
+
+	lua_pop(L, 2);
+
+	g_hdb->_ai->cinePlayVoice((int)index, (int)actor);
 	return 0;
 }
 


Commit: d285201ec84824537012a39588f56ccbaada9de3
    https://github.com/scummvm/scummvm/commit/d285201ec84824537012a39588f56ccbaada9de3
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:13+02:00

Commit Message:
HDB: Disable skipping manny quest for now

Changed paths:
    engines/hdb/hdb.cpp


diff --git a/engines/hdb/hdb.cpp b/engines/hdb/hdb.cpp
index 92d2939..242bb4c 100644
--- a/engines/hdb/hdb.cpp
+++ b/engines/hdb/hdb.cpp
@@ -34,7 +34,7 @@
 #include "hdb/console.h"
 #include "hdb/menu.h"
 
-#define CHEAT_PATCHES 1
+#define CHEAT_PATCHES 0
 
 namespace HDB {
 


Commit: 59417482096b378fe9cc6b65bd35b0dc9ffa13bb
    https://github.com/scummvm/scummvm/commit/59417482096b378fe9cc6b65bd35b0dc9ffa13bb
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:13+02:00

Commit Message:
HDB: Fixed AI::cineRemoveFromBlitList()

This fixes bug with only 1 manny envelope flying

Changed paths:
    engines/hdb/ai-cinematic.cpp


diff --git a/engines/hdb/ai-cinematic.cpp b/engines/hdb/ai-cinematic.cpp
index e5062a8..24ecd29 100644
--- a/engines/hdb/ai-cinematic.cpp
+++ b/engines/hdb/ai-cinematic.cpp
@@ -469,13 +469,14 @@ Picture *AI::cineFindInBlitList(const char *name) {
 
 void AI::cineRemoveFromBlitList(const char *name) {
 	for (int i = 0; i < _numCineBlitList; i++) {
-		if (Common::matchString(_cineBlitList[i]->id, name, true))
+		if (Common::matchString(_cineBlitList[i]->id, name, true)) {
 			delete _cineBlitList[i];
 			for (; i < _numCineBlitList - 1; i++)
 				_cineBlitList[i] = _cineBlitList[i + 1];
 			_numCineBlitList--;
 			_cineBlitList[_numCineBlitList] = NULL;
 			return;
+		}
 	}
 }
 


Commit: c63e7c838b1e00fa43af6160fb82ab259b68fe3f
    https://github.com/scummvm/scummvm/commit/c63e7c838b1e00fa43af6160fb82ab259b68fe3f
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:13+02:00

Commit Message:
HDB: Unstub stubs

Changed paths:
    engines/hdb/ai-inventory.cpp
    engines/hdb/ai-lists.cpp
    engines/hdb/ai-waypoint.cpp


diff --git a/engines/hdb/ai-inventory.cpp b/engines/hdb/ai-inventory.cpp
index ef67c73..65e8433 100644
--- a/engines/hdb/ai-inventory.cpp
+++ b/engines/hdb/ai-inventory.cpp
@@ -300,7 +300,7 @@ bool AI::completeDelivery(const char *id) {
 			for (; i < _numDeliveries; i++)
 				memcpy(&_deliveries[i], &_deliveries[i + 1], sizeof(_deliveries[0]));
 			_numDeliveries--;
-			warning("STUB: Play Voice: GUY_COMPLETED");
+			g_hdb->_sound->playVoice(GUY_COMPLETED, 1);
 			return true;
 		}
 	return false;
diff --git a/engines/hdb/ai-lists.cpp b/engines/hdb/ai-lists.cpp
index 53084dd..a8e6511 100644
--- a/engines/hdb/ai-lists.cpp
+++ b/engines/hdb/ai-lists.cpp
@@ -794,7 +794,10 @@ bool AI::checkTeleportList(AIEntity *e, int x, int y) {
 			}
 
 			// PANIC ZONE Teleports?
-			warning("STUB: checkTeleporterList: Toggle Panic Zone");
+			if (anim2 >= 2)
+				g_hdb->_window->startPanicZone();
+			else
+				g_hdb->_window->stopPanicZone();
 
 			// Is there an attack gem still floating around?
 			for (Common::Array<AIEntity *>::iterator it = _ents->begin(); it != _ents->end(); it++) {
@@ -849,7 +852,7 @@ void AI::addToTriggerList(char *luaFuncInit, char *luaFuncUse, int x, int y, int
 		strcpy(t->luaFuncUse, luaFuncUse);
 
 	if (!t->luaFuncUse[0])
-		warning("STUB: addToTriggerList: Open MessageBar");
+		g_hdb->_window->openMessageBar("Trigger without USE!", 10);
 
 	if (t->luaFuncInit[0]) {
 		g_hdb->_lua->pushFunction(t->luaFuncInit);
diff --git a/engines/hdb/ai-waypoint.cpp b/engines/hdb/ai-waypoint.cpp
index 687c57c..9e16e13 100644
--- a/engines/hdb/ai-waypoint.cpp
+++ b/engines/hdb/ai-waypoint.cpp
@@ -119,7 +119,7 @@ void AI::addWaypoint(int px, int py, int x, int y, int level) {
 						_waypoints[_numWaypoints].y = ny;
 						_waypoints[_numWaypoints].level = lvl2;
 						_numWaypoints++;
-						warning("STUB: Play SND_MENU_SLIDER");
+						g_hdb->_sound->playSound(SND_MENU_SLIDER);
 
 						if (onEvenTile(_player->x, _player->y))
 							setEntityGoal(_player, tx, ty);


Commit: 7cb5f460c0be865903d16aa7b3e6e61dac63e41f
    https://github.com/scummvm/scummvm/commit/7cb5f460c0be865903d16aa7b3e6e61dac63e41f
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:13+02:00

Commit Message:
HDB: Add member variables to Menu

Changed paths:
    engines/hdb/menu.cpp
    engines/hdb/menu.h


diff --git a/engines/hdb/menu.cpp b/engines/hdb/menu.cpp
index 4b65a8b..f0d42e5 100644
--- a/engines/hdb/menu.cpp
+++ b/engines/hdb/menu.cpp
@@ -26,9 +26,42 @@
 namespace HDB {
 
 bool Menu::init() {
-	_starWarp = 0;
+//	_starWarp = 0;
+	_titleActive = false;
+	_menuActive = false;
+	_optionsActive = false;
+	_gamefilesActive = false;
+	_newgameActive = false;
+	_warpActive = false;
+	_optionsScrolling = false;
+	_optionsScrollX = kMenuX;
+	_rocketX = kMRocketX;
+	_sayHDB = false;
 
-	warning("STUB: Menu::init()");
+	_nebulaY = 0;		// Used as a flag
+	_fStars[0].y = 0;	// Used as a flag
+
+	_keyAssignUp = Common::KEYCODE_UP;
+	_keyAssignDown = Common::KEYCODE_DOWN;
+	_keyAssignLeft = Common::KEYCODE_LEFT;
+	_keyAssignRight = Common::KEYCODE_RIGHT;
+	_keyAssignUse = Common::KEYCODE_RETURN;
+
+	_gCheckEmpty = g_hdb->_gfx->loadPic(G_CHECK_EMPTY);
+	_gCheckOff = g_hdb->_gfx->loadPic(G_CHECK_OFF);
+	_gCheckOn = g_hdb->_gfx->loadPic(G_CHECK_ON);
+	_gCheckLeft = g_hdb->_gfx->loadPic(G_CHECK_LEFT);
+	_gCheckRight = g_hdb->_gfx->loadPic(G_CHECK_RIGHT);
+
+	_contArrowUp = g_hdb->_gfx->loadPic(CTRL_ARROWUP);
+	_contArrowDown = g_hdb->_gfx->loadPic(CTRL_ARROWDN);
+	_contArrowLeft = g_hdb->_gfx->loadPic(CTRL_ARROWLEFT);
+	_contArrowRight = g_hdb->_gfx->loadPic(CTRL_ARROWRIGHT);
+	_contAssign = g_hdb->_gfx->loadPic(CTRL_ASSIGN);
+
+	_waitingForKey = false;
+	_warpPlaque = g_hdb->_gfx->loadPic(WARP_PLAQUE);
+	_hdbLogoScreen = g_hdb->_gfx->loadPic(TITLESCREEN);
 
 	return true;
 }
diff --git a/engines/hdb/menu.h b/engines/hdb/menu.h
index ebf1e5a..3e49051 100644
--- a/engines/hdb/menu.h
+++ b/engines/hdb/menu.h
@@ -32,6 +32,98 @@ namespace HDB {
 #define STARS_MONKEYSTONE_21		0x77ace3	// <same> for the Monkeystone #21
 #define STARS_MONKEYSTONE_21_FAKE	0x3548fe	// fake value that means it hasn't been unlocked
 
+enum {
+	kMenuX = 48 * 8,
+	kMenuY = 80,
+
+	kMenuItemWidth = 88,
+	kMenuItemHeight = 40,
+
+	kMResumeY =	48 * 4,
+	kMQuitY = 48 * 3,
+	kMOptionsY = 48 * 2,
+	kMLoadY = 48 * 1,
+	kMControlsY = 270,
+
+	kMenuExitY = kScreenHeight - 80,
+	kMenuExitXLeft = 60,
+	kMenuExitYTop = 48,
+	kMenuVortSaveY = 220,
+	kMenuVortSaveX = 76,
+
+	kMRocketX = 18 * 8,
+	kMRocketY = 48,
+	kMRocketYBottom = 28 * 8,
+	kMRocketEXHX = 6 * 8 - 4,
+	kMRocketEXHX2 = 11 * 8 - 4,
+	kMTitleY = 34 * 8,
+	kOohOhhX = 256,
+	kOohOhhY = 224,
+
+	kNewGameX = 220,
+	kNewGameX2 = kNewGameX + 50,
+
+	kModePuzzleY = 130,
+	kModeActionY = 220,
+
+	kOptionsX = 8 * 26,
+	kOptionsY = 8 * 10,
+
+	kVortSaveX = 200 - 44,
+	kVortSaveTextX = kVortSaveX + 40,
+	kVortSaveTextY = 72,
+	kSaveSlotX = 200,
+	kSaveSlotY = 80,
+
+	kQuitX = 0,
+	kQuitY = 0,
+	kQuitYesX1 = 30 * 8,
+	kQuitYesX2 = 38 * 8 + 4,
+	kQuitYesY1 = 50 * 8,
+	kQuitYesY2 = 53 * 8 + 4,
+	kQuitNoX1 = 41 * 8,
+	kQuitNoX2 = 49 * 8 + 4,
+	kQuitNoY1 = 50 * 8,
+	kQuitNoY2 = 53 * 8 + 4,
+
+	kControlX = 60,
+	kControlY = 40,
+	kControlUpX = 276 + kControlX,
+	kControlUpY = 114 + kControlY,
+	kControlDownX = 276 + kControlX,
+	kControlDownY = 129 + kControlY,
+	kControlLeftX = 396 + kControlX,
+	kControlLeftY = 114 + kControlY,
+	kControlRightX = 396 + kControlX,
+	kControlRightY = 129 + kControlY,
+	kControlUseX = 330 + kControlX,
+	kControlUseY = 209 + kControlY,
+	kControlWidth = 32,
+	kControlHeight = 16,
+
+	kAssignX = kControlX + 20 * 8,
+	kAssignY = kControlY + 150,
+
+	kBackoutX = 0,
+	kBackoutY = kScreenHeight - 32,
+
+	kWarpBackoutX = kBackoutX,
+	kWarpBackoutY = kBackoutY,
+
+	kWarpX = 214,
+	kWarpY = 160,
+
+	kScreenFade = 512,
+	kNebulaCount = 7,
+	kMaxStars = 10
+};
+
+struct Star {
+	int x, y, speed, anim, delay;
+
+	Star() : x(0), y(0), speed(0), anim(0), delay(0) {}
+};
+
 class Menu {
 public:
 
@@ -42,6 +134,46 @@ public:
 	void fillSavegameSlots();
 
 	int _starWarp;
+	int _titleCycle;
+	uint32 _titleDelay;
+	bool _titleActive;
+	SoundType _resumeSong;	// the song that was playing before entering the Options screen
+
+	Picture *_ohhOhhGfx;
+	Picture *_titleScreen, *_titleLogo, *_hdbLogoScreen, *_menuBackoutGfx, *_controlButtonGfx, *_controlsGfx, *_menuBackspaceGfx;
+
+	int _rocketY, _rocketYVel, _rocketEx;	// Rocket Vars
+	Picture	*_rocketEx1, *_rocketEx2, *_rocketMain, *_rocketSecond;
+	int	_rocketX;
+
+	int	_nebulaX, _nebulaY, _nebulaYVel, _nebulaWhich;
+	Picture *_nebulaGfx[kNebulaCount];
+
+	Picture	*_newGfx, *_loadGfx, *_optionsGfx, *_quitGfx, *_resumeGfx, *_slotGfx;
+	Picture	*_modePuzzleGfx, *_modeActionGfx, *_modeLoadGfx, *_modeSaveGfx, *_quitScreen;
+	Tile *_vortexian[3];
+	Picture	*_star[3], *_warpGfx;
+	uint32 _quitTimer;
+	Picture	*_starRedGfx[2], *_starGreenGfx[2], *_starBlueGfx[2], *_versionGfx;
+
+	bool _menuActive, _optionsScrolling, _newgameActive, _sayHDB;
+	int	_gamefilesActive, _clickDelay, _saveSlot, _optionsActive, _quitActive, _warpActive;
+	int	_optionsScrollX, _optionsXV, _oBannerY;
+	int	_nextScreen, _loadOrSave;
+
+	Common::KeyCode _keyAssignUp, _keyAssignDown, _keyAssignLeft, _keyAssignRight, _keyAssignUse;
+	Picture	*_contArrowUp, *_contArrowDown, *_contArrowLeft, *_contArrowRight, *_contAssign, *_warpPlaque;
+//	void	ShowControl(int x, int y, short key);
+
+	bool _waitingForKey;
+	int	_whichKey;
+
+	Picture	*_sliderLeft, *_sliderMid, *_sliderRight, *_sliderKnob;
+	Picture	*_gCheckEmpty, *_gCheckOn, *_gCheckOff, *_gCheckLeft, *_gCheckRight;
+
+	SoundType _introSong, _titleSong;
+
+	Star _fStars[kMaxStars];
 };
 
 } // End of Namespace


Commit: 3fc69963f400b556fe7f1ddcea751ea83b3a1d7a
    https://github.com/scummvm/scummvm/commit/3fc69963f400b556fe7f1ddcea751ea83b3a1d7a
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:13+02:00

Commit Message:
HDB: Add setInMapName() and related data

Changed paths:
    engines/hdb/hdb.cpp
    engines/hdb/hdb.h


diff --git a/engines/hdb/hdb.cpp b/engines/hdb/hdb.cpp
index 242bb4c..11b3bc2 100644
--- a/engines/hdb/hdb.cpp
+++ b/engines/hdb/hdb.cpp
@@ -58,6 +58,7 @@ HDBGame::HDBGame(OSystem *syst, const ADGameDescription *gameDesc) : Engine(syst
 
 	_currentMapname[0] = _currentLuaName[0] = 0;
 	_lastMapname[0] = _lastLuaName[0] = 0;
+	_inMapName[0] = 0;
 
 	_monkeystone7 = STARS_MONKEYSTONE_7_FAKE;
 	_monkeystone14 = STARS_MONKEYSTONE_14_FAKE;
@@ -652,6 +653,58 @@ void HDBGame::useEntity(AIEntity *e) {
 	}
 }
 
+struct {
+	const char *fName, *printName;
+} mapNames[] = {
+	{	"MAP00",			"HDS Colby Jack" },
+	{	"MAP01",			"Servandrones, Inc." },
+	{	"MAP02",			"Pushbot Storage" },
+	{	"MAP03",			"Rightbot Problems" },
+	{	"MAP04",			"Shockbot Secrets" },
+	{	"MAP05",			"The Drain Pain" },
+	{	"MAP06",			"Energy Column Tower" },
+	{	"MAP07",			"Water Supply Systems" },
+	{	"MAP08",			"Food Supply Systems" },
+	{	"MAP09",			"Purple Storage Room" },
+	{	"MAP10",			"Back On The Jack" },
+	{	"MAP11",			"Bridia" },
+	{	"MAP12",			"BEAL Offices" },
+	{	"MAP13",			"BEAL Labs" },
+	{	"MAP14",			"Earthen Plain" },
+	{	"MAP15",			"Fatfrog Swamp" },
+	{	"MAP16",			"Fatfrog Deeps" },
+	{	"MAP17",			"Glacier West" },
+	{	"MAP18",			"Glacier East" },
+	{	"MAP19",			"Mystery Pizza Factory" },
+	{	"MAP20",			"Colby Jack Attack" },
+	{	"MAP21",			"Pharitale" },
+	{	"MAP22",			"Happy Meadow" },
+	{	"MAP23",			"Water Caves" },
+	{	"MAP24",			"Rocky Crag" },
+	{	"MAP25",			"Dragon Deeps" },
+	{	"MAP26",			"Lower Dragon Deeps" },
+	{	"MAP27",			"Ice Dragon Valley" },
+	{	"MAP28",			"Faerie Glade" },
+	{	"MAP29",			"Palace In The Clouds" },
+	{	"MAP30",			"Monkeystone Star Zone" },
+};
+
+void HDBGame::setInMapName(const char *name) {
+	int i = 0;
+
+	while (mapNames[i].fName) {
+		if (!scumm_stricmp(name, mapNames[i].fName)) {
+			memset(&_inMapName, 0, 32);
+			strcpy(_inMapName, mapNames[i].printName);
+			return;
+		}
+		i++;
+	}
+
+	memset(&_inMapName, 0, 32);
+	strcpy(_inMapName, name);
+}
+
 Common::Error HDBGame::run() {
 
 	// Initialize System
diff --git a/engines/hdb/hdb.h b/engines/hdb/hdb.h
index 3444fbf..e16ee5a 100644
--- a/engines/hdb/hdb.h
+++ b/engines/hdb/hdb.h
@@ -48,10 +48,6 @@
 #include "hdb/sound.h"
 #include "hdb/window.h"
 
-#define MAX_SNDCACHE_MEM	0x400000	// 4Mb of sounds in memory
-#define MAX_TILES_CACHED	3500		// Max no of tiles in memory at once
-#define GFX_CACHE_LIMIT		0x800000
-
 struct ADGameDescription;
 
 namespace HDB {
@@ -211,7 +207,10 @@ public:
 		return _timeSlice - _prevTimeSlice;
 	}
 
-	char *lastMapname() { return _lastMapname; }
+	char *lastMapName() { return _lastMapname; }
+	char *currentMapName() { return _currentMapname; }
+	char *getInMapName() { return _inMapName; }
+	void setInMapName(const char *name);
 
 	void changeLevel(const char *name) {
 		strcpy(_changeMapname, name);
@@ -253,6 +252,8 @@ private:
 	char _currentLuaName[64];
 	char _lastLuaName[64];
 
+	char _inMapName[32];	// Name Inside Map file
+
 	int32 _monkeystone7;
 	int32 _monkeystone14;
 	int32 _monkeystone21;


Commit: 06c87e518c44ad64ee433689408013a7dbc0efc1
    https://github.com/scummvm/scummvm/commit/06c87e518c44ad64ee433689408013a7dbc0efc1
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:13+02:00

Commit Message:
HDB: Add HDBGame save() and load()

Changed paths:
    engines/hdb/hdb.cpp
    engines/hdb/hdb.h


diff --git a/engines/hdb/hdb.cpp b/engines/hdb/hdb.cpp
index 11b3bc2..649c4a9 100644
--- a/engines/hdb/hdb.cpp
+++ b/engines/hdb/hdb.cpp
@@ -127,6 +127,26 @@ bool HDBGame::init() {
 	return true;
 }
 
+void HDBGame::save(Common::OutSaveFile *out) {
+	out->write(_currentMapname, 64);
+	out->write(_lastMapname, 64);
+	out->write(_currentLuaName, 64);
+	out->writeSint32LE(_actionMode);
+	out->writeByte(_changeLevel);
+	out->write(_changeMapname, 64);
+	out->write(_inMapName, 32);
+}
+
+void HDBGame::load(Common::InSaveFile *in) {
+	in->read(_currentMapname, 64);
+	in->read(_lastMapname, 64);
+	in->read(_currentLuaName, 64);
+	_actionMode = in->readSint32LE();
+	_changeLevel = in->readByte();
+	in->read(_changeMapname, 64);
+	in->read(_inMapName, 32);
+}
+
 /*
 	Changes the current GameState to the next one.
 	Game State Transitions are deterministic: each state can
diff --git a/engines/hdb/hdb.h b/engines/hdb/hdb.h
index e16ee5a..01ed0b9 100644
--- a/engines/hdb/hdb.h
+++ b/engines/hdb/hdb.h
@@ -30,6 +30,7 @@
 #include "common/events.h"
 #include "common/str.h"
 #include "common/random.h"
+#include "common/savefile.h"
 #include "graphics/surface.h"
 
 #include "gui/debugger.h"
@@ -144,6 +145,8 @@ public:
 	// Game related members;
 
 	bool init();
+	void save(Common::OutSaveFile *out);
+	void load(Common::InSaveFile *in);
 
 	bool restartMap();
 	bool startMap(const char *name);


Commit: 8d57db257298d536f4d9e274e64d652a080462a8
    https://github.com/scummvm/scummvm/commit/8d57db257298d536f4d9e274e64d652a080462a8
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:13+02:00

Commit Message:
HDB: Add Map save() and loadSaveFile()

Changed paths:
    engines/hdb/map.cpp
    engines/hdb/map.h


diff --git a/engines/hdb/map.cpp b/engines/hdb/map.cpp
index c99f3f2..313e617 100644
--- a/engines/hdb/map.cpp
+++ b/engines/hdb/map.cpp
@@ -48,6 +48,133 @@ Map::~Map() {
 	}
 }
 
+void Map::save(Common::OutSaveFile *out) {
+
+	int i, count;
+
+	// Save Map Dimensions and Offsets
+	out->writeSint32LE(_mapX);
+	out->writeSint32LE(_mapY);
+	out->writeSint32LE(_width);
+	out->writeSint32LE(_height);
+	out->writeSint32LE(_mapTileX);
+	out->writeSint32LE(_mapTileY);
+	out->writeSint32LE(_mapTileXOff);
+	out->writeSint32LE(_mapTileYOff);
+
+	// Save out all Level2 Gratings and AnimCycle
+
+	out->writeSint32LE(_numGratings);
+	for (i = 0; i < _numGratings; i++)
+		out->write(_gratings[i], sizeof(_gratings[0]));
+
+	out->writeSint32LE(_animCycle);
+
+	// find out how many SLOW, MEDIUM & FAST bg tile anims there are and save them all out
+	out->writeUint32LE(_listBGAnimSlow.size());
+	for (i = 0; (uint)i < _listBGAnimSlow.size(); i++) {
+		out->writeUint32LE(_listBGAnimSlow[i]);
+	}
+
+	out->writeUint32LE(_listBGAnimMedium.size());
+	for (i = 0; (uint)i < _listBGAnimMedium.size(); i++) {
+		out->writeUint32LE(_listBGAnimMedium[i]);
+	}
+
+	out->writeUint32LE(_listBGAnimFast.size());
+	for (i = 0; (uint)i < _listBGAnimFast.size(); i++) {
+		out->writeUint32LE(_listBGAnimFast[i]);
+	}
+
+	// find out how many SLOW, MEDIUM & FAST fg tile anims there are and save them all out
+
+	out->writeUint32LE(_listFGAnimSlow.size());
+	for (i = 0; (uint)i < _listFGAnimSlow.size(); i++) {
+		out->writeUint32LE(_listFGAnimSlow[i]);
+	}
+
+	out->writeUint32LE(_listFGAnimMedium.size());
+	for (i = 0; (uint)i < _listFGAnimMedium.size(); i++) {
+		out->writeUint32LE(_listFGAnimMedium[i]);
+	}
+
+	out->writeUint32LE(_listFGAnimFast.size());
+	for (i = 0; (uint)i < _listFGAnimFast.size(); i++) {
+		out->writeUint32LE(_listFGAnimFast[i]);
+	}
+
+	// save map data
+	out->write(_background, sizeof(int32) * _width * _height);
+	out->write(_foreground, sizeof(int32) * _width * _height);
+	out->write(_mapExplosions, sizeof(byte) * _width * _height);
+	out->write(_mapExpBarrels, sizeof(byte) * _width * _height);
+	out->write(_mapLaserBeams, sizeof(byte) * _width * _height);
+}
+
+void Map::loadSaveFile(Common::InSaveFile *in) {
+	int i, count;
+
+	restartSystem();
+
+	// Load Map Dimensions and Offsets
+	_mapX = in->readSint32LE();
+	_mapY = in->readSint32LE();
+	_width = in->readSint32LE();
+	_height = in->readSint32LE();
+	_mapTileX = in->readSint32LE();
+	_mapTileY = in->readSint32LE();
+	_mapTileXOff = in->readSint32LE();
+	_mapTileYOff = in->readSint32LE();
+
+	// Load All level2 gratings and animCycle
+
+	_numGratings = in->readSint32LE();
+	for (i = 0; i < _numGratings; i++)
+		in->read(_gratings[i], sizeof(_gratings[0]));
+
+	_animCycle = in->readSint32LE();
+
+	// find out how many SLOW, MEDIUM & FAST bg tile anims there are and load them all out
+	_listBGAnimSlow.resize(in->readUint32LE());
+	for (i = 0; (uint)i < _listBGAnimSlow.size(); i++) {
+		_listBGAnimSlow[i] = in->readUint32LE();
+	}
+
+	_listBGAnimMedium.resize(in->readUint32LE());
+	for (i = 0; (uint)i < _listBGAnimMedium.size(); i++) {
+		_listBGAnimMedium[i] = in->readUint32LE();
+	}
+
+	_listBGAnimFast.resize(in->readUint32LE());
+	for (i = 0; (uint)i < _listBGAnimFast.size(); i++) {
+		_listBGAnimFast[i] = in->readUint32LE();
+	}
+
+	// find out how many SLOW, MEDIUM & FAST fg tile anims there are and load them all out
+
+	_listFGAnimSlow.resize(in->readUint32LE());
+	for (i = 0; (uint)i < _listFGAnimSlow.size(); i++) {
+		_listFGAnimSlow[i] = in->readUint32LE();
+	}
+
+	_listFGAnimMedium.resize(in->readUint32LE());
+	for (i = 0; (uint)i < _listFGAnimMedium.size(); i++) {
+		_listFGAnimMedium[i] = in->readUint32LE();
+	}
+
+	_listFGAnimFast.resize(in->readUint32LE());
+	for (i = 0; (uint)i < _listFGAnimFast.size(); i++) {
+		_listFGAnimFast[i] = in->readUint32LE();
+	}
+
+	// load map data
+	in->read(_background, sizeof(int32) * _width * _height);
+	in->read(_foreground, sizeof(int32) * _width * _height);
+	in->read(_mapExplosions, sizeof(byte) * _width * _height);
+	in->read(_mapExpBarrels, sizeof(byte) * _width * _height);
+	in->read(_mapLaserBeams, sizeof(byte) * _width * _height);
+}
+
 int Map::loadTiles() {
 
 	int tile, temp;
diff --git a/engines/hdb/map.h b/engines/hdb/map.h
index 3360e91..d6b0bda 100644
--- a/engines/hdb/map.h
+++ b/engines/hdb/map.h
@@ -74,6 +74,8 @@ public:
 	Map();
 	~Map();
 
+	void save(Common::OutSaveFile *out);
+	void loadSaveFile(Common::InSaveFile *in);
 	void restartSystem();
 
 	int loadTiles();


Commit: 40879e47ddcefff4be32133b2dd994b155459383
    https://github.com/scummvm/scummvm/commit/40879e47ddcefff4be32133b2dd994b155459383
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:13+02:00

Commit Message:
HDB: Fix Name Change

Changed paths:
    engines/hdb/lua-script.cpp


diff --git a/engines/hdb/lua-script.cpp b/engines/hdb/lua-script.cpp
index 7c9664f..da1f91e 100644
--- a/engines/hdb/lua-script.cpp
+++ b/engines/hdb/lua-script.cpp
@@ -1415,7 +1415,7 @@ bool LuaScript::initScript(Common::SeekableReadStream *stream, const char *scrip
 	}
 
 	// set the last mapname as a global
-	lua_pushstring(_state, g_hdb->lastMapname());
+	lua_pushstring(_state, g_hdb->lastMapName());
 	lua_setglobal(_state, "LASTMAP");
 
 	// Set the lowest printable line


Commit: cdf8d2548fc06b52e42019ae719d675f6a576f33
    https://github.com/scummvm/scummvm/commit/cdf8d2548fc06b52e42019ae719d675f6a576f33
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:13+02:00

Commit Message:
HDB: Remove unreferenced variable

Changed paths:
    engines/hdb/map.cpp


diff --git a/engines/hdb/map.cpp b/engines/hdb/map.cpp
index 313e617..be1cfe6 100644
--- a/engines/hdb/map.cpp
+++ b/engines/hdb/map.cpp
@@ -50,7 +50,7 @@ Map::~Map() {
 
 void Map::save(Common::OutSaveFile *out) {
 
-	int i, count;
+	int i;
 
 	// Save Map Dimensions and Offsets
 	out->writeSint32LE(_mapX);
@@ -112,7 +112,7 @@ void Map::save(Common::OutSaveFile *out) {
 }
 
 void Map::loadSaveFile(Common::InSaveFile *in) {
-	int i, count;
+	int i;
 
 	restartSystem();
 


Commit: 6559b7181900e8b174d92ff9b32759495c566bfb
    https://github.com/scummvm/scummvm/commit/6559b7181900e8b174d92ff9b32759495c566bfb
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:14+02:00

Commit Message:
HDB: Fix removeBGTileAnimation() and removeFGTileAnimation() implementations

Changed paths:
    engines/hdb/map.cpp


diff --git a/engines/hdb/map.cpp b/engines/hdb/map.cpp
index be1cfe6..b6e6774 100644
--- a/engines/hdb/map.cpp
+++ b/engines/hdb/map.cpp
@@ -984,61 +984,47 @@ void Map::addFGTileAnimation(int x, int y) {
 }
 
 void Map::removeBGTileAnimation(int x, int y) {
-	int i = y * _width + x;
+	uint idx = y * _width + x;
 
-	Tile *tile = g_hdb->_gfx->getTile(_background[i]);
-	if (!tile)
-		return;
-	uint32 flags = tile->_flags;
+	for (uint i = 0; i < _listBGAnimFast.size(); i++)
+		if (_listBGAnimFast[i] == idx) {
+			_listBGAnimFast.remove_at(i);
+			return;
+		}
 
-	if (flags & kFlagAnimFast) {
-		for (Common::Array<uint32>::iterator it = _listBGAnimFast.begin(); it!=_listBGAnimFast.end(); it++)
-			if ((uint)i == (*it)) {
-				_listBGAnimFast.erase(it);
-				break;
-			}
-	} else if (flags & kFlagAnimSlow) {
-		for (Common::Array<uint32>::iterator it = _listBGAnimSlow.begin(); it != _listBGAnimSlow.end(); it++)
-			if ((uint)i == (*it)) {
-				_listBGAnimSlow.erase(it);
-				break;
-			}
-	} else if (flags & kFlagAnimMedium) {
-		for (Common::Array<uint32>::iterator it = _listBGAnimMedium.begin(); it != _listBGAnimMedium.end(); it++)
-			if ((uint)i == (*it)) {
-				_listBGAnimMedium.erase(it);
-				break;
-			}
-	}
+	for (uint i = 0; i < _listBGAnimSlow.size(); i++)
+		if (_listBGAnimSlow[i] == idx) {
+			_listBGAnimSlow.remove_at(i);
+			return;
+		}
+
+	for (uint i = 0; i < _listBGAnimMedium.size(); i++)
+		if (_listBGAnimMedium[i] == idx) {
+			_listBGAnimMedium.remove_at(i);
+			return;
+		}
 }
 
 void Map::removeFGTileAnimation(int x, int y) {
-	int i = y * _width + x;
+	uint idx = y * _width + x;
 
-	Tile *tile = g_hdb->_gfx->getTile(_foreground[i]);
-	if (!tile)
-		return;
-	uint32 flags = tile->_flags;
+	for (uint i = 0; i < _listFGAnimFast.size(); i++)
+		if (_listFGAnimFast[i] == idx) {
+			_listFGAnimFast.remove_at(i);
+			return;
+		}
 
-	if (flags & kFlagAnimFast) {
-		for (Common::Array<uint32>::iterator it = _listFGAnimFast.begin(); it!=_listFGAnimFast.end(); it++)
-			if ((uint)i == (*it)) {
-				_listFGAnimFast.erase(it);
-				break;
-			}
-	} else if (flags & kFlagAnimSlow) {
-		for (Common::Array<uint32>::iterator it = _listFGAnimSlow.begin(); it != _listFGAnimSlow.end(); it++)
-			if ((uint)i == (*it)) {
-				_listFGAnimSlow.erase(it);
-				break;
-			}
-	} else if (flags & kFlagAnimMedium) {
-		for (Common::Array<uint32>::iterator it = _listFGAnimMedium.begin(); it != _listFGAnimMedium.end(); it++)
-			if ((uint)i == (*it)) {
-				_listFGAnimMedium.erase(it);
-				break;
-			}
-	}
+	for (uint i = 0; i < _listFGAnimSlow.size(); i++)
+		if (_listFGAnimSlow[i] == idx) {
+			_listFGAnimSlow.remove_at(i);
+			return;
+		}
+
+	for (uint i = 0; i < _listFGAnimMedium.size(); i++)
+		if (_listFGAnimMedium[i] == idx) {
+			_listFGAnimMedium.remove_at(i);
+			return;
+		}
 }
 
 void Map::getMapXY(int *x, int *y) {


Commit: c819a79c9b265893196e9c06dac6155235275e7e
    https://github.com/scummvm/scummvm/commit/c819a79c9b265893196e9c06dac6155235275e7e
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:14+02:00

Commit Message:
HDB: Add Window save() and loadSaveFile()

Changed paths:
    engines/hdb/window.cpp
    engines/hdb/window.h


diff --git a/engines/hdb/window.cpp b/engines/hdb/window.cpp
index 7637ffc..b115426 100644
--- a/engines/hdb/window.cpp
+++ b/engines/hdb/window.cpp
@@ -89,6 +89,76 @@ bool Window::init() {
 	return true;
 }
 
+void Window::save(Common::OutSaveFile *out) {
+
+	int i;
+
+	// Save out the various window and game state info
+
+	// clear out gfx ptrs in _pzInfo struct before writing...
+	memcpy(&_tempPzInfo, &_pzInfo, sizeof(_pzInfo));
+	for (i = 0; i < 10; i++) {
+		_tempPzInfo.gfxNumber[i] = NULL;
+		if (i < 2)
+			_tempPzInfo.gfxFace[i] = NULL;
+	}
+	_tempPzInfo.gfxPanic = _tempPzInfo.gfxZone = NULL;
+
+	out->write(&_tempPzInfo, sizeof(_pzInfo));
+	out->write(&_dialogInfo, sizeof(_dialogInfo));
+	out->writeSint32LE(_dialogDelay);
+	out->write(&_dialogChoiceInfo, sizeof(_dialogChoiceInfo));
+	out->write(&_msgInfo, sizeof(_msgInfo));
+	out->write(&_msgQueueStr, sizeof(char) * 128 * kMaxMsgQueue);
+	out->write(&_msgQueueWait, sizeof(int) * kMaxMsgQueue);
+	out->writeSint32LE(_numMsgQueue);
+	out->write(&_invWinInfo, sizeof(_invWinInfo));
+	out->write(&_dlvsInfo, sizeof(_dlvsInfo));
+	debug(9, "STUB: Save Try Again data");
+
+	out->writeUint32LE(_textOutList.size());
+	for (i = 0; (uint)i < _textOutList.size(); i++) {
+		out->write(_textOutList[i], sizeof(TOut));
+	}
+
+	out->write(&_infobarDimmed, sizeof(_infobarDimmed));
+
+}
+
+void Window::loadSaveFile(Common::InSaveFile *in) {
+
+	int i;
+
+	// Clear out everything
+	restartSystem();
+
+	// Load out various Window and Game State Info
+	in->read(&_pzInfo, sizeof(_pzInfo));
+	in->read(&_dialogInfo, sizeof(_dialogInfo));
+	_dialogDelay = in->readSint32LE();
+	if (_dialogDelay)
+		_dialogDelay = g_system->getMillis() + 1000;
+
+	in->read(&_dialogChoiceInfo, sizeof(_dialogChoiceInfo));
+	_dialogChoiceInfo.timeout = g_system->getMillis() + 1000;
+
+	in->read(&_msgInfo, sizeof(_msgInfo));
+	in->read(&_msgQueueStr, sizeof(char) * 128 * kMaxMsgQueue);
+	in->read(&_msgQueueWait, sizeof(int) * kMaxMsgQueue);
+	_numMsgQueue = in->readSint32LE();
+	in->read(&_invWinInfo, sizeof(_invWinInfo));
+	in->read(&_dlvsInfo, sizeof(_dlvsInfo));
+	debug(9, "STUB: Load Try Again data");
+
+	_textOutList.resize(in->readUint32LE());
+	for (i = 0; (uint)i < _textOutList.size(); i++) {
+		in->read(_textOutList[i], sizeof(TOut));
+		_textOutList[i]->timer = g_system->getMillis() + 1000;
+	}
+
+	in->read(&_infobarDimmed, sizeof(_infobarDimmed));
+}
+
 void Window::restartSystem() {
 	_numMsgQueue = 0;
 	_msgInfo.active = false;
diff --git a/engines/hdb/window.h b/engines/hdb/window.h
index 1615dea..be7bbfc 100644
--- a/engines/hdb/window.h
+++ b/engines/hdb/window.h
@@ -178,6 +178,8 @@ class Window {
 public:
 
 	bool init();
+	void save(Common::OutSaveFile *out);
+	void loadSaveFile(Common::InSaveFile *in);
 	void restartSystem();
 	void setInfobarDark(int value);
 


Commit: 55a58747e2fd10c2f5dd05d50ff2fb55a1e71ec6
    https://github.com/scummvm/scummvm/commit/55a58747e2fd10c2f5dd05d50ff2fb55a1e71ec6
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:14+02:00

Commit Message:
HDB: Add Gfx save() and loadSaveFile()

Changed paths:
    engines/hdb/gfx.cpp
    engines/hdb/gfx.h


diff --git a/engines/hdb/gfx.cpp b/engines/hdb/gfx.cpp
index 3fdba2e..57d0cc7 100644
--- a/engines/hdb/gfx.cpp
+++ b/engines/hdb/gfx.cpp
@@ -137,6 +137,22 @@ bool Gfx::init() {
 	return true;
 }
 
+void Gfx::save(Common::OutSaveFile *out) {
+	out->writeSint32LE(_currentSky);
+	out->write(&_fadeInfo, sizeof(_fadeInfo));
+	out->write(&_snowInfo, sizeof(_snowInfo));
+}
+
+void Gfx::loadSaveFile(Common::InSaveFile *in) {
+	_currentSky = in->readSint32LE();
+	in->read(&_fadeInfo, sizeof(_fadeInfo));
+	in->read(&_snowInfo, sizeof(_snowInfo));
+	setSky(_currentSky);
+	turnOffSnow();
+	if (_snowInfo.active)
+		turnOnSnow();
+}
+
 void Gfx::fillScreen(uint32 color) {
 	_globalSurface.fillRect(Common::Rect(kScreenWidth, kScreenHeight), color);
 	g_system->fillScreen(color);
diff --git a/engines/hdb/gfx.h b/engines/hdb/gfx.h
index 597bf7f..88fb250 100644
--- a/engines/hdb/gfx.h
+++ b/engines/hdb/gfx.h
@@ -91,6 +91,8 @@ public:
 	Graphics::ManagedSurface _globalSurface;
 
 	bool init();
+	void save(Common::OutSaveFile *out);
+	void loadSaveFile(Common::InSaveFile *in);
 	void fillScreen(uint32 color);
 	void updateVideo();
 	void setPointerState(int value);


Commit: 2eb9bdfee86c5687e7cdc4e588a8c00764ab98fa
    https://github.com/scummvm/scummvm/commit/2eb9bdfee86c5687e7cdc4e588a8c00764ab98fa
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:14+02:00

Commit Message:
HDB: Add stubbed Sound save() and loadSaveFile()

Changed paths:
    engines/hdb/sound.cpp
    engines/hdb/sound.h


diff --git a/engines/hdb/sound.cpp b/engines/hdb/sound.cpp
index 5f5cf86..cdda643 100644
--- a/engines/hdb/sound.cpp
+++ b/engines/hdb/sound.cpp
@@ -29,6 +29,14 @@ bool Sound::init() {
 	return true;
 }
 
+void Sound::save(Common::OutSaveFile *out) {
+	warning("STUB: Sound::save()");
+}
+
+void Sound::loadSaveFile(Common::InSaveFile *in) {
+	warning("STUB: Sound::loadSaveFile()");
+}
+
 bool Sound::playSound(int index) {
 	debug(9, "STUB: Play Sound");
 	return true;
diff --git a/engines/hdb/sound.h b/engines/hdb/sound.h
index 65c61f2..8d0d6ba 100644
--- a/engines/hdb/sound.h
+++ b/engines/hdb/sound.h
@@ -1388,6 +1388,8 @@ class Sound {
 public:
 
 	bool init();
+	void save(Common::OutSaveFile *out);
+	void loadSaveFile(Common::InSaveFile *in);
 	int getMusicVolume() {
 		debug(9, "STUB: Add Music System Variables");
 		return 1;


Commit: 6f472b60a65f01b250dc5c18d3209d4e555cc0bf
    https://github.com/scummvm/scummvm/commit/6f472b60a65f01b250dc5c18d3209d4e555cc0bf
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:14+02:00

Commit Message:
HDB: Fix Endian reading issues

Changed paths:
    engines/hdb/map.cpp


diff --git a/engines/hdb/map.cpp b/engines/hdb/map.cpp
index b6e6774..7f0c418 100644
--- a/engines/hdb/map.cpp
+++ b/engines/hdb/map.cpp
@@ -65,8 +65,11 @@ void Map::save(Common::OutSaveFile *out) {
 	// Save out all Level2 Gratings and AnimCycle
 
 	out->writeSint32LE(_numGratings);
-	for (i = 0; i < _numGratings; i++)
-		out->write(_gratings[i], sizeof(_gratings[0]));
+	for (i = 0; i < _numGratings; i++) {
+		out->writeUint16LE(_gratings[i]->x);
+		out->writeUint16LE(_gratings[i]->y);
+		out->writeUint16LE(_gratings[i]->tile);
+	}
 
 	out->writeSint32LE(_animCycle);
 
@@ -104,11 +107,16 @@ void Map::save(Common::OutSaveFile *out) {
 	}
 
 	// save map data
-	out->write(_background, sizeof(int32) * _width * _height);
-	out->write(_foreground, sizeof(int32) * _width * _height);
-	out->write(_mapExplosions, sizeof(byte) * _width * _height);
-	out->write(_mapExpBarrels, sizeof(byte) * _width * _height);
-	out->write(_mapLaserBeams, sizeof(byte) * _width * _height);
+	for (i = 0; i < _width * _height; i++)
+		out->writeSint32LE(_background[i]);
+	for (i = 0; i < _width * _height; i++)
+		out->writeSint32LE(_foreground[i]);
+	for (i = 0; i < _width * _height; i++)
+		out->writeByte(_mapExplosions[i]);
+	for (i = 0; i < _width * _height; i++)
+		out->writeByte(_mapExpBarrels[i]);
+	for (i = 0; i < _width * _height; i++)
+		out->writeByte(_mapLaserBeams[i]);
 }
 
 void Map::loadSaveFile(Common::InSaveFile *in) {
@@ -129,8 +137,11 @@ void Map::loadSaveFile(Common::InSaveFile *in) {
 	// Load All level2 gratings and animCycle
 
 	_numGratings = in->readSint32LE();
-	for (i = 0; i < _numGratings; i++)
-		in->read(_gratings[i], sizeof(_gratings[0]));
+	for (i = 0; i < _numGratings; i++) {
+		_gratings[i]->x = in->readUint16LE();
+		_gratings[i]->y = in->readUint16LE();
+		_gratings[i]->tile = in->readUint16LE();
+	}
 
 	_animCycle = in->readSint32LE();
 
@@ -168,11 +179,17 @@ void Map::loadSaveFile(Common::InSaveFile *in) {
 	}
 
 	// load map data
-	in->read(_background, sizeof(int32) * _width * _height);
-	in->read(_foreground, sizeof(int32) * _width * _height);
-	in->read(_mapExplosions, sizeof(byte) * _width * _height);
-	in->read(_mapExpBarrels, sizeof(byte) * _width * _height);
-	in->read(_mapLaserBeams, sizeof(byte) * _width * _height);
+
+	for (i = 0; i < _width * _height; i++)
+		_background[i] = in->readSint32LE();
+	for (i = 0; i < _width * _height; i++)
+		_foreground[i] = in->readSint32LE();
+	for (i = 0; i < _width * _height; i++)
+		_mapExplosions[i] = in->readByte();
+	for (i = 0; i < _width * _height; i++)
+		_mapExpBarrels[i] = in->readByte();
+	for (i = 0; i < _width * _height; i++)
+		_mapLaserBeams[i] = in->readByte();
 }
 
 int Map::loadTiles() {


Commit: 8b806991b99238b0f41b2b84492d4d8af7c84bf8
    https://github.com/scummvm/scummvm/commit/8b806991b99238b0f41b2b84492d4d8af7c84bf8
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:14+02:00

Commit Message:
HDB: Add save and loadSave functions

For Tile and Pic

Changed paths:
    engines/hdb/gfx.cpp
    engines/hdb/gfx.h


diff --git a/engines/hdb/gfx.cpp b/engines/hdb/gfx.cpp
index 57d0cc7..ba656c8 100644
--- a/engines/hdb/gfx.cpp
+++ b/engines/hdb/gfx.cpp
@@ -237,6 +237,38 @@ Tile *Gfx::loadTile(const char *tileName) {
 	return tile;
 }
 
+void Gfx::savePic(Picture *pic, Common::OutSaveFile *out) {
+	if (pic == NULL) {
+		for (int i = 0; i < 64; i++)
+			out->writeByte(0);
+	} else {
+		out->write(pic->getName(), 64);
+	}
+}
+
+void Gfx::saveTile(Tile *tile, Common::OutSaveFile *out) {
+	if (tile == NULL) {
+		for (int i = 0; i < 64; i++)
+			out->writeByte(0);
+	} else {
+		out->write(tile->getName(), 64);
+	}
+}
+
+void Gfx::loadPicSave(Picture *pic, Common::InSaveFile *in) {
+	delete pic;
+	char readName[64];
+	in->read(readName, 64);
+	pic = loadPic(readName);
+}
+
+void Gfx::loadTileSave(Tile *tile, Common::InSaveFile *in) {
+	delete tile;
+	char readName[64];
+	in->read(readName, 64);
+	tile = loadTile(readName);
+}
+
 Tile *Gfx::getTile(int index) {
 
 	if (index < 0 || index > _numTiles) {
diff --git a/engines/hdb/gfx.h b/engines/hdb/gfx.h
index 88fb250..6439fbf 100644
--- a/engines/hdb/gfx.h
+++ b/engines/hdb/gfx.h
@@ -114,6 +114,10 @@ public:
 
 	Picture *loadPic(const char *picName);
 	Tile *loadTile(const char *tileName);
+	void savePic(Picture *pic, Common::OutSaveFile *out);
+	void saveTile(Tile *tile, Common::OutSaveFile *out);
+	void loadPicSave(Picture *pic, Common::InSaveFile *in);
+	void loadTileSave(Tile *tile, Common::InSaveFile *in);
 
 	Tile *getTile(int index);
 	void cacheTileSequence(int index, int count);


Commit: 2990f6cff58ad8fd39d923d35081cf2468fe5cb1
    https://github.com/scummvm/scummvm/commit/2990f6cff58ad8fd39d923d35081cf2468fe5cb1
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:14+02:00

Commit Message:
HDB: Fix endian issues

Changed paths:
    engines/hdb/gfx.cpp


diff --git a/engines/hdb/gfx.cpp b/engines/hdb/gfx.cpp
index ba656c8..63e8215 100644
--- a/engines/hdb/gfx.cpp
+++ b/engines/hdb/gfx.cpp
@@ -138,15 +138,51 @@ bool Gfx::init() {
 }
 
 void Gfx::save(Common::OutSaveFile *out) {
+	int i;
+
 	out->writeSint32LE(_currentSky);
-	out->write(&_fadeInfo, sizeof(_fadeInfo));
-	out->write(&_snowInfo, sizeof(_snowInfo));
+
+	out->writeByte(_fadeInfo.active);
+	out->writeByte(_fadeInfo.stayFaded);
+	out->writeByte(_fadeInfo.isBlack);
+	out->writeSint32LE(_fadeInfo.speed);
+	out->writeByte(_fadeInfo.isFadeIn);
+	out->writeSint32LE(_fadeInfo.curStep);
+
+	out->writeByte(_snowInfo.active);
+	for (i = 0; i < MAX_SNOW; i++)
+		warning("STUB: Save Double Value");
+	for (i = 0; i < MAX_SNOW; i++)
+		warning("STUB: Save Double Value");
+	for (i = 0; i < MAX_SNOW; i++)
+		warning("STUB: Save Double Value");
+	for (i = 0; i < MAX_SNOW; i++)
+		out->writeSint32LE(_snowInfo.xvindex[i]);
 }
 
 void Gfx::loadSaveFile(Common::InSaveFile *in) {
+	int i;
+
 	_currentSky = in->readSint32LE();
-	in->read(&_fadeInfo, sizeof(_fadeInfo));
-	in->read(&_snowInfo, sizeof(_snowInfo));
+
+	_fadeInfo.active = in->readByte();
+	_fadeInfo.stayFaded = in->readByte();
+	_fadeInfo.isBlack = in->readByte();
+	_fadeInfo.speed = in->readSint32LE();
+	_fadeInfo.isFadeIn = in->readByte();
+	_fadeInfo.curStep = in->readSint32LE();
+
+	_snowInfo.active = in->readByte();
+
+	for (i = 0; i < MAX_SNOW; i++)
+		warning("STUB: Load Double Value");
+	for (i = 0; i < MAX_SNOW; i++)
+		warning("STUB: Load Double Value");
+	for (i = 0; i < MAX_SNOW; i++)
+		warning("STUB: Load Double Value");
+	for (i = 0; i < MAX_SNOW; i++)
+		_snowInfo.xvindex[i] = in->readSint32LE();
+
 	setSky(_currentSky);
 	turnOffSnow();
 	if (_snowInfo.active)


Commit: 0a6d4c042f5634979104e1418f07509e37532b22
    https://github.com/scummvm/scummvm/commit/0a6d4c042f5634979104e1418f07509e37532b22
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:14+02:00

Commit Message:
HDB: Fix endian issues

Changed paths:
    engines/hdb/window.cpp


diff --git a/engines/hdb/window.cpp b/engines/hdb/window.cpp
index b115426..54381d0 100644
--- a/engines/hdb/window.cpp
+++ b/engines/hdb/window.cpp
@@ -96,7 +96,21 @@ void Window::save(Common::OutSaveFile *out) {
 	// Save out the various window and game state info
 
 	// clear out gfx ptrs in _pzInfo struct before writing...
-	memcpy(&_tempPzInfo, &_pzInfo, sizeof(_pzInfo));
+
+	// Copy, clear and save Panic Zone Info
+	_tempPzInfo.active = _pzInfo.active;
+	_tempPzInfo.sequence = _pzInfo.sequence;
+	_tempPzInfo.timer = _pzInfo.timer;
+	_tempPzInfo.x1 = _pzInfo.x1;
+	_tempPzInfo.y1 = _pzInfo.y1;
+	_tempPzInfo.x2 = _pzInfo.x2;
+	_tempPzInfo.y2 = _pzInfo.y2;
+	_tempPzInfo.xv = _pzInfo.xv;
+	_tempPzInfo.yv = _pzInfo.yv;
+	_tempPzInfo.numberTime = _pzInfo.numberTime;
+	_tempPzInfo.numberTimeMaster = _pzInfo.numberTimeMaster;
+	_tempPzInfo.numberValue = _pzInfo.numberValue;
+
 	for (i = 0; i < 10; i++) {
 		_tempPzInfo.gfxNumber[i] = NULL;
 		if (i < 2)
@@ -104,25 +118,121 @@ void Window::save(Common::OutSaveFile *out) {
 	}
 	_tempPzInfo.gfxPanic = _tempPzInfo.gfxZone = NULL;
 
-	out->write(&_tempPzInfo, sizeof(_pzInfo));
-	out->write(&_dialogInfo, sizeof(_dialogInfo));
+	out->writeByte(_tempPzInfo.active);
+	out->writeSint32LE(_tempPzInfo.sequence);
+	out->writeSint32LE(_tempPzInfo.timer);
+	out->writeSint32LE(_tempPzInfo.x1);
+	out->writeSint32LE(_tempPzInfo.y1);
+	out->writeSint32LE(_tempPzInfo.x2);
+	out->writeSint32LE(_tempPzInfo.y2);
+	out->writeSint32LE(_tempPzInfo.xv);
+	out->writeSint32LE(_tempPzInfo.yv);
+	out->writeSint32LE(_tempPzInfo.numberTime);
+	out->writeSint32LE(_tempPzInfo.numberTimeMaster);
+	out->writeSint32LE(_tempPzInfo.numberValue);
+	g_hdb->_gfx->savePic(_tempPzInfo.gfxPanic, out);
+	g_hdb->_gfx->savePic(_tempPzInfo.gfxZone, out);
+	for (i = 0; i < 10; i++) {
+		g_hdb->_gfx->savePic(_tempPzInfo.gfxNumber[i], out);
+		if (i < 2)
+			g_hdb->_gfx->savePic(_tempPzInfo.gfxFace[i], out);
+	}
+
+	// Save Dialog Info
+	out->write(_dialogInfo.title, 64);
+	out->writeSint32LE(_dialogInfo.tileIndex);
+	out->write(_dialogInfo.string, 160);
+	out->writeByte(_dialogInfo.active);
+	out->writeSint32LE(_dialogInfo.x);
+	out->writeSint32LE(_dialogInfo.y);
+	out->writeSint32LE(_dialogInfo.width);
+	out->writeSint32LE(_dialogInfo.height);
+	out->writeSint32LE(_dialogInfo.titleWidth);
+	g_hdb->_gfx->savePic(_dialogInfo.gfx, out);
+	out->writeSint32LE(_dialogInfo.more);
+	out->writeSint32LE(_dialogInfo.el);
+	out->writeSint32LE(_dialogInfo.er);
+	out->writeSint32LE(_dialogInfo.et);
+	out->writeSint32LE(_dialogInfo.eb);
+	out->write(_dialogInfo.luaMore, 64);
+
+	// Save Dialog Delay
 	out->writeSint32LE(_dialogDelay);
-	out->write(&_dialogChoiceInfo, sizeof(_dialogChoiceInfo));
-	out->write(&_msgInfo, sizeof(_msgInfo));
-	out->write(&_msgQueueStr, sizeof(char) * 128 * kMaxMsgQueue);
-	out->write(&_msgQueueWait, sizeof(int) * kMaxMsgQueue);
+
+	// Save Dialog Choice Info
+	out->write(_dialogChoiceInfo.title, 64);
+	out->write(_dialogChoiceInfo.text, 160);
+	out->write(_dialogChoiceInfo.func, 64);
+	out->writeByte(_dialogChoiceInfo.active);
+	out->writeSint32LE(_dialogChoiceInfo.x);
+	out->writeSint32LE(_dialogChoiceInfo.y);
+	out->writeSint32LE(_dialogChoiceInfo.width);
+	out->writeSint32LE(_dialogChoiceInfo.height);
+	out->writeSint32LE(_dialogChoiceInfo.textHeight);
+	out->writeSint32LE(_dialogChoiceInfo.titleWidth);
+	out->writeSint32LE(_dialogChoiceInfo.el);
+	out->writeSint32LE(_dialogChoiceInfo.er);
+	out->writeSint32LE(_dialogChoiceInfo.et);
+	out->writeSint32LE(_dialogChoiceInfo.eb);
+	out->writeUint32LE(_dialogChoiceInfo.timeout);
+	out->writeSint32LE(_dialogChoiceInfo.selection);
+	out->writeSint32LE(_dialogChoiceInfo.numChoices);
+
+	for (i = 0; i < 10; i++) {
+		out->write(_dialogChoiceInfo.choices[i], 64);
+	}
+
+	// Save Msg Info
+	out->writeByte(_msgInfo.active);
+	out->write(_msgInfo.title, 128);
+	out->writeSint32LE(_msgInfo.timer);
+	out->writeSint32LE(_msgInfo.x);
+	out->writeSint32LE(_msgInfo.y);
+	out->writeSint32LE(_msgInfo.width);
+	out->writeSint32LE(_msgInfo.height);
+
+	for (i = 0; i < kMaxMsgQueue; i++)
+		out->write(_msgQueueStr[i], 128);
+	for (i = 0; i < kMaxMsgQueue; i++)
+		out->writeSint32LE(_msgQueueWait[i]);
 	out->writeSint32LE(_numMsgQueue);
-	out->write(&_invWinInfo, sizeof(_invWinInfo));
-	out->write(&_dlvsInfo, sizeof(_dlvsInfo));
+
+	// Save Inventory Info
+	out->writeSint32LE(_invWinInfo.x);
+	out->writeSint32LE(_invWinInfo.y);
+	out->writeSint32LE(_invWinInfo.width);
+	out->writeSint32LE(_invWinInfo.height);
+	out->writeSint32LE(_invWinInfo.selection);
+	out->writeByte(_invWinInfo.active);
+
+	// Save Deliveries Info
+	out->writeSint32LE(_dlvsInfo.x);
+	out->writeSint32LE(_dlvsInfo.y);
+	out->writeSint32LE(_dlvsInfo.width);
+	out->writeSint32LE(_dlvsInfo.height);
+	out->writeByte(_dlvsInfo.active);
+	out->writeSint32LE(_dlvsInfo.selected);
+	out->writeByte(_dlvsInfo.animate);
+	out->writeUint32LE(_dlvsInfo.delay1);
+	out->writeUint32LE(_dlvsInfo.delay2);
+	out->writeUint32LE(_dlvsInfo.delay3);
+	out->writeByte(_dlvsInfo.go1);
+	out->writeByte(_dlvsInfo.go2);
+	out->writeByte(_dlvsInfo.go3);
+
+	// Save Try Again Info
 	debug(9, "STUB: Save Try Again data");
 
+	// Save TextOut Info
 	out->writeUint32LE(_textOutList.size());
 	for (i = 0; (uint)i < _textOutList.size(); i++) {
-		out->write(_textOutList[i], sizeof(TOut));
+		out->write(_textOutList[i]->text, 128);
+		out->writeSint32LE(_textOutList[i]->x);
+		out->writeSint32LE(_textOutList[i]->y);
+		out->writeUint32LE(_textOutList[i]->timer);
 	}
 
-	out->write(&_infobarDimmed, sizeof(_infobarDimmed));
-
+	out->writeSint32LE(_infobarDimmed);
 }
 
 void Window::loadSaveFile(Common::InSaveFile *in) {
@@ -133,30 +243,110 @@ void Window::loadSaveFile(Common::InSaveFile *in) {
 	restartSystem();
 
 	// Load out various Window and Game State Info
+
+	// Load Panic Zone Info
 	in->read(&_pzInfo, sizeof(_pzInfo));
-	in->read(&_dialogInfo, sizeof(_dialogInfo));
+
+	// Load Dialog Info
+	in->read(_dialogInfo.title, 64);
+	_dialogInfo.tileIndex = in->readSint32LE();
+	in->read(_dialogInfo.string, 160);
+	_dialogInfo.active = in->readByte();
+	_dialogInfo.x = in->readSint32LE();
+	_dialogInfo.y = in->readSint32LE();
+	_dialogInfo.width = in->readSint32LE();
+	_dialogInfo.height = in->readSint32LE();
+	_dialogInfo.titleWidth = in->readSint32LE();
+	g_hdb->_gfx->loadPicSave(_dialogInfo.gfx, in);
+	_dialogInfo.more = in->readSint32LE();
+	_dialogInfo.el = in->readSint32LE();
+	_dialogInfo.er = in->readSint32LE();
+	_dialogInfo.et = in->readSint32LE();
+	_dialogInfo.eb = in->readSint32LE();
+	in->read(_dialogInfo.luaMore, 64);
+
+	// Load Dialog Delay
 	_dialogDelay = in->readSint32LE();
 	if (_dialogDelay)
 		_dialogDelay = g_system->getMillis() + 1000;
 
-	in->read(&_dialogChoiceInfo, sizeof(_dialogChoiceInfo));
+	// Load Dialog Choice Info
+	in->read(_dialogChoiceInfo.title, 64);
+	in->read(_dialogChoiceInfo.text, 160);
+	in->read(_dialogChoiceInfo.func, 64);
+	_dialogChoiceInfo.active = in->readByte();
+	_dialogChoiceInfo.x = in->readSint32LE();
+	_dialogChoiceInfo.y = in->readSint32LE();
+	_dialogChoiceInfo.width = in->readSint32LE();
+	_dialogChoiceInfo.height = in->readSint32LE();
+	_dialogChoiceInfo.textHeight = in->readSint32LE();
+	_dialogChoiceInfo.titleWidth = in->readSint32LE();
+	_dialogChoiceInfo.el = in->readSint32LE();
+	_dialogChoiceInfo.er = in->readSint32LE();
+	_dialogChoiceInfo.et = in->readSint32LE();
+	_dialogChoiceInfo.eb = in->readSint32LE();
+	_dialogChoiceInfo.timeout = in->readUint32LE();
+	_dialogChoiceInfo.selection = in->readSint32LE();
+	_dialogChoiceInfo.numChoices = in->readSint32LE();
+	for (i = 0; i < 10; i++)
+		in->read(_dialogChoiceInfo.choices[i], 64);
+
 	_dialogChoiceInfo.timeout = g_system->getMillis() + 1000;
 
-	in->read(&_msgInfo, sizeof(_msgInfo));
-	in->read(&_msgQueueStr, sizeof(char) * 128 * kMaxMsgQueue);
-	in->read(&_msgQueueWait, sizeof(int) * kMaxMsgQueue);
+	// Load Msg Info
+	_msgInfo.active = in->readByte();
+	in->read(_msgInfo.title, 128);
+	_msgInfo.timer = in->readSint32LE();
+	_msgInfo.x = in->readSint32LE();
+	_msgInfo.y = in->readSint32LE();
+	_msgInfo.width = in->readSint32LE();
+	_msgInfo.height = in->readSint32LE();
+
+	for (i = 0; i < kMaxMsgQueue; i++)
+		in->read(_msgQueueStr[i], 128);
+	for (i = 0; i < kMaxMsgQueue; i++)
+		_msgQueueWait[i] = in->readSint32LE();
+
 	_numMsgQueue = in->readSint32LE();
-	in->read(&_invWinInfo, sizeof(_invWinInfo));
-	in->read(&_dlvsInfo, sizeof(_dlvsInfo));
+
+	// Load Inventory Info
+	_invWinInfo.x = in->readSint32LE();
+	_invWinInfo.y = in->readSint32LE();
+	_invWinInfo.width = in->readSint32LE();
+	_invWinInfo.height = in->readSint32LE();
+	_invWinInfo.selection = in->readSint32LE();
+	_invWinInfo.active = in->readByte();
+
+	// Load Deliveries Info
+	_dlvsInfo.x = in->readSint32LE();
+	_dlvsInfo.y = in->readSint32LE();
+	_dlvsInfo.width = in->readSint32LE();
+	_dlvsInfo.height = in->readSint32LE();
+	_dlvsInfo.active = in->readByte();
+	_dlvsInfo.selected = in->readSint32LE();
+	_dlvsInfo.animate = in->readByte();
+	_dlvsInfo.delay1 = in->readUint32LE();
+	_dlvsInfo.delay2 = in->readUint32LE();
+	_dlvsInfo.delay3 = in->readUint32LE();
+	_dlvsInfo.go1 = in->readByte();
+	_dlvsInfo.go2 = in->readByte();
+	_dlvsInfo.go3 = in->readByte();
+
+	// Load Try Again Info
 	debug(9, "STUB: Load Try Again data");
 
+	// Load Textout Info
 	_textOutList.resize(in->readUint32LE());
 	for (i = 0; (uint)i < _textOutList.size(); i++) {
-		in->read(_textOutList[i], sizeof(TOut));
+		in->read(_textOutList[i]->text, 128);
+		_textOutList[i]->x = in->readSint32LE();
+		_textOutList[i]->y = in->readSint32LE();
+		_textOutList[i]->timer = in->readUint32LE();
 		_textOutList[i]->timer = g_system->getMillis() + 1000;
 	}
 
-	in->read(&_infobarDimmed, sizeof(_infobarDimmed));
+	// Load Infobar Info
+	_infobarDimmed = in->readSint32LE();
 }
 
 void Window::restartSystem() {


Commit: d2df277403477be99cb22fadbc448e2c3357e53c
    https://github.com/scummvm/scummvm/commit/d2df277403477be99cb22fadbc448e2c3357e53c
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:14+02:00

Commit Message:
HDB: Add saveSlot, loadSlot, saveGame and loadGame

Changed paths:
    engines/hdb/hdb.cpp
    engines/hdb/hdb.h


diff --git a/engines/hdb/hdb.cpp b/engines/hdb/hdb.cpp
index 649c4a9..df82881 100644
--- a/engines/hdb/hdb.cpp
+++ b/engines/hdb/hdb.cpp
@@ -427,11 +427,87 @@ void HDBGame::setTargetXY(int x, int y) {
 }
 
 bool HDBGame::saveSlot(int slot) {
-	warning("STUB: HDBGame::saveSlot(%d)", slot);
+
+	// If no map is loaded, don't try to save
+	if (!g_hdb->_map->isLoaded())
+		return false;
+
+	Common::OutSaveFile *out;
+
+	Common::String saveFileName = Common::String::format("%s.%03d", _targetName.c_str(), slot);
+	if (!(out = _saveFileMan->openForSaving(saveFileName)))
+		error("Unable to open save file");
+
+	warning("STUB: Save MetaData");
+	Graphics::saveThumbnail(*out);
+
+	// Actual Save Data
+	saveGame(out);
+#if 0
+	_lua->save(out, saveFileName);
+#endif
+
+	out->finalize();
+	if (out->err())
+		warning("Can't wrtie file '%s'. (Disk full?)", saveFileName.c_str());
+
+	delete out;
+
+	return true;
+}
+
+bool HDBGame::loadSlot(int slot) {
+	Common::InSaveFile *in;
+
+	Common::String saveFileName = Common::String::format("%s.%03d", _targetName.c_str(), slot);
+	if (!(in = _saveFileMan->openForLoading(saveFileName))) {
+		warning("missing savegame file %s", saveFileName.c_str());
+		if (g_hdb->_map->isLoaded())
+			g_hdb->setGameState(GAME_PLAY);
+		return false;
+	}
+
+	warning("STUB: Load MetaData");
+	Graphics::skipThumbnail(*in);
+
+	// Actual Save Data
+	loadGame(in);
+
+	delete in;
 
 	return true;
 }
 
+void HDBGame::saveGame(Common::OutSaveFile *out) {
+
+	// Save Map Name
+	out->write(_inMapName, 32);
+
+	// Save Map Object Data
+	_map->save(out);
+
+	// Save Window Object Data
+	_window->save(out);
+
+	// Save Gfx Object Data
+	_gfx->save(out);
+
+	// Save Sound Object Data
+	_sound->save(out);
+
+	// Save Game Object Data
+	save(out);
+
+	// Save AI Object Data
+#if 0
+	_ai->save(out);
+#endif
+}
+
+void HDBGame::loadGame(Common::InSaveFile *in) {
+	warning("STUB: Add loadGame()");
+}
+
 // PLAYER is trying to use this entity
 void HDBGame::useEntity(AIEntity *e) {
 	warning("STUB: HDBGame::useEntity incomplete");
diff --git a/engines/hdb/hdb.h b/engines/hdb/hdb.h
index 01ed0b9..fcd52da 100644
--- a/engines/hdb/hdb.h
+++ b/engines/hdb/hdb.h
@@ -32,6 +32,7 @@
 #include "common/random.h"
 #include "common/savefile.h"
 #include "graphics/surface.h"
+#include "graphics/thumbnail.h"
 
 #include "gui/debugger.h"
 #include "engines/engine.h"
@@ -157,6 +158,9 @@ public:
 	}
 
 	bool saveSlot(int slot);
+	bool loadSlot(int slot);
+	void saveGame(Common::OutSaveFile *out);
+	void loadGame(Common::InSaveFile *in);
 
 	void saveWhenReady(int slot) {
 		_saveInfo.active = true;


Commit: ce6b62d8968a14ad6b0eeef215ea0eeda106562f
    https://github.com/scummvm/scummvm/commit/ce6b62d8968a14ad6b0eeef215ea0eeda106562f
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:14+02:00

Commit Message:
HDB: Turn _gratinds[] and _foregrounds[] into structs from pointers

Changed paths:
    engines/hdb/map.cpp
    engines/hdb/map.h


diff --git a/engines/hdb/map.cpp b/engines/hdb/map.cpp
index 7f0c418..6fcb582 100644
--- a/engines/hdb/map.cpp
+++ b/engines/hdb/map.cpp
@@ -28,24 +28,9 @@ Map::Map() {
 	_mapLoaded = false;
 
 	_animCycle = 0;
-
-	for (int i = 0; i < kMaxGratings; i++) {
-		_gratings[i] = new Foreground;
-	}
-
-	for (int i = 0; i < kMaxForegrounds; i++) {
-		_foregrounds[i] = new Foreground;
-	}
 }
 
 Map::~Map() {
-	for (int i = 0; i < kMaxGratings; i++) {
-		delete _gratings[i];
-	}
-
-	for (int i = 0; i < kMaxForegrounds; i++) {
-		delete _foregrounds[i];
-	}
 }
 
 void Map::save(Common::OutSaveFile *out) {
@@ -66,9 +51,9 @@ void Map::save(Common::OutSaveFile *out) {
 
 	out->writeSint32LE(_numGratings);
 	for (i = 0; i < _numGratings; i++) {
-		out->writeUint16LE(_gratings[i]->x);
-		out->writeUint16LE(_gratings[i]->y);
-		out->writeUint16LE(_gratings[i]->tile);
+		out->writeUint16LE(_gratings[i].x);
+		out->writeUint16LE(_gratings[i].y);
+		out->writeUint16LE(_gratings[i].tile);
 	}
 
 	out->writeSint32LE(_animCycle);
@@ -138,9 +123,9 @@ void Map::loadSaveFile(Common::InSaveFile *in) {
 
 	_numGratings = in->readSint32LE();
 	for (i = 0; i < _numGratings; i++) {
-		_gratings[i]->x = in->readUint16LE();
-		_gratings[i]->y = in->readUint16LE();
-		_gratings[i]->tile = in->readUint16LE();
+		_gratings[i].x = in->readUint16LE();
+		_gratings[i].y = in->readUint16LE();
+		_gratings[i].tile = in->readUint16LE();
 	}
 
 	_animCycle = in->readSint32LE();
@@ -830,16 +815,16 @@ void Map::draw() {
 
 					if ((fTile->_flags & kFlagGrating) && (_numGratings < kMaxGratings)) {
 						// Check for Gratings Flag
-						_gratings[_numGratings]->x = screenX;
-						_gratings[_numGratings]->y = screenY;
-						_gratings[_numGratings]->tile = tileIndex;
+						_gratings[_numGratings].x = screenX;
+						_gratings[_numGratings].y = screenY;
+						_gratings[_numGratings].tile = tileIndex;
 						if (_numGratings < kMaxGratings)
 							_numGratings++;
 					} else if ((fTile->_flags & kFlagForeground)) {
 						// Check for Foregrounds Flag
-						_foregrounds[_numForegrounds]->x = screenX;
-						_foregrounds[_numForegrounds]->y = screenY;
-						_foregrounds[_numForegrounds]->tile = tileIndex;
+						_foregrounds[_numForegrounds].x = screenX;
+						_foregrounds[_numForegrounds].y = screenY;
+						_foregrounds[_numForegrounds].tile = tileIndex;
 						if (_numForegrounds < kMaxForegrounds)
 							_numForegrounds++;
 					} else {
@@ -900,7 +885,7 @@ void Map::drawEnts() {
 
 void Map::drawGratings() {
 	for (int i = 0; i < _numGratings; i++) {
-		g_hdb->_gfx->getTile(_gratings[i]->tile)->drawMasked(_gratings[i]->x, _gratings[i]->y);
+		g_hdb->_gfx->getTile(_gratings[i].tile)->drawMasked(_gratings[i].x, _gratings[i].y);
 	}
 
 	debug(8, "Gratings Count: %d", _numGratings);
@@ -908,7 +893,7 @@ void Map::drawGratings() {
 
 void Map::drawForegrounds() {
 	for (int i = 0; i < _numForegrounds; i++) {
-		g_hdb->_gfx->getTile(_foregrounds[i]->tile)->drawMasked(_foregrounds[i]->x, _foregrounds[i]->y);
+		g_hdb->_gfx->getTile(_foregrounds[i].tile)->drawMasked(_foregrounds[i].x, _foregrounds[i].y);
 	}
 
 	debug(8, "Foregrounds Count: %d", _numForegrounds);
diff --git a/engines/hdb/map.h b/engines/hdb/map.h
index d6b0bda..40191f7 100644
--- a/engines/hdb/map.h
+++ b/engines/hdb/map.h
@@ -145,7 +145,7 @@ public:
 	int _mapTileX, _mapTileY; // Tile Coordinates of Map
 	int _mapTileXOff, _mapTileYOff; // Tile Coordinates Offset (0-31)
 
-	Foreground *_gratings[kMaxGratings], *_foregrounds[kMaxForegrounds];
+	Foreground _gratings[kMaxGratings], _foregrounds[kMaxForegrounds];
 	int _numGratings, _numForegrounds;
 
 	int _animCycle;	// Tile Animation Counter


Commit: 82fe644f543c8375b5cd901538511fc4e3c0f192
    https://github.com/scummvm/scummvm/commit/82fe644f543c8375b5cd901538511fc4e3c0f192
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:14+02:00

Commit Message:
HDB: Remove unnecessary functions

Changed paths:
    engines/hdb/gfx.cpp
    engines/hdb/gfx.h
    engines/hdb/window.cpp


diff --git a/engines/hdb/gfx.cpp b/engines/hdb/gfx.cpp
index 63e8215..84d3d29 100644
--- a/engines/hdb/gfx.cpp
+++ b/engines/hdb/gfx.cpp
@@ -273,38 +273,6 @@ Tile *Gfx::loadTile(const char *tileName) {
 	return tile;
 }
 
-void Gfx::savePic(Picture *pic, Common::OutSaveFile *out) {
-	if (pic == NULL) {
-		for (int i = 0; i < 64; i++)
-			out->writeByte(0);
-	} else {
-		out->write(pic->getName(), 64);
-	}
-}
-
-void Gfx::saveTile(Tile *tile, Common::OutSaveFile *out) {
-	if (tile == NULL) {
-		for (int i = 0; i < 64; i++)
-			out->writeByte(0);
-	} else {
-		out->write(tile->getName(), 64);
-	}
-}
-
-void Gfx::loadPicSave(Picture *pic, Common::InSaveFile *in) {
-	delete pic;
-	char readName[64];
-	in->read(readName, 64);
-	pic = loadPic(readName);
-}
-
-void Gfx::loadTileSave(Tile *tile, Common::InSaveFile *in) {
-	delete tile;
-	char readName[64];
-	in->read(readName, 64);
-	tile = loadTile(readName);
-}
-
 Tile *Gfx::getTile(int index) {
 
 	if (index < 0 || index > _numTiles) {
diff --git a/engines/hdb/gfx.h b/engines/hdb/gfx.h
index 6439fbf..88fb250 100644
--- a/engines/hdb/gfx.h
+++ b/engines/hdb/gfx.h
@@ -114,10 +114,6 @@ public:
 
 	Picture *loadPic(const char *picName);
 	Tile *loadTile(const char *tileName);
-	void savePic(Picture *pic, Common::OutSaveFile *out);
-	void saveTile(Tile *tile, Common::OutSaveFile *out);
-	void loadPicSave(Picture *pic, Common::InSaveFile *in);
-	void loadTileSave(Tile *tile, Common::InSaveFile *in);
 
 	Tile *getTile(int index);
 	void cacheTileSequence(int index, int count);
diff --git a/engines/hdb/window.cpp b/engines/hdb/window.cpp
index 54381d0..3b0d7e8 100644
--- a/engines/hdb/window.cpp
+++ b/engines/hdb/window.cpp
@@ -98,18 +98,7 @@ void Window::save(Common::OutSaveFile *out) {
 	// clear out gfx ptrs in _pzInfo struct before writing...
 
 	// Copy, clear and save Panic Zone Info
-	_tempPzInfo.active = _pzInfo.active;
-	_tempPzInfo.sequence = _pzInfo.sequence;
-	_tempPzInfo.timer = _pzInfo.timer;
-	_tempPzInfo.x1 = _pzInfo.x1;
-	_tempPzInfo.y1 = _pzInfo.y1;
-	_tempPzInfo.x2 = _pzInfo.x2;
-	_tempPzInfo.y2 = _pzInfo.y2;
-	_tempPzInfo.xv = _pzInfo.xv;
-	_tempPzInfo.yv = _pzInfo.yv;
-	_tempPzInfo.numberTime = _pzInfo.numberTime;
-	_tempPzInfo.numberTimeMaster = _pzInfo.numberTimeMaster;
-	_tempPzInfo.numberValue = _pzInfo.numberValue;
+	memcpy(&_tempPzInfo, &_pzInfo, sizeof(_pzInfo));
 
 	for (i = 0; i < 10; i++) {
 		_tempPzInfo.gfxNumber[i] = NULL;
@@ -130,13 +119,6 @@ void Window::save(Common::OutSaveFile *out) {
 	out->writeSint32LE(_tempPzInfo.numberTime);
 	out->writeSint32LE(_tempPzInfo.numberTimeMaster);
 	out->writeSint32LE(_tempPzInfo.numberValue);
-	g_hdb->_gfx->savePic(_tempPzInfo.gfxPanic, out);
-	g_hdb->_gfx->savePic(_tempPzInfo.gfxZone, out);
-	for (i = 0; i < 10; i++) {
-		g_hdb->_gfx->savePic(_tempPzInfo.gfxNumber[i], out);
-		if (i < 2)
-			g_hdb->_gfx->savePic(_tempPzInfo.gfxFace[i], out);
-	}
 
 	// Save Dialog Info
 	out->write(_dialogInfo.title, 64);
@@ -148,7 +130,6 @@ void Window::save(Common::OutSaveFile *out) {
 	out->writeSint32LE(_dialogInfo.width);
 	out->writeSint32LE(_dialogInfo.height);
 	out->writeSint32LE(_dialogInfo.titleWidth);
-	g_hdb->_gfx->savePic(_dialogInfo.gfx, out);
 	out->writeSint32LE(_dialogInfo.more);
 	out->writeSint32LE(_dialogInfo.el);
 	out->writeSint32LE(_dialogInfo.er);
@@ -257,7 +238,6 @@ void Window::loadSaveFile(Common::InSaveFile *in) {
 	_dialogInfo.width = in->readSint32LE();
 	_dialogInfo.height = in->readSint32LE();
 	_dialogInfo.titleWidth = in->readSint32LE();
-	g_hdb->_gfx->loadPicSave(_dialogInfo.gfx, in);
 	_dialogInfo.more = in->readSint32LE();
 	_dialogInfo.el = in->readSint32LE();
 	_dialogInfo.er = in->readSint32LE();


Commit: 69303997aee1518b26eac27c60454bfb0633dc94
    https://github.com/scummvm/scummvm/commit/69303997aee1518b26eac27c60454bfb0633dc94
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:14+02:00

Commit Message:
HDB: Unstub double reads and writes

Changed paths:
    engines/hdb/gfx.cpp


diff --git a/engines/hdb/gfx.cpp b/engines/hdb/gfx.cpp
index 84d3d29..191da10 100644
--- a/engines/hdb/gfx.cpp
+++ b/engines/hdb/gfx.cpp
@@ -151,11 +151,11 @@ void Gfx::save(Common::OutSaveFile *out) {
 
 	out->writeByte(_snowInfo.active);
 	for (i = 0; i < MAX_SNOW; i++)
-		warning("STUB: Save Double Value");
+		out->writeDoubleLE(_snowInfo.x[i]);
 	for (i = 0; i < MAX_SNOW; i++)
-		warning("STUB: Save Double Value");
+		out->writeDoubleLE(_snowInfo.y[i]);
 	for (i = 0; i < MAX_SNOW; i++)
-		warning("STUB: Save Double Value");
+		out->writeDoubleLE(_snowInfo.yv[i]);
 	for (i = 0; i < MAX_SNOW; i++)
 		out->writeSint32LE(_snowInfo.xvindex[i]);
 }
@@ -175,11 +175,11 @@ void Gfx::loadSaveFile(Common::InSaveFile *in) {
 	_snowInfo.active = in->readByte();
 
 	for (i = 0; i < MAX_SNOW; i++)
-		warning("STUB: Load Double Value");
+		_snowInfo.x[i] = in->readDoubleLE();
 	for (i = 0; i < MAX_SNOW; i++)
-		warning("STUB: Load Double Value");
+		_snowInfo.y[i] = in->readDoubleLE();
 	for (i = 0; i < MAX_SNOW; i++)
-		warning("STUB: Load Double Value");
+		_snowInfo.yv[i] = in->readDoubleLE();
 	for (i = 0; i < MAX_SNOW; i++)
 		_snowInfo.xvindex[i] = in->readSint32LE();
 


Commit: 32465a119d4371093b686c72a7cd9efe00d1c91b
    https://github.com/scummvm/scummvm/commit/32465a119d4371093b686c72a7cd9efe00d1c91b
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:14+02:00

Commit Message:
HDB: Modify InvEnt to have AIEntity as member

Changed paths:
    engines/hdb/ai-funcs.cpp
    engines/hdb/ai-inventory.cpp
    engines/hdb/ai.h


diff --git a/engines/hdb/ai-funcs.cpp b/engines/hdb/ai-funcs.cpp
index 56b021a..1cd1b23 100644
--- a/engines/hdb/ai-funcs.cpp
+++ b/engines/hdb/ai-funcs.cpp
@@ -739,7 +739,7 @@ void AI::initAllEnts() {
 
 	int i;
 	for (i = 0; i < _numInventory; i++) {
-		AIEntity *temp = _inventory[i].ent;
+		AIEntity *temp = &_inventory[i].ent;
 
 		// Clear out all ptrs in entity before writing
 		for (int j = 0; j < kMaxAnimFrames; j++) {
diff --git a/engines/hdb/ai-inventory.cpp b/engines/hdb/ai-inventory.cpp
index 65e8433..8ed6e9e 100644
--- a/engines/hdb/ai-inventory.cpp
+++ b/engines/hdb/ai-inventory.cpp
@@ -60,7 +60,7 @@ bool AI::addToInventory(AIEntity *e) {
 		return false;
 	}
 
-	_inventory[_numInventory].ent = e;
+	_inventory[_numInventory].ent = *e;
 	_numInventory++;
 
 	// If weapon, ready it
@@ -106,7 +106,7 @@ void AI::clearInventory() {
 AIEntity *AI::getInvItem(int which) {
 	if (which >= _numInventory)
 		return NULL;
-	return _inventory[which].ent;
+	return &_inventory[which].ent;
 }
 
 int AI::queryInventory(const char *string) {
@@ -124,7 +124,7 @@ int AI::queryInventory(const char *string) {
 
 	count = 0;
 	for (i = _numInventory - 1; i >= 0; i--)
-		if (_inventory[i].ent->entityName && strstr(_inventory[i].ent->entityName, string))
+		if (_inventory[i].ent.entityName && strstr(_inventory[i].ent.entityName, string))
 			count++;
 
 	return count;
@@ -153,7 +153,7 @@ bool AI::removeInvItem(const char *string, int amount) {
 		found = 0;
 
 		for (i = _numInventory - 1; i >= 0; i--)
-			if (_inventory[i].ent->entityName && strstr(_inventory[i].ent->entityName, string)) {
+			if (_inventory[i].ent.entityName && strstr(_inventory[i].ent.entityName, string)) {
 				j = i;
 				memset(&_inventory[j], 0, sizeof(InvEnt));
 				while (j < _numInventory - 1) {
@@ -191,7 +191,7 @@ int AI::queryInventoryType(AIType which) {
 
 	count = 0;
 	for (i = 0; i < _numInventory; i++)
-		if (_inventory[i].ent->type == which)
+		if (_inventory[i].ent.type == which)
 			count++;
 
 	return count;
@@ -219,7 +219,7 @@ bool AI::removeInvItemType(AIType which, int amount) {
 		found = 0;
 
 		for (i = 0; i < _numInventory; i++)
-			if (_inventory[i].ent->type == which) {
+			if (_inventory[i].ent.type == which) {
 				j = i;
 				memset(&_inventory[j], 0, sizeof(InvEnt));
 				while (j < _numInventory - 1) {
@@ -258,7 +258,7 @@ bool AI::addItemToInventory(AIType type, int amount, const char *funcInit, const
 
 void AI::keepInvItem(AIType type) {
 	for (int i = 0; i < _numInventory; i++)
-		if (_inventory[i].ent->type == type)
+		if (_inventory[i].ent.type == type)
 			_inventory[i].keep = 1;
 }
 
diff --git a/engines/hdb/ai.h b/engines/hdb/ai.h
index 02a9288..e8bd20f 100644
--- a/engines/hdb/ai.h
+++ b/engines/hdb/ai.h
@@ -581,9 +581,9 @@ struct AnimTarget {
 
 struct InvEnt {
 	uint16 keep;
-	AIEntity *ent;
+	AIEntity ent;
 
-	InvEnt() : keep(0), ent(NULL) {}
+	InvEnt() : keep(0) {}
 };
 
 struct DlvEnt {
@@ -1013,10 +1013,10 @@ public:
 		return _numInventory;
 	}
 	AIType getInvItemType(int which) {
-		return _inventory[which].ent->type;
+		return _inventory[which].ent.type;
 	}
 	Tile *getInvItemGfx(int which) {
-		return _inventory[which].ent->standdownGfx[0];
+		return _inventory[which].ent.standdownGfx[0];
 	}
 
 	AIEntity *getInvItem(int which);


Commit: b4db168f2a9c8e48ccc59ad2998fb6e1b9289278
    https://github.com/scummvm/scummvm/commit/b4db168f2a9c8e48ccc59ad2998fb6e1b9289278
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:14+02:00

Commit Message:
HDB: Add AI save() and loadSaveFile()

There are stubs for Pointers and Function Pointers

Changed paths:
    engines/hdb/ai-init.cpp
    engines/hdb/ai.h


diff --git a/engines/hdb/ai-init.cpp b/engines/hdb/ai-init.cpp
index ede8b8e..47e8a11 100644
--- a/engines/hdb/ai-init.cpp
+++ b/engines/hdb/ai-init.cpp
@@ -981,6 +981,377 @@ void AI::restartSystem() {
 	_gatePuddles = 0;
 }
 
+void AI::save(Common::OutSaveFile *out) {
+	int i;
+
+	// Misc Variables
+	out->writeByte(_playerInvisible);
+	out->writeByte(_playerOnIce);
+	out->writeByte(_playerEmerging);
+	out->writeByte(_playerRunning);
+	warning("STUB: Save whether weapon is selected");
+
+	// Save Teleporters
+	for (i = 0; i < kMaxTeleporters; i++) {
+		out->writeUint16LE(_teleporters[i].x1);
+		out->writeUint16LE(_teleporters[i].y1);
+		out->writeUint16LE(_teleporters[i].x2);
+		out->writeUint16LE(_teleporters[i].y2);
+		out->writeUint32LE((int)_teleporters[i].dir1);
+		out->writeUint32LE((int)_teleporters[i].dir2);
+		out->writeUint16LE(_teleporters[i].level1);
+		out->writeUint16LE(_teleporters[i].level2);
+		out->writeUint16LE(_teleporters[i].usable1);
+		out->writeUint16LE(_teleporters[i].usable2);
+		out->writeUint16LE(_teleporters[i].anim1);
+		out->writeUint16LE(_teleporters[i].anim2);
+		out->write(_teleporters[i].luaFuncUse1, 32);
+		out->write(_teleporters[i].luaFuncUse2, 32);
+	}
+	out->writeSint32LE(_numTeleporters);
+
+	// Save Laser Data
+	out->writeByte(_laserRescan);
+	out->writeByte(_laserOnScreen);
+
+	// Save Persistent Data
+	out->writeSint32LE(_numGems);
+	out->writeSint32LE(_numGooCups);
+	out->writeSint32LE(_numMonkeystones);
+
+	// Save Inventory
+	for (i = 0; i < kMaxInventory; i++) {
+		out->writeUint16LE(_inventory[i].keep);
+		warning("STUB: Save Inventory Item");
+	}
+	out->writeUint32LE(_numInventory);
+
+	// Save Deliveries
+	for (i = 0; i < kMaxDeliveries; i++) {
+		out->write(_deliveries[i].itemTextName, 32);
+		out->write(_deliveries[i].itemGfxName, 32);
+		warning("STUB: Save _deliveries[i].itemGfx");
+		out->write(_deliveries[i].destTextName, 32);
+		out->write(_deliveries[i].destGfxName, 32);
+		warning("STUB: Save _deliveries[i].destGfx");
+		out->write(_deliveries[i].id, 32);
+	}
+	out->writeUint32LE(_numDeliveries);
+
+	// Save Waypoints
+	for (i = 0; i < kMaxWaypoints; i++) {
+		out->writeSint32LE(_waypoints[i].x);
+		out->writeSint32LE(_waypoints[i].y);
+		out->writeSint32LE(_waypoints[i].level);
+	}
+	out->writeUint32LE(_numWaypoints);
+
+	// Save Bridges
+	for (i = 0; i < kMaxBridges; i++) {
+		out->writeUint16LE(_bridges[i].x);
+		out->writeUint16LE(_bridges[i].y);
+		out->writeSint32LE((int)_bridges[i].dir);
+		out->writeUint16LE(_bridges[i].delay);
+		out->writeUint16LE(_bridges[i].anim);
+	}
+	out->writeUint32LE(_numBridges);
+
+	// Save Lua List
+	for (i = 0; i < kMaxLuaEnts; i++) {
+		out->writeUint16LE(_luaList[i].x);
+		out->writeUint16LE(_luaList[i].y);
+		out->writeUint16LE(_luaList[i].value1);
+		out->writeUint16LE(_luaList[i].value2);
+		out->write(_luaList[i].luaFuncInit, 32);
+		out->write(_luaList[i].luaFuncAction, 32);
+		out->write(_luaList[i].luaFuncUse, 32);
+	}
+	out->writeUint32LE(_numLuaList);
+
+	// Save Auto Actions
+	for (i = 0; i < kMaxAutoActions; i++) {
+		out->writeUint16LE(_autoActions[i].x);
+		out->writeUint16LE(_autoActions[i].y);
+		out->writeByte(_autoActions[i].activated);
+		out->write(_autoActions[i].luaFuncInit, 32);
+		out->write(_autoActions[i].luaFuncUse, 32);
+		out->write(_autoActions[i].entityName, 32);
+	}
+
+	// Save Actions
+	for (i = 0; i < kMaxActions; i++) {
+		out->writeUint16LE(_actions[i].x1);
+		out->writeUint16LE(_actions[i].y1);
+		out->writeUint16LE(_actions[i].x2);
+		out->writeUint16LE(_actions[i].y2);
+		out->write(_actions[i].luaFuncInit, 32);
+		out->write(_actions[i].luaFuncUse, 32);
+		out->write(_actions[i].entityName, 32);
+	}
+
+	// Save Fairystones
+	for (i = 0; i < kMaxFairystones; i++) {
+		out->writeUint16LE(_fairystones[i].srcX);
+		out->writeUint16LE(_fairystones[i].srcY);
+		out->writeUint16LE(_fairystones[i].destX);
+		out->writeUint16LE(_fairystones[i].destY);
+	}
+
+	// Save Callbacks
+	for (i = 0; i < kMaxCallbacks; i++) {
+		out->writeSint32LE((int)_callbacks[i].type);
+		out->writeUint16LE(_callbacks[i].x);
+		out->writeUint16LE(_callbacks[i].y);
+		out->writeUint16LE(_callbacks[i].delay);
+	}
+
+	// Save Gatepuddles
+	out->writeSint32LE(_gatePuddles);
+
+	// Save AnimTargets
+	out->writeUint32LE(_animTargets.size());
+	for (i = 0; (uint)i < _animTargets.size(); i++) {
+		out->writeUint16LE(_animTargets[i]->x);
+		out->writeUint16LE(_animTargets[i]->y);
+		out->writeUint16LE(_animTargets[i]->start);
+		out->writeUint16LE(_animTargets[i]->end);
+		out->writeSint16LE(_animTargets[i]->vel);
+		out->writeUint16LE(_animTargets[i]->animCycle);
+		out->writeUint16LE(_animTargets[i]->animFrame);
+		out->writeByte(_animTargets[i]->killAuto);
+		out->writeByte(_animTargets[i]->inMap);
+		warning("STUB: Save _animTargets[i].gfxList");
+	}
+
+	// Save ArrowPaths
+	out->writeUint32LE(_arrowPaths->size());
+	for (i = 0; (uint)i < _arrowPaths->size(); i++) {
+		out->writeUint16LE(_arrowPaths->operator[](i)->type);
+		out->writeSint32LE((int)_arrowPaths->operator[](i)->dir);
+		out->writeUint16LE(_arrowPaths->operator[](i)->tileX);
+		out->writeUint16LE(_arrowPaths->operator[](i)->tileY);
+	}
+
+	// Save HereT List
+	out->writeUint32LE(_hereList->size());
+	for (i = 0; (uint)i < _hereList->size(); i++) {
+		out->writeUint16LE(_hereList->operator[](i)->x);
+		out->writeUint16LE(_hereList->operator[](i)->y);
+		out->write(_hereList->operator[](i)->entName, 32);
+	}
+
+	// Save Triggers
+	out->writeUint32LE(_triggerList->size());
+	for (i = 0; (uint)i < _triggerList->size(); i++) {
+		out->write(_triggerList->operator[](i)->id, 32);
+		out->writeUint16LE(_triggerList->operator[](i)->x);
+		out->writeUint16LE(_triggerList->operator[](i)->y);
+		out->writeUint16LE(_triggerList->operator[](i)->value1);
+		out->writeUint16LE(_triggerList->operator[](i)->value2);
+		out->write(_triggerList->operator[](i)->luaFuncInit, 32);
+		out->write(_triggerList->operator[](i)->luaFuncUse, 32);
+	}
+
+	// Save Floats
+	out->writeUint32LE(_floats->size());
+	for (i = 0; (uint)i < _floats->size(); i++) {
+		warning("STUB: Save Float Entity");
+	}
+
+	// Save Ents
+	out->writeUint32LE(_ents->size());
+	for (i = 0; (uint)i < _ents->size(); i++) {
+		warning("STUB: Save Ent Entity");
+	}
+}
+
+void AI::loadSaveFile(Common::InSaveFile *in) {
+	int i;
+
+	// Clean everything out
+	restartSystem();
+
+	// Misc Variables
+	_playerInvisible = in->readByte();
+	_playerOnIce = in->readByte();
+	_playerEmerging = in->readByte();
+	_playerRunning = in->readByte();
+	warning("STUB: Load whether weapon is selected or not");
+
+	// Load Teleporters
+	for (i = 0; i < kMaxTeleporters; i++) {
+		_teleporters[i].x1 = in->readUint16LE();
+		_teleporters[i].y1 = in->readUint16LE();
+		_teleporters[i].x2 = in->readUint16LE();
+		_teleporters[i].y2 = in->readUint16LE();
+		_teleporters[i].dir1 = (AIDir)in->readUint32LE();
+		_teleporters[i].dir2 = (AIDir)in->readUint32LE();
+		_teleporters[i].level1 = in->readUint16LE();
+		_teleporters[i].level2 = in->readUint16LE();
+		_teleporters[i].usable1 = in->readUint16LE();
+		_teleporters[i].usable2 = in->readUint16LE();
+		_teleporters[i].anim1 = in->readUint16LE();
+		_teleporters[i].anim2 = in->readUint16LE();
+		in->read(_teleporters[i].luaFuncUse1, 32);
+		in->read(_teleporters[i].luaFuncUse2, 32);
+	}
+	_numTeleporters = in->readSint32LE();
+
+	// Load Laser Data
+	_laserRescan = in->readByte();
+	_laserOnScreen = in->readByte();
+
+	// Load Persistent Data
+	_numGems = in->readSint32LE();
+	_numGooCups = in->readSint32LE();
+	_numMonkeystones = in->readSint32LE();
+
+	// Load Inventory
+	for (i = 0; i < kMaxInventory; i++) {
+		_inventory[i].keep = in->readUint16LE();
+		warning("STUB: Load Inventory Item");
+	}
+	_numInventory = in->readUint32LE();
+
+	// Load Deliveries
+	for (i = 0; i < kMaxDeliveries; i++) {
+		in->read(_deliveries[i].itemTextName, 32);
+		in->read(_deliveries[i].itemGfxName, 32);
+		warning("STUB: Load _deliveries[i].itemGfx");
+		in->read(_deliveries[i].destTextName, 32);
+		in->read(_deliveries[i].destGfxName, 32);
+		warning("STUB: Load _deliveries[i].destGfx");
+		in->read(_deliveries[i].id, 32);
+	}
+	_numDeliveries = in->readUint32LE();
+
+	// Load Waypoints
+	for (i = 0; i < kMaxWaypoints; i++) {
+		_waypoints[i].x = in->readSint32LE();
+		_waypoints[i].y = in->readSint32LE();
+		_waypoints[i].level = in->readSint32LE();
+	}
+	_numWaypoints = in->readUint32LE();
+
+	// Load Bridges
+	for (i = 0; i < kMaxBridges; i++) {
+		_bridges[i].x = in->readUint16LE();
+		_bridges[i].y = in->readUint16LE();
+		_bridges[i].dir = (AIDir)in->readSint32LE();
+		_bridges[i].delay = in->readUint16LE();
+		_bridges[i].anim = in->readUint16LE();
+	}
+	_numBridges = in->readUint32LE();
+
+	// Load Lua List
+	for (i = 0; i < kMaxLuaEnts; i++) {
+		_luaList[i].x = in->readUint16LE();
+		_luaList[i].y = in->readUint16LE();
+		_luaList[i].value1 = in->readUint16LE();
+		_luaList[i].value2 = in->readUint16LE();
+		in->read(_luaList[i].luaFuncInit, 32);
+		in->read(_luaList[i].luaFuncAction, 32);
+		in->read(_luaList[i].luaFuncUse, 32);
+	}
+	_numLuaList = in->readUint32LE();
+
+	// Load Auto Actions
+	for (i = 0; i < kMaxAutoActions; i++) {
+		_autoActions[i].x = in->readUint16LE();
+		_autoActions[i].y = in->readUint16LE();
+		_autoActions[i].activated = in->readByte();
+		in->read(_autoActions[i].luaFuncInit, 32);
+		in->read(_autoActions[i].luaFuncUse, 32);
+		in->read(_autoActions[i].entityName, 32);
+	}
+
+	// Load Actions
+	for (i = 0; i < kMaxActions; i++) {
+		_actions[i].x1 = in->readUint16LE();
+		_actions[i].y1 = in->readUint16LE();
+		_actions[i].x2 = in->readUint16LE();
+		_actions[i].y2 = in->readUint16LE();
+		in->read(_actions[i].luaFuncInit, 32);
+		in->read(_actions[i].luaFuncUse, 32);
+		in->read(_actions[i].entityName, 32);
+	}
+
+	// Load Fairystones
+	for (i = 0; i < kMaxFairystones; i++) {
+		_fairystones[i].srcX = in->readUint16LE();
+		_fairystones[i].srcY = in->readUint16LE();
+		_fairystones[i].destX = in->readUint16LE();
+		_fairystones[i].destY = in->readUint16LE();
+	}
+
+	// Load Callbacks
+	for (i = 0; i < kMaxCallbacks; i++) {
+		_callbacks[i].type = (CallbackType)in->readSint32LE();
+		_callbacks[i].x = in->readUint16LE();
+		_callbacks[i].y = in->readUint16LE();
+		_callbacks[i].delay = in->readUint16LE();
+	}
+
+	// Load Gatepuddles
+	_gatePuddles = in->readSint32LE();
+
+	// Load AnimTargets
+	_animTargets.resize(in->readUint32LE());
+	for (i = 0; (uint)i < _animTargets.size(); i++) {
+		_animTargets[i]->x = in->readUint16LE();
+		_animTargets[i]->y = in->readUint16LE();
+		_animTargets[i]->start = in->readUint16LE();
+		_animTargets[i]->end = in->readUint16LE();
+		_animTargets[i]->vel = in->readSint16LE();
+		_animTargets[i]->animCycle = in->readUint16LE();
+		_animTargets[i]->animFrame = in->readUint16LE();
+		_animTargets[i]->killAuto = in->readByte();
+		_animTargets[i]->inMap = in->readByte();
+		warning("STUB: Load _animTargets[i].gfxList");
+	}
+
+	// Load ArrowPaths
+	_arrowPaths->resize(in->readUint32LE());
+	for (i = 0; (uint)i < _arrowPaths->size(); i++) {
+		_arrowPaths->operator[](i)->type = in->readUint16LE();
+		_arrowPaths->operator[](i)->dir = (AIDir)in->readSint32LE();
+		_arrowPaths->operator[](i)->tileX = in->readUint16LE();
+		_arrowPaths->operator[](i)->tileY = in->readUint16LE();
+	}
+
+	// Load HereT List
+	_hereList->resize(in->readUint32LE());
+	for (i = 0; (uint)i < _hereList->size(); i++) {
+		_hereList->operator[](i)->x = in->readUint16LE();
+		_hereList->operator[](i)->y = in->readUint16LE();
+		in->read(_hereList->operator[](i)->entName, 32);
+	}
+
+	// Load Triggers
+	_triggerList->resize(in->readUint32LE());
+	for (i = 0; (uint)i < _triggerList->size(); i++) {
+		in->read(_triggerList->operator[](i)->id, 32);
+		_triggerList->operator[](i)->x = in->readUint16LE();
+		_triggerList->operator[](i)->y = in->readUint16LE();
+		_triggerList->operator[](i)->value1 = in->readUint16LE();
+		_triggerList->operator[](i)->value2 = in->readUint16LE();
+		in->read(_triggerList->operator[](i)->luaFuncInit, 32);
+		in->read(_triggerList->operator[](i)->luaFuncUse, 32);
+	}
+
+	// Load Floats
+	_floats->resize(in->readUint32LE());
+	for (i = 0; (uint)i < _floats->size(); i++) {
+		warning("STUB: Load Float Entity");
+	}
+
+	// Load Ents
+	_ents->resize(in->readUint32LE());
+	for (i = 0; (uint)i < _ents->size(); i++) {
+		warning("STUB: Load Ent Entity");
+	}
+}
+
 void AI::initAnimInfo() {
 	if (g_hdb->_map->checkOneTileExistInRange(_useSwitchOff, 2))
 		g_hdb->_gfx->getTile(_useSwitchOn);
diff --git a/engines/hdb/ai.h b/engines/hdb/ai.h
index e8bd20f..7328c11 100644
--- a/engines/hdb/ai.h
+++ b/engines/hdb/ai.h
@@ -783,6 +783,8 @@ public:
 	bool init();
 	void clearPersistent();
 	void restartSystem();
+	void save(Common::OutSaveFile *out);
+	void loadSaveFile(Common::InSaveFile *in);
 	void initAnimInfo();
 
 	// Entity Functions


Commit: 14f8e0574f94004966dafbfc1855a7bd194c029f
    https://github.com/scummvm/scummvm/commit/14f8e0574f94004966dafbfc1855a7bd194c029f
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:14+02:00

Commit Message:
GRAPHICS: Fix Managed Surface alpha blending

Changed paths:
    graphics/managed_surface.cpp


diff --git a/graphics/managed_surface.cpp b/graphics/managed_surface.cpp
index 3124f8a..6e7275c 100644
--- a/graphics/managed_surface.cpp
+++ b/graphics/managed_surface.cpp
@@ -284,7 +284,7 @@ void transBlit(const Surface &src, const Common::Rect &srcRect, Surface &dest, c
 				destLine[xCtr] = overrideColor ? overrideColor : srcVal;
 			} else {
 				// Otherwise we have to manually decode and re-encode each pixel
-				srcFormat.colorToARGB(*srcLine, aSrc, rSrc, gSrc, bSrc);
+				srcFormat.colorToARGB(srcVal, aSrc, rSrc, gSrc, bSrc);
 				destFormat.colorToRGB(destLine[xCtr], rDest, gDest, bDest);
 
 				if (aSrc == 0) {


Commit: 3851c2d9a6bd17c8dd4ca116711120f893167ab6
    https://github.com/scummvm/scummvm/commit/3851c2d9a6bd17c8dd4ca116711120f893167ab6
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:14+02:00

Commit Message:
GRAPHICS: Added source transparency parameter to ManagedSurface::transBlit

Changed paths:
    graphics/managed_surface.cpp
    graphics/managed_surface.h


diff --git a/graphics/managed_surface.cpp b/graphics/managed_surface.cpp
index 6e7275c..583859a 100644
--- a/graphics/managed_surface.cpp
+++ b/graphics/managed_surface.cpp
@@ -236,25 +236,25 @@ void ManagedSurface::blitFrom(const Surface &src, const Common::Rect &srcRect,
 	addDirtyRect(Common::Rect(0, 0, this->w, this->h));
 }
 
-void ManagedSurface::transBlitFrom(const Surface &src, uint transColor, bool flipped, uint overrideColor) {
+void ManagedSurface::transBlitFrom(const Surface &src, uint transColor, bool flipped, uint overrideColor, uint srcAlpha) {
 	transBlitFrom(src, Common::Rect(0, 0, src.w, src.h), Common::Rect(0, 0, this->w, this->h),
 		transColor, flipped, overrideColor);
 }
 
 void ManagedSurface::transBlitFrom(const Surface &src, const Common::Point &destPos,
-		uint transColor, bool flipped, uint overrideColor) {
+		uint transColor, bool flipped, uint overrideColor, uint srcAlpha) {
 	transBlitFrom(src, Common::Rect(0, 0, src.w, src.h), Common::Rect(destPos.x, destPos.y,
 		destPos.x + src.w, destPos.y + src.h), transColor, flipped, overrideColor);
 }
 
 void ManagedSurface::transBlitFrom(const Surface &src, const Common::Rect &srcRect,
-		const Common::Point &destPos, uint transColor, bool flipped, uint overrideColor) {
+		const Common::Point &destPos, uint transColor, bool flipped, uint overrideColor, uint srcAlpha) {
 	transBlitFrom(src, srcRect, Common::Rect(destPos.x, destPos.y,
 		destPos.x + srcRect.width(), destPos.y + srcRect.height()), transColor, flipped, overrideColor);
 }
 
 template<typename TSRC, typename TDEST>
-void transBlit(const Surface &src, const Common::Rect &srcRect, Surface &dest, const Common::Rect &destRect, TSRC transColor, bool flipped, uint overrideColor) {
+void transBlit(const Surface &src, const Common::Rect &srcRect, Surface &dest, const Common::Rect &destRect, TSRC transColor, bool flipped, uint overrideColor, uint srcAlpha) {
 	int scaleX = SCALE_THRESHOLD * srcRect.width() / destRect.width();
 	int scaleY = SCALE_THRESHOLD * srcRect.height() / destRect.height();
 	const Graphics::PixelFormat &srcFormat = src.format;
@@ -279,7 +279,7 @@ void transBlit(const Surface &src, const Common::Rect &srcRect, Surface &dest, c
 			if (srcVal == transColor)
 				continue;
 
-			if (srcFormat == destFormat) {
+			if (srcFormat == destFormat && srcAlpha == 0xff) {
 				// Matching formats, so we can do a straight copy
 				destLine[xCtr] = overrideColor ? overrideColor : srcVal;
 			} else {
@@ -287,6 +287,10 @@ void transBlit(const Surface &src, const Common::Rect &srcRect, Surface &dest, c
 				srcFormat.colorToARGB(srcVal, aSrc, rSrc, gSrc, bSrc);
 				destFormat.colorToRGB(destLine[xCtr], rDest, gDest, bDest);
 
+				if (srcAlpha != 0xff) {
+					aSrc = aSrc * srcAlpha / 255;
+				}
+
 				if (aSrc == 0) {
 					// Completely transparent, so skip
 					continue;
@@ -311,11 +315,11 @@ void transBlit(const Surface &src, const Common::Rect &srcRect, Surface &dest, c
 
 #define HANDLE_BLIT(SRC_BYTES, DEST_BYTES, SRC_TYPE, DEST_TYPE) \
 	if (src.format.bytesPerPixel == SRC_BYTES && format.bytesPerPixel == DEST_BYTES) \
-		transBlit<SRC_TYPE, DEST_TYPE>(src, srcRect, _innerSurface, destRect, transColor, flipped, overrideColor); \
+		transBlit<SRC_TYPE, DEST_TYPE>(src, srcRect, _innerSurface, destRect, transColor, flipped, overrideColor, srcAlpha); \
 	else
 
 void ManagedSurface::transBlitFrom(const Surface &src, const Common::Rect &srcRect,
-	const Common::Rect &destRect, uint transColor, bool flipped, uint overrideColor) {
+	const Common::Rect &destRect, uint transColor, bool flipped, uint overrideColor, uint srcAlpha) {
 	if (src.w == 0 || src.h == 0 || destRect.width() == 0 || destRect.height() == 0)
 		return;
 
diff --git a/graphics/managed_surface.h b/graphics/managed_surface.h
index c143222..b643d1b 100644
--- a/graphics/managed_surface.h
+++ b/graphics/managed_surface.h
@@ -235,8 +235,9 @@ public:
 	 * @param flipped		Specifies whether to horizontally flip the image
 	 * @param overrideColor	Optional color to use instead of non-transparent pixels from
 	 *						the source surface
+	 * @param srcAlpha		Optional additional transparency applied to src
 	 */
-	void transBlitFrom(const Surface &src, uint transColor = 0, bool flipped = false, uint overrideColor = 0);
+	void transBlitFrom(const Surface &src, uint transColor = 0, bool flipped = false, uint overrideColor = 0, uint srcAlpha = 0xff);
 
 	/**
 	 * Copies another surface into this one ignoring pixels of a designated transparent color
@@ -246,9 +247,10 @@ public:
 	 * @param flipped		Specifies whether to horizontally flip the image
 	 * @param overrideColor	Optional color to use instead of non-transparent pixels from
 	 *						the source surface
+	 * @param srcAlpha		Optional additional transparency applied to src
 	 */
 	void transBlitFrom(const Surface &src, const Common::Point &destPos,
-		uint transColor = 0, bool flipped = false, uint overrideColor = 0);
+		uint transColor = 0, bool flipped = false, uint overrideColor = 0, uint srcAlpha = 0xff);
 
 	/**
 	 * Copies another surface into this one ignoring pixels of a designated transparent color
@@ -259,9 +261,10 @@ public:
 	 * @param flipped		Specifies whether to horizontally flip the image
 	 * @param overrideColor	Optional color to use instead of non-transparent pixels from
 	 *						the source surface
+	 * @param srcAlpha		Optional additional transparency applied to src
 	 */
 	void transBlitFrom(const Surface &src, const Common::Rect &srcRect, const Common::Point &destPos,
-		uint transColor = 0, bool flipped = false, uint overrideColor = 0);
+		uint transColor = 0, bool flipped = false, uint overrideColor = 0, uint srcAlpha = 0xff);
 
 	/**
 	 * Copies another surface into this one ignoring pixels of a designated transparent color
@@ -273,9 +276,10 @@ public:
 	 * @param flipped		Specifies whether to horizontally flip the image
 	 * @param overrideColor	Optional color to use instead of non-transparent pixels from
 	 *						the source surface
+	 * @param srcAlpha		Optional additional transparency applied to src
 	 */
 	void transBlitFrom(const Surface &src, const Common::Rect &srcRect, const Common::Rect &destRect,
-		uint transColor = 0, bool flipped = false, uint overrideColor = 0);
+		uint transColor = 0, bool flipped = false, uint overrideColor = 0, uint srcAlpha = 0xff);
 
 	/**
 	 * Clear the entire surface


Commit: 168ca5fc0d831ef8fbba8e697e5b4b3f5cdc204b
    https://github.com/scummvm/scummvm/commit/168ca5fc0d831ef8fbba8e697e5b4b3f5cdc204b
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:14+02:00

Commit Message:
HDB: Used transparent alpha blitting

Changed paths:
    engines/hdb/ai-bots.cpp
    engines/hdb/ai-funcs.cpp
    engines/hdb/gfx.cpp
    engines/hdb/gfx.h


diff --git a/engines/hdb/ai-bots.cpp b/engines/hdb/ai-bots.cpp
index fafeadc..ec1cc6b 100644
--- a/engines/hdb/ai-bots.cpp
+++ b/engines/hdb/ai-bots.cpp
@@ -1685,8 +1685,7 @@ void aiMeerkatInit2(AIEntity *e) {
 
 void aiMeerkatDraw(AIEntity *e, int mx, int my) {
 	char word[3];
-	debug(9, "FIXME: Replace MaskedBlitting with AlphaMaskedBlitting");
-	g_hdb->_window->getGemGfx()->drawMasked(e->value1 - mx, e->value2 - my);
+	g_hdb->_window->getGemGfx()->drawMasked(e->value1 - mx, e->value2 - my, 255 - e->blinkFrames * 16);
 	g_hdb->_gfx->setCursor(e->value1 + 12 - mx, e->value2 - 8 - my);
 	word[2] = 0;
 	if (!e->special1Frames) {
@@ -1848,7 +1847,7 @@ void aiMeerkatLookAround(AIEntity *e) {
 
 //-------------------------------------------------------------------
 //
-//	FATFROG : Just sits in place and blasts out his tongue if you're 
+//	FATFROG : Just sits in place and blasts out his tongue if you're
 //		within range.
 //
 //-------------------------------------------------------------------
diff --git a/engines/hdb/ai-funcs.cpp b/engines/hdb/ai-funcs.cpp
index 1cd1b23..87bcb90 100644
--- a/engines/hdb/ai-funcs.cpp
+++ b/engines/hdb/ai-funcs.cpp
@@ -1714,8 +1714,7 @@ void AI::drawEnts(int x, int y, int w, int h) {
 			switch (e->type) {
 			case AI_VORTEXIAN:
 				if (e->draw)
-					e->draw->drawMasked(e->x - x + e->drawXOff, e->y - y + e->drawYOff);
-				debug(9, "STUB: AI::drawEnts: Replace Masked Blitting with Alpha Masked Blitting");
+					e->draw->drawMasked(e->x - x + e->drawXOff, e->y - y + e->drawYOff, e->value2 & 0xff);
 				break;
 			case AI_GUY: // Draw Player Last
 				break;
diff --git a/engines/hdb/gfx.cpp b/engines/hdb/gfx.cpp
index 191da10..a093389 100644
--- a/engines/hdb/gfx.cpp
+++ b/engines/hdb/gfx.cpp
@@ -808,8 +808,8 @@ int Picture::draw(int x, int y) {
 	return 0;
 }
 
-int Picture::drawMasked(int x, int y) {
-	g_hdb->_gfx->_globalSurface.transBlitFrom(_surface, Common::Point(x, y), 0xf81f);
+int Picture::drawMasked(int x, int y, int alpha) {
+	g_hdb->_gfx->_globalSurface.transBlitFrom(_surface, Common::Point(x, y), 0xf81f, false, 0, alpha & 0xff);
 
 	Common::Rect clip(_surface.getBounds());
 	clip.moveTo(x, y);
@@ -866,8 +866,8 @@ int Tile::draw(int x, int y) {
 	return 0;
 }
 
-int Tile::drawMasked(int x, int y) {
-	g_hdb->_gfx->_globalSurface.transBlitFrom(_surface, Common::Point(x, y), 0xf81f);
+int Tile::drawMasked(int x, int y, int alpha) {
+	g_hdb->_gfx->_globalSurface.transBlitFrom(_surface, Common::Point(x, y), 0xf81f, false, 0, alpha & 0xff);
 
 	Common::Rect clip(_surface.getBounds());
 	clip.moveTo(x, y);
diff --git a/engines/hdb/gfx.h b/engines/hdb/gfx.h
index 88fb250..e49b0c5 100644
--- a/engines/hdb/gfx.h
+++ b/engines/hdb/gfx.h
@@ -221,7 +221,7 @@ public:
 
 	Graphics::Surface load(Common::SeekableReadStream *stream);
 	int draw(int x, int y);
-	int drawMasked(int x, int y);
+	int drawMasked(int x, int y, int alpha = 0xff);
 	void free();
 
 	int _width, _height;
@@ -244,7 +244,7 @@ public:
 
 	Graphics::Surface load(Common::SeekableReadStream *stream);
 	int draw(int x, int y);
-	int drawMasked(int x, int y);
+	int drawMasked(int x, int y, int alpha = 0xff);
 	void free();
 
 	uint32 _flags;


Commit: a7d78a1b00ddb11c9f3e5ecc03afa22e899da98e
    https://github.com/scummvm/scummvm/commit/a7d78a1b00ddb11c9f3e5ecc03afa22e899da98e
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:14+02:00

Commit Message:
HDB: Fix Sky handling

Now sky appears on Map 29

Changed paths:
    engines/hdb/gfx.cpp


diff --git a/engines/hdb/gfx.cpp b/engines/hdb/gfx.cpp
index a093389..3303a5b 100644
--- a/engines/hdb/gfx.cpp
+++ b/engines/hdb/gfx.cpp
@@ -70,7 +70,7 @@ bool Gfx::init() {
 		_tLookupArray[index].skyIndex = 0;
 		_tLookupArray[index].animIndex = index;
 		// Check if the loaded Tile is a Sky Tile
-		if (((Common::String)tileData[index]).contains("sky") && (skyIndex < kMaxSkies)) {
+		if (strstr(tileData[index], "sky") && (skyIndex < kMaxSkies)) {
 			_tLookupArray[index].skyIndex = skyIndex + 1;
 			_skyTiles[skyIndex] = index;
 			skyIndex++;
@@ -103,14 +103,15 @@ bool Gfx::init() {
 
 	// Init Sky Data
 	_currentSky = 0;
-	_tileSkyStars = getTileIndex("t32_sky_stars");
-	_tileSkyStarsLeft = getTileIndex("t32_sky_stars_left_slow");
-	_tileSkyClouds = getTileIndex("t32_sky_clouds"); // Not completely sure about this filename.
+	_tileSkyStars = getTileIndex(TILE_SKY_STARS);
+	_tileSkyStarsLeft = getTileIndex(TILE_SKY_STARS_LEFT_SLOW);
+	_tileSkyClouds = getTileIndex(TILE_SKY_CLOUDS); // Not completely sure about this filename.
 	_skyClouds = NULL;
 
 	/*
 		TODO: Setup Gamma Table
 	*/
+	warning("STUB: Gfx::init() gamma missing");
 
 	// Load Mouse Pointer and Display Cursor
 	_mousePointer[0] = loadPic(PIC_MOUSE_CURSOR1);
@@ -459,11 +460,11 @@ void Gfx::setSky(int skyIndex) {
 	if (tileIndex == _tileSkyStars) {
 		setup3DStars();
 		return;
-	} else if (skyIndex == _tileSkyStarsLeft) {
+	} else if (tileIndex == _tileSkyStarsLeft) {
 		setup3DStarsLeft();
 		return;
-	} else if (skyIndex == _tileSkyStars) {
-		_skyClouds = getPicture("cloudy_skies");
+	} else if (tileIndex == _tileSkyClouds) {
+		_skyClouds = getPicture(CLOUDY_SKIES);
 		return;
 	}
 }
@@ -514,11 +515,9 @@ void Gfx::drawSky() {
 
 	if (tile == _tileSkyStars) {
 		draw3DStars();
-	}
-	else if (tile == _tileSkyStarsLeft) {
+	} else if (tile == _tileSkyStarsLeft) {
 		draw3DStarsLeft();
-	}
-	else if (tile == _tileSkyClouds) {
+	} else if (tile == _tileSkyClouds) {
 		static int offset = 0, wait = 0;
 		for (int j = -64; j < kScreenHeight; j += 64) {
 			for (int i = -64; i < kScreenWidth; i += 64) {


Commit: a8a43329bba6aab75423758426cfb8f8e1608df5
    https://github.com/scummvm/scummvm/commit/a8a43329bba6aab75423758426cfb8f8e1608df5
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:14+02:00

Commit Message:
HDB: Initialise variables

Changed paths:
    engines/hdb/map.cpp


diff --git a/engines/hdb/map.cpp b/engines/hdb/map.cpp
index 6fcb582..d725dc7 100644
--- a/engines/hdb/map.cpp
+++ b/engines/hdb/map.cpp
@@ -28,6 +28,8 @@ Map::Map() {
 	_mapLoaded = false;
 
 	_animCycle = 0;
+
+	_numForegrounds = _numGratings = 0;
 }
 
 Map::~Map() {


Commit: 56f0e3f930b8b88feb13d202ec7ee910fc247563
    https://github.com/scummvm/scummvm/commit/56f0e3f930b8b88feb13d202ec7ee910fc247563
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:15+02:00

Commit Message:
HDB: Removed useless warning

Changed paths:
    engines/hdb/ai-funcs.cpp


diff --git a/engines/hdb/ai-funcs.cpp b/engines/hdb/ai-funcs.cpp
index 87bcb90..28681df 100644
--- a/engines/hdb/ai-funcs.cpp
+++ b/engines/hdb/ai-funcs.cpp
@@ -344,11 +344,11 @@ bool AI::cacheEntGfx(AIEntity *e, bool init) {
 							e->standrightGfx[e->standrightFrames] = gfx;
 							e->standrightFrames++;
 							break;
-							// DOLLY states
-							// angry[4] = standright[4]
-							// kissright[4]/kissleft[4] = standleft[8]
-							// panic[4]/laugh[4] = standdown[8]
-							// dollyuseright[5] = special1[5]
+						// DOLLY states
+						// angry[4] = standright[4]
+						// kissright[4]/kissleft[4] = standleft[8]
+						// panic[4]/laugh[4] = standdown[8]
+						// dollyuseright[5] = special1[5]
 						case STATE_ANGRY:
 							e->standrightGfx[e->standrightFrames] = gfx;
 							e->standrightFrames++;
@@ -374,13 +374,13 @@ bool AI::cacheEntGfx(AIEntity *e, bool init) {
 							e->special1Frames++;
 							break;
 
-							// SARGE yelling
+						// SARGE yelling
 						case STATE_YELL:
 							e->special1Gfx[e->special1Frames] = gfx;
 							e->special1Frames++;
 							break;
 						default:
-							warning("AI-FUNCS: cacheEntGfx: Unintended State");
+							// no op
 							break;
 						}
 					} else {


Commit: fffa7bd1a23b6d0695c5055cd580d0603ff9640d
    https://github.com/scummvm/scummvm/commit/fffa7bd1a23b6d0695c5055cd580d0603ff9640d
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:15+02:00

Commit Message:
HDB: Unstub _ai->save() call

Changed paths:
    engines/hdb/hdb.cpp


diff --git a/engines/hdb/hdb.cpp b/engines/hdb/hdb.cpp
index df82881..c82c9d6 100644
--- a/engines/hdb/hdb.cpp
+++ b/engines/hdb/hdb.cpp
@@ -499,9 +499,9 @@ void HDBGame::saveGame(Common::OutSaveFile *out) {
 	save(out);
 
 	// Save AI Object Data
-#if 0
+
 	_ai->save(out);
-#endif
+
 }
 
 void HDBGame::loadGame(Common::InSaveFile *in) {


Commit: ebbee5cef40a8ce7152df717cd804dbf89a22198
    https://github.com/scummvm/scummvm/commit/ebbee5cef40a8ce7152df717cd804dbf89a22198
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:15+02:00

Commit Message:
HDB: Add FuncLookUp structs and functions

Changed paths:
    engines/hdb/ai-init.cpp
    engines/hdb/ai.h


diff --git a/engines/hdb/ai-init.cpp b/engines/hdb/ai-init.cpp
index 47e8a11..b7869e1 100644
--- a/engines/hdb/ai-init.cpp
+++ b/engines/hdb/ai-init.cpp
@@ -671,6 +671,233 @@ AIEntTypeInfo aiEntList[] = {
 	{ END_AI_TYPES,			NULL,					NULL,					NULL,					NULL }
 };
 
+FuncLookUp aiFuncList[] = {
+	{aiPlayerInit,				"aiPlayerInit"},
+	{aiPlayerInit2,				"aiPlayerInit2"},
+	{aiPlayerAction,			"aiPlayerAction"},
+	{(FuncPtr)aiPlayerDraw,		"aiPlayerDraw"},
+	{aiGemAttackInit,			"aiGemAttackInit"},
+	{aiGemAttackAction,			"aiGemAttackAction"},
+	{aiDollyInit,				"aiDollyInit"},
+	{aiDollyInit2,				"aiDollyInit2"},
+	{aiSergeantInit,			"aiSergeantInit"},
+	{aiSergeantInit2,			"aiSergeantInit2"},
+	{aiSergeantAction,			"aiSergeantAction"},
+	{aiSpacedudeInit,			"aiSpacedudeInit"},
+	{aiSpacedudeInit2,			"aiSpacedudeInit2"},
+	{aiChickenInit,				"aiChickenInit"},
+	{aiChickenInit2,			"aiChickenInit2"},
+	{aiChickenAction,			"aiChickenAction"},
+	{aiChickenUse,				"aiChickenUse"},
+	{aiCrateInit,				"aiCrateInit"},
+	{aiCrateInit2,				"aiCrateInit2"},
+	{aiCrateAction,				"aiCrateAction"},
+	{aiBarrelLightInit,			"aiBarrelLightInit"},
+	{aiBarrelLightInit2,		"aiBarrelLightInit2"},
+	{aiBarrelLightAction,		"aiBarrelLightAction"},
+	{aiBarrelHeavyInit,			"aiBarrelHeavyInit"},
+	{aiBarrelHeavyInit2,		"aiBarrelHeavyInit2"},
+	{aiBarrelHeavyAction,		"aiBarrelHeavyAction"},
+	{aiBarrelExplode,			"aiBarrelExplode"},
+	{aiBarrelExplodeInit,		"aiBarrelExplodeInit"},
+	{aiBarrelExplodeInit2,		"aiBarrelExplodeInit2"},
+	{aiBarrelExplodeSpread,		"aiBarrelExplodeSpread"},
+	{aiBarrelExplodeAction,		"aiBarrelExplodeAction"},
+	{aiCellInit,				"aiCellInit"},
+	{aiCellInit2,				"aiCellInit2"},
+	{aiMaintBotInit,			"aiMaintBotInit"},
+	{aiMaintBotInit2,			"aiMaintBotInit2"},
+	{aiMaintBotAction,			"aiMaintBotAction"},
+	{aiPdaInit,					"aiPdaInit"},
+	{aiPdaInit2,				"aiPdaInit2"},
+	{aiCabKeyInit,				"aiCabKeyInit"},
+	{aiCabKeyInit2,				"aiCabKeyInit2"},
+	{aiItemChickenInit,			"aiItemChickenInit"},
+	{aiItemChickenInit2,		"aiItemChickenInit2"},
+	{aiEnvelopeWhiteInit,		"aiEnvelopeWhiteInit"},
+	{aiEnvelopeWhiteInit2,		"aiEnvelopeWhiteInit2"},
+	{aiEnvelopeBlueInit,		"aiEnvelopeBlueInit"},
+	{aiEnvelopeBlueInit2,		"aiEnvelopeBlueInit2"},
+	{aiEnvelopeRedInit,			"aiEnvelopeRedInit"},
+	{aiEnvelopeRedInit2,		"aiEnvelopeRedInit2"},
+	{aiTransceiverInit,			"aiTransceiverInit"},
+	{aiTransceiverInit2,		"aiTransceiverInit2"},
+	{aiTransceiverAction,		"aiTransceiverAction"},
+	{aiMonkeystoneInit,			"aiMonkeystoneInit"},
+	{aiMonkeystoneInit2,		"aiMonkeystoneInit2"},
+	{aiMonkeystoneUse,			"aiMonkeystoneUse"},
+	{aiMonkeystoneAction,		"aiMonkeystoneAction"},
+	{aiGemAction,				"aiGemAction"},
+	{aiGemWhiteInit,			"aiGemWhiteInit"},
+	{aiGemWhiteInit2,			"aiGemWhiteInit2"},
+	{aiGooCupInit,				"aiGooCupInit"},
+	{aiGooCupInit2,				"aiGooCupInit2"},
+	{aiGooCupUse,				"aiGooCupUse"},
+	{aiVortexianInit,			"aiVortexianInit"},
+	{aiVortexianInit2,			"aiVortexianInit2"},
+	{aiVortexianAction,			"aiVortexianAction"},
+	{aiVortexianUse,			"aiVortexianUse"},
+	{aiNoneInit,				"aiNoneInit"},
+	{aiGenericAction,			"aiGenericAction"},
+	{aiGetItemAction,			"aiGetItemAction"},
+	{aiScientistInit,			"aiScientistInit"},
+	{aiScientistInit2,			"aiScientistInit2"},
+	{aiFourFirerInit,			"aiFourFirerInit"},
+	{aiFourFirerInit2,			"aiFourFirerInit2"},
+	{aiFourFirerAction,			"aiFourFirerAction"},
+	{aiRailRiderInit,			"aiRailRiderInit"},
+	{aiRailRiderInit2,			"aiRailRiderInit2"},
+	{aiRailRiderAction,			"aiRailRiderAction"},
+	{aiRailRiderUse,			"aiRailRiderUse"},
+	{aiRailRiderOnUse,			"aiRailRiderOnUse"},
+	{aiRailRiderOnAction,		"aiRailRiderOnAction"},
+	{aiShockBotInit,			"aiShockBotInit"},
+	{aiShockBotInit2,			"aiShockBotInit2"},
+	{aiShockBotAction,			"aiShockBotAction"},
+	{(FuncPtr)aiShockBotShock,	"aiShockBotShock"},
+	{aiOmniBotMissileInit,		"aiOmniBotMissileInit"},
+	{aiOmniBotMissileInit2,		"aiOmniBotMissileInit2"},
+	{aiOmniBotMissileAction,	"aiOmniBotMissileAction"},
+	{aiSlugAttackInit,			"aiSlugAttackInit"},
+	{aiSlugAttackInit2,			"aiSlugAttackInit2"},
+	{aiSlugAttackAction,		"aiSlugAttackAction"},
+	{(FuncPtr)aiSlugAttackDraw, "aiSlugAttackDraw"},
+	{aiDeadWorkerInit,			"aiDeadWorkerInit"},
+	{aiDeadWorkerInit2,			"aiDeadWorkerInit2"},
+	{aiWorkerInit,				"aiWorkerInit"},
+	{aiWorkerInit2,				"aiWorkerInit2"},
+	{aiAccountantInit,			"aiAccountantInit"},
+	{aiAccountantInit2,			"aiAccountantInit2"},
+	{aiFrogStatueInit,			"aiFrogStatueInit"},
+	{aiFrogStatueInit2,			"aiFrogStatueInit2"},
+	{aiFrogStatueAction,		"aiFrogStatueAction"},
+	{aiClubInit,				"aiClubInit"},
+	{aiClubInit2,				"aiClubInit2"},
+	{aiRoboStunnerInit,			"aiRoboStunnerInit"},
+	{aiRoboStunnerInit2,		"aiRoboStunnerInit2"},
+	{aiRoboStunnerAction,		"aiRoboStunnerAction"},
+	{aiSlugSlingerInit2,		"aiSlugSlingerInit2"},
+	{aiSlugSlingerInit,			"aiSlugSlingerInit"},
+	{aiTurnBotAction,			"aiTurnBotAction"},
+	{aiTurnBotInit,				"aiTurnBotInit"},
+	{aiTurnBotInit2,			"aiTurnBotInit2"},
+	{aiPushBotInit,				"aiPushBotInit"},
+	{aiPushBotInit2,			"aiPushBotInit2"},
+	{aiPushBotAction,			"aiPushBotAction"},
+	{aiOmniBotInit,				"aiOmniBotInit"},
+	{aiOmniBotInit2,			"aiOmniBotInit2"},
+	{aiOmniBotAction,			"aiOmniBotAction"},
+	{aiOmniBotMove,				"aiOmniBotMove"},
+	{aiLaserAction,				"aiLaserAction"},
+	{(FuncPtr)aiLaserDraw,		"aiLaserDraw"},
+	{aiLaserInit,				"aiLaserInit"},
+	{aiLaserInit2,				"aiLaserInit2"},
+	{aiDiverterInit,			"aiDiverterInit"},
+	{aiDiverterInit2,			"aiDiverterInit2"},
+	{aiDiverterAction,			"aiDiverterAction"},
+	{(FuncPtr)aiDiverterDraw,	"aiDiverterDraw"},
+	{aiRightBotInit,			"aiRightBotInit"},
+	{aiRightBotInit2,			"aiRightBotInit2"},
+	{aiRightBotAction,			"aiRightBotAction"},
+	{aiPushBotInit,				"aiPushBotInit"},
+	{aiPushBotInit2,			"aiPushBotInit2"},
+	{aiPushBotAction,			"aiPushBotAction"},
+	{aiDeadEyeWalkInPlace,		"aiDeadEyeWalkInPlace" },
+	{aiDeadEyeInit,				"aiDeadEyeInit"},
+	{aiDeadEyeInit2,			"aiDeadEyeInit2"},
+	{aiDeadEyeAction,			"aiDeadEyeAction"},
+	{aiMeerkatLookAround,		"aiMeerkatLookAround" },
+	{aiMeerkatInit,				"aiMeerkatInit"},
+	{aiMeerkatInit2,			"aiMeerkatInit2"},
+	{(FuncPtr)aiMeerkatDraw,	"aiMeerkatDraw"},
+	{aiMeerkatAction,			"aiMeerkatAction"},
+	{aiFatFrogInit,				"aiFatFrogInit"},
+	{aiFatFrogInit2,			"aiFatFrogInit2"},
+	{aiFatFrogAction,			"aiFatFrogAction"},
+	{(FuncPtr)aiFatFrogTongueDraw, "aiFatFrogTongueDraw"},
+	{aiGoodFairyInit,			"aiGoodFairyInit"},
+	{aiGoodFairyInit2,			"aiGoodFairyInit2"},
+	{aiGoodFairyAction,			"aiGoodFairyAction"},
+	{aiBadFairyInit,			"aiBadFairyInit"},
+	{aiBadFairyInit2,			"aiBadFairyInit2"},
+	{aiBadFairyAction,			"aiBadFairyAction"},
+	{aiGatePuddleInit,			"aiGatePuddleInit"},
+	{aiGatePuddleInit2,			"aiGatePuddleInit2"},
+	{aiGatePuddleAction,		"aiGatePuddleAction"},
+	{aiIcePuffSnowballAction,	"aiIcePuffSnowballAction" },
+	{(FuncPtr)aiIcePuffSnowballDraw,	"aiIcePuffSnowballDraw"},
+	{aiIcePuffInit,				"aiIcePuffInit"},
+	{aiIcePuffInit2,			"aiIcePuffInit2"},
+	{aiIcePuffAction,			"aiIcePuffAction"},
+	{aiBuzzflyInit,				"aiBuzzflyInit"},
+	{aiBuzzflyInit2,			"aiBuzzflyInit2"},
+	{aiBuzzflyAction,			"aiBuzzflyAction"},
+	{aiDragonInit,				"aiDragonInit"},
+	{aiDragonInit2,				"aiDragonInit2"},
+	{aiDragonAction,			"aiDragonAction"},
+	{aiDragonUse,				"aiDragonUse"	},
+	{aiDragonWake,				"aiDragonWake"},
+	{(FuncPtr)aiDragonDraw,		"aiDragonDraw"},
+	{aiEnvelopeGreenInit,		"aiEnvelopeGreenInit"},
+	{aiEnvelopeGreenInit2,		"aiEnvelopeGreenInit2"},
+	{aiGemBlueInit,				"aiGemBlueInit"},
+	{aiGemBlueInit2,			"aiGemBlueInit2"},
+	{aiGemRedInit,				"aiGemRedInit"},
+	{aiGemRedInit2,				"aiGemRedInit2"},
+	{aiGemGreenInit,			"aiGemGreenInit"},
+	{aiGemGreenInit2,			"aiGemGreenInit2"},
+	{aiTeaCupInit,				"aiTeaCupInit"},
+	{aiTeaCupInit2,				"aiTeaCupInit2"},
+	{aiCookieInit,				"aiCookieInit"},
+	{aiCookieInit2,				"aiCookieInit2"},
+	{aiBurgerInit,				"aiBurgerInit"},
+	{aiBurgerInit2,				"aiBurgerInit2"},
+	{aiBookInit,				"aiBookInit"},
+	{aiBookInit2,				"aiBookInit2"},
+	{aiClipboardInit,			"aiClipboardInit"},
+	{aiClipboardInit2,			"aiClipboardInit2"},
+	{aiNoteInit,				"aiNoteInit"},
+	{aiNoteInit2,				"aiNoteInit2"},
+	{aiKeycardWhiteInit,		"aiKeycardWhiteInit"},
+	{aiKeycardWhiteInit2,		"aiKeycardWhiteInit2"},
+	{aiKeycardBlueInit,			"aiKeycardBlueInit"},
+	{aiKeycardBlueInit2,		"aiKeycardBlueInit2"},
+	{aiKeycardRedInit,			"aiKeycardRedInit"},
+	{aiKeycardRedInit2,			"aiKeycardRedInit2"},
+	{aiKeycardGreenInit,		"aiKeycardGreenInit"},
+	{aiKeycardGreenInit2,		"aiKeycardGreenInit2"},
+	{aiKeycardPurpleInit,		"aiKeycardPurpleInit"},
+	{aiKeycardPurpleInit2,		"aiKeycardPurpleInit2"},
+	{aiKeycardBlackInit,		"aiKeycardBlackInit"},
+	{aiKeycardBlackInit2,		"aiKeycardBlackInit2"},
+	{aiSeedInit,				"aiSeedInit"},
+	{aiSeedInit2,				"aiSeedInit2"},
+	{aiSodaInit,				"aiSodaInit"},
+	{aiSodaInit2,				"aiSodaInit2"},
+	{aiDollyTool1Init,			"aiDollyTool1Init"},
+	{aiDollyTool1Init2,			"aiDollyTool1Init2"},
+	{aiDollyTool2Init,			"aiDollyTool2Init"},
+	{aiDollyTool2Init2,			"aiDollyTool2Init2"},
+	{aiDollyTool3Init,			"aiDollyTool3Init"},
+	{aiDollyTool3Init2,			"aiDollyTool3Init2"},
+	{aiDollyTool4Init,			"aiDollyTool4Init"},
+	{aiDollyTool4Init2,			"aiDollyTool4Init2"},
+	{aiRouterInit,				"aiRouterInit"},
+	{aiRouterInit2,				"aiRouterInit2"},
+	{aiSlicerInit,				"aiSlicerInit"},
+	{aiSlicerInit2,				"aiSlicerInit2"},
+	{aiPackageInit,				"aiPackageInit"},
+	{aiPackageInit2,			"aiPackageInit2"},
+	{aiMagicEggInit,			"aiMagicEggInit"},
+	{aiMagicEggInit2,			"aiMagicEggInit2"},
+	{aiMagicEggAction,			"aiMagicEggAction"},
+	{aiMagicEggUse,				"aiMagicEggUse"},
+	{aiIceBlockInit,			"aiIceBlockInit"},
+	{aiIceBlockInit2,			"aiIceBlockInit2"},
+	{aiIceBlockAction,			"aiIceBlockAction"},
+	{NULL, NULL}
+};
+
 AI::AI() {
 	_ents = new Common::Array<AIEntity *>;
 	_floats = new Common::Array<AIEntity *>;
@@ -807,6 +1034,32 @@ void AI::clearPersistent() {
 	_numGems = _numGooCups = _numMonkeystones = 0;
 }
 
+const char *AI::funcLookUp(void(*function)(AIEntity *e)) {
+	if (!function)
+		return NULL;
+
+	int i = 0;
+	while (aiFuncList[i].funcName) {
+		if (aiFuncList[i].function == function)
+			return aiFuncList[i].funcName;
+		i++;
+	}
+	return NULL;
+}
+
+FuncPtr AI::funcLookUp(const char *function) {
+	if (!function)
+		return NULL;
+
+	int i = 0;
+	while (aiFuncList[i].funcName) {
+		if (!scumm_stricmp(aiFuncList[i].funcName, function))
+			return aiFuncList[i].function;
+		i++;
+	}
+	return NULL;
+}
+
 void AI::restartSystem() {
 	warning("STUB: AI::restartSystem incomplete");
 
diff --git a/engines/hdb/ai.h b/engines/hdb/ai.h
index 7328c11..3cb0cc0 100644
--- a/engines/hdb/ai.h
+++ b/engines/hdb/ai.h
@@ -541,6 +541,10 @@ struct AIEntity {
 	}
 };
 
+// Structs for Function Table Lookup for SaveGames
+typedef void(*FuncPtr)(AIEntity *);
+typedef void(*EntFuncPtr)(AIEntity *, int, int);
+
 struct AIEntTypeInfo {
 	AIType type;
 	const char *luaName;
@@ -549,7 +553,13 @@ struct AIEntTypeInfo {
 	void (*initFunc2)(AIEntity *e);
 };
 
+struct FuncLookUp {
+	void(*function)(AIEntity *e);
+	const char *funcName;
+};
+
 extern AIEntTypeInfo aiEntList[];
+extern FuncLookUp aiFuncList[];
 
 struct AIEntLevel2 {
 	uint16 x;
@@ -783,6 +793,8 @@ public:
 	bool init();
 	void clearPersistent();
 	void restartSystem();
+	const char *funcLookUp(void(*function)(AIEntity *e));
+	FuncPtr funcLookUp(const char *function);
 	void save(Common::OutSaveFile *out);
 	void loadSaveFile(Common::InSaveFile *in);
 	void initAnimInfo();


Commit: 17eaafacfdf4aa487cb596fd887d89f7bc911883
    https://github.com/scummvm/scummvm/commit/17eaafacfdf4aa487cb596fd887d89f7bc911883
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:15+02:00

Commit Message:
HDB: Unstub code for saving and loading Gfx

Changed paths:
    engines/hdb/ai-init.cpp
    engines/hdb/window.h


diff --git a/engines/hdb/ai-init.cpp b/engines/hdb/ai-init.cpp
index b7869e1..a9416f9 100644
--- a/engines/hdb/ai-init.cpp
+++ b/engines/hdb/ai-init.cpp
@@ -1235,7 +1235,7 @@ void AI::restartSystem() {
 }
 
 void AI::save(Common::OutSaveFile *out) {
-	int i;
+	int i, j;
 
 	// Misc Variables
 	out->writeByte(_playerInvisible);
@@ -1275,7 +1275,6 @@ void AI::save(Common::OutSaveFile *out) {
 	// Save Inventory
 	for (i = 0; i < kMaxInventory; i++) {
 		out->writeUint16LE(_inventory[i].keep);
-		warning("STUB: Save Inventory Item");
 	}
 	out->writeUint32LE(_numInventory);
 
@@ -1283,10 +1282,8 @@ void AI::save(Common::OutSaveFile *out) {
 	for (i = 0; i < kMaxDeliveries; i++) {
 		out->write(_deliveries[i].itemTextName, 32);
 		out->write(_deliveries[i].itemGfxName, 32);
-		warning("STUB: Save _deliveries[i].itemGfx");
 		out->write(_deliveries[i].destTextName, 32);
 		out->write(_deliveries[i].destGfxName, 32);
-		warning("STUB: Save _deliveries[i].destGfx");
 		out->write(_deliveries[i].id, 32);
 	}
 	out->writeUint32LE(_numDeliveries);
@@ -1419,7 +1416,7 @@ void AI::save(Common::OutSaveFile *out) {
 }
 
 void AI::loadSaveFile(Common::InSaveFile *in) {
-	int i;
+	int i, j;
 
 	// Clean everything out
 	restartSystem();
@@ -1462,7 +1459,6 @@ void AI::loadSaveFile(Common::InSaveFile *in) {
 	// Load Inventory
 	for (i = 0; i < kMaxInventory; i++) {
 		_inventory[i].keep = in->readUint16LE();
-		warning("STUB: Load Inventory Item");
 	}
 	_numInventory = in->readUint32LE();
 
@@ -1470,10 +1466,8 @@ void AI::loadSaveFile(Common::InSaveFile *in) {
 	for (i = 0; i < kMaxDeliveries; i++) {
 		in->read(_deliveries[i].itemTextName, 32);
 		in->read(_deliveries[i].itemGfxName, 32);
-		warning("STUB: Load _deliveries[i].itemGfx");
 		in->read(_deliveries[i].destTextName, 32);
 		in->read(_deliveries[i].destGfxName, 32);
-		warning("STUB: Load _deliveries[i].destGfx");
 		in->read(_deliveries[i].id, 32);
 	}
 	_numDeliveries = in->readUint32LE();
@@ -1548,6 +1542,43 @@ void AI::loadSaveFile(Common::InSaveFile *in) {
 	// Load Gatepuddles
 	_gatePuddles = in->readSint32LE();
 
+	// Cache Gfx for Panic Zone, if needed
+	for (i = 0; i < _numTeleporters; i++)
+		if ((_teleporters[i].anim1 == 2) ||
+			(_teleporters[i].anim2 == 2) &&
+			!g_hdb->_window->_pzInfo.gfxPanic) {
+			g_hdb->_window->loadPanicZoneGfx();
+			break;
+		}
+
+	// Cache Graphics for Inventory and Deliveries
+	for (i = 0; i < _numInventory; i++) {
+		AIEntity *temp = &_inventory[i].ent;
+
+		// Clear out all ptrs in entity before writing out
+
+		for (j = 0; j < kMaxAnimFrames; j++)
+			temp->blinkGfx[j] = temp->movedownGfx[j] = temp->moveupGfx[j] =
+			temp->moveleftGfx[j] = temp->moverightGfx[j] = temp->standdownGfx[j] =
+			temp->standupGfx[j] = temp->standleftGfx[j] = temp->standrightGfx[j] =
+			temp->special1Gfx[j] = NULL;
+
+		temp->blinkFrames = temp->movedownFrames = temp->moveupFrames = temp->moveleftFrames =
+			temp->moverightFrames = temp->standdownFrames = temp->standupFrames = temp->standleftFrames =
+			temp->standrightFrames = 0;
+
+		temp->draw = NULL;
+		temp->aiDraw = NULL;
+		temp->aiAction = temp->aiInit = temp->aiUse = NULL;
+
+		cacheEntGfx(temp, false);
+	}
+
+	for (i = 0; i < _numDeliveries; i++) {
+		_deliveries[i].itemGfx = g_hdb->_gfx->getTileGfx(_deliveries[i].itemGfxName, -1);
+		_deliveries[i].destGfx = g_hdb->_gfx->getTileGfx(_deliveries[i].destGfxName, -1);
+	}
+
 	// Load AnimTargets
 	_animTargets.resize(in->readUint32LE());
 	for (i = 0; (uint)i < _animTargets.size(); i++) {
diff --git a/engines/hdb/window.h b/engines/hdb/window.h
index be7bbfc..21dd98d 100644
--- a/engines/hdb/window.h
+++ b/engines/hdb/window.h
@@ -273,6 +273,8 @@ public:
 		return _gemGfx;
 	}
 
+	PanicZone _pzInfo, _tempPzInfo;
+
 private:
 
 	DialogInfo _dialogInfo;
@@ -286,8 +288,6 @@ private:
 	Common::Array<TOut *> _textOutList;
 	DlvsInfo _dlvsInfo;
 
-	PanicZone _pzInfo, _tempPzInfo;
-
 	char _msgQueueStr[kMaxMsgQueue][128];
 	int _msgQueueWait[kMaxMsgQueue];
 	int _numMsgQueue;


Commit: 910c1ed36dd67571caf03156e136c86b2822bb01
    https://github.com/scummvm/scummvm/commit/910c1ed36dd67571caf03156e136c86b2822bb01
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:15+02:00

Commit Message:
HDB: Unstub Load/Save _ents and _floats

Changed paths:
    engines/hdb/ai-init.cpp


diff --git a/engines/hdb/ai-init.cpp b/engines/hdb/ai-init.cpp
index a9416f9..3d2c5be 100644
--- a/engines/hdb/ai-init.cpp
+++ b/engines/hdb/ai-init.cpp
@@ -1402,16 +1402,202 @@ void AI::save(Common::OutSaveFile *out) {
 		out->write(_triggerList->operator[](i)->luaFuncUse, 32);
 	}
 
+	AIEntity *e, temp;
+	char funcString[32];
+	const char *lookUp;
+
 	// Save Floats
 	out->writeUint32LE(_floats->size());
 	for (i = 0; (uint)i < _floats->size(); i++) {
-		warning("STUB: Save Float Entity");
+		e = _floats->operator[](i);
+		memcpy(&temp, e, sizeof(AIEntity));
+
+		// Write out 32-char names for the function ptrs we have in the entity struct
+		lookUp = funcLookUp(e->aiAction);
+		memset(&funcString, 0, 32);
+		if (!lookUp && e->aiAction)
+			error("AI::save: No matching ACTION function for func-string");
+		if (lookUp)
+			strcpy(funcString, lookUp);
+		out->write(funcString, 32);
+
+		lookUp = funcLookUp(e->aiUse);
+		memset(&funcString, 0, 32);
+		if (!lookUp && e->aiUse)
+			error("AI::save: No matching USE function for func-string");
+		if (lookUp)
+			strcpy(funcString, lookUp);
+		out->write(funcString, 32);
+
+		lookUp = funcLookUp(e->aiInit);
+		memset(&funcString, 0, 32);
+		if (!lookUp && e->aiInit)
+			error("AI::save: No matching INIT function for func-string");
+		if (lookUp)
+			strcpy(funcString, lookUp);
+		out->write(funcString, 32);
+
+		lookUp = funcLookUp(e->aiInit2);
+		memset(&funcString, 0, 32);
+		if (!lookUp && e->aiInit2)
+			error("AI::save: No matching INIT2 function for func-string");
+		if (lookUp)
+			strcpy(funcString, lookUp);
+		out->write(funcString, 32);
+
+		lookUp = funcLookUp((FuncPtr)e->aiDraw);
+		memset(&funcString, 0, 32);
+		if (!lookUp && e->aiDraw)
+			error("AI::save: No matching DRAW function for func-string");
+		if (lookUp)
+			strcpy(funcString, lookUp);
+		out->write(funcString, 32);
+
+		// Clear out all ptrs in Entity before writing it out
+		for (j = 0; j < kMaxAnimFrames; j++)
+			temp.blinkGfx[j] = temp.movedownGfx[j] = temp.moveupGfx[j] = temp.moveleftGfx[j] =
+				temp.moverightGfx[j] = temp.standdownGfx[j] = temp.standupGfx[j] = temp.standleftGfx[j] =
+				temp.standrightGfx[j] = temp.special1Gfx[j] = NULL;
+
+		temp.blinkFrames = temp.movedownFrames = temp.moveupFrames = temp.moveleftFrames =
+			temp.moverightFrames = temp.standdownFrames = temp.standupFrames = temp.standleftFrames =
+			temp.standrightFrames = temp.special1Frames = 0;
+
+		temp.draw = NULL;
+		temp.aiDraw = NULL;
+		temp.aiAction = temp.aiInit = temp.aiUse = NULL;
+
+		// Save AIEntity
+		out->writeSint32LE((int)temp.type);
+		out->writeSint32LE((int)temp.state);
+		out->writeSint32LE((int)temp.dir);
+		out->write(temp.luaFuncInit, 32);
+		out->write(temp.luaFuncAction, 32);
+		out->write(temp.luaFuncUse, 32);
+		out->writeUint16LE(temp.level);
+		out->writeUint16LE(temp.value1);
+		out->writeUint16LE(temp.value2);
+		out->writeSint32LE((int)temp.dir2);
+		out->writeUint16LE(temp.x);
+		out->writeUint16LE(temp.y);
+		out->writeSint16LE(temp.drawXOff);
+		out->writeSint16LE(temp.drawYOff);
+		out->writeUint16LE(temp.onScreen);
+		out->writeUint16LE(temp.moveSpeed);
+		out->writeSint16LE(temp.xVel);
+		out->writeSint16LE(temp.yVel);
+		out->writeUint16LE(temp.tileX);
+		out->writeUint16LE(temp.tileY);
+		out->writeUint16LE(temp.goalX);
+		out->writeUint16LE(temp.goalY);
+		out->writeUint16LE(temp.touchpX);
+		out->writeUint16LE(temp.touchpY);
+		out->writeUint16LE(temp.touchpTile);
+		out->writeUint16LE(temp.touchpWait);
+		out->writeUint16LE(temp.stunnedWait);
+		out->writeSint16LE(temp.sequence);
+		out->write(temp.entityName, 32);
+		out->write(temp.printedName, 32);
+		out->writeUint16LE(temp.animFrame);
+		out->writeUint16LE(temp.animDelay);
+		out->writeUint16LE(temp.animCycle);
 	}
 
 	// Save Ents
 	out->writeUint32LE(_ents->size());
 	for (i = 0; (uint)i < _ents->size(); i++) {
-		warning("STUB: Save Ent Entity");
+		e = _floats->operator[](i);
+		memcpy(&temp, e, sizeof(AIEntity));
+
+		// Write out 32-char names for the function ptrs we have in the entity struct
+		lookUp = funcLookUp(e->aiAction);
+		memset(&funcString, 0, 32);
+		if (!lookUp && e->aiAction)
+			error("AI::save: No matching ACTION function for func-string");
+		if (lookUp)
+			strcpy(funcString, lookUp);
+		out->write(funcString, 32);
+
+		lookUp = funcLookUp(e->aiUse);
+		memset(&funcString, 0, 32);
+		if (!lookUp && e->aiUse)
+			error("AI::save: No matching USE function for func-string");
+		if (lookUp)
+			strcpy(funcString, lookUp);
+		out->write(funcString, 32);
+
+		lookUp = funcLookUp(e->aiInit);
+		memset(&funcString, 0, 32);
+		if (!lookUp && e->aiInit)
+			error("AI::save: No matching INIT function for func-string");
+		if (lookUp)
+			strcpy(funcString, lookUp);
+		out->write(funcString, 32);
+
+		lookUp = funcLookUp(e->aiInit2);
+		memset(&funcString, 0, 32);
+		if (!lookUp && e->aiInit2)
+			error("AI::save: No matching INIT2 function for func-string");
+		if (lookUp)
+			strcpy(funcString, lookUp);
+		out->write(funcString, 32);
+
+		lookUp = funcLookUp((FuncPtr)e->aiDraw);
+		memset(&funcString, 0, 32);
+		if (!lookUp && e->aiDraw)
+			error("AI::save: No matching DRAW function for func-string");
+		if (lookUp)
+			strcpy(funcString, lookUp);
+		out->write(funcString, 32);
+
+		// Clear out all ptrs in Entity before writing it out
+		for (j = 0; j < kMaxAnimFrames; j++)
+			temp.blinkGfx[j] = temp.movedownGfx[j] = temp.moveupGfx[j] = temp.moveleftGfx[j] =
+			temp.moverightGfx[j] = temp.standdownGfx[j] = temp.standupGfx[j] = temp.standleftGfx[j] =
+			temp.standrightGfx[j] = temp.special1Gfx[j] = NULL;
+
+		temp.blinkFrames = temp.movedownFrames = temp.moveupFrames = temp.moveleftFrames =
+			temp.moverightFrames = temp.standdownFrames = temp.standupFrames = temp.standleftFrames =
+			temp.standrightFrames = temp.special1Frames = 0;
+
+		temp.draw = NULL;
+		temp.aiDraw = NULL;
+		temp.aiAction = temp.aiInit = temp.aiUse = NULL;
+
+		// Save AIEntity
+		out->writeSint32LE((int)temp.type);
+		out->writeSint32LE((int)temp.state);
+		out->writeSint32LE((int)temp.dir);
+		out->write(temp.luaFuncInit, 32);
+		out->write(temp.luaFuncAction, 32);
+		out->write(temp.luaFuncUse, 32);
+		out->writeUint16LE(temp.level);
+		out->writeUint16LE(temp.value1);
+		out->writeUint16LE(temp.value2);
+		out->writeSint32LE((int)temp.dir2);
+		out->writeUint16LE(temp.x);
+		out->writeUint16LE(temp.y);
+		out->writeSint16LE(temp.drawXOff);
+		out->writeSint16LE(temp.drawYOff);
+		out->writeUint16LE(temp.onScreen);
+		out->writeUint16LE(temp.moveSpeed);
+		out->writeSint16LE(temp.xVel);
+		out->writeSint16LE(temp.yVel);
+		out->writeUint16LE(temp.tileX);
+		out->writeUint16LE(temp.tileY);
+		out->writeUint16LE(temp.goalX);
+		out->writeUint16LE(temp.goalY);
+		out->writeUint16LE(temp.touchpX);
+		out->writeUint16LE(temp.touchpY);
+		out->writeUint16LE(temp.touchpTile);
+		out->writeUint16LE(temp.touchpWait);
+		out->writeUint16LE(temp.stunnedWait);
+		out->writeSint16LE(temp.sequence);
+		out->write(temp.entityName, 32);
+		out->write(temp.printedName, 32);
+		out->writeUint16LE(temp.animFrame);
+		out->writeUint16LE(temp.animDelay);
+		out->writeUint16LE(temp.animCycle);
 	}
 }
 
@@ -1623,17 +1809,171 @@ void AI::loadSaveFile(Common::InSaveFile *in) {
 		in->read(_triggerList->operator[](i)->luaFuncUse, 32);
 	}
 
+	AIEntity *e;
+	char funcString[32];
+	FuncPtr init, init2, use, action;
+	EntFuncPtr draw;
+
 	// Load Floats
 	_floats->resize(in->readUint32LE());
 	for (i = 0; (uint)i < _floats->size(); i++) {
-		warning("STUB: Load Float Entity");
+		e = new AIEntity;
+		action = init = init2 = use = NULL;
+		draw = NULL;
+
+		// Read 32-char names for the function ptrs we have in entity struct
+		in->read(funcString, 32);
+		if (funcString[0])
+			action = funcLookUp(funcString);
+
+		in->read(funcString, 32);
+		if (funcString[0])
+			use = funcLookUp(funcString);
+
+		in->read(funcString, 32);
+		if (funcString[0])
+			init = funcLookUp(funcString);
+
+		in->read(funcString, 32);
+		if (funcString[0])
+			init2 = funcLookUp(funcString);
+
+		in->read(funcString, 32);
+		if (funcString[0])
+			draw = (EntFuncPtr)funcLookUp(funcString);
+
+		// Load AIEntity
+		e->type = (AIType)in->readSint32LE();
+		e->state = (AIState)in->readSint32LE();
+		e->dir = (AIDir)in->readSint32LE();
+		in->read(e->luaFuncInit, 32);
+		in->read(e->luaFuncAction, 32);
+		in->read(e->luaFuncUse, 32);
+		e->level = in->readUint16LE();
+		e->value1 = in->readUint16LE();
+		e->value2 = in->readUint16LE();
+		e->dir2 = (AIDir)in->readSint32LE();
+		e->x = in->readUint16LE();
+		e->y = in->readUint16LE();
+		e->drawXOff = in->readSint16LE();
+		e->drawYOff = in->readSint16LE();
+		e->onScreen = in->readUint16LE();
+		e->moveSpeed = in->readUint16LE();
+		e->xVel = in->readSint16LE();
+		e->yVel = in->readSint16LE();
+		e->tileX = in->readUint16LE();
+		e->tileY = in->readUint16LE();
+		e->goalX = in->readUint16LE();
+		e->goalY = in->readUint16LE();
+		e->touchpX = in->readUint16LE();
+		e->touchpY = in->readUint16LE();
+		e->touchpTile = in->readUint16LE();
+		e->touchpWait = in->readUint16LE();
+		e->stunnedWait = in->readUint16LE();
+		e->sequence = in->readSint16LE();
+		in->read(e->entityName, 32);
+		in->read(e->printedName, 32);
+		e->animFrame = in->readUint16LE();
+		e->animDelay = in->readUint16LE();
+		e->animCycle = in->readUint16LE();
+
+		e->aiAction = action;
+		e->aiInit = init;
+		e->aiInit2 = init2;
+		e->aiUse = use;
+		e->aiDraw = draw;
+
+		// Cache All Entity Graphics
+		cacheEntGfx(e, false);
+
+		// Push Float
+		_floats->push_back(e);
 	}
 
 	// Load Ents
 	_ents->resize(in->readUint32LE());
 	for (i = 0; (uint)i < _ents->size(); i++) {
-		warning("STUB: Load Ent Entity");
+		e = new AIEntity;
+		action = init = init2 = use = NULL;
+		draw = NULL;
+
+		// Read 32-char names for the function ptrs we have in entity struct
+		in->read(funcString, 32);
+		if (funcString[0])
+			action = funcLookUp(funcString);
+
+		in->read(funcString, 32);
+		if (funcString[0])
+			use = funcLookUp(funcString);
+
+		in->read(funcString, 32);
+		if (funcString[0])
+			init = funcLookUp(funcString);
+
+		in->read(funcString, 32);
+		if (funcString[0])
+			init2 = funcLookUp(funcString);
+
+		in->read(funcString, 32);
+		if (funcString[0])
+			draw = (EntFuncPtr)funcLookUp(funcString);
+
+		// Load AIEntity
+		e->type = (AIType)in->readSint32LE();
+		e->state = (AIState)in->readSint32LE();
+		e->dir = (AIDir)in->readSint32LE();
+		in->read(e->luaFuncInit, 32);
+		in->read(e->luaFuncAction, 32);
+		in->read(e->luaFuncUse, 32);
+		e->level = in->readUint16LE();
+		e->value1 = in->readUint16LE();
+		e->value2 = in->readUint16LE();
+		e->dir2 = (AIDir)in->readSint32LE();
+		e->x = in->readUint16LE();
+		e->y = in->readUint16LE();
+		e->drawXOff = in->readSint16LE();
+		e->drawYOff = in->readSint16LE();
+		e->onScreen = in->readUint16LE();
+		e->moveSpeed = in->readUint16LE();
+		e->xVel = in->readSint16LE();
+		e->yVel = in->readSint16LE();
+		e->tileX = in->readUint16LE();
+		e->tileY = in->readUint16LE();
+		e->goalX = in->readUint16LE();
+		e->goalY = in->readUint16LE();
+		e->touchpX = in->readUint16LE();
+		e->touchpY = in->readUint16LE();
+		e->touchpTile = in->readUint16LE();
+		e->touchpWait = in->readUint16LE();
+		e->stunnedWait = in->readUint16LE();
+		e->sequence = in->readSint16LE();
+		in->read(e->entityName, 32);
+		in->read(e->printedName, 32);
+		e->animFrame = in->readUint16LE();
+		e->animDelay = in->readUint16LE();
+		e->animCycle = in->readUint16LE();
+
+		e->aiAction = action;
+		e->aiInit = init;
+		e->aiInit2 = init2;
+		e->aiUse = use;
+		e->aiDraw = draw;
+
+		// Cache All Entity Graphics
+		cacheEntGfx(e, false);
+
+		// Push Entity
+		_ents->push_back(e);
+
+		if (e->type == AI_GUY)
+			_player = e;
 	}
+
+	// Cache-in all animating tiles
+	initAnimInfo();
+
+	// Set the Player weapon
+	warning("STUB: Set the Player weapon");
 }
 
 void AI::initAnimInfo() {


Commit: d510e3efe5da326b0a2c12a86f9937b097494b2b
    https://github.com/scummvm/scummvm/commit/d510e3efe5da326b0a2c12a86f9937b097494b2b
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:15+02:00

Commit Message:
HDB: Unstub save/load _animTargets[i].gfxList

Changed paths:
    engines/hdb/ai-init.cpp


diff --git a/engines/hdb/ai-init.cpp b/engines/hdb/ai-init.cpp
index 3d2c5be..b76e55e 100644
--- a/engines/hdb/ai-init.cpp
+++ b/engines/hdb/ai-init.cpp
@@ -1370,7 +1370,6 @@ void AI::save(Common::OutSaveFile *out) {
 		out->writeUint16LE(_animTargets[i]->animFrame);
 		out->writeByte(_animTargets[i]->killAuto);
 		out->writeByte(_animTargets[i]->inMap);
-		warning("STUB: Save _animTargets[i].gfxList");
 	}
 
 	// Save ArrowPaths
@@ -1506,7 +1505,7 @@ void AI::save(Common::OutSaveFile *out) {
 	// Save Ents
 	out->writeUint32LE(_ents->size());
 	for (i = 0; (uint)i < _ents->size(); i++) {
-		e = _floats->operator[](i);
+		e = _ents->operator[](i);
 		memcpy(&temp, e, sizeof(AIEntity));
 
 		// Write out 32-char names for the function ptrs we have in the entity struct
@@ -1777,7 +1776,7 @@ void AI::loadSaveFile(Common::InSaveFile *in) {
 		_animTargets[i]->animFrame = in->readUint16LE();
 		_animTargets[i]->killAuto = in->readByte();
 		_animTargets[i]->inMap = in->readByte();
-		warning("STUB: Load _animTargets[i].gfxList");
+		memset(_animTargets[i]->gfxList, 0, kMaxAnimTFrames);
 	}
 
 	// Load ArrowPaths


Commit: 961f3b46f0cf1a458a425c576914cfc621bf962d
    https://github.com/scummvm/scummvm/commit/961f3b46f0cf1a458a425c576914cfc621bf962d
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:15+02:00

Commit Message:
HDB: Add structs and functions for Lua Globals

Changed paths:
    engines/hdb/lua-script.cpp
    engines/hdb/lua-script.h


diff --git a/engines/hdb/lua-script.cpp b/engines/hdb/lua-script.cpp
index da1f91e..337496b 100644
--- a/engines/hdb/lua-script.cpp
+++ b/engines/hdb/lua-script.cpp
@@ -86,6 +86,64 @@ bool LuaScript::loadLua(const char *name) {
 	return true;
 }
 
+void LuaScript::saveGlobalNumber(const char *global, double value) {
+	// see if global already exists; if so, overwrite it.
+	for (uint i = 0; i < _globals.size(); i++) {
+		if (!scumm_stricmp(global, _globals[i]->global)) {
+			_globals[i]->valueOrString = 0;
+			_globals[i]->value = value;
+			return;
+		}
+	}
+
+	Global *g = new Global;
+	strcpy(g->global, global);
+	g->valueOrString = 0;
+	g->value = value;
+
+	_globals.push_back(g);
+}
+
+void LuaScript::saveGlobalString(const char *global, const char *string) {
+	if (!string)
+		return;
+
+	// see if global already exists; if so, overwrite it.
+	for (uint i = 0; i < _globals.size(); i++) {
+		if (!scumm_stricmp(global, _globals[i]->global)) {
+			_globals[i]->valueOrString = 1;
+			strcpy(_globals[i]->string, string);
+			return;
+		}
+	}
+
+	Global *g = new Global;
+	strcpy(g->global, global);
+	g->valueOrString = 1;
+	strcpy(g->string, string);
+
+	_globals.push_back(g);
+}
+
+void LuaScript::loadGlobal(const char *global) {
+	for (uint i = 0; i < _globals.size(); i++) {
+		if (!scumm_stricmp(global, _globals[i]->global)) {
+			if (_globals[i]->valueOrString) {
+				lua_pushstring(_state, _globals[i]->string);
+				lua_setglobal(_state, _globals[i]->global);
+			} else {
+				lua_pushnumber(_state, _globals[i]->value);
+				lua_setglobal(_state, _globals[i]->global);
+			}
+			return;
+		}
+	}
+}
+
+void LuaScript::purgeGlobals() {
+	_globals.clear();
+}
+
 void LuaScript::setLuaGlobalValue(const char *name, int value) {
 	if (!_state)
 		return;
diff --git a/engines/hdb/lua-script.h b/engines/hdb/lua-script.h
index 4f2ffd2..b84a19d 100644
--- a/engines/hdb/lua-script.h
+++ b/engines/hdb/lua-script.h
@@ -37,12 +37,28 @@ enum {
 	kCameraYOff = (32 * 2 + 16)		// 2.50 Tiles Extra
 };
 
+struct Global {
+	char	global[32];			// name of global variable
+	int		valueOrString;	// value = 0, string = 1
+	double	value;				// value
+	char	string[32];			// string
+
+	Global() : valueOrString(0), value(0) {
+		global[0] = 0;
+		string[0] = 0;
+	}
+};
+
 class LuaScript {
 public:
 	LuaScript();
 	~LuaScript();
 
 	bool loadLua(const char *name);
+	void saveGlobalNumber(const char *global, double value);
+	void saveGlobalString(const char *global, const char *string);
+	void loadGlobal(const char *global);
+	void purgeGlobals();
 
 	bool init();
 	bool initScript(Common::SeekableReadStream *stream, const char *scriptName, int32 length);
@@ -74,6 +90,8 @@ private:
 	bool registerExtensions();
 	void stripComments(char *chunk);
 	void addPatches(Common::String &chunk, const char *scriptName);
+
+	Common::Array<Global *> _globals;
 };
 
 void lua_printstack(lua_State *L);


Commit: 85a8209d97992572d98a2f4bb20a9b9faa706b0c
    https://github.com/scummvm/scummvm/commit/85a8209d97992572d98a2f4bb20a9b9faa706b0c
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:15+02:00

Commit Message:
HDB: Add save/load for the Lua Globals environment

Changed paths:
    engines/hdb/hdb.cpp
    engines/hdb/lua-script.cpp
    engines/hdb/lua-script.h


diff --git a/engines/hdb/hdb.cpp b/engines/hdb/hdb.cpp
index c82c9d6..3259241 100644
--- a/engines/hdb/hdb.cpp
+++ b/engines/hdb/hdb.cpp
@@ -435,6 +435,7 @@ bool HDBGame::saveSlot(int slot) {
 	Common::OutSaveFile *out;
 
 	Common::String saveFileName = Common::String::format("%s.%03d", _targetName.c_str(), slot);
+	Common::String saveLuaName = Common::String::format("%s.l.%03d", _targetName.c_str(), slot);
 	if (!(out = _saveFileMan->openForSaving(saveFileName)))
 		error("Unable to open save file");
 
@@ -443,9 +444,7 @@ bool HDBGame::saveSlot(int slot) {
 
 	// Actual Save Data
 	saveGame(out);
-#if 0
-	_lua->save(out, saveFileName);
-#endif
+	_lua->save(out, saveLuaName.c_str());
 
 	out->finalize();
 	if (out->err())
diff --git a/engines/hdb/lua-script.cpp b/engines/hdb/lua-script.cpp
index 337496b..58f7929 100644
--- a/engines/hdb/lua-script.cpp
+++ b/engines/hdb/lua-script.cpp
@@ -144,6 +144,52 @@ void LuaScript::purgeGlobals() {
 	_globals.clear();
 }
 
+void LuaScript::save(Common::OutSaveFile *out, const char *fName) {
+	out->writeUint32LE(_globals.size());
+
+	// Save Globals
+	for (uint i = 0; i < _globals.size(); i++) {
+		out->write(_globals[i]->global, 32);
+		out->writeSint32LE(_globals[i]->valueOrString);
+		out->writeDoubleLE(_globals[i]->value);
+		out->write(_globals[i]->string, 32);
+	}
+
+	// Delete Lua Save File
+	Common::InSaveFile *inLua = g_system->getSavefileManager()->openForLoading(fName);
+	if (inLua)
+		delete inLua;
+
+	lua_getglobal(_state, "SaveState");
+	lua_pushstring(_state, fName);
+	if (lua_pcall(_state, 0, 0, -2)) {
+		error("An error occured while saving \"%s\": %s.", fName, lua_tostring(_state, -1));
+		lua_pop(_state, -1);
+	}
+}
+
+void LuaScript::loadSaveFile(Common::InSaveFile *in, const char *fName) {
+	// Clear out all globals
+	_globals.clear();
+
+	// Start reading globals
+	_globals.resize(in->readUint32LE());
+	for (uint i = 0; i < _globals.size(); i++) {
+		in->read(_globals[i]->global, 32);
+		_globals[i]->valueOrString = in->readSint32LE();
+		_globals[i]->value = in->readDoubleLE();
+		in->read(_globals[i]->string, 32);
+	}
+
+	lua_getglobal(_state, "LoadState");
+	lua_pushstring(_state, fName);
+	if (lua_pcall(_state, 0, 0, -2)) {
+		error("An error occured while loading \"%s\": %s.", fName, lua_tostring(_state, -1));
+		lua_pop(_state, -1);
+	}
+
+}
+
 void LuaScript::setLuaGlobalValue(const char *name, int value) {
 	if (!_state)
 		return;
diff --git a/engines/hdb/lua-script.h b/engines/hdb/lua-script.h
index b84a19d..22168a9 100644
--- a/engines/hdb/lua-script.h
+++ b/engines/hdb/lua-script.h
@@ -59,6 +59,8 @@ public:
 	void saveGlobalString(const char *global, const char *string);
 	void loadGlobal(const char *global);
 	void purgeGlobals();
+	void save(Common::OutSaveFile *out, const char *fName);
+	void loadSaveFile(Common::InSaveFile *in, const char *fName);
 
 	bool init();
 	bool initScript(Common::SeekableReadStream *stream, const char *scriptName, int32 length);


Commit: 2315a05ad39e013b009e98baafcbd9b7edb717a1
    https://github.com/scummvm/scummvm/commit/2315a05ad39e013b009e98baafcbd9b7edb717a1
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:15+02:00

Commit Message:
HDB: Fix calling Lua save/load

Changed paths:
    engines/hdb/lua-script.cpp


diff --git a/engines/hdb/lua-script.cpp b/engines/hdb/lua-script.cpp
index 58f7929..8ce614c 100644
--- a/engines/hdb/lua-script.cpp
+++ b/engines/hdb/lua-script.cpp
@@ -162,10 +162,8 @@ void LuaScript::save(Common::OutSaveFile *out, const char *fName) {
 
 	lua_getglobal(_state, "SaveState");
 	lua_pushstring(_state, fName);
-	if (lua_pcall(_state, 0, 0, -2)) {
-		error("An error occured while saving \"%s\": %s.", fName, lua_tostring(_state, -1));
-		lua_pop(_state, -1);
-	}
+
+	lua_call(_state, 1, 0);
 }
 
 void LuaScript::loadSaveFile(Common::InSaveFile *in, const char *fName) {
@@ -181,13 +179,14 @@ void LuaScript::loadSaveFile(Common::InSaveFile *in, const char *fName) {
 		in->read(_globals[i]->string, 32);
 	}
 
+	// Error handling function to be executed after the function is put on the stack
+	lua_rawgeti(_state, LUA_REGISTRYINDEX, _pcallErrorhandlerRegistryIndex);
+	lua_insert(_state, -2);
+
 	lua_getglobal(_state, "LoadState");
 	lua_pushstring(_state, fName);
-	if (lua_pcall(_state, 0, 0, -2)) {
-		error("An error occured while loading \"%s\": %s.", fName, lua_tostring(_state, -1));
-		lua_pop(_state, -1);
-	}
 
+	lua_call(_state, 1, 0);
 }
 
 void LuaScript::setLuaGlobalValue(const char *name, int value) {


Commit: 6e60d6a287e3bea956cc607f2f2ebfc5b3d11829
    https://github.com/scummvm/scummvm/commit/6e60d6a287e3bea956cc607f2f2ebfc5b3d11829
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:15+02:00

Commit Message:
HDB: Unstub saveGlobal, loadGlobal, purgeGlobals

Changed paths:
    engines/hdb/lua-script.cpp


diff --git a/engines/hdb/lua-script.cpp b/engines/hdb/lua-script.cpp
index 8ce614c..bef9c05 100644
--- a/engines/hdb/lua-script.cpp
+++ b/engines/hdb/lua-script.cpp
@@ -1086,17 +1086,40 @@ static int startMap(lua_State *L) {
 }
 
 static int saveGlobal(lua_State *L) {
-	warning("STUB: SAVE GLOBAL");
+	const char *global = lua_tostring(L, 1);
+	int type;
+
+	g_hdb->_lua->checkParameters("saveGlobal", 1);
+
+	lua_pop(L, 1);
+
+	lua_getglobal(L, global);
+	type = lua_type(L, 1);
+	if (type == LUA_TNUMBER) {
+		double value = lua_tonumber(L, 1);
+		g_hdb->_lua->saveGlobalNumber(global, value);
+	} else if (type == LUA_TSTRING) {
+		const char *string = lua_tostring(L, 1);
+		g_hdb->_lua->saveGlobalString(global, string);
+	}
+
 	return 0;
 }
 
 static int loadGlobal(lua_State *L) {
-	warning("STUB: LOAD GLOBAL");
+	const char *global = lua_tostring(L, 1);
+
+	g_hdb->_lua->checkParameters("loadGlobal", 1);
+
+	lua_pop(L, 1);
+
+	g_hdb->_lua->loadGlobal(global);
+
 	return 0;
 }
 
 static int purgeGlobals(lua_State *L) {
-	warning("STUB: PURGE GLOBALS");
+	g_hdb->_lua->purgeGlobals();
 	return 0;
 }
 


Commit: b7b8b23d295e8701b69a4bea27892a62aab988c7
    https://github.com/scummvm/scummvm/commit/b7b8b23d295e8701b69a4bea27892a62aab988c7
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:15+02:00

Commit Message:
HDB: Add openFile, write, closeFile Lua functions

Changed paths:
    engines/hdb/hdb.cpp
    engines/hdb/lua-script.cpp
    engines/hdb/lua-script.h


diff --git a/engines/hdb/hdb.cpp b/engines/hdb/hdb.cpp
index 3259241..d97e127 100644
--- a/engines/hdb/hdb.cpp
+++ b/engines/hdb/hdb.cpp
@@ -435,7 +435,6 @@ bool HDBGame::saveSlot(int slot) {
 	Common::OutSaveFile *out;
 
 	Common::String saveFileName = Common::String::format("%s.%03d", _targetName.c_str(), slot);
-	Common::String saveLuaName = Common::String::format("%s.l.%03d", _targetName.c_str(), slot);
 	if (!(out = _saveFileMan->openForSaving(saveFileName)))
 		error("Unable to open save file");
 
@@ -444,11 +443,11 @@ bool HDBGame::saveSlot(int slot) {
 
 	// Actual Save Data
 	saveGame(out);
-	_lua->save(out, saveLuaName.c_str());
+	_lua->save(out, _targetName.c_str(), slot);
 
 	out->finalize();
 	if (out->err())
-		warning("Can't wrtie file '%s'. (Disk full?)", saveFileName.c_str());
+		warning("Can't write file '%s'. (Disk full?)", saveFileName.c_str());
 
 	delete out;
 
diff --git a/engines/hdb/lua-script.cpp b/engines/hdb/lua-script.cpp
index bef9c05..0a1b311 100644
--- a/engines/hdb/lua-script.cpp
+++ b/engines/hdb/lua-script.cpp
@@ -41,6 +41,9 @@ struct ScriptPatch {
 	{"GLOBAL.LUA", "if( getglobal( \"map\"..tostring(v1)..\"_complete\" ) ) then", "if( _G[\"map\"..tostring(v1)..\"_complete\"] ) then"},
 	{"GLOBAL.LUA", "closefunc = getglobal( npcdef.codename..\"_use\" )", "closefunc = _G[npcdef.codename..\"_use\"]"},
 	{"GLOBAL.LUA", "strsub(", "string.sub("}, // line 15
+	{"GLOBAL.LUA", "for i,v in globals() do", "for i,v in pairs(_G) do"},
+	{"GLOBAL.LUA", "return gsub( s, \"\\n\", \"\\\\\\n\" )", "return string.gsub( s, \"\\n\", \"\\\\\\n\" )"},
+	{"GLOBAL.LUA", "for i,v in t do", "for i,v in pairs(t) do"},
 	{"MAP00.LUA", "tempfunc = function() emptybed_use( %x, %y, %v1, %v2 ) end", "tempfunc = function() emptybed_use(x, y, v1, v2) end"},
 	{"MAP00.LUA", "if( getn( beds ) == 0 ) then", "if( #beds == 0 ) then"},
 	{"MAP01.LUA", "if( covert_index < getn(covert_dialog) ) then", "if( covert_index < #covert_dialog ) then"},
@@ -144,7 +147,7 @@ void LuaScript::purgeGlobals() {
 	_globals.clear();
 }
 
-void LuaScript::save(Common::OutSaveFile *out, const char *fName) {
+void LuaScript::save(Common::OutSaveFile *out, const char *targetName, int slot) {
 	out->writeUint32LE(_globals.size());
 
 	// Save Globals
@@ -155,14 +158,11 @@ void LuaScript::save(Common::OutSaveFile *out, const char *fName) {
 		out->write(_globals[i]->string, 32);
 	}
 
-	// Delete Lua Save File
-	Common::InSaveFile *inLua = g_system->getSavefileManager()->openForLoading(fName);
-	if (inLua)
-		delete inLua;
-
+	Common::String saveLuaName = Common::String::format("%s.l.%03d", targetName, slot);
+	lua_printstack(_state);
 	lua_getglobal(_state, "SaveState");
-	lua_pushstring(_state, fName);
 
+	lua_pushstring(_state, saveLuaName.c_str());
 	lua_call(_state, 1, 0);
 }
 
@@ -1191,6 +1191,57 @@ static int playVoice(lua_State *L) {
 	return 0;
 }
 
+static int openFile(lua_State *L) {
+
+	const char *fName = lua_tostring(L, 1);
+	const char *mode = lua_tostring(L, 2);
+
+	g_hdb->_lua->checkParameters("openFile", 2);
+
+	lua_pop(L, 2);
+
+	if (!scumm_stricmp(mode, "wt")) {
+		// Delete Lua Save File
+		Common::InSaveFile *inLua = g_system->getSavefileManager()->openForLoading(fName);
+		if (inLua)
+			delete inLua;
+
+		Common::OutSaveFile *outLua = g_system->getSavefileManager()->openForSaving(fName);
+		if (!outLua)
+			error("Cannot open %s", fName);
+		lua_pushlightuserdata(L, outLua);
+	}
+
+	return 1;
+}
+
+static int write(lua_State *L) {
+	Common::OutSaveFile *out = (Common::OutSaveFile *)lua_topointer(L, 1);
+	const char *data = lua_tostring(L, 2);
+
+	g_hdb->_lua->checkParameters("write", 2);
+
+	lua_pop(L, 2);
+
+	out->write(data, strlen(data));
+
+	return 0;
+}
+
+static int closeFile(lua_State *L) {
+	Common::OutSaveFile *out = (Common::OutSaveFile *)lua_topointer(L, 1);
+
+	g_hdb->_lua->checkParameters("closeFile", 1);
+
+	lua_pop(L, 1);
+
+	out->finalize();
+
+	delete out;
+
+	return 0;
+}
+
 /*
 	Lua Initialization Code
 */
@@ -1490,6 +1541,10 @@ struct FuncInit {
 	{  "Cine_TextOut",			cineTextOut			},
 	{  "Cine_CenterTextOut",	cineCenterTextOut	},
 	{  "Cine_PlayVoice",		cinePlayVoice		},
+
+	{	"openfile",				openFile,			},
+	{	"write",				write,			},
+	{	"closefile",			closeFile,			},
 	{ NULL, NULL }
 };
 
diff --git a/engines/hdb/lua-script.h b/engines/hdb/lua-script.h
index 22168a9..ff061af 100644
--- a/engines/hdb/lua-script.h
+++ b/engines/hdb/lua-script.h
@@ -59,7 +59,7 @@ public:
 	void saveGlobalString(const char *global, const char *string);
 	void loadGlobal(const char *global);
 	void purgeGlobals();
-	void save(Common::OutSaveFile *out, const char *fName);
+	void save(Common::OutSaveFile *out, const char *targetName, int slot);
 	void loadSaveFile(Common::InSaveFile *in, const char *fName);
 
 	bool init();


Commit: cbbe538e5d7cbd7bba4f70d04be345ec493d994a
    https://github.com/scummvm/scummvm/commit/cbbe538e5d7cbd7bba4f70d04be345ec493d994a
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:15+02:00

Commit Message:
HDB: More Global script patches

Changed paths:
    engines/hdb/lua-script.cpp


diff --git a/engines/hdb/lua-script.cpp b/engines/hdb/lua-script.cpp
index 0a1b311..fd7d147 100644
--- a/engines/hdb/lua-script.cpp
+++ b/engines/hdb/lua-script.cpp
@@ -44,6 +44,9 @@ struct ScriptPatch {
 	{"GLOBAL.LUA", "for i,v in globals() do", "for i,v in pairs(_G) do"},
 	{"GLOBAL.LUA", "return gsub( s, \"\\n\", \"\\\\\\n\" )", "return string.gsub( s, \"\\n\", \"\\\\\\n\" )"},
 	{"GLOBAL.LUA", "for i,v in t do", "for i,v in pairs(t) do"},
+	{"GLOBAL.LUA", "if type(v) == 'userdata' or type(v) == 'function' then return end", "if type(v) == 'userdata' or type(v) == 'function' or i == 'package' then return end" }, // Line 16
+	{"GLOBAL.LUA", "for npcname,npcdata in npcs do", "for npcname,npcdata in pairs(npcs) do"}, // Line 66
+	{"GLOBAL.LUA", "for dlgname,dlgdata in npcdata.dialog do", "for dlgname,dlgdata in pairs(npcdata.dialog) do"}, // Line 67
 	{"MAP00.LUA", "tempfunc = function() emptybed_use( %x, %y, %v1, %v2 ) end", "tempfunc = function() emptybed_use(x, y, v1, v2) end"},
 	{"MAP00.LUA", "if( getn( beds ) == 0 ) then", "if( #beds == 0 ) then"},
 	{"MAP01.LUA", "if( covert_index < getn(covert_dialog) ) then", "if( covert_index < #covert_dialog ) then"},
@@ -1224,6 +1227,7 @@ static int write(lua_State *L) {
 	lua_pop(L, 2);
 
 	out->write(data, strlen(data));
+	debugN(3, "%s", data);
 
 	return 0;
 }


Commit: e166f4e3ffb9da0fa3f49832555144c1b37d9281
    https://github.com/scummvm/scummvm/commit/e166f4e3ffb9da0fa3f49832555144c1b37d9281
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:15+02:00

Commit Message:
HDB: And even more script patches

Changed paths:
    engines/hdb/lua-script.cpp


diff --git a/engines/hdb/lua-script.cpp b/engines/hdb/lua-script.cpp
index fd7d147..347ff24 100644
--- a/engines/hdb/lua-script.cpp
+++ b/engines/hdb/lua-script.cpp
@@ -47,6 +47,8 @@ struct ScriptPatch {
 	{"GLOBAL.LUA", "if type(v) == 'userdata' or type(v) == 'function' then return end", "if type(v) == 'userdata' or type(v) == 'function' or i == 'package' then return end" }, // Line 16
 	{"GLOBAL.LUA", "for npcname,npcdata in npcs do", "for npcname,npcdata in pairs(npcs) do"}, // Line 66
 	{"GLOBAL.LUA", "for dlgname,dlgdata in npcdata.dialog do", "for dlgname,dlgdata in pairs(npcdata.dialog) do"}, // Line 67
+	{"GLOBAL.LUA", "s = format( \"npcs.%s.dialog.%s.counter", "s = string.format( \"npcs.%s.dialog.%s.counter"}, // Line 68
+	{"GLOBAL.LUA", "s = format( \"npcs.%s.dialog.%s.finished = ", "s = string.format( \"npcs.%s.dialog.%s.finished = "}, // line 70
 	{"MAP00.LUA", "tempfunc = function() emptybed_use( %x, %y, %v1, %v2 ) end", "tempfunc = function() emptybed_use(x, y, v1, v2) end"},
 	{"MAP00.LUA", "if( getn( beds ) == 0 ) then", "if( #beds == 0 ) then"},
 	{"MAP01.LUA", "if( covert_index < getn(covert_dialog) ) then", "if( covert_index < #covert_dialog ) then"},


Commit: ec0bd5e667cb65b65d3e8cdb49d0f2804e7f1548
    https://github.com/scummvm/scummvm/commit/ec0bd5e667cb65b65d3e8cdb49d0f2804e7f1548
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:15+02:00

Commit Message:
HDB: Add global patch for io, os, sctrings

Changed paths:
    engines/hdb/lua-script.cpp


diff --git a/engines/hdb/lua-script.cpp b/engines/hdb/lua-script.cpp
index 347ff24..2fe5520 100644
--- a/engines/hdb/lua-script.cpp
+++ b/engines/hdb/lua-script.cpp
@@ -44,7 +44,7 @@ struct ScriptPatch {
 	{"GLOBAL.LUA", "for i,v in globals() do", "for i,v in pairs(_G) do"},
 	{"GLOBAL.LUA", "return gsub( s, \"\\n\", \"\\\\\\n\" )", "return string.gsub( s, \"\\n\", \"\\\\\\n\" )"},
 	{"GLOBAL.LUA", "for i,v in t do", "for i,v in pairs(t) do"},
-	{"GLOBAL.LUA", "if type(v) == 'userdata' or type(v) == 'function' then return end", "if type(v) == 'userdata' or type(v) == 'function' or i == 'package' then return end" }, // Line 16
+	{"GLOBAL.LUA", "if type(v) == 'userdata' or type(v) == 'function' then return end", "if type(v) == 'userdata' or type(v) == 'function' or i == 'package' or i == 'os' or i == 'io' or i == 'sctrings' then return end" }, // Line 16
 	{"GLOBAL.LUA", "for npcname,npcdata in npcs do", "for npcname,npcdata in pairs(npcs) do"}, // Line 66
 	{"GLOBAL.LUA", "for dlgname,dlgdata in npcdata.dialog do", "for dlgname,dlgdata in pairs(npcdata.dialog) do"}, // Line 67
 	{"GLOBAL.LUA", "s = format( \"npcs.%s.dialog.%s.counter", "s = string.format( \"npcs.%s.dialog.%s.counter"}, // Line 68


Commit: ac9f2d634bc8c84fcb2b698a0361cb503c0a8bb9
    https://github.com/scummvm/scummvm/commit/ac9f2d634bc8c84fcb2b698a0361cb503c0a8bb9
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:15+02:00

Commit Message:
HDB: Add loadGame() and Sound::stopMusic()

Changed paths:
    engines/hdb/hdb.cpp
    engines/hdb/hdb.h
    engines/hdb/sound.cpp
    engines/hdb/sound.h


diff --git a/engines/hdb/hdb.cpp b/engines/hdb/hdb.cpp
index d97e127..cebcb11 100644
--- a/engines/hdb/hdb.cpp
+++ b/engines/hdb/hdb.cpp
@@ -137,7 +137,7 @@ void HDBGame::save(Common::OutSaveFile *out) {
 	out->write(_inMapName, 32);
 }
 
-void HDBGame::load(Common::InSaveFile *in) {
+void HDBGame::loadSaveFile(Common::InSaveFile *in) {
 	in->read(_currentMapname, 64);
 	in->read(_lastMapname, 64);
 	in->read(_currentLuaName, 64);
@@ -499,11 +499,36 @@ void HDBGame::saveGame(Common::OutSaveFile *out) {
 	// Save AI Object Data
 
 	_ai->save(out);
-
 }
 
 void HDBGame::loadGame(Common::InSaveFile *in) {
-	warning("STUB: Add loadGame()");
+	// Load Map Name
+	in->read(_inMapName, 32);
+
+	g_hdb->_sound->stopMusic();
+	_timeSeconds = 0;
+	_timePlayed = 0;
+
+	// Load Map Object Data
+	_map->loadSaveFile(in);
+
+	// Load Window Object Data
+	_window->loadSaveFile(in);
+
+	// Load Gfx Object Data
+	_gfx->loadSaveFile(in);
+
+	// Load Sound Object Data
+	_sound->loadSaveFile(in);
+
+	// Load Game Object Data
+	loadSaveFile(in);
+
+	// Load AI Object Data
+
+	_ai->loadSaveFile(in);
+
+	_gfx->turnOffFade();
 }
 
 // PLAYER is trying to use this entity
diff --git a/engines/hdb/hdb.h b/engines/hdb/hdb.h
index fcd52da..fce1138 100644
--- a/engines/hdb/hdb.h
+++ b/engines/hdb/hdb.h
@@ -147,7 +147,7 @@ public:
 
 	bool init();
 	void save(Common::OutSaveFile *out);
-	void load(Common::InSaveFile *in);
+	void loadSaveFile(Common::InSaveFile *in);
 
 	bool restartMap();
 	bool startMap(const char *name);
diff --git a/engines/hdb/sound.cpp b/engines/hdb/sound.cpp
index cdda643..d14ec50 100644
--- a/engines/hdb/sound.cpp
+++ b/engines/hdb/sound.cpp
@@ -57,6 +57,10 @@ bool Sound::stopChannel(int channel) {
 	return true;
 }
 
+void Sound::stopMusic() {
+	debug(9, "STUB: Stop Music");
+}
+
 void Sound::markSoundCacheFreeable() {
 	warning("STUB: Sound::markSoundCacheFreeable() ");
 }
diff --git a/engines/hdb/sound.h b/engines/hdb/sound.h
index 8d0d6ba..176d093 100644
--- a/engines/hdb/sound.h
+++ b/engines/hdb/sound.h
@@ -1399,6 +1399,7 @@ public:
 	bool playSoundEx(int index, int channel, bool loop);
 	bool playVoice(int index, int actor);
 	bool stopChannel(int channel);
+	void stopMusic();
 
 	void markSoundCacheFreeable();
 };


Commit: 963043f3b27e11dbe5524673bfd5e0e720ecf0ff
    https://github.com/scummvm/scummvm/commit/963043f3b27e11dbe5524673bfd5e0e720ecf0ff
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:15+02:00

Commit Message:
HDB: Shift Save/Load functions to saveload.cpp

Changed paths:
  A engines/hdb/saveload.cpp
    engines/hdb/hdb.cpp
    engines/hdb/hdb.h
    engines/hdb/module.mk


diff --git a/engines/hdb/hdb.cpp b/engines/hdb/hdb.cpp
index cebcb11..376c3a7 100644
--- a/engines/hdb/hdb.cpp
+++ b/engines/hdb/hdb.cpp
@@ -244,7 +244,7 @@ bool HDBGame::startMap(const char *name) {
 	//
 	if (!scumm_strnicmp(name, "map", 3) && scumm_stricmp(name, "map30")) {
 		_menu->fillSavegameSlots();
-		saveSlot(0);          // we ignore the slot parameter in everything else since we just keep saving...
+		saveGameState(0);          // we ignore the slot parameter in everything else since we just keep saving...
 	}
 	return true;
 }
@@ -426,111 +426,6 @@ void HDBGame::setTargetXY(int x, int y) {
 	}
 }
 
-bool HDBGame::saveSlot(int slot) {
-
-	// If no map is loaded, don't try to save
-	if (!g_hdb->_map->isLoaded())
-		return false;
-
-	Common::OutSaveFile *out;
-
-	Common::String saveFileName = Common::String::format("%s.%03d", _targetName.c_str(), slot);
-	if (!(out = _saveFileMan->openForSaving(saveFileName)))
-		error("Unable to open save file");
-
-	warning("STUB: Save MetaData");
-	Graphics::saveThumbnail(*out);
-
-	// Actual Save Data
-	saveGame(out);
-	_lua->save(out, _targetName.c_str(), slot);
-
-	out->finalize();
-	if (out->err())
-		warning("Can't write file '%s'. (Disk full?)", saveFileName.c_str());
-
-	delete out;
-
-	return true;
-}
-
-bool HDBGame::loadSlot(int slot) {
-	Common::InSaveFile *in;
-
-	Common::String saveFileName = Common::String::format("%s.%03d", _targetName.c_str(), slot);
-	if (!(in = _saveFileMan->openForLoading(saveFileName))) {
-		warning("missing savegame file %s", saveFileName.c_str());
-		if (g_hdb->_map->isLoaded())
-			g_hdb->setGameState(GAME_PLAY);
-		return false;
-	}
-
-	warning("STUB: Load MetaData");
-	Graphics::skipThumbnail(*in);
-
-	// Actual Save Data
-	loadGame(in);
-
-	delete in;
-
-	return true;
-}
-
-void HDBGame::saveGame(Common::OutSaveFile *out) {
-
-	// Save Map Name
-	out->write(_inMapName, 32);
-
-	// Save Map Object Data
-	_map->save(out);
-
-	// Save Window Object Data
-	_window->save(out);
-
-	// Save Gfx Object Data
-	_gfx->save(out);
-
-	// Save Sound Object Data
-	_sound->save(out);
-
-	// Save Game Object Data
-	save(out);
-
-	// Save AI Object Data
-
-	_ai->save(out);
-}
-
-void HDBGame::loadGame(Common::InSaveFile *in) {
-	// Load Map Name
-	in->read(_inMapName, 32);
-
-	g_hdb->_sound->stopMusic();
-	_timeSeconds = 0;
-	_timePlayed = 0;
-
-	// Load Map Object Data
-	_map->loadSaveFile(in);
-
-	// Load Window Object Data
-	_window->loadSaveFile(in);
-
-	// Load Gfx Object Data
-	_gfx->loadSaveFile(in);
-
-	// Load Sound Object Data
-	_sound->loadSaveFile(in);
-
-	// Load Game Object Data
-	loadSaveFile(in);
-
-	// Load AI Object Data
-
-	_ai->loadSaveFile(in);
-
-	_gfx->turnOffFade();
-}
-
 // PLAYER is trying to use this entity
 void HDBGame::useEntity(AIEntity *e) {
 	warning("STUB: HDBGame::useEntity incomplete");
@@ -968,7 +863,7 @@ Common::Error HDBGame::run() {
 				_sound->playSound(SND_VORTEX_SAVE);
 				_ai->stopEntity(e);
 				_menu->fillSavegameSlots();
-				saveSlot(_saveInfo.slot);
+				saveGameState(_saveInfo.slot);
 				_saveInfo.active = false;
 			}
 		}
diff --git a/engines/hdb/hdb.h b/engines/hdb/hdb.h
index fce1138..260ca4a 100644
--- a/engines/hdb/hdb.h
+++ b/engines/hdb/hdb.h
@@ -157,8 +157,8 @@ public:
 		_changeLevel = true;
 	}
 
-	bool saveSlot(int slot);
-	bool loadSlot(int slot);
+	Common::Error saveGameState(int slot);
+	Common::Error loadGameState(int slot);
 	void saveGame(Common::OutSaveFile *out);
 	void loadGame(Common::InSaveFile *in);
 
diff --git a/engines/hdb/module.mk b/engines/hdb/module.mk
index 7fa8431..e3e56eb 100644
--- a/engines/hdb/module.mk
+++ b/engines/hdb/module.mk
@@ -20,6 +20,7 @@ MODULE_OBJS := \
 	map.o \
 	menu.o \
 	sound.o \
+	saveload.o \
 	window.o
 
 MODULE_DIRS += \
diff --git a/engines/hdb/saveload.cpp b/engines/hdb/saveload.cpp
new file mode 100644
index 0000000..1ae78fe
--- /dev/null
+++ b/engines/hdb/saveload.cpp
@@ -0,0 +1,132 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "hdb/hdb.h"
+
+namespace HDB {
+
+Common::Error HDBGame::saveGameState(int slot) {
+
+	// If no map is loaded, don't try to save
+	if (!g_hdb->_map->isLoaded())
+		return Common::kCreatingFileFailed;
+
+	Common::OutSaveFile *out;
+
+	Common::String saveFileName = Common::String::format("%s.%03d", _targetName.c_str(), slot);
+	if (!(out = _saveFileMan->openForSaving(saveFileName)))
+		error("Unable to open save file");
+
+	warning("STUB: Save MetaData");
+	Graphics::saveThumbnail(*out);
+
+	// Actual Save Data
+	saveGame(out);
+	_lua->save(out, _targetName.c_str(), slot);
+
+	out->finalize();
+	if (out->err())
+		warning("Can't write file '%s'. (Disk full?)", saveFileName.c_str());
+
+	delete out;
+
+	return Common::kNoError;
+}
+
+Common::Error HDBGame::loadGameState(int slot) {
+	Common::InSaveFile *in;
+
+	Common::String saveFileName = Common::String::format("%s.%03d", _targetName.c_str(), slot);
+	if (!(in = _saveFileMan->openForLoading(saveFileName))) {
+		warning("missing savegame file %s", saveFileName.c_str());
+		if (g_hdb->_map->isLoaded())
+			g_hdb->setGameState(GAME_PLAY);
+		return Common::kReadingFailed;
+	}
+
+	warning("STUB: Load MetaData");
+	Graphics::skipThumbnail(*in);
+
+	// Actual Save Data
+	loadGame(in);
+
+	delete in;
+
+	return Common::kNoError;
+}
+
+void HDBGame::saveGame(Common::OutSaveFile *out) {
+
+	// Save Map Name
+	out->write(_inMapName, 32);
+
+	// Save Map Object Data
+	_map->save(out);
+
+	// Save Window Object Data
+	_window->save(out);
+
+	// Save Gfx Object Data
+	_gfx->save(out);
+
+	// Save Sound Object Data
+	_sound->save(out);
+
+	// Save Game Object Data
+	save(out);
+
+	// Save AI Object Data
+
+	_ai->save(out);
+}
+
+void HDBGame::loadGame(Common::InSaveFile *in) {
+	// Load Map Name
+	in->read(_inMapName, 32);
+
+	g_hdb->_sound->stopMusic();
+	_timeSeconds = 0;
+	_timePlayed = 0;
+
+	// Load Map Object Data
+	_map->loadSaveFile(in);
+
+	// Load Window Object Data
+	_window->loadSaveFile(in);
+
+	// Load Gfx Object Data
+	_gfx->loadSaveFile(in);
+
+	// Load Sound Object Data
+	_sound->loadSaveFile(in);
+
+	// Load Game Object Data
+	loadSaveFile(in);
+
+	// Load AI Object Data
+
+	_ai->loadSaveFile(in);
+
+	_gfx->turnOffFade();
+}
+
+} // End of Namespace
\ No newline at end of file


Commit: d5a32a2b4e735e9156120cab521319fea2b5024b
    https://github.com/scummvm/scummvm/commit/d5a32a2b4e735e9156120cab521319fea2b5024b
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:15+02:00

Commit Message:
HDB: Add missing time code

Changed paths:
    engines/hdb/hdb.cpp
    engines/hdb/hdb.h


diff --git a/engines/hdb/hdb.cpp b/engines/hdb/hdb.cpp
index 376c3a7..8fb091c 100644
--- a/engines/hdb/hdb.cpp
+++ b/engines/hdb/hdb.cpp
@@ -60,6 +60,8 @@ HDBGame::HDBGame(OSystem *syst, const ADGameDescription *gameDesc) : Engine(syst
 	_lastMapname[0] = _lastLuaName[0] = 0;
 	_inMapName[0] = 0;
 
+	_timePlayed = _timeSlice = _prevTimeSlice = _timeSeconds = _tiempo = 0;
+
 	_monkeystone7 = STARS_MONKEYSTONE_7_FAKE;
 	_monkeystone14 = STARS_MONKEYSTONE_14_FAKE;
 	_monkeystone21 = STARS_MONKEYSTONE_21_FAKE;
@@ -250,6 +252,9 @@ bool HDBGame::startMap(const char *name) {
 }
 
 void HDBGame::paint() {
+
+	_tiempo = g_system->getMillis();
+
 	switch (_gameState) {
 	case GAME_TITLE:
 		debug(9, "STUB: MENU::DrawTitle required");
@@ -866,6 +871,9 @@ Common::Error HDBGame::run() {
 				saveGameState(_saveInfo.slot);
 				_saveInfo.active = false;
 			}
+
+			// calculate time spent ONLY in the game...
+			_timePlayed += g_system->getMillis() - _tiempo;
 		}
 
 		// Update Timer that's NOT used for in-game Timing
diff --git a/engines/hdb/hdb.h b/engines/hdb/hdb.h
index 260ca4a..2b41c7f 100644
--- a/engines/hdb/hdb.h
+++ b/engines/hdb/hdb.h
@@ -202,15 +202,15 @@ public:
 		_timePlayed = _timeSeconds = 0;
 	}
 
-	uint16 getTime() {
+	uint32 getTime() {
 		return _timePlayed / 1000;
 	}
 
-	uint16 getTimeSlice() {
+	uint32 getTimeSlice() {
 		return _timeSlice;
 	}
 
-	uint16 getTimeSliceDelta() {
+	uint32 getTimeSliceDelta() {
 		return _timeSlice - _prevTimeSlice;
 	}
 
@@ -244,6 +244,8 @@ private:
 	uint32 _timeSlice, _prevTimeSlice;
 	uint32 _timeSeconds;
 
+	uint32 _tiempo;
+
 	Console *_console;
 
 	// Game Variables


Commit: 00b53b48a93005cde65860f9786f0fa2de96b33b
    https://github.com/scummvm/scummvm/commit/00b53b48a93005cde65860f9786f0fa2de96b33b
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:15+02:00

Commit Message:
HDB: Add stubbed functions

Changed paths:
    engines/hdb/menu.cpp
    engines/hdb/menu.h
    engines/hdb/sound.cpp
    engines/hdb/sound.h


diff --git a/engines/hdb/menu.cpp b/engines/hdb/menu.cpp
index f0d42e5..47253ea 100644
--- a/engines/hdb/menu.cpp
+++ b/engines/hdb/menu.cpp
@@ -76,6 +76,14 @@ void Menu::startTitle() {
 
 }
 
+void Menu::startMenu() {
+	debug(9, "STUB: Start Menu");
+}
+
+void Menu::freeMenu() {
+	debug(9, "STUB: Free Menu");
+}
+
 void Menu::fillSavegameSlots() {
 	warning("STUB: PMenu::fillSavegameSlots()");
 }
diff --git a/engines/hdb/menu.h b/engines/hdb/menu.h
index 3e49051..834928a 100644
--- a/engines/hdb/menu.h
+++ b/engines/hdb/menu.h
@@ -130,6 +130,8 @@ public:
 	bool init();
 
 	void startTitle();
+	void startMenu();
+	void freeMenu();
 
 	void fillSavegameSlots();
 
diff --git a/engines/hdb/sound.cpp b/engines/hdb/sound.cpp
index d14ec50..ad5c7b5 100644
--- a/engines/hdb/sound.cpp
+++ b/engines/hdb/sound.cpp
@@ -37,6 +37,10 @@ void Sound::loadSaveFile(Common::InSaveFile *in) {
 	warning("STUB: Sound::loadSaveFile()");
 }
 
+void Sound::clearPersistent() {
+	warning("STUB: Sound::clearPersistent()");
+}
+
 bool Sound::playSound(int index) {
 	debug(9, "STUB: Play Sound");
 	return true;
diff --git a/engines/hdb/sound.h b/engines/hdb/sound.h
index 176d093..9941dbe 100644
--- a/engines/hdb/sound.h
+++ b/engines/hdb/sound.h
@@ -1390,6 +1390,7 @@ public:
 	bool init();
 	void save(Common::OutSaveFile *out);
 	void loadSaveFile(Common::InSaveFile *in);
+	void clearPersistent();
 	int getMusicVolume() {
 		debug(9, "STUB: Add Music System Variables");
 		return 1;


Commit: b503e2ba711476982af2ba455505b17c0bb236c9
    https://github.com/scummvm/scummvm/commit/b503e2ba711476982af2ba455505b17c0bb236c9
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:16+02:00

Commit Message:
HDB: Add missing code in changeGameState()

Changed paths:
    engines/hdb/hdb.cpp


diff --git a/engines/hdb/hdb.cpp b/engines/hdb/hdb.cpp
index 8fb091c..ec2aba4 100644
--- a/engines/hdb/hdb.cpp
+++ b/engines/hdb/hdb.cpp
@@ -162,12 +162,22 @@ void HDBGame::changeGameState() {
 
 	switch (_gameState) {
 	case GAME_TITLE:
+		_menu->startMenu();
 		_gameState = GAME_MENU;
 		break;
 	case GAME_MENU:
+		_menu->freeMenu();
+		_sound->stopMusic();
+		_sound->clearPersistent();
+		_ai->clearPersistent();
+		_timePlayed = 0;
+		_timeSeconds = 0;
+		if (!startMap("CINE_INTRO"))
+			error("Can't load CINE_INTRO");
 		_gameState = GAME_PLAY;
 		break;
 	case GAME_PLAY:
+		_menu->startMenu();
 		_gameState = GAME_MENU;
 		break;
 	case GAME_LOADING:


Commit: 9b43fbfa9fdfa6483f1ba1574689f49525d7ddc9
    https://github.com/scummvm/scummvm/commit/9b43fbfa9fdfa6483f1ba1574689f49525d7ddc9
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:16+02:00

Commit Message:
HDB: Save/Load _timePlayed

Changed paths:
    engines/hdb/saveload.cpp


diff --git a/engines/hdb/saveload.cpp b/engines/hdb/saveload.cpp
index 1ae78fe..394b804 100644
--- a/engines/hdb/saveload.cpp
+++ b/engines/hdb/saveload.cpp
@@ -36,7 +36,6 @@ Common::Error HDBGame::saveGameState(int slot) {
 	if (!(out = _saveFileMan->openForSaving(saveFileName)))
 		error("Unable to open save file");
 
-	warning("STUB: Save MetaData");
 	Graphics::saveThumbnail(*out);
 
 	// Actual Save Data
@@ -63,7 +62,6 @@ Common::Error HDBGame::loadGameState(int slot) {
 		return Common::kReadingFailed;
 	}
 
-	warning("STUB: Load MetaData");
 	Graphics::skipThumbnail(*in);
 
 	// Actual Save Data
@@ -76,7 +74,8 @@ Common::Error HDBGame::loadGameState(int slot) {
 
 void HDBGame::saveGame(Common::OutSaveFile *out) {
 
-	// Save Map Name
+	// Save Map Name and Time
+	out->writeUint32LE(_timeSeconds + (_timePlayed / 1000));
 	out->write(_inMapName, 32);
 
 	// Save Map Object Data
@@ -100,12 +99,12 @@ void HDBGame::saveGame(Common::OutSaveFile *out) {
 }
 
 void HDBGame::loadGame(Common::InSaveFile *in) {
-	// Load Map Name
+	// Load Map Name and Time
+	_timeSeconds = in->readUint32LE();;
+	_timePlayed = 0;
 	in->read(_inMapName, 32);
 
 	g_hdb->_sound->stopMusic();
-	_timeSeconds = 0;
-	_timePlayed = 0;
 
 	// Load Map Object Data
 	_map->loadSaveFile(in);


Commit: b1cbf1aeab159235d90f832d7d59f1312533914f
    https://github.com/scummvm/scummvm/commit/b1cbf1aeab159235d90f832d7d59f1312533914f
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:16+02:00

Commit Message:
HDB: Add subbed Menu functions

Changed paths:
    engines/hdb/menu.cpp
    engines/hdb/menu.h


diff --git a/engines/hdb/menu.cpp b/engines/hdb/menu.cpp
index 47253ea..995950d 100644
--- a/engines/hdb/menu.cpp
+++ b/engines/hdb/menu.cpp
@@ -66,6 +66,22 @@ bool Menu::init() {
 	return true;
 }
 
+void Menu::startMenu() {
+	debug(9, "STUB: Start Menu");
+}
+
+void Menu::changeToMenu() {
+	warning("STUB: Change To Menu");
+}
+
+void Menu::drawMenu() {
+	warning("STUB: Draw Menu");
+}
+
+void Menu::freeMenu() {
+	debug(9, "STUB: Free Menu");
+}
+
 void Menu::startTitle() {
 	// REMOVE: Putting this here since Menu hasn't been implemented yet.
 	// Defaults the game into Action Mode
@@ -76,12 +92,8 @@ void Menu::startTitle() {
 
 }
 
-void Menu::startMenu() {
-	debug(9, "STUB: Start Menu");
-}
-
-void Menu::freeMenu() {
-	debug(9, "STUB: Free Menu");
+void Menu::drawTitle() {
+	warning("STUB: Draw Title");
 }
 
 void Menu::fillSavegameSlots() {
diff --git a/engines/hdb/menu.h b/engines/hdb/menu.h
index 834928a..4adfa2c 100644
--- a/engines/hdb/menu.h
+++ b/engines/hdb/menu.h
@@ -129,9 +129,12 @@ public:
 
 	bool init();
 
-	void startTitle();
 	void startMenu();
+	void changeToMenu();	// Changing from Intro to Menu
+	void drawMenu();
 	void freeMenu();
+	void startTitle();
+	void drawTitle();
 
 	void fillSavegameSlots();
 


Commit: 6e0e4411a18323b8cf60f964f688b41c94e89652
    https://github.com/scummvm/scummvm/commit/6e0e4411a18323b8cf60f964f688b41c94e89652
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:16+02:00

Commit Message:
HDB: Removed useless warning

Changed paths:
    engines/hdb/ai-funcs.cpp


diff --git a/engines/hdb/ai-funcs.cpp b/engines/hdb/ai-funcs.cpp
index 28681df..11b504a 100644
--- a/engines/hdb/ai-funcs.cpp
+++ b/engines/hdb/ai-funcs.cpp
@@ -404,7 +404,6 @@ bool AI::cacheEntGfx(AIEntity *e, bool init) {
 							_clubRightFrames++;
 							break;
 						default:
-							warning("AI-FUNCS: cacheEntGfx: Unintended State");
 							break;
 						}
 					}


Commit: d12d3ee64754600f96fb73090975ab9cea0621fb
    https://github.com/scummvm/scummvm/commit/d12d3ee64754600f96fb73090975ab9cea0621fb
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:16+02:00

Commit Message:
HDB: Proper prototype for saveGameState()

Changed paths:
    engines/hdb/hdb.cpp
    engines/hdb/hdb.h
    engines/hdb/saveload.cpp


diff --git a/engines/hdb/hdb.cpp b/engines/hdb/hdb.cpp
index ec2aba4..1f45a40 100644
--- a/engines/hdb/hdb.cpp
+++ b/engines/hdb/hdb.cpp
@@ -256,7 +256,7 @@ bool HDBGame::startMap(const char *name) {
 	//
 	if (!scumm_strnicmp(name, "map", 3) && scumm_stricmp(name, "map30")) {
 		_menu->fillSavegameSlots();
-		saveGameState(0);          // we ignore the slot parameter in everything else since we just keep saving...
+		saveGameState(0, Common::String::format("Autosave %s", name)); // we ignore the slot parameter in everything else since we just keep saving...
 	}
 	return true;
 }
@@ -878,7 +878,7 @@ Common::Error HDBGame::run() {
 				_sound->playSound(SND_VORTEX_SAVE);
 				_ai->stopEntity(e);
 				_menu->fillSavegameSlots();
-				saveGameState(_saveInfo.slot);
+				saveGameState(_saveInfo.slot, "FIXME"); // Add here date/level name // TODO
 				_saveInfo.active = false;
 			}
 
diff --git a/engines/hdb/hdb.h b/engines/hdb/hdb.h
index 2b41c7f..f09b81d 100644
--- a/engines/hdb/hdb.h
+++ b/engines/hdb/hdb.h
@@ -157,7 +157,7 @@ public:
 		_changeLevel = true;
 	}
 
-	Common::Error saveGameState(int slot);
+	Common::Error saveGameState(int slot, const Common::String &desc);
 	Common::Error loadGameState(int slot);
 	void saveGame(Common::OutSaveFile *out);
 	void loadGame(Common::InSaveFile *in);
diff --git a/engines/hdb/saveload.cpp b/engines/hdb/saveload.cpp
index 394b804..5f977fe 100644
--- a/engines/hdb/saveload.cpp
+++ b/engines/hdb/saveload.cpp
@@ -24,7 +24,7 @@
 
 namespace HDB {
 
-Common::Error HDBGame::saveGameState(int slot) {
+Common::Error HDBGame::saveGameState(int slot, const Common::String &desc) {
 
 	// If no map is loaded, don't try to save
 	if (!g_hdb->_map->isLoaded())
@@ -128,4 +128,4 @@ void HDBGame::loadGame(Common::InSaveFile *in) {
 	_gfx->turnOffFade();
 }
 
-} // End of Namespace
\ No newline at end of file
+} // End of Namespace


Commit: c71426e2f88b5c8fedd4c0e26557d868a88a650f
    https://github.com/scummvm/scummvm/commit/c71426e2f88b5c8fedd4c0e26557d868a88a650f
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:16+02:00

Commit Message:
HDB: Fix warnings

Changed paths:
    engines/hdb/ai-bots.cpp
    engines/hdb/ai-init.cpp


diff --git a/engines/hdb/ai-bots.cpp b/engines/hdb/ai-bots.cpp
index ec1cc6b..1541477 100644
--- a/engines/hdb/ai-bots.cpp
+++ b/engines/hdb/ai-bots.cpp
@@ -2058,6 +2058,9 @@ void aiFatFrogAction(AIEntity *e) {
 			e->animFrame++;
 		}
 		break;
+	default:
+		// no op
+		break;
 	}
 }
 
diff --git a/engines/hdb/ai-init.cpp b/engines/hdb/ai-init.cpp
index b76e55e..7fd3551 100644
--- a/engines/hdb/ai-init.cpp
+++ b/engines/hdb/ai-init.cpp
@@ -1729,8 +1729,8 @@ void AI::loadSaveFile(Common::InSaveFile *in) {
 
 	// Cache Gfx for Panic Zone, if needed
 	for (i = 0; i < _numTeleporters; i++)
-		if ((_teleporters[i].anim1 == 2) ||
-			(_teleporters[i].anim2 == 2) &&
+		if (((_teleporters[i].anim1 == 2) ||
+			 (_teleporters[i].anim2 == 2)) &&
 			!g_hdb->_window->_pzInfo.gfxPanic) {
 			g_hdb->_window->loadPanicZoneGfx();
 			break;


Commit: 8403960c994caf3cbbab58a3f214e40d498e81d5
    https://github.com/scummvm/scummvm/commit/8403960c994caf3cbbab58a3f214e40d498e81d5
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:16+02:00

Commit Message:
HDB: Added more code for loading save states from the command line

Changed paths:
    engines/hdb/detection.cpp
    engines/hdb/hdb.cpp
    engines/hdb/saveload.cpp


diff --git a/engines/hdb/detection.cpp b/engines/hdb/detection.cpp
index 5169450..a63b85f 100644
--- a/engines/hdb/detection.cpp
+++ b/engines/hdb/detection.cpp
@@ -107,13 +107,17 @@ public:
 	}
 
 	virtual bool hasFeature(MetaEngineFeature f) const;
+	virtual int getMaximumSaveSlot() const;
 	virtual bool createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const;
 };
 
 bool HDBMetaEngine::hasFeature(MetaEngineFeature f) const {
-	return false;
+	return
+		(f == kSupportsLoadingDuringStartup);
 }
 
+int HDBMetaEngine::getMaximumSaveSlot() const { return 9; }
+
 bool HDBMetaEngine::createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const {
 	if (desc) {
 		*engine = new HDB::HDBGame(syst, desc);
diff --git a/engines/hdb/hdb.cpp b/engines/hdb/hdb.cpp
index 1f45a40..462cb81 100644
--- a/engines/hdb/hdb.cpp
+++ b/engines/hdb/hdb.cpp
@@ -776,7 +776,11 @@ Common::Error HDBGame::run() {
 
 		startMap(mapname);
 	} else {
-		startMap("MAP00");
+		if (ConfMan.hasKey("save_slot")) {
+			loadGameState(ConfMan.getInt("save_slot"));
+		} else {
+			startMap("MAP00");
+		}
 	}
 
 	//_window->openDialog("Sgt. Filibuster", 0, "You address me as 'sarge' or 'sergeant' or get your snappin' teeth kicked in! Got me?", 0, NULL);
diff --git a/engines/hdb/saveload.cpp b/engines/hdb/saveload.cpp
index 5f977fe..b8d2252 100644
--- a/engines/hdb/saveload.cpp
+++ b/engines/hdb/saveload.cpp
@@ -67,6 +67,11 @@ Common::Error HDBGame::loadGameState(int slot) {
 	// Actual Save Data
 	loadGame(in);
 
+	_lua->loadLua(_currentLuaName); // load the Lua code FIRST! (if no file, it's ok)
+
+	saveFileName = Common::String::format("%s.l.%03d", _targetName.c_str(), slot);
+	_lua->loadSaveFile(in, saveFileName.c_str());
+
 	delete in;
 
 	return Common::kNoError;


Commit: 2b46fcf06d1635332a48c009c21953d053be69a6
    https://github.com/scummvm/scummvm/commit/2b46fcf06d1635332a48c009c21953d053be69a6
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:16+02:00

Commit Message:
HDB: Properly process non-existent save loading

Changed paths:
    engines/hdb/hdb.cpp


diff --git a/engines/hdb/hdb.cpp b/engines/hdb/hdb.cpp
index 462cb81..fa54390 100644
--- a/engines/hdb/hdb.cpp
+++ b/engines/hdb/hdb.cpp
@@ -776,11 +776,8 @@ Common::Error HDBGame::run() {
 
 		startMap(mapname);
 	} else {
-		if (ConfMan.hasKey("save_slot")) {
-			loadGameState(ConfMan.getInt("save_slot"));
-		} else {
+		if (!ConfMan.hasKey("save_slot") || (loadGameState(ConfMan.getInt("save_slot")).getCode() != Common::kNoError))
 			startMap("MAP00");
-		}
 	}
 
 	//_window->openDialog("Sgt. Filibuster", 0, "You address me as 'sarge' or 'sergeant' or get your snappin' teeth kicked in! Got me?", 0, NULL);


Commit: 168921d7d74788e12e2ebb99ceccd9dba09c61e2
    https://github.com/scummvm/scummvm/commit/168921d7d74788e12e2ebb99ceccd9dba09c61e2
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:16+02:00

Commit Message:
HDB: Added debug output to save/load code

Changed paths:
    engines/hdb/saveload.cpp


diff --git a/engines/hdb/saveload.cpp b/engines/hdb/saveload.cpp
index b8d2252..d0fb1d4 100644
--- a/engines/hdb/saveload.cpp
+++ b/engines/hdb/saveload.cpp
@@ -78,32 +78,42 @@ Common::Error HDBGame::loadGameState(int slot) {
 }
 
 void HDBGame::saveGame(Common::OutSaveFile *out) {
+	debug(1, "HDBGame::saveGame: start at %u", out->pos());
 
 	// Save Map Name and Time
 	out->writeUint32LE(_timeSeconds + (_timePlayed / 1000));
 	out->write(_inMapName, 32);
 
+	debug(1, "HDBGame::saveGame: map at %u", out->pos());
 	// Save Map Object Data
 	_map->save(out);
 
 	// Save Window Object Data
+	debug(1, "HDBGame::saveGame: window at %u", out->pos());
 	_window->save(out);
 
 	// Save Gfx Object Data
+	debug(1, "HDBGame::saveGame: gfx at %u", out->pos());
 	_gfx->save(out);
 
 	// Save Sound Object Data
+	debug(1, "HDBGame::saveGame: sound at %u", out->pos());
 	_sound->save(out);
 
 	// Save Game Object Data
+	debug(1, "HDBGame::saveGame: game object at %u", out->pos());
 	save(out);
 
 	// Save AI Object Data
-
+	debug(1, "HDBGame::saveGame: ai at %u", out->pos());
 	_ai->save(out);
+
+	debug(1, "HDBGame::saveGame: end at %u", out->pos());
 }
 
 void HDBGame::loadGame(Common::InSaveFile *in) {
+	debug(1, "HDBGame::loadGame: start at %u", in->pos());
+
 	// Load Map Name and Time
 	_timeSeconds = in->readUint32LE();;
 	_timePlayed = 0;
@@ -112,24 +122,31 @@ void HDBGame::loadGame(Common::InSaveFile *in) {
 	g_hdb->_sound->stopMusic();
 
 	// Load Map Object Data
+	debug(1, "HDBGame::loadGame: map at %u", in->pos());
 	_map->loadSaveFile(in);
 
 	// Load Window Object Data
+	debug(1, "HDBGame::loadGame: window at %u", in->pos());
 	_window->loadSaveFile(in);
 
 	// Load Gfx Object Data
+	debug(1, "HDBGame::loadGame: gfx at %u", in->pos());
 	_gfx->loadSaveFile(in);
 
 	// Load Sound Object Data
+	debug(1, "HDBGame::loadGame: sound at %u", in->pos());
 	_sound->loadSaveFile(in);
 
 	// Load Game Object Data
+	debug(1, "HDBGame::loadGame: game object at %u", in->pos());
 	loadSaveFile(in);
 
 	// Load AI Object Data
-
+	debug(1, "HDBGame::loadGame: ai at %u", in->pos());
 	_ai->loadSaveFile(in);
 
+	debug(1, "HDBGame::loadGame: end at %u", in->pos());
+
 	_gfx->turnOffFade();
 }
 


Commit: f544c83def7196afdbd696bc550ac2a2d6f0d2fe
    https://github.com/scummvm/scummvm/commit/f544c83def7196afdbd696bc550ac2a2d6f0d2fe
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:16+02:00

Commit Message:
HDB: Allocate memory on loading

Changed paths:
    engines/hdb/map.cpp


diff --git a/engines/hdb/map.cpp b/engines/hdb/map.cpp
index d725dc7..b285330 100644
--- a/engines/hdb/map.cpp
+++ b/engines/hdb/map.cpp
@@ -167,14 +167,23 @@ void Map::loadSaveFile(Common::InSaveFile *in) {
 
 	// load map data
 
+	_background = new int16[_width * _height];
 	for (i = 0; i < _width * _height; i++)
 		_background[i] = in->readSint32LE();
+
+	_foreground = new int16[_width * _height];
 	for (i = 0; i < _width * _height; i++)
 		_foreground[i] = in->readSint32LE();
+
+	_mapExplosions = new byte[_width * _height];
 	for (i = 0; i < _width * _height; i++)
 		_mapExplosions[i] = in->readByte();
+
+	_mapExpBarrels = new byte[_width * _height];
 	for (i = 0; i < _width * _height; i++)
 		_mapExpBarrels[i] = in->readByte();
+
+	_mapLaserBeams = new byte[_width * _height];
 	for (i = 0; i < _width * _height; i++)
 		_mapLaserBeams[i] = in->readByte();
 }


Commit: 458646981f5b2accbf7d741f43a0f21d8c0a6c1e
    https://github.com/scummvm/scummvm/commit/458646981f5b2accbf7d741f43a0f21d8c0a6c1e
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:16+02:00

Commit Message:
HDB: Fix Window::loadSaveFile()

Changed paths:
    engines/hdb/window.cpp


diff --git a/engines/hdb/window.cpp b/engines/hdb/window.cpp
index 3b0d7e8..6e21555 100644
--- a/engines/hdb/window.cpp
+++ b/engines/hdb/window.cpp
@@ -226,7 +226,25 @@ void Window::loadSaveFile(Common::InSaveFile *in) {
 	// Load out various Window and Game State Info
 
 	// Load Panic Zone Info
-	in->read(&_pzInfo, sizeof(_pzInfo));
+	for (i = 0; i < 10; i++) {
+		_pzInfo.gfxNumber[i] = NULL;
+		if (i < 2)
+			_pzInfo.gfxFace[i] = NULL;
+	}
+	_pzInfo.gfxPanic = _pzInfo.gfxZone = NULL;
+
+	_pzInfo.active = in->readByte();
+	_pzInfo.sequence = in->readSint32LE();
+	_pzInfo.timer = in->readSint32LE();
+	_pzInfo.x1 = in->readSint32LE();
+	_pzInfo.y1 = in->readSint32LE();
+	_pzInfo.x2 = in->readSint32LE();
+	_pzInfo.y2 = in->readSint32LE();
+	_pzInfo.xv = in->readSint32LE();
+	_pzInfo.yv = in->readSint32LE();
+	_pzInfo.numberTime = in->readSint32LE();
+	_pzInfo.numberTimeMaster = in->readSint32LE();
+	_pzInfo.numberValue = in->readSint32LE();
 
 	// Load Dialog Info
 	in->read(_dialogInfo.title, 64);


Commit: 42edeb4114279e16e699ba5f65f727acb3040529
    https://github.com/scummvm/scummvm/commit/42edeb4114279e16e699ba5f65f727acb3040529
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:16+02:00

Commit Message:
HDB: Fix AI::loadSaveFile()

Changed paths:
    engines/hdb/ai-init.cpp


diff --git a/engines/hdb/ai-init.cpp b/engines/hdb/ai-init.cpp
index 7fd3551..7b9a823 100644
--- a/engines/hdb/ai-init.cpp
+++ b/engines/hdb/ai-init.cpp
@@ -1780,12 +1780,17 @@ void AI::loadSaveFile(Common::InSaveFile *in) {
 	}
 
 	// Load ArrowPaths
-	_arrowPaths->resize(in->readUint32LE());
-	for (i = 0; (uint)i < _arrowPaths->size(); i++) {
-		_arrowPaths->operator[](i)->type = in->readUint16LE();
-		_arrowPaths->operator[](i)->dir = (AIDir)in->readSint32LE();
-		_arrowPaths->operator[](i)->tileX = in->readUint16LE();
-		_arrowPaths->operator[](i)->tileY = in->readUint16LE();
+
+	uint32 arrowPathSIze = in->readUint32LE();
+	for (i = 0; (uint)i < arrowPathSIze; i++) {
+		ArrowPath *arrowPath = new ArrowPath;
+
+		arrowPath->type = in->readUint16LE();
+		arrowPath->dir = (AIDir)in->readSint32LE();
+		arrowPath->tileX = in->readUint16LE();
+		arrowPath->tileY = in->readUint16LE();
+
+		_arrowPaths->push_back(arrowPath);
 	}
 
 	// Load HereT List
@@ -1797,15 +1802,19 @@ void AI::loadSaveFile(Common::InSaveFile *in) {
 	}
 
 	// Load Triggers
-	_triggerList->resize(in->readUint32LE());
-	for (i = 0; (uint)i < _triggerList->size(); i++) {
-		in->read(_triggerList->operator[](i)->id, 32);
-		_triggerList->operator[](i)->x = in->readUint16LE();
-		_triggerList->operator[](i)->y = in->readUint16LE();
-		_triggerList->operator[](i)->value1 = in->readUint16LE();
-		_triggerList->operator[](i)->value2 = in->readUint16LE();
-		in->read(_triggerList->operator[](i)->luaFuncInit, 32);
-		in->read(_triggerList->operator[](i)->luaFuncUse, 32);
+	uint32 tsize = in->readUint32LE();
+	for (i = 0; (uint)i < tsize; i++) {
+		Trigger *t = new Trigger;
+
+		in->read(t->id, 32);
+		t->x = in->readUint16LE();
+		t->y = in->readUint16LE();
+		t->value1 = in->readUint16LE();
+		t->value2 = in->readUint16LE();
+		in->read(t->luaFuncInit, 32);
+		in->read(t->luaFuncUse, 32);
+
+		_triggerList->push_back(t);
 	}
 
 	AIEntity *e;
@@ -1814,8 +1823,8 @@ void AI::loadSaveFile(Common::InSaveFile *in) {
 	EntFuncPtr draw;
 
 	// Load Floats
-	_floats->resize(in->readUint32LE());
-	for (i = 0; (uint)i < _floats->size(); i++) {
+	uint32 fsize = in->readUint32LE();
+	for (i = 0; (uint)i < fsize; i++) {
 		e = new AIEntity;
 		action = init = init2 = use = NULL;
 		draw = NULL;
@@ -1890,8 +1899,8 @@ void AI::loadSaveFile(Common::InSaveFile *in) {
 	}
 
 	// Load Ents
-	_ents->resize(in->readUint32LE());
-	for (i = 0; (uint)i < _ents->size(); i++) {
+	uint32 esize = in->readUint32LE();
+	for (i = 0; (uint)i < esize; i++) {
 		e = new AIEntity;
 		action = init = init2 = use = NULL;
 		draw = NULL;


Commit: 6fe1d65ca71e787cbe61c2713082679b1049d8fd
    https://github.com/scummvm/scummvm/commit/6fe1d65ca71e787cbe61c2713082679b1049d8fd
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:16+02:00

Commit Message:
HDB: Added initial version for Lua dofile()

Changed paths:
    engines/hdb/lua-script.cpp


diff --git a/engines/hdb/lua-script.cpp b/engines/hdb/lua-script.cpp
index 2fe5520..ab8d7ef 100644
--- a/engines/hdb/lua-script.cpp
+++ b/engines/hdb/lua-script.cpp
@@ -1215,6 +1215,8 @@ static int openFile(lua_State *L) {
 		if (!outLua)
 			error("Cannot open %s", fName);
 		lua_pushlightuserdata(L, outLua);
+	} else {
+		error("LUA openFile: Unsupported mode '%s'", mode);
 	}
 
 	return 1;
@@ -1229,7 +1231,6 @@ static int write(lua_State *L) {
 	lua_pop(L, 2);
 
 	out->write(data, strlen(data));
-	debugN(3, "%s", data);
 
 	return 0;
 }
@@ -1248,6 +1249,23 @@ static int closeFile(lua_State *L) {
 	return 0;
 }
 
+static int dofile(lua_State *L) {
+	const char *fName = lua_tostring(L, 1);
+
+	g_hdb->_lua->checkParameters("dofile", 1);
+
+	lua_pop(L, 1);
+
+	Common::InSaveFile *in = g_system->getSavefileManager()->openForLoading(fName);
+
+	if (!in)
+		error("Lua dofile: cannot open file '%s'", fName);
+
+	delete in;
+
+	return 0;
+}
+
 /*
 	Lua Initialization Code
 */
@@ -1549,8 +1567,9 @@ struct FuncInit {
 	{  "Cine_PlayVoice",		cinePlayVoice		},
 
 	{	"openfile",				openFile,			},
-	{	"write",				write,			},
+	{	"write",				write,				},
 	{	"closefile",			closeFile,			},
+	{	"dofile",				dofile,				},
 	{ NULL, NULL }
 };
 


Commit: d0b5e0fbc75cdb929dd3c666d4a64c8a83f3ecc6
    https://github.com/scummvm/scummvm/commit/d0b5e0fbc75cdb929dd3c666d4a64c8a83f3ecc6
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:16+02:00

Commit Message:
HDB: Remove non-functioning code

Changed paths:
    engines/hdb/lua-script.cpp


diff --git a/engines/hdb/lua-script.cpp b/engines/hdb/lua-script.cpp
index ab8d7ef..7a33355 100644
--- a/engines/hdb/lua-script.cpp
+++ b/engines/hdb/lua-script.cpp
@@ -1206,11 +1206,6 @@ static int openFile(lua_State *L) {
 	lua_pop(L, 2);
 
 	if (!scumm_stricmp(mode, "wt")) {
-		// Delete Lua Save File
-		Common::InSaveFile *inLua = g_system->getSavefileManager()->openForLoading(fName);
-		if (inLua)
-			delete inLua;
-
 		Common::OutSaveFile *outLua = g_system->getSavefileManager()->openForSaving(fName);
 		if (!outLua)
 			error("Cannot open %s", fName);


Commit: 38bdb36b239fbeb7e6e38adeacd83c8cfb7caa9b
    https://github.com/scummvm/scummvm/commit/38bdb36b239fbeb7e6e38adeacd83c8cfb7caa9b
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:16+02:00

Commit Message:
HDB: Finish implementation of Lua dofile()

Changed paths:
    engines/hdb/lua-script.cpp


diff --git a/engines/hdb/lua-script.cpp b/engines/hdb/lua-script.cpp
index 7a33355..b563de3 100644
--- a/engines/hdb/lua-script.cpp
+++ b/engines/hdb/lua-script.cpp
@@ -1256,8 +1256,21 @@ static int dofile(lua_State *L) {
 	if (!in)
 		error("Lua dofile: cannot open file '%s'", fName);
 
+	int length = in->size();
+	char *chunk = new char[length + 1];
+	in->read((void *)chunk, length);
+
+	chunk[length] = '\0'; // be on the safe side
+
+	Common::String chunkString(chunk);
+	delete[] chunk;
+
 	delete in;
 
+	if (!g_hdb->_lua->executeChunk(chunkString, fName)) {
+		return 0;
+	}
+
 	return 0;
 }
 


Commit: a8b4749c7eb8ab9471fecc7ab0e7aa20470c1e30
    https://github.com/scummvm/scummvm/commit/a8b4749c7eb8ab9471fecc7ab0e7aa20470c1e30
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:16+02:00

Commit Message:
HDB: Add Input::assignKey(), LuaScript::isValid()

Changed paths:
    engines/hdb/input.h
    engines/hdb/lua-script.h


diff --git a/engines/hdb/input.h b/engines/hdb/input.h
index d12f333..ffd6c0d 100644
--- a/engines/hdb/input.h
+++ b/engines/hdb/input.h
@@ -61,6 +61,16 @@ public:
 		return _mouseY;
 	}
 
+	void assignKey(int whichKey, Common::KeyCode keyPressed) {
+		switch (whichKey) {
+		case 0: _keyUp = keyPressed; return;
+		case 1: _keyDown = keyPressed; return;
+		case 2: _keyLeft = keyPressed; return;
+		case 3: _keyRight = keyPressed; return;
+		case 4: _keyUse = keyPressed; return;
+		}
+	}
+
 private:
 
 	uint16 _buttons;	// Flags for buttons
diff --git a/engines/hdb/lua-script.h b/engines/hdb/lua-script.h
index ff061af..5124ac2 100644
--- a/engines/hdb/lua-script.h
+++ b/engines/hdb/lua-script.h
@@ -80,6 +80,9 @@ public:
 	const char *getStringOffStack();
 
 	void setLuaGlobalValue(const char *name, int value);
+	bool isValid() {
+		return _systemInit;
+	}
 
 private:
 	lua_State *_state;


Commit: 9d9a1b6c0f1dfd16cf7a9f6d3d94d45ecf10cf98
    https://github.com/scummvm/scummvm/commit/9d9a1b6c0f1dfd16cf7a9f6d3d94d45ecf10cf98
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:16+02:00

Commit Message:
HDB: Add readConfig(), writeConfig() and Cheating

Changed paths:
    engines/hdb/hdb.cpp
    engines/hdb/hdb.h
    engines/hdb/menu.cpp
    engines/hdb/menu.h


diff --git a/engines/hdb/hdb.cpp b/engines/hdb/hdb.cpp
index fa54390..51a8a1d 100644
--- a/engines/hdb/hdb.cpp
+++ b/engines/hdb/hdb.cpp
@@ -56,6 +56,8 @@ HDBGame::HDBGame(OSystem *syst, const ADGameDescription *gameDesc) : Engine(syst
 	_window = new Window;
 	_rnd = new Common::RandomSource("hdb");
 
+	_cheating = false;
+
 	_currentMapname[0] = _currentLuaName[0] = 0;
 	_lastMapname[0] = _lastLuaName[0] = 0;
 	_inMapName[0] = 0;
@@ -233,6 +235,8 @@ bool HDBGame::restartMap() {
 	_ai->getPlayerXY(&x, &y);
 	_map->centerMapXY(x + 16, y + 16);
 
+	warning("STUB: Cheating - Lua Validation");
+
 	return true;
 }
 
diff --git a/engines/hdb/hdb.h b/engines/hdb/hdb.h
index f09b81d..a690be2 100644
--- a/engines/hdb/hdb.h
+++ b/engines/hdb/hdb.h
@@ -31,6 +31,7 @@
 #include "common/str.h"
 #include "common/random.h"
 #include "common/savefile.h"
+#include "common/config-manager.h"
 #include "graphics/surface.h"
 #include "graphics/thumbnail.h"
 
@@ -235,6 +236,13 @@ public:
 	void setStarsMonkeystone14(int32 value) { _monkeystone14 = value; }
 	void setStarsMonkeystone21(int32 value) { _monkeystone21 = value; }
 
+	void setCheatingOn() {
+		_cheating = true;
+	}
+	bool getCheatingOn() {
+		return _cheating;
+	}
+
 	bool _gameShutdown;
 	Graphics::PixelFormat _format;
 
@@ -254,6 +262,7 @@ private:
 	GameState _gameState;
 	int _actionMode; // 0 or 1
 	int _pauseFlag;
+	bool _cheating;
 
 	char _currentMapname[64];
 	char _lastMapname[64];
@@ -275,7 +284,6 @@ private:
 		int  slot;
 	} _saveInfo, _loadInfo;
 
-
 };
 
 extern HDBGame *g_hdb;
diff --git a/engines/hdb/menu.cpp b/engines/hdb/menu.cpp
index 995950d..a19e9b3 100644
--- a/engines/hdb/menu.cpp
+++ b/engines/hdb/menu.cpp
@@ -66,6 +66,91 @@ bool Menu::init() {
 	return true;
 }
 
+void Menu::readConfig() {
+	warning("STUB: readConfig: Music Config not implemented");
+
+	if (ConfMan.hasKey(CONFIG_MSTONE7)) {
+		g_hdb->setStarsMonkeystone7(ConfMan.getInt(CONFIG_MSTONE7));
+	} else {
+		ConfMan.setInt(CONFIG_MSTONE7, STARS_MONKEYSTONE_7_FAKE);
+	}
+
+	if (ConfMan.hasKey(CONFIG_MSTONE14)) {
+		g_hdb->setStarsMonkeystone14(ConfMan.getInt(CONFIG_MSTONE14));
+	} else {
+		ConfMan.setInt(CONFIG_MSTONE14, STARS_MONKEYSTONE_14_FAKE);
+	}
+
+	if (ConfMan.hasKey(CONFIG_MSTONE21)) {
+		g_hdb->setStarsMonkeystone21(ConfMan.getInt(CONFIG_MSTONE21));
+	} else {
+		ConfMan.setInt(CONFIG_MSTONE21, STARS_MONKEYSTONE_21_FAKE);
+	}
+
+	if (ConfMan.hasKey(CONFIG_KEY_UP)) {
+		_keyAssignUp = (Common::KeyCode)ConfMan.getInt(CONFIG_KEY_UP);
+		g_hdb->_input->assignKey(0, _keyAssignUp);
+	} else {
+		ConfMan.setInt(CONFIG_KEY_UP, _keyAssignUp);
+	}
+
+	if (ConfMan.hasKey(CONFIG_KEY_DOWN)) {
+		_keyAssignDown = (Common::KeyCode)ConfMan.getInt(CONFIG_KEY_DOWN);
+		g_hdb->_input->assignKey(1, _keyAssignDown);
+	} else {
+		ConfMan.setInt(CONFIG_KEY_DOWN, _keyAssignDown);
+	}
+
+	if (ConfMan.hasKey(CONFIG_KEY_LEFT)) {
+		_keyAssignLeft = (Common::KeyCode)ConfMan.getInt(CONFIG_KEY_LEFT);
+		g_hdb->_input->assignKey(2, _keyAssignLeft);
+	} else {
+		ConfMan.setInt(CONFIG_KEY_LEFT, _keyAssignLeft);
+	}
+
+	if (ConfMan.hasKey(CONFIG_KEY_RIGHT)) {
+		_keyAssignRight = (Common::KeyCode)ConfMan.getInt(CONFIG_KEY_RIGHT);
+		g_hdb->_input->assignKey(3, _keyAssignRight);
+	} else {
+		ConfMan.setInt(CONFIG_KEY_RIGHT, _keyAssignRight);
+	}
+
+	if (ConfMan.hasKey(CONFIG_KEY_USE)) {
+		_keyAssignUse = (Common::KeyCode)ConfMan.getInt(CONFIG_KEY_USE);
+		g_hdb->_input->assignKey(4, _keyAssignUse);
+	} else {
+		ConfMan.setInt(CONFIG_KEY_USE, _keyAssignUse);
+	}
+
+	if (ConfMan.hasKey(CONFIG_CHEAT)) {
+		g_hdb->setCheatingOn();
+	}
+
+	ConfMan.flushToDisk();
+}
+
+void Menu::writeConfig() {
+	warning("STUB: writeConfig: Music Config not implemented");
+
+	int value;
+
+	value = g_hdb->getStarsMonkeystone7();
+	ConfMan.setInt(CONFIG_MSTONE7, value);
+	value = g_hdb->getStarsMonkeystone14();
+	ConfMan.setInt(CONFIG_MSTONE14, value);
+	value = g_hdb->getStarsMonkeystone21();
+	ConfMan.setInt(CONFIG_MSTONE21, value);
+
+	ConfMan.setInt(CONFIG_KEY_UP, _keyAssignUp);
+	ConfMan.setInt(CONFIG_KEY_DOWN, _keyAssignDown);
+	ConfMan.setInt(CONFIG_KEY_LEFT, _keyAssignLeft);
+	ConfMan.setInt(CONFIG_KEY_RIGHT, _keyAssignRight);
+	ConfMan.setInt(CONFIG_KEY_USE, _keyAssignUse);
+
+	if (g_hdb->getCheatingOn())
+		ConfMan.set(CONFIG_CHEAT, "1");
+}
+
 void Menu::startMenu() {
 	debug(9, "STUB: Start Menu");
 }
diff --git a/engines/hdb/menu.h b/engines/hdb/menu.h
index 4adfa2c..7dcf9fc 100644
--- a/engines/hdb/menu.h
+++ b/engines/hdb/menu.h
@@ -32,7 +32,30 @@ namespace HDB {
 #define STARS_MONKEYSTONE_21		0x77ace3	// <same> for the Monkeystone #21
 #define STARS_MONKEYSTONE_21_FAKE	0x3548fe	// fake value that means it hasn't been unlocked
 
+#define	CONFIG_MUSICVOL		"music_volume"
+#define	CONFIG_SOUNDVOL		"sound_volume"
+#define	CONFIG_MSTONE7		"hdb_memory_heap"
+#define	CONFIG_MSTONE14		"lua_stack_offset"
+#define	CONFIG_MSTONE21		"fmod_mix_timer"
+#define	CONFIG_SOUNDCACHE	"sound_cache_max"
+#define	CONFIG_GFXCACHE		"gfx_cache_max"
+#define	CONFIG_CHEAT		"hypercheat"
+
+#define	CONFIG_KEY_UP		"keyup"
+#define	CONFIG_KEY_DOWN		"keydown"
+#define	CONFIG_KEY_LEFT		"keyleft"
+#define	CONFIG_KEY_RIGHT	"keyright"
+#define	CONFIG_KEY_USE		"keyuse"
+#define	CONFIG_VOICES		"voices"
+
 enum {
+	kStarRedX = 70,
+	kStarRedY = 20,
+	kStarGreenX = 70,
+	kStarGreenY = 100,
+	kStarBlueX = 70,
+	kStarBlueY = 180,
+
 	kMenuX = 48 * 8,
 	kMenuY = 80,
 
@@ -129,6 +152,9 @@ public:
 
 	bool init();
 
+	void readConfig();
+	void writeConfig();
+
 	void startMenu();
 	void changeToMenu();	// Changing from Intro to Menu
 	void drawMenu();


Commit: 538ab04493f91b120b7be300af2925d044683b80
    https://github.com/scummvm/scummvm/commit/538ab04493f91b120b7be300af2925d044683b80
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:16+02:00

Commit Message:
HDB: Added missing calls to loadGameState()

Changed paths:
    engines/hdb/saveload.cpp


diff --git a/engines/hdb/saveload.cpp b/engines/hdb/saveload.cpp
index d0fb1d4..726374f 100644
--- a/engines/hdb/saveload.cpp
+++ b/engines/hdb/saveload.cpp
@@ -62,6 +62,8 @@ Common::Error HDBGame::loadGameState(int slot) {
 		return Common::kReadingFailed;
 	}
 
+	_window->closeAll();
+
 	Graphics::skipThumbnail(*in);
 
 	// Actual Save Data
@@ -74,6 +76,14 @@ Common::Error HDBGame::loadGameState(int slot) {
 
 	delete in;
 
+	// center the player on the screen
+	int x, y;
+	_ai->getPlayerXY(&x, &y);
+	_map->centerMapXY(x + 16, y + 16);
+
+	if (!_ai->cinematicsActive())
+		_gfx->turnOffFade();
+
 	return Common::kNoError;
 }
 


Commit: 6c0684cbbaa028cbeaf58cef68d2fcecdd900041
    https://github.com/scummvm/scummvm/commit/6c0684cbbaa028cbeaf58cef68d2fcecdd900041
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:16+02:00

Commit Message:
HDB: Added missing calls to Map::Map::loadSaveFile()

Changed paths:
    engines/hdb/map.cpp


diff --git a/engines/hdb/map.cpp b/engines/hdb/map.cpp
index b285330..fb84bc0 100644
--- a/engines/hdb/map.cpp
+++ b/engines/hdb/map.cpp
@@ -186,6 +186,10 @@ void Map::loadSaveFile(Common::InSaveFile *in) {
 	_mapLaserBeams = new byte[_width * _height];
 	for (i = 0; i < _width * _height; i++)
 		_mapLaserBeams[i] = in->readByte();
+
+	// load all the map's tiles (cache)
+	loadTiles();
+	_mapLoaded = true;
 }
 
 int Map::loadTiles() {


Commit: c00223a6e9b42ee46e6a94ba478a3a022e821248
    https://github.com/scummvm/scummvm/commit/c00223a6e9b42ee46e6a94ba478a3a022e821248
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:16+02:00

Commit Message:
HDB: Add stubbed songPlaying() and startMusic()

Changed paths:
    engines/hdb/sound.cpp
    engines/hdb/sound.h


diff --git a/engines/hdb/sound.cpp b/engines/hdb/sound.cpp
index ad5c7b5..75e3362 100644
--- a/engines/hdb/sound.cpp
+++ b/engines/hdb/sound.cpp
@@ -56,6 +56,16 @@ bool Sound::playVoice(int index, int actor) {
 	return true;
 }
 
+bool Sound::startMusic(SoundType song) {
+	warning("STUB: Start Music");
+	return true;
+}
+
+bool Sound::songPlaying(SoundType song) {
+	warning("STUB: Check if Song is playing");
+	return true;
+}
+
 bool Sound::stopChannel(int channel) {
 	debug(9, "STUB: Stop Channel");
 	return true;
diff --git a/engines/hdb/sound.h b/engines/hdb/sound.h
index 9941dbe..6574562 100644
--- a/engines/hdb/sound.h
+++ b/engines/hdb/sound.h
@@ -1399,6 +1399,8 @@ public:
 	bool playSound(int index);
 	bool playSoundEx(int index, int channel, bool loop);
 	bool playVoice(int index, int actor);
+	bool startMusic(SoundType song);
+	bool songPlaying(SoundType song);
 	bool stopChannel(int channel);
 	void stopMusic();
 


Commit: 0ae4cb1ea7907c7d558cb89ad101f762a0d64c8c
    https://github.com/scummvm/scummvm/commit/0ae4cb1ea7907c7d558cb89ad101f762a0d64c8c
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:16+02:00

Commit Message:
HDB: Shift HDB::save() and HDB::loadSaveFile...

...to saveload.cpp

Changed paths:
    engines/hdb/hdb.cpp
    engines/hdb/saveload.cpp


diff --git a/engines/hdb/hdb.cpp b/engines/hdb/hdb.cpp
index 51a8a1d..29869e2 100644
--- a/engines/hdb/hdb.cpp
+++ b/engines/hdb/hdb.cpp
@@ -131,26 +131,6 @@ bool HDBGame::init() {
 	return true;
 }
 
-void HDBGame::save(Common::OutSaveFile *out) {
-	out->write(_currentMapname, 64);
-	out->write(_lastMapname, 64);
-	out->write(_currentLuaName, 64);
-	out->writeSint32LE(_actionMode);
-	out->writeByte(_changeLevel);
-	out->write(_changeMapname, 64);
-	out->write(_inMapName, 32);
-}
-
-void HDBGame::loadSaveFile(Common::InSaveFile *in) {
-	in->read(_currentMapname, 64);
-	in->read(_lastMapname, 64);
-	in->read(_currentLuaName, 64);
-	_actionMode = in->readSint32LE();
-	_changeLevel = in->readByte();
-	in->read(_changeMapname, 64);
-	in->read(_inMapName, 32);
-}
-
 /*
 	Changes the current GameState to the next one.
 	Game State Transitions are deterministic: each state can
diff --git a/engines/hdb/saveload.cpp b/engines/hdb/saveload.cpp
index 726374f..1bf9ce3 100644
--- a/engines/hdb/saveload.cpp
+++ b/engines/hdb/saveload.cpp
@@ -160,4 +160,24 @@ void HDBGame::loadGame(Common::InSaveFile *in) {
 	_gfx->turnOffFade();
 }
 
+void HDBGame::save(Common::OutSaveFile *out) {
+	out->write(_currentMapname, 64);
+	out->write(_lastMapname, 64);
+	out->write(_currentLuaName, 64);
+	out->writeSint32LE(_actionMode);
+	out->writeByte(_changeLevel);
+	out->write(_changeMapname, 64);
+	out->write(_inMapName, 32);
+}
+
+void HDBGame::loadSaveFile(Common::InSaveFile *in) {
+	in->read(_currentMapname, 64);
+	in->read(_lastMapname, 64);
+	in->read(_currentLuaName, 64);
+	_actionMode = in->readSint32LE();
+	_changeLevel = in->readByte();
+	in->read(_changeMapname, 64);
+	in->read(_inMapName, 32);
+}
+
 } // End of Namespace


Commit: 4c20c8be129a2e720341802783109dec6a07c944
    https://github.com/scummvm/scummvm/commit/4c20c8be129a2e720341802783109dec6a07c944
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:16+02:00

Commit Message:
HDB: Add Sine and Cosine table

Changed paths:
    engines/hdb/gfx.cpp
    engines/hdb/gfx.h
    engines/hdb/hdb.h


diff --git a/engines/hdb/gfx.cpp b/engines/hdb/gfx.cpp
index 3303a5b..ddee59f 100644
--- a/engines/hdb/gfx.cpp
+++ b/engines/hdb/gfx.cpp
@@ -29,11 +29,15 @@ Gfx::Gfx() {
 	_gfxCache = new Common::Array<GfxCache *>;
 	_globalSurface.create(kScreenWidth, kScreenHeight, g_hdb->_format);
 	_pointerDisplayable = 1;
+	_sines = new Common::SineTable(360);
+	_cosines = new Common::CosineTable(360);
 	_systemInit = false;
 }
 
 Gfx::~Gfx() {
 	delete _gfxCache;
+	delete _sines;
+	delete _cosines;
 	_globalSurface.free();
 }
 
diff --git a/engines/hdb/gfx.h b/engines/hdb/gfx.h
index e49b0c5..d057cae 100644
--- a/engines/hdb/gfx.h
+++ b/engines/hdb/gfx.h
@@ -151,6 +151,15 @@ public:
 	void setCursor(int x, int y);
 	void getCursor(int *x, int *y);
 
+	// Trig Functions
+
+	double getSin(int index) {
+		return _sines->at(index);
+	}
+	double getCos(int index) {
+		return _cosines->at(index);
+	}
+
 private:
 	int _numTiles;
 	TileLookup *_tLookupArray;
@@ -211,6 +220,8 @@ private:
 
 	bool _systemInit;
 
+	Common::SineTable *_sines;
+	Common::CosineTable *_cosines;
 };
 
 class Picture {
diff --git a/engines/hdb/hdb.h b/engines/hdb/hdb.h
index a690be2..c6ea518 100644
--- a/engines/hdb/hdb.h
+++ b/engines/hdb/hdb.h
@@ -31,6 +31,8 @@
 #include "common/str.h"
 #include "common/random.h"
 #include "common/savefile.h"
+#include "common/sinetables.h"
+#include "common/cosinetables.h"
 #include "common/config-manager.h"
 #include "graphics/surface.h"
 #include "graphics/thumbnail.h"


Commit: 40765c4e9bab19906ce9e9581ccafb7528703e69
    https://github.com/scummvm/scummvm/commit/40765c4e9bab19906ce9e9581ccafb7528703e69
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:16+02:00

Commit Message:
HDB: Add Save struct and _saveHeader

Changed paths:
    engines/hdb/hdb.h
    engines/hdb/saveload.cpp


diff --git a/engines/hdb/hdb.h b/engines/hdb/hdb.h
index c6ea518..361ad09 100644
--- a/engines/hdb/hdb.h
+++ b/engines/hdb/hdb.h
@@ -114,6 +114,18 @@ enum Flag {
 	kFlagPlummet		= 0x8000000
 };
 
+struct Save {
+	char saveID[12];
+	int fileSlot;
+	char mapName[32];
+	uint32 seconds;
+
+	Save() : fileSlot(0), seconds(0) {
+		saveID[0] = 0;
+		mapName[0] = 0;
+	}
+};
+
 class HDBGame : public Engine {
 public:
 	HDBGame(OSystem *syst, const ADGameDescription *gameDesc);
@@ -217,6 +229,10 @@ public:
 		return _timeSlice - _prevTimeSlice;
 	}
 
+	const Common::String *getTargetName() {
+		return &_targetName;
+	}
+
 	char *lastMapName() { return _lastMapname; }
 	char *currentMapName() { return _currentMapname; }
 	char *getInMapName() { return _inMapName; }
@@ -245,6 +261,7 @@ public:
 		return _cheating;
 	}
 
+	Save _saveHeader;
 	bool _gameShutdown;
 	Graphics::PixelFormat _format;
 
diff --git a/engines/hdb/saveload.cpp b/engines/hdb/saveload.cpp
index 1bf9ce3..6bd212b 100644
--- a/engines/hdb/saveload.cpp
+++ b/engines/hdb/saveload.cpp
@@ -38,6 +38,11 @@ Common::Error HDBGame::saveGameState(int slot, const Common::String &desc) {
 
 	Graphics::saveThumbnail(*out);
 
+	memset(&_saveHeader, 0, sizeof(Save));
+	strcpy(_saveHeader.saveID, saveFileName.c_str());
+	_saveHeader.seconds = _timeSeconds + (_timePlayed / 1000);
+	strcpy(_saveHeader.mapName, _inMapName);
+
 	// Actual Save Data
 	saveGame(out);
 	_lua->save(out, _targetName.c_str(), slot);
@@ -91,7 +96,7 @@ void HDBGame::saveGame(Common::OutSaveFile *out) {
 	debug(1, "HDBGame::saveGame: start at %u", out->pos());
 
 	// Save Map Name and Time
-	out->writeUint32LE(_timeSeconds + (_timePlayed / 1000));
+	out->writeUint32LE(_saveHeader.seconds);
 	out->write(_inMapName, 32);
 
 	debug(1, "HDBGame::saveGame: map at %u", out->pos());
@@ -130,6 +135,8 @@ void HDBGame::loadGame(Common::InSaveFile *in) {
 	in->read(_inMapName, 32);
 
 	g_hdb->_sound->stopMusic();
+	_saveHeader.seconds = _timeSeconds;
+	strcpy(_saveHeader.mapName, _inMapName);
 
 	// Load Map Object Data
 	debug(1, "HDBGame::loadGame: map at %u", in->pos());


Commit: ac4deacf500034a7b88dd73ea219a48367ec84f5
    https://github.com/scummvm/scummvm/commit/ac4deacf500034a7b88dd73ea219a48367ec84f5
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:16+02:00

Commit Message:
HDB: Unstub fillGameSaveSlots()

Changed paths:
    engines/hdb/menu.cpp
    engines/hdb/menu.h


diff --git a/engines/hdb/menu.cpp b/engines/hdb/menu.cpp
index a19e9b3..6382d33 100644
--- a/engines/hdb/menu.cpp
+++ b/engines/hdb/menu.cpp
@@ -182,7 +182,26 @@ void Menu::drawTitle() {
 }
 
 void Menu::fillSavegameSlots() {
-	warning("STUB: PMenu::fillSavegameSlots()");
+	int i;
+	int max = kNumSaveSlots;
+
+	Common::InSaveFile *in;
+	Common::String saveGameFile;
+
+	for (i = 0; i < max; i++) {
+		saveGameFile = Common::String::format("%s.%03d", g_hdb->getTargetName()->c_str(), i);
+		in = g_system->getSavefileManager()->openForLoading(saveGameFile);
+
+		if (!in) {
+			memset(&_saveGames[i], 0, sizeof(Save));
+		} else {
+			strcpy(_saveGames[i].saveID, saveGameFile.c_str());
+			_saveGames[i].seconds = in->readUint32LE();
+			in->read(_saveGames[i].mapName, 32);
+			delete in;
+		}
+		_saveGames[i].fileSlot = i + 1;
+	}
 }
 
 } // End of Namespace
diff --git a/engines/hdb/menu.h b/engines/hdb/menu.h
index 7dcf9fc..5c79f58 100644
--- a/engines/hdb/menu.h
+++ b/engines/hdb/menu.h
@@ -48,6 +48,12 @@ namespace HDB {
 #define	CONFIG_KEY_USE		"keyuse"
 #define	CONFIG_VOICES		"voices"
 
+#define	TITLE_DELAY1		2				// time to wait before OOH OOH
+#define	TITLE_DELAY2		0.5				// time to spend doing OOH OOH
+#define	TITLE_DELAY3		1				// time to wait before ending title
+
+#define centerPic(x)	(kScreenWidth / 2 - x->_width / 2)
+
 enum {
 	kStarRedX = 70,
 	kStarRedY = 20,
@@ -164,13 +170,15 @@ public:
 
 	void fillSavegameSlots();
 
+	Save _saveGames[kNumSaveSlots + 1];
+
 	int _starWarp;
 	int _titleCycle;
 	uint32 _titleDelay;
 	bool _titleActive;
 	SoundType _resumeSong;	// the song that was playing before entering the Options screen
 
-	Picture *_ohhOhhGfx;
+	Picture *_oohOohGfx;
 	Picture *_titleScreen, *_titleLogo, *_hdbLogoScreen, *_menuBackoutGfx, *_controlButtonGfx, *_controlsGfx, *_menuBackspaceGfx;
 
 	int _rocketY, _rocketYVel, _rocketEx;	// Rocket Vars


Commit: 29d1c96f0e42cd8411b6523c57544ad34e7f38f5
    https://github.com/scummvm/scummvm/commit/29d1c96f0e42cd8411b6523c57544ad34e7f38f5
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:17+02:00

Commit Message:
HDB: Add startTitle() and drawTitle()

Changed paths:
    engines/hdb/menu.cpp
    engines/hdb/menu.h


diff --git a/engines/hdb/menu.cpp b/engines/hdb/menu.cpp
index 6382d33..2021693 100644
--- a/engines/hdb/menu.cpp
+++ b/engines/hdb/menu.cpp
@@ -167,18 +167,227 @@ void Menu::freeMenu() {
 	debug(9, "STUB: Free Menu");
 }
 
-void Menu::startTitle() {
-	// REMOVE: Putting this here since Menu hasn't been implemented yet.
+char nebulaNames[kNebulaCount][32] = {
+	BACKSCROLL_PLANET1,
+	BACKSCROLL_PLANET2,
+	BACKSCROLL_PLANET3,
+	BACKSCROLL_PLANET4,
+	BACKSCROLL_PLANET5,
+	BACKSCROLL_GALAXY1,
+	BACKSCROLL_GALAXY2
+};
+
+bool Menu::startTitle() {
 	// Defaults the game into Action Mode
+	warning("REMOVE: Putting this here since Menu hasn't been implemented yet");
 	g_hdb->setActionMode(1);
 	g_hdb->setGameState(GAME_PLAY);
 
-	warning("STUB: Menu::startTitle()");
+	int i;
+
+	readConfig();
+
+	_titleScreen = g_hdb->_gfx->loadPic(MONKEYLOGOSCREEN);
+	if (!_titleScreen)
+		return false;
+
+	_oohOohGfx = g_hdb->_gfx->loadPic(MONKEYLOGO_OOHOOH);
+	_rocketMain = g_hdb->_gfx->loadPic(MENU_ROCKETSHIP1);
+	_rocketSecond = g_hdb->_gfx->loadPic(MENU_ROCKETSHIP2);
+	_rocketEx1 = g_hdb->_gfx->loadPic(MENU_EXHAUST1);
+	_rocketEx2 = g_hdb->_gfx->loadPic(MENU_EXHAUST2);
+	_titleLogo = g_hdb->_gfx->loadPic(TITLELOGO);
+
+	for (i = 0; i < kNebulaCount; i++)
+		_nebulaGfx[i] = g_hdb->_gfx->loadPic(nebulaNames[i]);
+
+	_titleCycle = 1;	// 1 = Waiting for OOH OOH
 
+	_titleDelay = g_system->getMillis() + 1000 * TITLE_DELAY1;
+
+	g_hdb->_sound->stopMusic();
+	_introSong = SONG_TITLE;
+	_titleSong = SONG_MENU;
+	g_hdb->_sound->startMusic(_introSong);
+
+	return _titleActive = true;
 }
 
 void Menu::drawTitle() {
-	warning("STUB: Draw Title");
+	static int	line;
+	static uint32 time;
+
+	//sound.UpdateMusic();
+
+	if (!_titleActive)
+		return;
+
+	//-------------------------------------------------------------------
+	// draw special gfx
+	//-------------------------------------------------------------------
+	switch (_titleCycle) {
+	case 1:
+	case 3:
+		// draw entire screen
+		_titleScreen->draw(0, 0);
+		break;
+
+	case 2:
+		// draw entire screen & ooh ooh
+		_titleScreen->draw(0, 0);
+		_oohOohGfx->draw(kOohOhhX, kOohOhhY);
+		break;
+
+	case 4: // fadeout monkeystone logo
+		_titleScreen->draw(0, 0);
+		break;
+
+	case 5: // fadein HDB title screen
+	case 6: // wait
+	case 7: // fadeout HDB title screen
+		_hdbLogoScreen->draw(0, 0);
+		break;
+
+		// draw the rocket & exhaust until it stops
+	case 8:
+		g_hdb->_gfx->draw3DStars();
+
+		// draw nebula
+		_nebulaGfx[_nebulaWhich]->draw(_nebulaX, _nebulaY);
+		_nebulaY += _nebulaYVel;
+		if (_nebulaY > kScreenHeight + (kScreenHeight / 2)) {
+			_nebulaWhich = g_hdb->_rnd->getRandomNumber(kNebulaCount);
+			_nebulaX = g_hdb->_rnd->getRandomNumber(kScreenWidth) + 10;
+			_nebulaY = -11 * 8;
+			_nebulaYVel = g_hdb->_rnd->getRandomNumber(4) + 1;
+			if (_nebulaWhich > 4)		// galaxy?
+				_nebulaYVel = 1;
+		}
+
+		// draw rocket
+		_rocketMain->drawMasked(kMRocketX, _rocketY);
+		_rocketSecond->drawMasked(kMRocketX + 40, _rocketY + kMRocketYBottom);
+
+		// exhaust
+		if (_rocketEx < 5) {
+			_rocketEx1->drawMasked(kMRocketX + kMRocketEXHX, _rocketY + kMRocketYBottom);
+			_rocketEx2->drawMasked(kMRocketX + kMRocketEXHX2, _rocketY + kMRocketYBottom);
+		} else if (_rocketEx >= 5 && _rocketEx < 10) {
+			_rocketEx2->drawMasked(kMRocketX + kMRocketEXHX, _rocketY + kMRocketYBottom);
+			_rocketEx1->drawMasked(kMRocketX + kMRocketEXHX2, _rocketY + kMRocketYBottom);
+		} else {
+			_rocketEx = 0;
+			_rocketEx1->drawMasked(kMRocketX + kMRocketEXHX, _rocketY + kMRocketYBottom);
+			_rocketEx2->drawMasked(kMRocketX + kMRocketEXHX2, _rocketY + kMRocketYBottom);
+		}
+		_rocketEx++;
+
+		// title logo
+		_titleLogo->drawMasked(centerPic(_titleLogo), _rocketY + kMTitleY);
+
+		break;
+	}
+
+	// timer countdown...
+	if (_titleDelay > g_system->getMillis())
+		return;
+
+	//-------------------------------------------------------------------
+	// change title state...
+	//-------------------------------------------------------------------
+	switch (_titleCycle) {
+		//-------------------------------------------------------------------
+		// MONKEYSTONE LOGO
+		//-------------------------------------------------------------------
+		// time to OOH OOH
+	case 1:
+		_titleDelay = (uint32)(g_system->getMillis() + 1000 * TITLE_DELAY2);
+		g_hdb->_sound->playSound(SND_MONKEY_OOHOOH);
+		_titleCycle++;
+		break;
+
+		// delay after OOH OOH
+	case 2:
+		_titleDelay = g_system->getMillis() + 1000 * TITLE_DELAY3;
+		_titleCycle++;
+		break;
+
+		// done with delay; set up the fadeout...
+	case 3:
+		time = g_hdb->getTimeSliceDelta();
+		g_hdb->_gfx->setFade(false, false, kScreenFade / time); // FADEOUT
+		_titleCycle++;
+		g_hdb->_sound->stopMusic();
+	break;
+
+	// wait for fadeout, then start music
+	case 4:
+		if (g_hdb->_gfx->isFadeActive())
+			break;
+
+		g_hdb->_gfx->setFade(true, false, kScreenFade / time); // FADEIN
+		g_hdb->_sound->startMusic(_titleSong);
+		_titleCycle++;
+	break;
+
+		//-------------------------------------------------------------------
+		// HDB TITLE SCREEN
+		//-------------------------------------------------------------------
+		// wait for fadein to stop
+	case 5:
+		if (g_hdb->_gfx->isFadeActive())
+			break;
+		_titleDelay = g_system->getMillis() + 5000;
+		_titleCycle++;
+		break;
+
+		// set fadeout to stars
+	case 6:
+		g_hdb->_gfx->setFade(false, false, kScreenFade / time);		// FADEOUT
+		_titleCycle++;
+		break;
+
+		// get rocket ready
+	case 7:
+		if (g_hdb->_gfx->isFadeActive())
+			break;
+		g_hdb->_gfx->turnOffFade();
+		g_hdb->_gfx->fillScreen(0);
+		{
+			_titleCycle++;
+			_rocketY = kScreenHeight;	// ycoord
+			_rocketYVel = -1;		// yspeed
+			_rocketEx = 0;			// exhaust toggle
+			g_hdb->_gfx->setup3DStars();	// setup the star info
+
+			_nebulaWhich = g_hdb->_rnd->getRandomNumber(kNebulaCount);
+			_nebulaX = g_hdb->_rnd->getRandomNumber(kScreenWidth) + 10;
+			_nebulaY = -11 * 8;
+			_nebulaYVel = g_hdb->_rnd->getRandomNumber(10) + 2;
+			if (_nebulaWhich > 4)		// galaxy?
+				_nebulaYVel = 1;
+		}
+		break;
+
+		// move rocket up the screen!
+	case 8:
+		_titleDelay = 1;
+
+		_rocketY += _rocketYVel;
+		if (_rocketY < kMRocketY) {
+			_rocketY = kMRocketY;
+			_titleCycle = 12;
+			_titleDelay = 1;
+		}
+
+		break;
+
+		// shut down title....start up menu!
+	case 12:
+		_titleActive = false;
+		g_hdb->changeGameState();
+		break;
+	}
 }
 
 void Menu::fillSavegameSlots() {
diff --git a/engines/hdb/menu.h b/engines/hdb/menu.h
index 5c79f58..626f26a 100644
--- a/engines/hdb/menu.h
+++ b/engines/hdb/menu.h
@@ -161,12 +161,12 @@ public:
 	void readConfig();
 	void writeConfig();
 
+	bool startTitle();
+	void drawTitle();
 	void startMenu();
 	void changeToMenu();	// Changing from Intro to Menu
 	void drawMenu();
 	void freeMenu();
-	void startTitle();
-	void drawTitle();
 
 	void fillSavegameSlots();
 


Commit: 6f4e80b836823a5b4731dc3a29c0e8bc9e4ce92e
    https://github.com/scummvm/scummvm/commit/6f4e80b836823a5b4731dc3a29c0e8bc9e4ce92e
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:17+02:00

Commit Message:
HDB: Add stubbed Sound functions

Changed paths:
    engines/hdb/sound.h


diff --git a/engines/hdb/sound.h b/engines/hdb/sound.h
index 6574562..8e7b052 100644
--- a/engines/hdb/sound.h
+++ b/engines/hdb/sound.h
@@ -1395,6 +1395,14 @@ public:
 		debug(9, "STUB: Add Music System Variables");
 		return 1;
 	}
+	int getSFXVolume() {
+		debug(9, "STUB: Add Music System Variables");
+		return 1;
+	}
+	int getVoiceStatus() {
+		debug(9, "STUB: Add Music System Variables");
+		return 1;
+	}
 
 	bool playSound(int index);
 	bool playSoundEx(int index, int channel, bool loop);


Commit: 69e4668422e0e7f3e6887de49d63b8d1a65846a5
    https://github.com/scummvm/scummvm/commit/69e4668422e0e7f3e6887de49d63b8d1a65846a5
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:17+02:00

Commit Message:
HDB: Add centerPrint()

Changed paths:
    engines/hdb/gfx.cpp
    engines/hdb/gfx.h


diff --git a/engines/hdb/gfx.cpp b/engines/hdb/gfx.cpp
index ddee59f..57a3d28 100644
--- a/engines/hdb/gfx.cpp
+++ b/engines/hdb/gfx.cpp
@@ -732,6 +732,20 @@ int Gfx::stringLength(const char *string) {
 	return w;
 }
 
+void Gfx::centerPrint(const char *string) {
+	int totalWidth = 0, i;
+
+	for (i = 0; i < (int)strlen(string); i++) {
+		if (string[i] == ' ')
+			totalWidth += kFontSpace;
+		else if (string[i] != '\n')
+			totalWidth += _charInfoBlocks[string[i]]->width;
+	}
+
+	setCursor(kScreenWidth / 2 - totalWidth / 2, _cursorX);
+	drawText(string);
+}
+
 void Gfx::setTextEdges(int left, int right, int top, int bottom) {
 	_eLeft = left;
 	_eRight = right;
diff --git a/engines/hdb/gfx.h b/engines/hdb/gfx.h
index d057cae..d113df4 100644
--- a/engines/hdb/gfx.h
+++ b/engines/hdb/gfx.h
@@ -144,6 +144,7 @@ public:
 	void drawText(const char *string);
 	void getDimensions(const char *string, int *pixelsWide, int *lines);
 	int stringLength(const char *string);
+	void centerPrint(const char *string);
 	void setTextEdges(int left, int right, int top, int bottom);
 	void getTextEdges(int *left, int *right, int *top, int *bottom);
 	void setKernLead(int kern, int lead);


Commit: 9fcb307d1c6cfc4926d8f289ae886e75a22dc228
    https://github.com/scummvm/scummvm/commit/9fcb307d1c6cfc4926d8f289ae886e75a22dc228
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:17+02:00

Commit Message:
HDB: Add isVoiceless()

Changed paths:
    engines/hdb/hdb.h


diff --git a/engines/hdb/hdb.h b/engines/hdb/hdb.h
index 361ad09..4e0ea0d 100644
--- a/engines/hdb/hdb.h
+++ b/engines/hdb/hdb.h
@@ -233,6 +233,15 @@ public:
 		return &_targetName;
 	}
 
+	bool isVoiceless() {
+		/*
+			FIXME: Add hyperspace-nv.mpc to gameDescriptions[] 
+			in detection.cpp, and add a flag check for it.
+			Until then, the voiceless version is unsupported.
+		*/
+		return false;
+	}
+
 	char *lastMapName() { return _lastMapname; }
 	char *currentMapName() { return _currentMapname; }
 	char *getInMapName() { return _inMapName; }


Commit: 5cb46f624604f8d27e56c49e01511a10dfd0d810
    https://github.com/scummvm/scummvm/commit/5cb46f624604f8d27e56c49e01511a10dfd0d810
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:17+02:00

Commit Message:
HDB: Add Menu functions and other stubs

Changed paths:
    engines/hdb/menu.cpp
    engines/hdb/menu.h


diff --git a/engines/hdb/menu.cpp b/engines/hdb/menu.cpp
index 2021693..909aab2 100644
--- a/engines/hdb/menu.cpp
+++ b/engines/hdb/menu.cpp
@@ -26,7 +26,8 @@
 namespace HDB {
 
 bool Menu::init() {
-//	_starWarp = 0;
+	_starWarp = 0;
+	_rocketEx = 0;
 	_titleActive = false;
 	_menuActive = false;
 	_optionsActive = false;
@@ -152,30 +153,554 @@ void Menu::writeConfig() {
 }
 
 void Menu::startMenu() {
-	debug(9, "STUB: Start Menu");
+	int	i;
+
+	// stuff that gets loaded-in at Title Screen
+	if (!_titleLogo) {
+		_titleLogo = g_hdb->_gfx->loadPic(TITLELOGO);
+		for (i = 0; i < kNebulaCount; i++)
+			_nebulaGfx[i] = g_hdb->_gfx->loadPic(nebulaNames[i]);
+
+		_rocketMain = g_hdb->_gfx->loadPic(MENU_ROCKETSHIP1);
+		_rocketSecond = g_hdb->_gfx->loadPic(MENU_ROCKETSHIP2);
+		_rocketEx1 = g_hdb->_gfx->loadPic(MENU_EXHAUST1);
+		_rocketEx2 = g_hdb->_gfx->loadPic(MENU_EXHAUST2);
+	}
+	//
+	// menu-only stuff
+	//
+	_newGfx = g_hdb->_gfx->loadPic(MENU_NEWGAME);
+	_loadGfx = g_hdb->_gfx->loadPic(MENU_LOADGAME);
+	_optionsGfx = g_hdb->_gfx->loadPic(MENU_OPTIONS);
+	_quitGfx = g_hdb->_gfx->loadPic(MENU_QUIT);
+	_resumeGfx = g_hdb->_gfx->loadPic(MENU_RESUME);
+	_slotGfx = g_hdb->_gfx->loadPic(GAMEFILE_SLOT);
+	_menuBackoutGfx = g_hdb->_gfx->loadPic(MENU_BACK);
+	_menuBackspaceGfx = g_hdb->_gfx->loadPic(MENU_BACKSPACE);
+	_controlButtonGfx = g_hdb->_gfx->loadPic(MENU_CONTROLS);
+	_controlsGfx = g_hdb->_gfx->loadPic(PIC_CONTROLSSCREEN);
+
+	_vortexian[0] = g_hdb->_gfx->loadTile(GROUP_ENT_VORTEXIAN_STANDDOWN"01");
+	_vortexian[1] = g_hdb->_gfx->loadTile(GROUP_ENT_VORTEXIAN_STANDDOWN"02");
+	_vortexian[2] = g_hdb->_gfx->loadTile(GROUP_ENT_VORTEXIAN_STANDDOWN"03");
+
+	_modeLoadGfx = g_hdb->_gfx->loadPic(MENU_LOAD);
+	_modeSaveGfx = g_hdb->_gfx->loadPic(MENU_SAVE);
+
+	_modePuzzleGfx = g_hdb->_gfx->loadPic(MODE_PUZZLE);
+	_modeActionGfx = g_hdb->_gfx->loadPic(MODE_ACTION);
+
+	_sliderLeft = g_hdb->_gfx->loadPic(MENU_SLIDER_LEFT);
+	_sliderMid = g_hdb->_gfx->loadPic(MENU_SLIDER_MID);
+	_sliderRight = g_hdb->_gfx->loadPic(MENU_SLIDER_RIGHT);
+	_sliderKnob = g_hdb->_gfx->loadPic(MENU_SLIDER_KNOB);
+
+	_starRedGfx[0] = g_hdb->_gfx->loadPic(SECRETSTAR_RED1);
+	_starRedGfx[1] = g_hdb->_gfx->loadPic(SECRETSTAR_RED2);
+	_starGreenGfx[0] = g_hdb->_gfx->loadPic(SECRETSTAR_GREEN1);
+	_starGreenGfx[1] = g_hdb->_gfx->loadPic(SECRETSTAR_GREEN2);
+	_starBlueGfx[0] = g_hdb->_gfx->loadPic(SECRETSTAR_BLUE1);
+	_starBlueGfx[1] = g_hdb->_gfx->loadPic(SECRETSTAR_BLUE2);
+
+	// setup menu falling stars
+	_star[0] = g_hdb->_gfx->loadPic(STAR_1);
+	_star[1] = g_hdb->_gfx->loadPic(STAR_2);
+	_star[2] = g_hdb->_gfx->loadPic(STAR_3);
+
+	_versionGfx = g_hdb->_gfx->loadPic(MENU_VERSION_NUMBER);
+
+	_warpGfx = g_hdb->_gfx->loadPic(MENU_WARP);
+
+	// if we're popping back into menu, don't init this
+	if (!_fStars[0].y) {
+		for (i = 0; i < kMaxStars; i++) {
+			_fStars[i].y = -30;
+			_fStars[i].x = g_hdb->_rnd->getRandomNumber(kScreenWidth);
+			_fStars[i].speed = g_hdb->_rnd->getRandomNumber(5) + 1;
+			_fStars[i].anim = g_hdb->_rnd->getRandomNumber(3);
+			_fStars[i].delay = 5;
+		}
+	}
+
+	_quitScreen = NULL;
+
+	// did we skip the intro?
+	if (!_nebulaY) {
+		g_hdb->_gfx->setup3DStars();	// setup the star info
+
+		_nebulaWhich = g_hdb->_rnd->getRandomNumber(kNebulaCount);
+		_nebulaX = g_hdb->_rnd->getRandomNumber(kScreenWidth) + 10;
+		_nebulaY = -20;
+		_nebulaYVel = g_hdb->_rnd->getRandomNumber(10) + 2;
+	}
+
+	_optionsScrollX = kMenuX;
+	_oBannerY = -48;
+	_rocketY = kMRocketY;
+	_rocketX = kMRocketX;
+	_menuActive = true;
+	_clickDelay = 30;
+
+	fillSavegameSlots();
+
+	// did we already say "HYPERSPACE DELIVERY BOY!" ??
+	// if not, this is a great time to check for Copy Protection!
+	if (_sayHDB == false) {
+		g_hdb->_sound->playSound(SND_HDB);
+		_sayHDB = true;
+	}
 }
 
 void Menu::changeToMenu() {
-	warning("STUB: Change To Menu");
+	if (!g_hdb->_sound->songPlaying(_titleSong)) {
+		g_hdb->_sound->stopMusic();
+		g_hdb->_sound->startMusic(_titleSong);
+	}
 }
 
 void Menu::drawMenu() {
-	warning("STUB: Draw Menu");
+	// DEC the counter...
+	if (_clickDelay)
+		_clickDelay--;
+
+	//	sound.UpdateMusic();		// fading in/out
+	g_hdb->_gfx->turnOffFade();			// heh
+
+	//-------------------------------------------------------------------
+	// Draw the MAIN MENU
+	//-------------------------------------------------------------------
+	if (_menuActive) {
+		drawRocketAndSelections();
+
+		// draw version #
+		_versionGfx->drawMasked(kScreenWidth - 6 * 8, kScreenHeight - 8);
+
+		//
+		// see if the Options/GameFiles menu has scrolled off
+		//
+		if (_optionsScrolling) {
+			_optionsScrollX += _optionsXV;
+			_rocketX += -_optionsXV;
+			_oBannerY += _optionsXV / 3;
+			_optionsXV += 3;
+			if (_optionsScrollX > kScreenWidth + 10) {
+				switch (_nextScreen) {
+				case 0: _optionsActive = true; break;
+				case 1: _gamefilesActive = 1; break;
+				case 2: _newgameActive = true; break;
+				}
+
+				_oBannerY = 0;
+				_optionsScrolling = false;
+				_menuActive = false;
+			}
+		}
+
+		//
+		// Draw the Secret Stars! (tm)
+		//
+		if (g_hdb->getStarsMonkeystone7() == STARS_MONKEYSTONE_7 ||
+			g_hdb->getStarsMonkeystone14() == STARS_MONKEYSTONE_14 ||
+			g_hdb->getStarsMonkeystone21() == STARS_MONKEYSTONE_21) {
+			static int anim = 0, angler = 0, angleb = 90, angleg = 180;
+			static uint32 anim_time;
+
+			if (g_hdb->getStarsMonkeystone7() == STARS_MONKEYSTONE_7)
+				_starRedGfx[anim]->drawMasked(
+					kStarRedX + (int)(5 * g_hdb->_gfx->getCos(angler)),
+					kStarRedY + (int)(5 * g_hdb->_gfx->getSin(angler))
+				);
+			if (g_hdb->getStarsMonkeystone14() == STARS_MONKEYSTONE_14)
+				_starGreenGfx[anim]->drawMasked(
+					kStarGreenX + (int)(5 * g_hdb->_gfx->getCos(angleg)),
+					kStarGreenY + (int)(5 * g_hdb->_gfx->getSin(angleg))
+				);
+			if (g_hdb->getStarsMonkeystone21() == STARS_MONKEYSTONE_21)
+				_starBlueGfx[anim]->drawMasked(
+					kStarBlueX + (int)(5 * g_hdb->_gfx->getCos(angleb)),
+					kStarBlueY + (int)(5 * g_hdb->_gfx->getSin(angleb))
+				);
+
+			angler += 10; if (angler > 359) angler = 0;
+			angleg += 10; if (angleg > 359) angleg = 0;
+			angleb += 10; if (angleb > 359) angleb = 0;
+
+			if (anim_time < g_hdb->getTimeSlice()) {
+				anim_time = g_hdb->getTimeSlice() + 500;
+				anim = 1 - anim;
+			}
+		}
+
+		//#ifndef HDB_DEMO
+		//
+		// Draw WARP
+		//
+		if (g_hdb->getCheatingOn() && _warpGfx)
+			_warpGfx->drawMasked(0, kScreenHeight - _warpGfx->_height);
+		//#endif
+	} else if (_newgameActive) {
+		//-------------------------------------------------------------------
+		// Draw the NEWGAME menu
+		//-------------------------------------------------------------------
+		g_hdb->_gfx->draw3DStars();
+
+		//
+		// see if the Options menu has scrolled back on
+		//
+		if (_optionsScrolling) {
+			_optionsScrollX += _optionsXV;
+			_rocketX += -_optionsXV;
+			_oBannerY += _optionsXV / 3;
+			_optionsXV -= 3;
+			if (_optionsScrollX < kMenuX) {
+				_optionsScrollX = kMenuX;
+				_rocketX = kMRocketX;
+				_oBannerY = -48;
+				_optionsScrolling = false;
+				_newgameActive = false;
+				_menuActive = true;
+			}
+
+			drawRocketAndSelections();
+		} else {
+			drawNebula();
+			_newGfx->drawMasked(centerPic(_newGfx), _oBannerY);
+
+			_modePuzzleGfx->drawMasked(kNewGameX, kModePuzzleY);
+			_modePuzzleGfx->drawMasked(kNewGameX, kModeActionY);
+
+			g_hdb->_gfx->setCursor(kNewGameX2, kModePuzzleY - 10);
+			g_hdb->_gfx->drawText("PUZZLE MODE");
+			g_hdb->_gfx->setCursor(kNewGameX2, kModePuzzleY + 10);
+			g_hdb->_gfx->drawText("In this mode, the focus");
+			g_hdb->_gfx->setCursor(kNewGameX2, kModePuzzleY + 22);
+			g_hdb->_gfx->drawText("is on solving puzzles and");
+			g_hdb->_gfx->setCursor(kNewGameX2, kModePuzzleY + 34);
+			g_hdb->_gfx->drawText("avoiding enemies.");
+
+			g_hdb->_gfx->setCursor(kNewGameX2, kModeActionY - 10);
+			g_hdb->_gfx->drawText("ACTION MODE");
+			g_hdb->_gfx->setCursor(kNewGameX2, kModeActionY + 10);
+			g_hdb->_gfx->drawText("In this mode, the focus");
+			g_hdb->_gfx->setCursor(kNewGameX2, kModeActionY + 22);
+			g_hdb->_gfx->drawText("is on solving puzzles and");
+			g_hdb->_gfx->setCursor(kNewGameX2, kModeActionY + 34);
+			g_hdb->_gfx->drawText("attacking enemies!");
+
+			// title logo
+			_titleLogo->drawMasked(centerPic(_titleLogo), _rocketY + kMTitleY);
+			_menuBackoutGfx->drawMasked(kBackoutX, kBackoutY);
+		}
+	} else if (_optionsActive) {
+		//-------------------------------------------------------------------
+		// Draw the OPTIONS menu
+		//-------------------------------------------------------------------
+		g_hdb->_gfx->draw3DStars();
+
+		//
+		// see if the Options menu has scrolled back on
+		//
+		if (_optionsScrolling) {
+			_optionsScrollX += _optionsXV;
+			_rocketX += -_optionsXV;
+			_oBannerY += _optionsXV / 3;
+			_optionsXV -= 3;
+			if (_optionsScrollX < kMenuX) {
+				_optionsScrollX = kMenuX;
+				_rocketX = kMRocketX;
+				_oBannerY = -48;
+				_optionsScrolling = false;
+				_optionsActive = false;
+				_menuActive = true;
+			}
+
+			drawRocketAndSelections();
+		} else if (_optionsActive == 1) {
+			//
+			// Options menu content
+			//
+			static	int		hand_off, hand_yvel = 1;
+
+			drawNebula();
+			_optionsGfx->drawMasked(centerPic(_optionsGfx), _oBannerY);
+
+			g_hdb->_gfx->setCursor(kOptionsX + kOptionSPC, kOptionsY);
+			if (!g_hdb->_sound->getMusicVolume())
+				g_hdb->_gfx->drawText("Music OFF");
+			else
+				g_hdb->_gfx->drawText("Music Volume");
+
+			drawSlider(kOptionsX, kOptionsY + 20, g_hdb->_sound->getMusicVolume());
+
+			g_hdb->_gfx->setCursor(kOptionsX + kOptionSPC, kOptionsY + kOptionLineSPC * 2);
+			if (!g_hdb->_sound->getSFXVolume())
+				g_hdb->_gfx->drawText("Sound Effects OFF");
+			else
+				g_hdb->_gfx->drawText("Sound Effects Volume");
+
+			drawSlider(kOptionsX, kOptionsY + kOptionLineSPC * 2 + 20, g_hdb->_sound->getSFXVolume());
+
+			// Voices ON or OFF
+			drawToggle(kOptionsX, kOptionsY + kOptionLineSPC * 4 + 20, g_hdb->_sound->getVoiceStatus());
+
+			if (!g_hdb->isVoiceless()) {
+				g_hdb->_gfx->setCursor(kOptionsX + kOptionSPC + 24, kOptionsY + kOptionLineSPC * 4 + 24);
+				if (!g_hdb->_sound->getVoiceStatus())
+					g_hdb->_gfx->drawText("Voice Dialogue OFF");
+				else
+					g_hdb->_gfx->drawText("Voice Dialogue ON");
+			}
+
+
+			// title logo
+			_titleLogo->drawMasked(centerPic(_titleLogo), _rocketY + kMTitleY);
+			_menuBackoutGfx->drawMasked(kBackoutX, kBackoutY);
+			_controlButtonGfx->drawMasked(centerPic(_controlButtonGfx), kMControlsY);
+		} else if (_optionsActive == 2) {
+			//
+			// Draw CONTROLS screen
+			//
+				controlsDraw();
+				return;
+		}
+	} else if (_gamefilesActive) {
+		//-------------------------------------------------------------------
+		//	DRAW GAMEFILES MENU
+		//-------------------------------------------------------------------
+		int		i;
+
+		g_hdb->_gfx->draw3DStars();
+		//
+		// see if the Options menu has scrolled back on
+		//
+		if (_optionsScrolling) {
+			_optionsScrollX += _optionsXV;
+			_rocketX += -_optionsXV;
+			_oBannerY += _optionsXV / 3;
+			_optionsXV -= 3;
+			if (_optionsScrollX < kMenuX) {
+				_optionsScrollX = kMenuX;
+				_rocketX = kMRocketX;
+				_oBannerY = -48;
+				_optionsScrolling = false;
+				_gamefilesActive = false;
+				_menuActive = true;
+			}
+
+			drawRocketAndSelections();
+		} else {
+			static int	anim = 0;
+			static	uint32 anim_time = 0;
+
+			drawNebula();
+			_titleLogo->drawMasked(centerPic(_titleLogo), _rocketY + kMTitleY);
+			// CHOOSE SLOT screen
+			_modeLoadGfx->drawMasked(centerPic(_modeLoadGfx), _oBannerY);
+			_menuBackoutGfx->drawMasked(kBackoutX, kBackoutY);
+
+
+			if (_saveGames[0].seconds) {
+				_vortexian[anim]->drawMasked(kVortSaveX, kVortSaveY);
+			}
+			if (anim_time < g_hdb->getTimeSlice()) {
+				anim_time = g_hdb->getTimeSlice() + 50;
+				anim++;
+				if (anim > 2)
+					anim = 0;
+			}
+
+			for (i = 0; i < kNumSaveSlots; i++) {
+				char	buff[16];
+				int		seconds = _saveGames[i].seconds;
+
+				_slotGfx->drawMasked(kSaveSlotX - 8, i * 32 + (kSaveSlotY - 4));
+				if (seconds || _saveGames[i].mapName[0]) {
+
+					g_hdb->_gfx->setTextEdges(0, kScreenWidth + 60, 0, kScreenHeight);
+					g_hdb->_gfx->setCursor(kSaveSlotX, i * 32 + kSaveSlotY);
+					g_hdb->_gfx->drawText(_saveGames[i].mapName);
+
+					g_hdb->_gfx->setCursor(kSaveSlotX + 180, i * 32 + kSaveSlotY);
+					sprintf(buff, "%02d:%02d", seconds / 3600, (seconds / 60) % 60);
+					g_hdb->_gfx->drawText(buff);
+				}
+			}
+		}
+	} else if (_warpActive) {
+		//-------------------------------------------------------------------
+		//	DRAW WARP MENU
+		//-------------------------------------------------------------------
+		int		i;
+		char	string[32];
+
+		g_hdb->_gfx->draw3DStars();
+		drawNebula();
+		drawWarpScreen();
+		// title logo
+		_titleLogo->drawMasked(centerPic(_titleLogo), _rocketY + kMTitleY);
+		_menuBackoutGfx->drawMasked(kWarpBackoutX, kWarpBackoutY);
+
+		for (i = 0; i < 10; i++) {
+			sprintf(string, "Map %2d", i);
+			g_hdb->_gfx->setCursor(kWarpX + 4, i * 16 + kWarpY);
+			g_hdb->_gfx->drawText(string);
+		}
+		for (i = 0; i < 10; i++) {
+			sprintf(string, "Map %d", i + 10);
+			g_hdb->_gfx->setCursor(kWarpX + 80, i * 16 + kWarpY);
+			g_hdb->_gfx->drawText(string);
+		}
+		for (i = 0; i < 10; i++) {
+			sprintf(string, "Map %d", i + 20);
+			g_hdb->_gfx->setCursor(kWarpX + 160, i * 16 + kWarpY);
+			g_hdb->_gfx->drawText(string);
+		}
+
+		if (_warpActive > 1) {
+			g_hdb->_gfx->setCursor(kWarpX + 60, kWarpY + 164);
+			sprintf(string, "Warping to MAP%d", _warpActive - 2);
+			g_hdb->_gfx->centerPrint(string);
+		}
+	} else if (_quitActive) {
+		//-------------------------------------------------------------------
+		//	DRAW QUIT SCREEN
+		//-------------------------------------------------------------------
+		g_hdb->_gfx->draw3DStars();
+		drawNebula();
+		{
+			if (!_quitScreen)
+				_quitScreen = g_hdb->_gfx->loadPic(PIC_QUITSCREEN);
+			_quitScreen->drawMasked(kQuitX, kQuitY);
+		}
+	}
 }
 
 void Menu::freeMenu() {
-	debug(9, "STUB: Free Menu");
-}
+	int		i;
+
+	// title sequence stuff
+	if (_titleScreen)
+		_titleScreen->free();
+	_titleScreen = NULL;
+	if (_oohOohGfx)
+		_oohOohGfx->free();
+	_oohOohGfx = NULL;
+
+	if (_newGfx)
+		_newGfx->free();
+	_newGfx = NULL;
+	if (_loadGfx)
+		_loadGfx->free();
+	_loadGfx = NULL;
+	if (_optionsGfx)
+		_optionsGfx->free();
+	_optionsGfx = NULL;
+	if (_quitGfx)
+		_quitGfx->free();
+	_quitGfx = NULL;
+	if (_resumeGfx)
+		_resumeGfx->free();
+	_resumeGfx = NULL;
+	if (_slotGfx)
+		_slotGfx->free();
+	_slotGfx = NULL;
+	if (_rocketMain)
+		_rocketMain->free();
+	_rocketMain = NULL;
+	if (_rocketSecond)
+		_rocketSecond->free();
+	_rocketSecond = NULL;
+	if (_rocketEx1)
+		_rocketEx1->free();
+	_rocketEx1 = NULL;
+	if (_rocketEx2)
+		_rocketEx2->free();
+	_rocketEx2 = NULL;
+	if (_titleLogo)
+		_titleLogo->free();
+	_titleLogo = NULL;
+
+	if (_hdbLogoScreen)
+		_hdbLogoScreen->free();
+	_hdbLogoScreen = NULL;
+
+	if (_nebulaGfx[0])
+		for (i = 0; i < kNebulaCount; i++) {
+			_nebulaGfx[i]->free();
+			_nebulaGfx[i] = NULL;
+		}
+
+	if (_sliderLeft)
+		_sliderLeft->free();
+	_sliderLeft = NULL;
+	if (_sliderMid)
+		_sliderMid->free();
+	_sliderMid = NULL;
+	if (_sliderRight)
+		_sliderRight->free();
+	_sliderRight = NULL;
+	if (_sliderKnob)
+		_sliderKnob->free();
+	_sliderKnob = NULL;
+	if (_modePuzzleGfx)
+		_modePuzzleGfx->free();
+	_modePuzzleGfx = NULL;
+	if (_modeActionGfx)
+		_modeActionGfx->free();
+	_modeActionGfx = NULL;
+	if (_modeLoadGfx)
+		_modeLoadGfx->free();
+	_modeLoadGfx = NULL;
+	if (_modeSaveGfx)
+		_modeSaveGfx->free();
+	_modeSaveGfx = NULL;
+	if (_menuBackoutGfx)
+		_menuBackoutGfx->free();
+	_menuBackoutGfx = NULL;
+
+	if (_controlButtonGfx)
+		_controlButtonGfx->free();
+	_controlButtonGfx = NULL;
+
+	if (_controlsGfx)
+		_controlsGfx->free();
+	_controlsGfx = NULL;
+
+	if (_vortexian[0]) {
+		_vortexian[0]->free();
+		_vortexian[1]->free();
+		_vortexian[2]->free();
+		_vortexian[0] = _vortexian[1] = _vortexian[2] = NULL;
+	}
+
+	if (_star[0]) {
+		_star[0]->free();
+		_star[1]->free();
+		_star[2]->free();
+		_star[0] = _star[1] = _star[2] = NULL;
+	}
+
+	// secret stars
+	if (_starRedGfx[0]) {
+		_starRedGfx[0]->free();
+		_starRedGfx[1]->free();
+		_starGreenGfx[0]->free();
+		_starGreenGfx[1]->free();
+		_starBlueGfx[0]->free();
+		_starBlueGfx[1]->free();
+		_starRedGfx[0] = _starRedGfx[1] = NULL;
+		_starGreenGfx[0] = _starGreenGfx[1] = NULL;
+		_starBlueGfx[0] = _starBlueGfx[1] = NULL;
+	}
 
-char nebulaNames[kNebulaCount][32] = {
-	BACKSCROLL_PLANET1,
-	BACKSCROLL_PLANET2,
-	BACKSCROLL_PLANET3,
-	BACKSCROLL_PLANET4,
-	BACKSCROLL_PLANET5,
-	BACKSCROLL_GALAXY1,
-	BACKSCROLL_GALAXY2
-};
+	if (_versionGfx)
+		_versionGfx->free();
+	_versionGfx = NULL;
+
+	if (_warpGfx)
+		_warpGfx->free();
+	_warpGfx = NULL;
+}
 
 bool Menu::startTitle() {
 	// Defaults the game into Action Mode
@@ -413,4 +938,36 @@ void Menu::fillSavegameSlots() {
 	}
 }
 
+void Menu::processInput(int x, int y) {
+	warning("STUB: Menu: processInput");
+}
+
+void Menu::controlsInput(int x, int y) {
+	warning("STUB: Menu: controlsInput");
+}
+
+void Menu::controlsDraw() {
+	warning("STUB: Menu: controlsDraw");
+}
+
+void Menu::drawNebula() {
+	warning("STUB: Menu: drawNebula");
+}
+
+void Menu::drawRocketAndSelections() {
+	warning("STUB: Menu: drawRocketAndSelections");
+}
+
+void Menu::drawSlider(int x, int y, int offset) {
+	warning("STUB: Menu: drawSlider");
+}
+
+void Menu::drawToggle(int x, int y, bool flag) {
+	warning("STUB: Menu: drawToggle");
+}
+
+void Menu::drawWarpScreen() {
+	warning("STUB: Menu: drawWarpScreen");
+}
+
 } // End of Namespace
diff --git a/engines/hdb/menu.h b/engines/hdb/menu.h
index 626f26a..19ff2d6 100644
--- a/engines/hdb/menu.h
+++ b/engines/hdb/menu.h
@@ -100,7 +100,7 @@ enum {
 
 	kVortSaveX = 200 - 44,
 	kVortSaveTextX = kVortSaveX + 40,
-	kVortSaveTextY = 72,
+	kVortSaveY = 72,
 	kSaveSlotX = 200,
 	kSaveSlotY = 80,
 
@@ -144,7 +144,10 @@ enum {
 
 	kScreenFade = 512,
 	kNebulaCount = 7,
-	kMaxStars = 10
+	kMaxStars = 10,
+
+	kOptionSPC = 16,
+	kOptionLineSPC = 32
 };
 
 struct Star {
@@ -168,6 +171,18 @@ public:
 	void drawMenu();
 	void freeMenu();
 
+	void processInput(int x, int y);	// this is where the items are clicked!
+	void controlsInput(int x, int y);	// take mouse input and pass through to menu
+	void controlsDraw();
+	void drawNebula();
+	void drawRocketAndSelections();		// draw the background stuff
+	void drawSlider(int x, int y, int offset);
+	void drawToggle(int x, int y, bool flag);
+	void drawWarpScreen();
+	void saveSong(SoundType song) {
+		_resumeSong = song;
+	}
+
 	void fillSavegameSlots();
 
 	Save _saveGames[kNumSaveSlots + 1];
@@ -213,6 +228,16 @@ public:
 	SoundType _introSong, _titleSong;
 
 	Star _fStars[kMaxStars];
+
+	char nebulaNames[kNebulaCount][32] = {
+		BACKSCROLL_PLANET1,
+		BACKSCROLL_PLANET2,
+		BACKSCROLL_PLANET3,
+		BACKSCROLL_PLANET4,
+		BACKSCROLL_PLANET5,
+		BACKSCROLL_GALAXY1,
+		BACKSCROLL_GALAXY2
+	};
 };
 
 } // End of Namespace


Commit: 93155c6433ef7dd3c0f9752b161b2b53b3e72115
    https://github.com/scummvm/scummvm/commit/93155c6433ef7dd3c0f9752b161b2b53b3e72115
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:17+02:00

Commit Message:
HDB: Fix Window::loadSaveFile()

Changed paths:
    engines/hdb/window.cpp


diff --git a/engines/hdb/window.cpp b/engines/hdb/window.cpp
index 6e21555..643a11f 100644
--- a/engines/hdb/window.cpp
+++ b/engines/hdb/window.cpp
@@ -334,13 +334,17 @@ void Window::loadSaveFile(Common::InSaveFile *in) {
 	debug(9, "STUB: Load Try Again data");
 
 	// Load Textout Info
-	_textOutList.resize(in->readUint32LE());
-	for (i = 0; (uint)i < _textOutList.size(); i++) {
-		in->read(_textOutList[i]->text, 128);
-		_textOutList[i]->x = in->readSint32LE();
-		_textOutList[i]->y = in->readSint32LE();
-		_textOutList[i]->timer = in->readUint32LE();
-		_textOutList[i]->timer = g_system->getMillis() + 1000;
+	uint32 tsize = in->readUint32LE();
+	for (i = 0; (uint)i < tsize; i++) {
+		TOut *t = new TOut;
+
+		in->read(t->text, 128);
+		t->x = in->readSint32LE();
+		t->y = in->readSint32LE();
+		t->timer = in->readUint32LE();
+		t->timer = g_system->getMillis() + 1000;
+
+		_textOutList.push_back(t);
 	}
 
 	// Load Infobar Info


Commit: e7016e52a9be6b07a4cb3dcca1e8c875078a2bb1
    https://github.com/scummvm/scummvm/commit/e7016e52a9be6b07a4cb3dcca1e8c875078a2bb1
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:17+02:00

Commit Message:
HDB: Refarcot entity save/loading into separate methods

Changed paths:
    engines/hdb/ai-init.cpp
    engines/hdb/ai.h
    engines/hdb/saveload.cpp


diff --git a/engines/hdb/ai-init.cpp b/engines/hdb/ai-init.cpp
index 7b9a823..66e78f1 100644
--- a/engines/hdb/ai-init.cpp
+++ b/engines/hdb/ai-init.cpp
@@ -1235,7 +1235,7 @@ void AI::restartSystem() {
 }
 
 void AI::save(Common::OutSaveFile *out) {
-	int i, j;
+	int i;
 
 	// Misc Variables
 	out->writeByte(_playerInvisible);
@@ -1401,202 +1401,22 @@ void AI::save(Common::OutSaveFile *out) {
 		out->write(_triggerList->operator[](i)->luaFuncUse, 32);
 	}
 
-	AIEntity *e, temp;
-	char funcString[32];
-	const char *lookUp;
+	AIEntity *e;
 
 	// Save Floats
 	out->writeUint32LE(_floats->size());
 	for (i = 0; (uint)i < _floats->size(); i++) {
 		e = _floats->operator[](i);
-		memcpy(&temp, e, sizeof(AIEntity));
-
-		// Write out 32-char names for the function ptrs we have in the entity struct
-		lookUp = funcLookUp(e->aiAction);
-		memset(&funcString, 0, 32);
-		if (!lookUp && e->aiAction)
-			error("AI::save: No matching ACTION function for func-string");
-		if (lookUp)
-			strcpy(funcString, lookUp);
-		out->write(funcString, 32);
-
-		lookUp = funcLookUp(e->aiUse);
-		memset(&funcString, 0, 32);
-		if (!lookUp && e->aiUse)
-			error("AI::save: No matching USE function for func-string");
-		if (lookUp)
-			strcpy(funcString, lookUp);
-		out->write(funcString, 32);
-
-		lookUp = funcLookUp(e->aiInit);
-		memset(&funcString, 0, 32);
-		if (!lookUp && e->aiInit)
-			error("AI::save: No matching INIT function for func-string");
-		if (lookUp)
-			strcpy(funcString, lookUp);
-		out->write(funcString, 32);
-
-		lookUp = funcLookUp(e->aiInit2);
-		memset(&funcString, 0, 32);
-		if (!lookUp && e->aiInit2)
-			error("AI::save: No matching INIT2 function for func-string");
-		if (lookUp)
-			strcpy(funcString, lookUp);
-		out->write(funcString, 32);
-
-		lookUp = funcLookUp((FuncPtr)e->aiDraw);
-		memset(&funcString, 0, 32);
-		if (!lookUp && e->aiDraw)
-			error("AI::save: No matching DRAW function for func-string");
-		if (lookUp)
-			strcpy(funcString, lookUp);
-		out->write(funcString, 32);
-
-		// Clear out all ptrs in Entity before writing it out
-		for (j = 0; j < kMaxAnimFrames; j++)
-			temp.blinkGfx[j] = temp.movedownGfx[j] = temp.moveupGfx[j] = temp.moveleftGfx[j] =
-				temp.moverightGfx[j] = temp.standdownGfx[j] = temp.standupGfx[j] = temp.standleftGfx[j] =
-				temp.standrightGfx[j] = temp.special1Gfx[j] = NULL;
-
-		temp.blinkFrames = temp.movedownFrames = temp.moveupFrames = temp.moveleftFrames =
-			temp.moverightFrames = temp.standdownFrames = temp.standupFrames = temp.standleftFrames =
-			temp.standrightFrames = temp.special1Frames = 0;
-
-		temp.draw = NULL;
-		temp.aiDraw = NULL;
-		temp.aiAction = temp.aiInit = temp.aiUse = NULL;
-
-		// Save AIEntity
-		out->writeSint32LE((int)temp.type);
-		out->writeSint32LE((int)temp.state);
-		out->writeSint32LE((int)temp.dir);
-		out->write(temp.luaFuncInit, 32);
-		out->write(temp.luaFuncAction, 32);
-		out->write(temp.luaFuncUse, 32);
-		out->writeUint16LE(temp.level);
-		out->writeUint16LE(temp.value1);
-		out->writeUint16LE(temp.value2);
-		out->writeSint32LE((int)temp.dir2);
-		out->writeUint16LE(temp.x);
-		out->writeUint16LE(temp.y);
-		out->writeSint16LE(temp.drawXOff);
-		out->writeSint16LE(temp.drawYOff);
-		out->writeUint16LE(temp.onScreen);
-		out->writeUint16LE(temp.moveSpeed);
-		out->writeSint16LE(temp.xVel);
-		out->writeSint16LE(temp.yVel);
-		out->writeUint16LE(temp.tileX);
-		out->writeUint16LE(temp.tileY);
-		out->writeUint16LE(temp.goalX);
-		out->writeUint16LE(temp.goalY);
-		out->writeUint16LE(temp.touchpX);
-		out->writeUint16LE(temp.touchpY);
-		out->writeUint16LE(temp.touchpTile);
-		out->writeUint16LE(temp.touchpWait);
-		out->writeUint16LE(temp.stunnedWait);
-		out->writeSint16LE(temp.sequence);
-		out->write(temp.entityName, 32);
-		out->write(temp.printedName, 32);
-		out->writeUint16LE(temp.animFrame);
-		out->writeUint16LE(temp.animDelay);
-		out->writeUint16LE(temp.animCycle);
+
+		e->save(out);
 	}
 
 	// Save Ents
 	out->writeUint32LE(_ents->size());
 	for (i = 0; (uint)i < _ents->size(); i++) {
 		e = _ents->operator[](i);
-		memcpy(&temp, e, sizeof(AIEntity));
-
-		// Write out 32-char names for the function ptrs we have in the entity struct
-		lookUp = funcLookUp(e->aiAction);
-		memset(&funcString, 0, 32);
-		if (!lookUp && e->aiAction)
-			error("AI::save: No matching ACTION function for func-string");
-		if (lookUp)
-			strcpy(funcString, lookUp);
-		out->write(funcString, 32);
-
-		lookUp = funcLookUp(e->aiUse);
-		memset(&funcString, 0, 32);
-		if (!lookUp && e->aiUse)
-			error("AI::save: No matching USE function for func-string");
-		if (lookUp)
-			strcpy(funcString, lookUp);
-		out->write(funcString, 32);
-
-		lookUp = funcLookUp(e->aiInit);
-		memset(&funcString, 0, 32);
-		if (!lookUp && e->aiInit)
-			error("AI::save: No matching INIT function for func-string");
-		if (lookUp)
-			strcpy(funcString, lookUp);
-		out->write(funcString, 32);
-
-		lookUp = funcLookUp(e->aiInit2);
-		memset(&funcString, 0, 32);
-		if (!lookUp && e->aiInit2)
-			error("AI::save: No matching INIT2 function for func-string");
-		if (lookUp)
-			strcpy(funcString, lookUp);
-		out->write(funcString, 32);
-
-		lookUp = funcLookUp((FuncPtr)e->aiDraw);
-		memset(&funcString, 0, 32);
-		if (!lookUp && e->aiDraw)
-			error("AI::save: No matching DRAW function for func-string");
-		if (lookUp)
-			strcpy(funcString, lookUp);
-		out->write(funcString, 32);
-
-		// Clear out all ptrs in Entity before writing it out
-		for (j = 0; j < kMaxAnimFrames; j++)
-			temp.blinkGfx[j] = temp.movedownGfx[j] = temp.moveupGfx[j] = temp.moveleftGfx[j] =
-			temp.moverightGfx[j] = temp.standdownGfx[j] = temp.standupGfx[j] = temp.standleftGfx[j] =
-			temp.standrightGfx[j] = temp.special1Gfx[j] = NULL;
-
-		temp.blinkFrames = temp.movedownFrames = temp.moveupFrames = temp.moveleftFrames =
-			temp.moverightFrames = temp.standdownFrames = temp.standupFrames = temp.standleftFrames =
-			temp.standrightFrames = temp.special1Frames = 0;
-
-		temp.draw = NULL;
-		temp.aiDraw = NULL;
-		temp.aiAction = temp.aiInit = temp.aiUse = NULL;
-
-		// Save AIEntity
-		out->writeSint32LE((int)temp.type);
-		out->writeSint32LE((int)temp.state);
-		out->writeSint32LE((int)temp.dir);
-		out->write(temp.luaFuncInit, 32);
-		out->write(temp.luaFuncAction, 32);
-		out->write(temp.luaFuncUse, 32);
-		out->writeUint16LE(temp.level);
-		out->writeUint16LE(temp.value1);
-		out->writeUint16LE(temp.value2);
-		out->writeSint32LE((int)temp.dir2);
-		out->writeUint16LE(temp.x);
-		out->writeUint16LE(temp.y);
-		out->writeSint16LE(temp.drawXOff);
-		out->writeSint16LE(temp.drawYOff);
-		out->writeUint16LE(temp.onScreen);
-		out->writeUint16LE(temp.moveSpeed);
-		out->writeSint16LE(temp.xVel);
-		out->writeSint16LE(temp.yVel);
-		out->writeUint16LE(temp.tileX);
-		out->writeUint16LE(temp.tileY);
-		out->writeUint16LE(temp.goalX);
-		out->writeUint16LE(temp.goalY);
-		out->writeUint16LE(temp.touchpX);
-		out->writeUint16LE(temp.touchpY);
-		out->writeUint16LE(temp.touchpTile);
-		out->writeUint16LE(temp.touchpWait);
-		out->writeUint16LE(temp.stunnedWait);
-		out->writeSint16LE(temp.sequence);
-		out->write(temp.entityName, 32);
-		out->write(temp.printedName, 32);
-		out->writeUint16LE(temp.animFrame);
-		out->writeUint16LE(temp.animDelay);
-		out->writeUint16LE(temp.animCycle);
+
+		e->save(out);
 	}
 }
 
@@ -1818,78 +1638,13 @@ void AI::loadSaveFile(Common::InSaveFile *in) {
 	}
 
 	AIEntity *e;
-	char funcString[32];
-	FuncPtr init, init2, use, action;
-	EntFuncPtr draw;
 
 	// Load Floats
 	uint32 fsize = in->readUint32LE();
 	for (i = 0; (uint)i < fsize; i++) {
 		e = new AIEntity;
-		action = init = init2 = use = NULL;
-		draw = NULL;
-
-		// Read 32-char names for the function ptrs we have in entity struct
-		in->read(funcString, 32);
-		if (funcString[0])
-			action = funcLookUp(funcString);
-
-		in->read(funcString, 32);
-		if (funcString[0])
-			use = funcLookUp(funcString);
-
-		in->read(funcString, 32);
-		if (funcString[0])
-			init = funcLookUp(funcString);
-
-		in->read(funcString, 32);
-		if (funcString[0])
-			init2 = funcLookUp(funcString);
-
-		in->read(funcString, 32);
-		if (funcString[0])
-			draw = (EntFuncPtr)funcLookUp(funcString);
-
-		// Load AIEntity
-		e->type = (AIType)in->readSint32LE();
-		e->state = (AIState)in->readSint32LE();
-		e->dir = (AIDir)in->readSint32LE();
-		in->read(e->luaFuncInit, 32);
-		in->read(e->luaFuncAction, 32);
-		in->read(e->luaFuncUse, 32);
-		e->level = in->readUint16LE();
-		e->value1 = in->readUint16LE();
-		e->value2 = in->readUint16LE();
-		e->dir2 = (AIDir)in->readSint32LE();
-		e->x = in->readUint16LE();
-		e->y = in->readUint16LE();
-		e->drawXOff = in->readSint16LE();
-		e->drawYOff = in->readSint16LE();
-		e->onScreen = in->readUint16LE();
-		e->moveSpeed = in->readUint16LE();
-		e->xVel = in->readSint16LE();
-		e->yVel = in->readSint16LE();
-		e->tileX = in->readUint16LE();
-		e->tileY = in->readUint16LE();
-		e->goalX = in->readUint16LE();
-		e->goalY = in->readUint16LE();
-		e->touchpX = in->readUint16LE();
-		e->touchpY = in->readUint16LE();
-		e->touchpTile = in->readUint16LE();
-		e->touchpWait = in->readUint16LE();
-		e->stunnedWait = in->readUint16LE();
-		e->sequence = in->readSint16LE();
-		in->read(e->entityName, 32);
-		in->read(e->printedName, 32);
-		e->animFrame = in->readUint16LE();
-		e->animDelay = in->readUint16LE();
-		e->animCycle = in->readUint16LE();
-
-		e->aiAction = action;
-		e->aiInit = init;
-		e->aiInit2 = init2;
-		e->aiUse = use;
-		e->aiDraw = draw;
+
+		e->load(in);
 
 		// Cache All Entity Graphics
 		cacheEntGfx(e, false);
@@ -1902,70 +1657,8 @@ void AI::loadSaveFile(Common::InSaveFile *in) {
 	uint32 esize = in->readUint32LE();
 	for (i = 0; (uint)i < esize; i++) {
 		e = new AIEntity;
-		action = init = init2 = use = NULL;
-		draw = NULL;
-
-		// Read 32-char names for the function ptrs we have in entity struct
-		in->read(funcString, 32);
-		if (funcString[0])
-			action = funcLookUp(funcString);
-
-		in->read(funcString, 32);
-		if (funcString[0])
-			use = funcLookUp(funcString);
-
-		in->read(funcString, 32);
-		if (funcString[0])
-			init = funcLookUp(funcString);
-
-		in->read(funcString, 32);
-		if (funcString[0])
-			init2 = funcLookUp(funcString);
-
-		in->read(funcString, 32);
-		if (funcString[0])
-			draw = (EntFuncPtr)funcLookUp(funcString);
-
-		// Load AIEntity
-		e->type = (AIType)in->readSint32LE();
-		e->state = (AIState)in->readSint32LE();
-		e->dir = (AIDir)in->readSint32LE();
-		in->read(e->luaFuncInit, 32);
-		in->read(e->luaFuncAction, 32);
-		in->read(e->luaFuncUse, 32);
-		e->level = in->readUint16LE();
-		e->value1 = in->readUint16LE();
-		e->value2 = in->readUint16LE();
-		e->dir2 = (AIDir)in->readSint32LE();
-		e->x = in->readUint16LE();
-		e->y = in->readUint16LE();
-		e->drawXOff = in->readSint16LE();
-		e->drawYOff = in->readSint16LE();
-		e->onScreen = in->readUint16LE();
-		e->moveSpeed = in->readUint16LE();
-		e->xVel = in->readSint16LE();
-		e->yVel = in->readSint16LE();
-		e->tileX = in->readUint16LE();
-		e->tileY = in->readUint16LE();
-		e->goalX = in->readUint16LE();
-		e->goalY = in->readUint16LE();
-		e->touchpX = in->readUint16LE();
-		e->touchpY = in->readUint16LE();
-		e->touchpTile = in->readUint16LE();
-		e->touchpWait = in->readUint16LE();
-		e->stunnedWait = in->readUint16LE();
-		e->sequence = in->readSint16LE();
-		in->read(e->entityName, 32);
-		in->read(e->printedName, 32);
-		e->animFrame = in->readUint16LE();
-		e->animDelay = in->readUint16LE();
-		e->animCycle = in->readUint16LE();
-
-		e->aiAction = action;
-		e->aiInit = init;
-		e->aiInit2 = init2;
-		e->aiUse = use;
-		e->aiDraw = draw;
+
+		e->load(in);
 
 		// Cache All Entity Graphics
 		cacheEntGfx(e, false);
diff --git a/engines/hdb/ai.h b/engines/hdb/ai.h
index 3cb0cc0..2e213ce 100644
--- a/engines/hdb/ai.h
+++ b/engines/hdb/ai.h
@@ -539,6 +539,9 @@ struct AIEntity {
 			moverightGfx[i] = new Tile;
 		}
 	}
+
+	void save(Common::OutSaveFile *out);
+	void load(Common::InSaveFile *in);
 };
 
 // Structs for Function Table Lookup for SaveGames
diff --git a/engines/hdb/saveload.cpp b/engines/hdb/saveload.cpp
index 6bd212b..9c8186d 100644
--- a/engines/hdb/saveload.cpp
+++ b/engines/hdb/saveload.cpp
@@ -187,4 +187,158 @@ void HDBGame::loadSaveFile(Common::InSaveFile *in) {
 	in->read(_inMapName, 32);
 }
 
+void AIEntity::save(Common::OutSaveFile *out) {
+	char funcString[32];
+	const char *lookUp;
+
+
+	// Write out 32-char names for the function ptrs we have in the entity struct
+	lookUp = g_hdb->_ai->funcLookUp(aiAction);
+	memset(&funcString, 0, 32);
+	if (!lookUp && aiAction)
+		error("AIEntity::save: No matching ACTION function for func-string");
+	if (lookUp)
+		strcpy(funcString, lookUp);
+	out->write(funcString, 32);
+
+	lookUp = g_hdb->_ai->funcLookUp(aiUse);
+	memset(&funcString, 0, 32);
+	if (!lookUp && aiUse)
+		error("AIEntity::save: No matching USE function for func-string");
+	if (lookUp)
+		strcpy(funcString, lookUp);
+	out->write(funcString, 32);
+
+	lookUp = g_hdb->_ai->funcLookUp(aiInit);
+	memset(&funcString, 0, 32);
+	if (!lookUp && aiInit)
+		error("AIEntity::save: No matching INIT function for func-string");
+	if (lookUp)
+		strcpy(funcString, lookUp);
+	out->write(funcString, 32);
+
+	lookUp = g_hdb->_ai->funcLookUp(aiInit2);
+	memset(&funcString, 0, 32);
+	if (!lookUp && aiInit2)
+		error("AIEntity::save: No matching INIT2 function for func-string");
+	if (lookUp)
+		strcpy(funcString, lookUp);
+	out->write(funcString, 32);
+
+	lookUp = g_hdb->_ai->funcLookUp((FuncPtr)aiDraw);
+	memset(&funcString, 0, 32);
+	if (!lookUp && aiDraw)
+		error("AIEntity::save: No matching DRAW function for func-string");
+	if (lookUp)
+		strcpy(funcString, lookUp);
+	out->write(funcString, 32);
+
+	// Save AIEntity
+	out->writeSint32LE((int)type);
+	out->writeSint32LE((int)state);
+	out->writeSint32LE((int)dir);
+	out->write(luaFuncInit, 32);
+	out->write(luaFuncAction, 32);
+	out->write(luaFuncUse, 32);
+	out->writeUint16LE(level);
+	out->writeUint16LE(value1);
+	out->writeUint16LE(value2);
+	out->writeSint32LE((int)dir2);
+	out->writeUint16LE(x);
+	out->writeUint16LE(y);
+	out->writeSint16LE(drawXOff);
+	out->writeSint16LE(drawYOff);
+	out->writeUint16LE(onScreen);
+	out->writeUint16LE(moveSpeed);
+	out->writeSint16LE(xVel);
+	out->writeSint16LE(yVel);
+	out->writeUint16LE(tileX);
+	out->writeUint16LE(tileY);
+	out->writeUint16LE(goalX);
+	out->writeUint16LE(goalY);
+	out->writeUint16LE(touchpX);
+	out->writeUint16LE(touchpY);
+	out->writeUint16LE(touchpTile);
+	out->writeUint16LE(touchpWait);
+	out->writeUint16LE(stunnedWait);
+	out->writeSint16LE(sequence);
+	out->write(entityName, 32);
+	out->write(printedName, 32);
+	out->writeUint16LE(animFrame);
+	out->writeUint16LE(animDelay);
+	out->writeUint16LE(animCycle);
+}
+
+void AIEntity::load(Common::InSaveFile *in) {
+	char funcString[32];
+	FuncPtr init, init2, use, action;
+	EntFuncPtr drawf;
+
+	action = init = init2 = use = NULL;
+	drawf = NULL;
+
+	// Read 32-char names for the function ptrs we have in entity struct
+	in->read(funcString, 32);
+	if (funcString[0])
+		action = g_hdb->_ai->funcLookUp(funcString);
+
+	in->read(funcString, 32);
+	if (funcString[0])
+		use = g_hdb->_ai->funcLookUp(funcString);
+
+	in->read(funcString, 32);
+	if (funcString[0])
+		init = g_hdb->_ai->funcLookUp(funcString);
+
+	in->read(funcString, 32);
+	if (funcString[0])
+		init2 = g_hdb->_ai->funcLookUp(funcString);
+
+	in->read(funcString, 32);
+	if (funcString[0])
+		drawf = (EntFuncPtr)g_hdb->_ai->funcLookUp(funcString);
+
+	// Load AIEntity
+	type = (AIType)in->readSint32LE();
+	state = (AIState)in->readSint32LE();
+	dir = (AIDir)in->readSint32LE();
+	in->read(luaFuncInit, 32);
+	in->read(luaFuncAction, 32);
+	in->read(luaFuncUse, 32);
+	level = in->readUint16LE();
+	value1 = in->readUint16LE();
+	value2 = in->readUint16LE();
+	dir2 = (AIDir)in->readSint32LE();
+	x = in->readUint16LE();
+	y = in->readUint16LE();
+	drawXOff = in->readSint16LE();
+	drawYOff = in->readSint16LE();
+	onScreen = in->readUint16LE();
+	moveSpeed = in->readUint16LE();
+	xVel = in->readSint16LE();
+	yVel = in->readSint16LE();
+	tileX = in->readUint16LE();
+	tileY = in->readUint16LE();
+	goalX = in->readUint16LE();
+	goalY = in->readUint16LE();
+	touchpX = in->readUint16LE();
+	touchpY = in->readUint16LE();
+	touchpTile = in->readUint16LE();
+	touchpWait = in->readUint16LE();
+	stunnedWait = in->readUint16LE();
+	sequence = in->readSint16LE();
+	in->read(entityName, 32);
+	in->read(printedName, 32);
+	animFrame = in->readUint16LE();
+	animDelay = in->readUint16LE();
+	animCycle = in->readUint16LE();
+
+	aiAction = action;
+	aiInit = init;
+	aiInit2 = init2;
+	aiUse = use;
+	aiDraw = drawf;
+}
+
+
 } // End of Namespace


Commit: fe309b1456b027310e08dd6cf862cbef565285b3
    https://github.com/scummvm/scummvm/commit/fe309b1456b027310e08dd6cf862cbef565285b3
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:17+02:00

Commit Message:
HDB: Fix save/loading of inventory

Changed paths:
    engines/hdb/ai-init.cpp


diff --git a/engines/hdb/ai-init.cpp b/engines/hdb/ai-init.cpp
index 66e78f1..5eeff2b 100644
--- a/engines/hdb/ai-init.cpp
+++ b/engines/hdb/ai-init.cpp
@@ -1275,6 +1275,7 @@ void AI::save(Common::OutSaveFile *out) {
 	// Save Inventory
 	for (i = 0; i < kMaxInventory; i++) {
 		out->writeUint16LE(_inventory[i].keep);
+		_inventory[i].ent.save(out);
 	}
 	out->writeUint32LE(_numInventory);
 
@@ -1464,6 +1465,7 @@ void AI::loadSaveFile(Common::InSaveFile *in) {
 	// Load Inventory
 	for (i = 0; i < kMaxInventory; i++) {
 		_inventory[i].keep = in->readUint16LE();
+		_inventory[i].ent.load(in);
 	}
 	_numInventory = in->readUint32LE();
 


Commit: a8877bce1b882a515e0c9b45fa5aa8d908359d91
    https://github.com/scummvm/scummvm/commit/a8877bce1b882a515e0c9b45fa5aa8d908359d91
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:17+02:00

Commit Message:
HDB: Add drawNebula(), drawRocketsAndSelections()

Changed paths:
    engines/hdb/menu.cpp


diff --git a/engines/hdb/menu.cpp b/engines/hdb/menu.cpp
index 909aab2..0d7832b 100644
--- a/engines/hdb/menu.cpp
+++ b/engines/hdb/menu.cpp
@@ -951,11 +951,77 @@ void Menu::controlsDraw() {
 }
 
 void Menu::drawNebula() {
-	warning("STUB: Menu: drawNebula");
+	// draw nebula
+	_nebulaGfx[_nebulaWhich]->draw(_nebulaX, _nebulaY);
+	_nebulaY += _nebulaYVel;
+
+	if (_nebulaY > kScreenHeight + (kScreenHeight / 2)) {
+		_nebulaWhich = g_hdb->_rnd->getRandomNumber(kNebulaCount);
+		_nebulaX = g_hdb->_rnd->getRandomNumber(kScreenWidth) + 10;
+		_nebulaY = -11 * 8;
+		_nebulaYVel = g_hdb->_rnd->getRandomNumber(4) + 1;
+		if (_nebulaWhich > 4)		// galaxy?
+			_nebulaYVel = 1;
+	}
+
+	//
+	// draw the falling stars
+	//
+	int		i;
+
+	for (i = 0; i < kMaxStars; i++) {
+		_fStars[i].y += _fStars[i].speed;
+		if (_fStars[i].y > kScreenHeight) {
+			_fStars[i].y = (g_hdb->_rnd->getRandomNumber(30) + 30) * -1;
+			_fStars[i].speed = g_hdb->_rnd->getRandomNumber(5) + 1;
+		}
+		if (_fStars[i].delay-- < 1) {
+			_fStars[i].delay = 5;
+			_fStars[i].anim = (_fStars[i].anim + 1) % 3;
+		}
+		_star[_fStars[i].anim]->drawMasked(_fStars[i].x, _fStars[i].y);
+	}
 }
 
 void Menu::drawRocketAndSelections() {
-	warning("STUB: Menu: drawRocketAndSelections");
+	g_hdb->_gfx->draw3DStars();
+	drawNebula();
+
+	// top-down/up scrolling stuff
+	switch (_nextScreen) {
+	case 0: _optionsGfx->drawMasked(centerPic(_optionsGfx), _oBannerY); break;
+	case 1: _modeLoadGfx->drawMasked(centerPic(_modeLoadGfx), _oBannerY); break;
+	case 2: _newGfx->drawMasked(centerPic(_newGfx), _oBannerY); break;
+	}
+
+	// menu items
+	_newGfx->drawMasked(_optionsScrollX, kMenuY);
+	_modeLoadGfx->drawMasked(_optionsScrollX, kMenuY + kMLoadY);
+	_optionsGfx->drawMasked(_optionsScrollX, kMenuY + kMOptionsY);
+	_quitGfx->drawMasked(_optionsScrollX, kMenuY + kMQuitY);
+	if (g_hdb->_map->isLoaded() || _saveGames[5].seconds)
+		_resumeGfx->drawMasked(_optionsScrollX, kMenuY + kMResumeY);
+
+	// draw rocket
+	_rocketMain->drawMasked(_rocketX, _rocketY);
+	_rocketSecond->drawMasked(_rocketX + 40, _rocketY + kMRocketYBottom);
+
+	// exhaust
+	if (_rocketEx < 5) {
+		_rocketEx1->drawMasked(kMRocketX + kMRocketEXHX, _rocketY + kMRocketYBottom);
+		_rocketEx2->drawMasked(kMRocketX + kMRocketEXHX2, _rocketY + kMRocketYBottom);
+	} else if (_rocketEx >= 5 && _rocketEx < 10) {
+		_rocketEx2->drawMasked(kMRocketX + kMRocketEXHX, _rocketY + kMRocketYBottom);
+		_rocketEx1->drawMasked(kMRocketX + kMRocketEXHX2, _rocketY + kMRocketYBottom);
+	} else {
+		_rocketEx = 0;
+		_rocketEx1->drawMasked(kMRocketX + kMRocketEXHX, _rocketY + kMRocketYBottom);
+		_rocketEx2->drawMasked(kMRocketX + kMRocketEXHX2, _rocketY + kMRocketYBottom);
+	}
+	_rocketEx++;
+
+	// title logo
+	_titleLogo->drawMasked(centerPic(_titleLogo), _rocketY + kMTitleY);
 }
 
 void Menu::drawSlider(int x, int y, int offset) {


Commit: 23239d54f6984079b9cd551fc842ef8e62b83670
    https://github.com/scummvm/scummvm/commit/23239d54f6984079b9cd551fc842ef8e62b83670
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:17+02:00

Commit Message:
HDB: Unstub drawToggle, drawSlider, drawWarpScreen

Changed paths:
    engines/hdb/menu.cpp


diff --git a/engines/hdb/menu.cpp b/engines/hdb/menu.cpp
index 0d7832b..1cf9337 100644
--- a/engines/hdb/menu.cpp
+++ b/engines/hdb/menu.cpp
@@ -1025,15 +1025,45 @@ void Menu::drawRocketAndSelections() {
 }
 
 void Menu::drawSlider(int x, int y, int offset) {
-	warning("STUB: Menu: drawSlider");
+	int	i, x1;
+
+	x1 = x;
+
+	_sliderLeft->drawMasked(x, y);
+	x += _sliderLeft->_width;
+
+	for (i = 0; i < 12; i++) {
+		_sliderMid->draw(x, y);
+		x += _sliderMid->_width;
+	}
+
+	_sliderRight->drawMasked(x, y);
+	_sliderKnob->drawMasked(x1 + (offset * 200) / 256, y + 2);
 }
 
 void Menu::drawToggle(int x, int y, bool flag) {
-	warning("STUB: Menu: drawToggle");
+	int	i, x1;
+
+	x1 = x;
+
+	_gCheckLeft->drawMasked(x, y);
+	x += _gCheckLeft->_width;
+
+	for (i = 0; i < 12; i++) {
+		_gCheckEmpty->draw(x, y);
+		x += _gCheckEmpty->_width;
+	}
+
+	_gCheckRight->drawMasked(x, y);
+
+	if (!flag)
+		_gCheckOff->drawMasked(x1 + _sliderLeft->_width, y);
+	else
+		_gCheckOn->drawMasked(x1 + _sliderLeft->_width, y);
 }
 
 void Menu::drawWarpScreen() {
-	warning("STUB: Menu: drawWarpScreen");
+	_warpPlaque->drawMasked(centerPic(_warpPlaque), 64);
 }
 
 } // End of Namespace


Commit: cf5863c7946e570f268280c383b23843b7e41e71
    https://github.com/scummvm/scummvm/commit/cf5863c7946e570f268280c383b23843b7e41e71
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:17+02:00

Commit Message:
HDB: Filter out more Lua globals from saving

Changed paths:
    engines/hdb/lua-script.cpp


diff --git a/engines/hdb/lua-script.cpp b/engines/hdb/lua-script.cpp
index b563de3..37e4d6d 100644
--- a/engines/hdb/lua-script.cpp
+++ b/engines/hdb/lua-script.cpp
@@ -44,7 +44,7 @@ struct ScriptPatch {
 	{"GLOBAL.LUA", "for i,v in globals() do", "for i,v in pairs(_G) do"},
 	{"GLOBAL.LUA", "return gsub( s, \"\\n\", \"\\\\\\n\" )", "return string.gsub( s, \"\\n\", \"\\\\\\n\" )"},
 	{"GLOBAL.LUA", "for i,v in t do", "for i,v in pairs(t) do"},
-	{"GLOBAL.LUA", "if type(v) == 'userdata' or type(v) == 'function' then return end", "if type(v) == 'userdata' or type(v) == 'function' or i == 'package' or i == 'os' or i == 'io' or i == 'sctrings' then return end" }, // Line 16
+	{"GLOBAL.LUA", "if type(v) == 'userdata' or type(v) == 'function' then return end", "if type(v) == 'userdata' or type(v) == 'function' or i == 'package' or i == 'os' or i == 'io' or i == 'string' or i == 'table' then return end" }, // Line 16
 	{"GLOBAL.LUA", "for npcname,npcdata in npcs do", "for npcname,npcdata in pairs(npcs) do"}, // Line 66
 	{"GLOBAL.LUA", "for dlgname,dlgdata in npcdata.dialog do", "for dlgname,dlgdata in pairs(npcdata.dialog) do"}, // Line 67
 	{"GLOBAL.LUA", "s = format( \"npcs.%s.dialog.%s.counter", "s = string.format( \"npcs.%s.dialog.%s.counter"}, // Line 68


Commit: d5a779168f2110f4041f78d0f4d3dc5145d9b5ce
    https://github.com/scummvm/scummvm/commit/d5a779168f2110f4041f78d0f4d3dc5145d9b5ce
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:17+02:00

Commit Message:
HDB: Add Pause Button

Changed paths:
    engines/hdb/input.cpp


diff --git a/engines/hdb/input.cpp b/engines/hdb/input.cpp
index 9762910..212b239 100644
--- a/engines/hdb/input.cpp
+++ b/engines/hdb/input.cpp
@@ -209,7 +209,6 @@ void Input::stylusMove(int x, int y) {
 		warning("STUB: stylusMove: Menu::processInput() required");
 		break;
 	default:
-		debug(9, "stylusMove: Unintended GameState");
 		break;
 	}
 }
@@ -284,10 +283,23 @@ void Input::updateMouseButtons(int l, int m, int r) {
 void Input::updateKeys(Common::Event event, bool keyDown) {
 
 	debug(9, "STUB: updateKeys: Check for Quit key");
-	debug(9, "STUB: updateKeys: Check for Pause key");
 
 	uint16 buttons = getButtons();
 
+	// PAUSE key pressed?
+	{
+		static int	current = 0, last = 0;
+		last = current;
+		if (keyDown && event.kbd.keycode == Common::KEYCODE_p && g_hdb->getGameState() == GAME_PLAY) {
+			current = 1;
+			if (!last) {
+				g_hdb->togglePause();
+				g_hdb->_sound->playSound(SND_POP);
+			}
+		} else
+			current = 0;
+	}
+
 	if (!g_hdb->getPause()) {
 		if (event.kbd.keycode == _keyUp) {
 			if (keyDown) {


Commit: a510482d64d7f77c3a0f9500cfd137d897524a03
    https://github.com/scummvm/scummvm/commit/a510482d64d7f77c3a0f9500cfd137d897524a03
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:17+02:00

Commit Message:
HDB: Add stubs in Sound and Input

Changed paths:
    engines/hdb/input.cpp
    engines/hdb/sound.cpp
    engines/hdb/sound.h


diff --git a/engines/hdb/input.cpp b/engines/hdb/input.cpp
index 212b239..256b6fb 100644
--- a/engines/hdb/input.cpp
+++ b/engines/hdb/input.cpp
@@ -348,8 +348,10 @@ void Input::updateKeys(Common::Event event, bool keyDown) {
 		if (keyDown) {
 			buttons |= kButtonA;
 			g_hdb->_gfx->showPointer(true);
+			warning("STUB: changetoMenu");
 		} else {
 			buttons &= ~kButtonA;
+			warning("STUB: changetoMenu");
 		}
 	} else if (event.kbd.keycode == _keyDebug) {
 		if (keyDown) {
diff --git a/engines/hdb/sound.cpp b/engines/hdb/sound.cpp
index 75e3362..d7967e2 100644
--- a/engines/hdb/sound.cpp
+++ b/engines/hdb/sound.cpp
@@ -75,6 +75,16 @@ void Sound::stopMusic() {
 	debug(9, "STUB: Stop Music");
 }
 
+bool Sound::freeSound(int index) {
+	debug(9, "STUB: Free Sound");
+	return true;
+}
+
+SoundType Sound::whatSongIsPlaying() {
+	debug(9, "STUB: whatSongIsPlaying");
+	return SONG_NONE;
+}
+
 void Sound::markSoundCacheFreeable() {
 	warning("STUB: Sound::markSoundCacheFreeable() ");
 }
diff --git a/engines/hdb/sound.h b/engines/hdb/sound.h
index 8e7b052..895f6d9 100644
--- a/engines/hdb/sound.h
+++ b/engines/hdb/sound.h
@@ -1391,14 +1391,23 @@ public:
 	void save(Common::OutSaveFile *out);
 	void loadSaveFile(Common::InSaveFile *in);
 	void clearPersistent();
+	void setMusicVolume(int value) {
+		debug(9, "STUB: Add Music System Variables");
+	}
 	int getMusicVolume() {
 		debug(9, "STUB: Add Music System Variables");
 		return 1;
 	}
+	void setSFXVolume(int value) {
+		debug(9, "STUB: Add Music System Variables");
+	}
 	int getSFXVolume() {
 		debug(9, "STUB: Add Music System Variables");
 		return 1;
 	}
+	void setVoiceStatus(int value) {
+		debug(9, "STUB: Add Music System Variables");
+	}
 	int getVoiceStatus() {
 		debug(9, "STUB: Add Music System Variables");
 		return 1;
@@ -1411,6 +1420,9 @@ public:
 	bool songPlaying(SoundType song);
 	bool stopChannel(int channel);
 	void stopMusic();
+	bool freeSound(int index);
+
+	SoundType whatSongIsPlaying();
 
 	void markSoundCacheFreeable();
 };


Commit: bb6c18496f2e84b0dce2defef5fd67ee8d0ada2e
    https://github.com/scummvm/scummvm/commit/bb6c18496f2e84b0dce2defef5fd67ee8d0ada2e
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:17+02:00

Commit Message:
HDB: Add _menuKey

Changed paths:
    engines/hdb/menu.cpp
    engines/hdb/menu.h


diff --git a/engines/hdb/menu.cpp b/engines/hdb/menu.cpp
index 1cf9337..739fed4 100644
--- a/engines/hdb/menu.cpp
+++ b/engines/hdb/menu.cpp
@@ -38,6 +38,7 @@ bool Menu::init() {
 	_optionsScrollX = kMenuX;
 	_rocketX = kMRocketX;
 	_sayHDB = false;
+	_menuKey = 0;
 
 	_nebulaY = 0;		// Used as a flag
 	_fStars[0].y = 0;	// Used as a flag
diff --git a/engines/hdb/menu.h b/engines/hdb/menu.h
index 19ff2d6..4c30aeb 100644
--- a/engines/hdb/menu.h
+++ b/engines/hdb/menu.h
@@ -185,6 +185,13 @@ public:
 
 	void fillSavegameSlots();
 
+	void setMenuKey(int status) {
+		_menuKey = status;
+	}
+	int getMenuKey() {
+		return _menuKey;
+	}
+
 	Save _saveGames[kNumSaveSlots + 1];
 
 	int _starWarp;
@@ -238,6 +245,8 @@ public:
 		BACKSCROLL_GALAXY1,
 		BACKSCROLL_GALAXY2
 	};
+
+	int _menuKey;
 };
 
 } // End of Namespace


Commit: 611041701e58b3f9abcb8a528a7ea46005168db8
    https://github.com/scummvm/scummvm/commit/611041701e58b3f9abcb8a528a7ea46005168db8
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:17+02:00

Commit Message:
HDB: Unstub processInput()

Changed paths:
    engines/hdb/menu.cpp


diff --git a/engines/hdb/menu.cpp b/engines/hdb/menu.cpp
index 739fed4..e03724f 100644
--- a/engines/hdb/menu.cpp
+++ b/engines/hdb/menu.cpp
@@ -940,7 +940,309 @@ void Menu::fillSavegameSlots() {
 }
 
 void Menu::processInput(int x, int y) {
-	warning("STUB: Menu: processInput");
+	// do not enter if clicking too fast
+	if (_clickDelay)
+		return;
+	_clickDelay = 3;
+
+	//-------------------------------------------------------------------
+	//	MAIN MENU INPUT
+	//-------------------------------------------------------------------
+	if (_menuActive) {
+		int	resume = getMenuKey();
+		// quit game?
+		if (x >= kMenuX && x < kMenuX + kMenuItemWidth &&
+			y >= kMenuY + kMQuitY && y < kMenuY + kMQuitY + kMenuItemHeight) {
+			g_hdb->_sound->playSound(SND_BYE);
+			_quitTimer = g_hdb->getTimeSlice() + 1000;
+			_quitActive = true;
+			_menuActive = false;
+			return;
+		} else if (x >= kMenuX && x < kMenuX + kMenuItemWidth &&
+			y >= kMenuY && y < kMenuY + kMenuItemHeight) {
+			// new game?
+			_optionsScrolling = true;
+			_optionsXV = 5;
+			g_hdb->_sound->playSound(SND_MENU_ACCEPT);
+			g_hdb->_sound->freeSound(SND_HDB);
+			_nextScreen = 2;
+		} else if (x >= kMenuX && x < kMenuX + kMenuItemWidth &&
+			y >= kMenuY + kMLoadY && y < kMenuY + kMLoadY + kMenuItemHeight) {
+			// game files?
+				_optionsScrolling = true;
+				_optionsXV = 5;
+				g_hdb->_sound->playSound(SND_MENU_ACCEPT);
+				_nextScreen = 1;
+		} else if (x >= kMenuX && x < kMenuX + kMenuItemWidth &&
+			y >= kMenuY + kMOptionsY && y < kMenuY + kMOptionsY + kMenuItemHeight) {
+			// options?
+			SoundType temp;
+			temp = g_hdb->_sound->whatSongIsPlaying();
+			if (temp != SONG_NONE)
+				_resumeSong = temp;
+			_optionsScrolling = true;
+			_optionsXV = 5;
+			_nextScreen = 0;
+			g_hdb->_sound->playSound(SND_MENU_ACCEPT);
+		} else if (((x >= kMenuX && x < kMenuX + kMenuItemWidth &&
+			y >= kMenuY + kMResumeY && y < kMenuY + kMResumeY + kMenuItemHeight) || resume) &&
+			(true == g_hdb->_map->isLoaded() || _saveGames[5].seconds)) {
+			// resume game? ( must be playing already or have an autosave )
+			g_hdb->_sound->playSound(SND_POP);
+			freeMenu();
+			// if we're on the secret level, RESUME will load the autosave...
+			if (g_hdb->_map->isLoaded() && scumm_strnicmp(g_hdb->currentMapName(), "map30", 5))
+				g_hdb->setGameState(GAME_PLAY);
+			else {
+				if (g_hdb->loadGameState(kAutoSaveSlot).getCode() == Common::kNoError) {
+					g_hdb->setGameState(GAME_PLAY);
+				}
+			}
+		} else if (g_hdb->getStarsMonkeystone7() == STARS_MONKEYSTONE_7 ||
+			g_hdb->getStarsMonkeystone14() == STARS_MONKEYSTONE_14 ||
+			g_hdb->getStarsMonkeystone21() == STARS_MONKEYSTONE_21) {
+			// Secret Stars! (tm)
+			if (x >= kStarRedX && x <= kStarRedX + _starRedGfx[0]->_width &&
+				y >= kStarRedY && y <= kStarRedY + _starRedGfx[0]->_height &&
+				g_hdb->getStarsMonkeystone7() == STARS_MONKEYSTONE_7) {
+				_optionsActive = false;
+				g_hdb->setGameState(GAME_PLAY);
+				if (scumm_strnicmp(g_hdb->currentMapName(), "map30", 5))	// don't save if we're already on 30!
+					g_hdb->saveGameState(kAutoSaveSlot, "FIXME"); // Add here date/level name // TODO
+				_starWarp = 0;
+				g_hdb->_sound->playSound(SND_MONKEYSTONE_SECRET_STAR);
+				g_hdb->startMap("map30");
+			} else if (x >= kStarGreenX && x <= kStarGreenX + _starGreenGfx[0]->_width &&
+				y >= kStarGreenY && y <= kStarGreenY + _starGreenGfx[0]->_height &&
+				g_hdb->getStarsMonkeystone14() == STARS_MONKEYSTONE_14) {
+				_optionsActive = false;
+				g_hdb->setGameState(GAME_PLAY);
+				if (scumm_strnicmp(g_hdb->currentMapName(), "map30", 5))	// don't save if we're already on 30!
+					g_hdb->saveGameState(kAutoSaveSlot, "FIXME"); // Add here date/level name // TODO
+				_starWarp = 1;
+				g_hdb->_sound->playSound(SND_MONKEYSTONE_SECRET_STAR);
+				g_hdb->startMap("map30");
+
+			} else if (x >= kStarBlueX && x <= kStarBlueX + _starBlueGfx[0]->_width &&
+				y >= kStarBlueY && y <= kStarBlueY + _starBlueGfx[0]->_height &&
+				g_hdb->getStarsMonkeystone21() == STARS_MONKEYSTONE_21) {
+				_optionsActive = false;
+				g_hdb->setGameState(GAME_PLAY);
+				if (scumm_strnicmp(g_hdb->currentMapName(), "map30", 5))	// don't save if we're already on 30!
+					g_hdb->saveGameState(kAutoSaveSlot, "FIXME"); // Add here date/level name // TODO
+				_starWarp = 2;
+				g_hdb->_sound->playSound(SND_MONKEYSTONE_SECRET_STAR);
+				g_hdb->startMap("map30");
+			}
+		}
+		// secret warp menu? (click on nebula!)
+		int		open;
+		if (!g_hdb->getCheatingOn())
+			open = (x >= _nebulaX && x < _nebulaX + 16 && y >= _nebulaY && y < _nebulaY + 16);
+		else
+			open = (y > kMenuExitY && x < kMenuExitXLeft);
+
+		if (open) {
+
+			g_hdb->_sound->playSound(SND_MONKEYSTONE_SECRET_STAR);
+
+			_menuActive = false;
+			_warpActive = true;
+			_clickDelay = 30;
+		}
+	} else if (_newgameActive) {
+		//-------------------------------------------------------------------
+		//	NEWGAME INPUT
+		//-------------------------------------------------------------------
+		int	xit = getMenuKey();
+
+		if (y >= kMenuExitY || y < kMenuExitYTop || xit) {
+			_optionsScrolling = true;
+			_optionsXV = -5;
+			g_hdb->_sound->playSound(SND_MENU_BACKOUT);
+		}
+
+		// PUZZLE MODE area
+		if (y >= kModePuzzleY - 10 && y <= kModeActionY - 10) {
+			g_hdb->setActionMode(0);
+			g_hdb->_sound->playSound(SND_MENU_ACCEPT);
+			_newgameActive = false;
+			g_hdb->changeGameState();
+			// that's it!  the Game Loop takes over from here...
+		} else if (y >= kModeActionY - 10 && y <= kMenuExitY) {
+			// ACTION MODE area
+			g_hdb->setActionMode(1);
+			g_hdb->_sound->playSound(SND_MENU_ACCEPT);
+			_newgameActive = false;
+			g_hdb->changeGameState();
+		}
+	} else if (_optionsActive) {
+		//-------------------------------------------------------------------
+		//	OPTIONS INPUT
+		//-------------------------------------------------------------------
+		int	offset, oldVol;
+
+		int	xit = getMenuKey();
+
+		//
+		// Controls screen
+		//
+		if (_optionsActive == 2) {
+			controlsInput(x, y);
+			return;
+		}
+
+		// Slider 1
+		if (x >= 0 && x <= kOptionsX + 200 &&
+			y >= kOptionsY + 20 && y <= kOptionsY + 36) {
+			oldVol = g_hdb->_sound->getMusicVolume();
+			if (x < kOptionsX) {
+				if (oldVol) {
+					g_hdb->_sound->stopMusic();
+					g_hdb->_sound->setMusicVolume(0);
+					g_hdb->_sound->playSound(SND_GUI_INPUT);
+				}
+			} else {
+				offset = ((x - kOptionsX) * 256) / 200;
+				g_hdb->_sound->setMusicVolume(offset);
+				if (!oldVol)
+					g_hdb->_sound->startMusic(_resumeSong);
+			}
+		} else if (x >= 0 && x <= kOptionsX + 200 &&
+			y >= kOptionsY + kOptionLineSPC * 2 + 20 && y <= kOptionsY + kOptionLineSPC * 2 + 36) {
+			// Slider 2
+			if (x >= kOptionsX)
+				offset = ((x - kOptionsX) * 256) / 200;
+			else
+				offset = 0;
+			g_hdb->_sound->setSFXVolume(offset);
+			g_hdb->_sound->playSound(SND_MENU_SLIDER);
+		} else if (x >= kOptionsX && x <= kOptionsX + 200 &&
+			y >= kOptionsY + kOptionLineSPC * 4 + 24 && y <= kOptionsY + kOptionLineSPC * 4 + 40) {
+			// Voices ON/OFF
+			if (!g_hdb->isVoiceless()) {
+				int value = g_hdb->_sound->getVoiceStatus();
+				value ^= 1;
+				g_hdb->_sound->setVoiceStatus(value);
+				g_hdb->_sound->playSound(SND_GUI_INPUT);
+			}
+		} else if (y >= kMenuExitY || y < kMenuExitYTop || xit) {
+			g_hdb->_sound->playSound(SND_MENU_BACKOUT);
+			_optionsScrolling = true;
+			_optionsXV = -5;
+		} else if (x >= (kScreenWidth / 2 - _controlButtonGfx->_width / 2) && x < (kScreenWidth / 2 + _controlButtonGfx->_width / 2) &&
+			y >= kMControlsY && y < kMControlsY + _controlButtonGfx->_height) {
+			// CONTROLS BUTTON!
+			_optionsActive = 2;
+			_clickDelay = 20;
+			g_hdb->_sound->playSound(SND_POP);
+		}
+	} else if (_gamefilesActive) {
+		//-------------------------------------------------------------------
+		//	GAMEFILES INPUT
+		//-------------------------------------------------------------------
+		int	xit = getMenuKey();
+
+		if (y >= kMenuExitY + 15 || y < kMenuExitYTop || xit) {
+			_optionsScrolling = true;
+			_optionsXV = -5;
+			g_hdb->_sound->playSound(SND_MENU_BACKOUT);
+		}
+
+		int		i;
+		for (i = 0; i < kNumSaveSlots; i++)
+			if (y >= (i * 32 + kSaveSlotY - 4) && y <= (i * 32 + kSaveSlotY + 24))
+				break;
+		if (i >= kNumSaveSlots)
+			return;
+
+		_saveSlot = i;
+
+		// LOAD GAME!
+		{
+			// clicked on empty slot?
+			if (!_saveGames[i].seconds && !_saveGames[i].mapName[0]) {
+				g_hdb->_sound->playSound(SND_MENU_BACKOUT);
+				return;
+			}
+
+			g_hdb->_sound->playSound(SND_MENU_ACCEPT);
+			if (g_hdb->loadGameState(_saveSlot).getCode() == Common::kNoError) {
+				_gamefilesActive = false;
+
+				freeMenu();
+				g_hdb->setGameState(GAME_PLAY);
+				// if we're at the very start of the level, re-init the level
+				if (!_saveGames[i].seconds) {
+					g_hdb->_lua->callFunction("level_loaded", 0); // call "level_loaded" Lua function, if it exists
+					if (!g_hdb->_ai->cinematicsActive())
+						g_hdb->_gfx->turnOffFade();
+				}
+			}
+		}
+	} else if (_warpActive) {
+		//-------------------------------------------------------------------
+		//	WARP INPUT
+		//-------------------------------------------------------------------
+		int		map;
+
+		int	xit = getMenuKey();
+
+		if (y >= kMenuExitY && x < kMenuExitXLeft || xit) {
+			_menuActive = true;
+			_warpActive = false;
+			g_hdb->_sound->playSound(SND_MENU_BACKOUT);
+			_clickDelay = 10;
+		} else if (y >= kWarpY && y < kWarpY + 160) {
+			char	string[16];
+
+			if (x > kWarpX + 160)
+				map = 20;
+			else
+				if (x > kWarpX + 80)
+					map = 10;
+				else
+					map = 0;
+
+			map += (y - kWarpY) / 16;
+
+			_warpActive = map + 2;
+			g_hdb->paint();
+			debug(9, "STUB: Add Debug check");
+			_warpActive = 0;
+
+			if (map < 10)
+				sprintf(string, "MAP0%d", map);
+			else
+				sprintf(string, "MAP%d", map);
+			freeMenu();
+			g_hdb->setGameState(GAME_PLAY);
+			g_hdb->_sound->stopMusic();
+			g_hdb->_ai->clearPersistent();
+			g_hdb->resetTimer();
+			g_hdb->_sound->playSound(SND_POP);
+			g_hdb->startMap(string);
+		}
+	} else if (_quitActive) {
+		//-------------------------------------------------------------------
+		//	QUIT INPUT
+		//-------------------------------------------------------------------
+		int	xit = getMenuKey();
+
+		if ((x >= kQuitNoX1 && x <= kQuitNoX2 && y > kQuitNoY1 && y < kQuitNoY2 && _quitTimer < g_hdb->getTimeSlice()) || xit) {
+			g_hdb->_sound->playSound(SND_MENU_BACKOUT);
+			_quitScreen->free();
+			_quitScreen = NULL;
+
+			_menuActive = true;
+			_quitActive = 0;
+		} else if (_quitTimer < g_hdb->getTimeSlice()) {
+			if (x >= kQuitYesX1 && x <= kQuitYesX2 && y > kQuitYesY1 && y < kQuitYesY2) {
+				writeConfig();
+				warning("STUB: End game: Call Destroy()");
+			}
+		}
+	}
 }
 
 void Menu::controlsInput(int x, int y) {


Commit: 5b4602fdbee1cae593ccc8bc8b8d353a4274f4ac
    https://github.com/scummvm/scummvm/commit/5b4602fdbee1cae593ccc8bc8b8d353a4274f4ac
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:17+02:00

Commit Message:
HDB: Set _menuKey

Changed paths:
    engines/hdb/input.cpp


diff --git a/engines/hdb/input.cpp b/engines/hdb/input.cpp
index 256b6fb..7f37b43 100644
--- a/engines/hdb/input.cpp
+++ b/engines/hdb/input.cpp
@@ -21,6 +21,7 @@
  */
 
 #include "hdb/hdb.h"
+#include "hdb/menu.h"
 
 namespace HDB {
 
@@ -348,10 +349,10 @@ void Input::updateKeys(Common::Event event, bool keyDown) {
 		if (keyDown) {
 			buttons |= kButtonA;
 			g_hdb->_gfx->showPointer(true);
-			warning("STUB: changetoMenu");
+			g_hdb->_menu->setMenuKey(1);
 		} else {
 			buttons &= ~kButtonA;
-			warning("STUB: changetoMenu");
+			g_hdb->_menu->setMenuKey(0);
 		}
 	} else if (event.kbd.keycode == _keyDebug) {
 		if (keyDown) {


Commit: 58512d2123339a137172516d1669fe6fced97d3e
    https://github.com/scummvm/scummvm/commit/58512d2123339a137172516d1669fe6fced97d3e
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:17+02:00

Commit Message:
HDB: Add Bonus Star functions

Changed paths:
    engines/hdb/gfx.cpp
    engines/hdb/gfx.h


diff --git a/engines/hdb/gfx.cpp b/engines/hdb/gfx.cpp
index 57a3d28..ddc397d 100644
--- a/engines/hdb/gfx.cpp
+++ b/engines/hdb/gfx.cpp
@@ -26,6 +26,7 @@ namespace HDB {
 
 Gfx::Gfx() {
 	_tLookupArray = NULL;
+	_starsInfo.active = false;
 	_gfxCache = new Common::Array<GfxCache *>;
 	_globalSurface.create(kScreenWidth, kScreenHeight, g_hdb->_format);
 	_pointerDisplayable = 1;
@@ -780,6 +781,76 @@ void Gfx::getCursor(int *x, int *y) {
 	*y = _cursorY;
 }
 
+void Gfx::turnOnBonusStars(int which) {
+	int	i;
+	_starsInfo.active = true;
+	for (i = 0; i < 10; i++)
+		_starsInfo.starAngle[i] = (36 * (i + 1)) - 10;
+	if (!_starsInfo.gfx[0]) {
+		switch (which) {
+		case 0:		// Red Star
+			_starsInfo.gfx[0] = loadPic(SECRETSTAR_RED1);
+			_starsInfo.gfx[1] = loadPic(SECRETSTAR_RED2);
+			break;
+		case 1:		// Green Star
+			_starsInfo.gfx[0] = loadPic(SECRETSTAR_GREEN1);
+			_starsInfo.gfx[1] = loadPic(SECRETSTAR_GREEN2);
+			break;
+		case 2:		// Blue Star
+			_starsInfo.gfx[0] = loadPic(SECRETSTAR_BLUE1);
+			_starsInfo.gfx[1] = loadPic(SECRETSTAR_BLUE2);
+			break;
+		}
+	}
+
+	_starsInfo.radius = 0;
+	_starsInfo.angleSpeed = 25;
+	_starsInfo.timer = g_hdb->getTimeSlice() + 500;
+	_starsInfo.anim = 0;
+	_starsInfo.totalTime = g_hdb->getTimeSlice() + 5000;		// 5 seconds long
+	g_hdb->_sound->playSound(SND_MONKEYSTONE_SECRET_STAR);
+}
+
+void Gfx::drawBonusStars() {
+	int		i, w, h;
+
+	if (!_starsInfo.active)
+		return;
+
+	if (_starsInfo.timer < g_hdb->getTimeSlice()) {
+		_starsInfo.timer = g_hdb->getTimeSlice() + 500;
+		_starsInfo.anim = 1 - _starsInfo.anim;
+	}
+
+	w = _starsInfo.gfx[0]->_width / 2;
+	h = _starsInfo.gfx[0]->_height / 2;
+
+	for (i = 0; i < 10; i++) {
+		_starsInfo.gfx[_starsInfo.anim]->drawMasked(
+			(int)(480 / 2 + ((float)_starsInfo.radius / 2)) + (int)((double)_starsInfo.radius * _cosines->at(_starsInfo.starAngle[i]) - w),
+			(480 / 2) + (int)((double)_starsInfo.radius * _sines->at(_starsInfo.starAngle[i]) - h)
+		);
+
+		int angle = (int)(_starsInfo.starAngle[i] + _starsInfo.angleSpeed);
+		if (angle >= 360)
+			angle = 0;
+		_starsInfo.starAngle[i] = angle;
+	}
+
+	_starsInfo.radius++;
+	_starsInfo.angleSpeed -= 0.25;
+	if (_starsInfo.angleSpeed < 15)
+		_starsInfo.angleSpeed = 15;
+
+	// timed out?
+	if (_starsInfo.totalTime < g_hdb->getTimeSlice()) {
+		_starsInfo.active = false;
+		_starsInfo.gfx[0]->free();
+		_starsInfo.gfx[1]->free();
+		_starsInfo.gfx[0] = _starsInfo.gfx[1] = 0;
+	}
+}
+
 Picture::Picture() : _width(0), _height(0), _name("") {
 	_surface.create(_width, _height, g_hdb->_format);
 }
diff --git a/engines/hdb/gfx.h b/engines/hdb/gfx.h
index d113df4..a097b6f 100644
--- a/engines/hdb/gfx.h
+++ b/engines/hdb/gfx.h
@@ -161,6 +161,11 @@ public:
 		return _cosines->at(index);
 	}
 
+	// Bonus star functions
+
+	void turnOnBonusStars(int which);
+	void drawBonusStars();
+
 private:
 	int _numTiles;
 	TileLookup *_tLookupArray;
@@ -205,6 +210,16 @@ private:
 	Picture *_starField[4];
 	Picture *_skyClouds;
 
+	struct {
+		bool active;
+		int starAngle[10];
+		Picture *gfx[2];
+		uint32 timer;
+		int anim, radius;
+		double angleSpeed;
+		uint32 totalTime;
+	} _starsInfo;
+
 	// Cursor
 	int _cursorX, _cursorY;
 	Picture *_mousePointer[8];	// Gfx for screen pointer (4 Animations)


Commit: f5b9d417b7b6f2d1a86ba68b22fa84aa04a7992d
    https://github.com/scummvm/scummvm/commit/f5b9d417b7b6f2d1a86ba68b22fa84aa04a7992d
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:17+02:00

Commit Message:
HDB: Set and Draw Bonus Stars

Changed paths:
    engines/hdb/ai-player.cpp
    engines/hdb/ai.h
    engines/hdb/hdb.cpp
    engines/hdb/menu.h


diff --git a/engines/hdb/ai-player.cpp b/engines/hdb/ai-player.cpp
index 6f3ba61..56a08ed 100644
--- a/engines/hdb/ai-player.cpp
+++ b/engines/hdb/ai-player.cpp
@@ -21,6 +21,7 @@
  */
 
 #include "hdb/hdb.h"
+#include "hdb/menu.h"
 
 namespace HDB {
 
@@ -1589,7 +1590,24 @@ void aiMonkeystoneUse(AIEntity *e) {
 	g_hdb->_window->openMessageBar(monkBuff, kMsgDelay);
 
 	// have we unlocked a secret star(tm)???
-	warning("STUB: Set Secret Stars");
+	if (val == 7) {
+		g_hdb->_window->openMessageBar("Red Star is Ready!", kMsgDelay * 2);
+		g_hdb->setStarsMonkeystone7(STARS_MONKEYSTONE_7);
+		g_hdb->_menu->writeConfig();
+		g_hdb->_gfx->turnOnBonusStars(0);
+	}
+	if (val == 14) {
+		g_hdb->_window->openMessageBar("Green Star is GO!", kMsgDelay * 2);
+		g_hdb->setStarsMonkeystone14(STARS_MONKEYSTONE_14);
+		g_hdb->_menu->writeConfig();
+		g_hdb->_gfx->turnOnBonusStars(1);
+	}
+	if (val == 21) {
+		g_hdb->_window->openMessageBar("Blue Star is Born!", kMsgDelay * 2);
+		g_hdb->setStarsMonkeystone21(STARS_MONKEYSTONE_21);
+		g_hdb->_menu->writeConfig();
+		g_hdb->_gfx->turnOnBonusStars(2);
+	}
 }
 
 void aiGemAction(AIEntity *e) {
diff --git a/engines/hdb/ai.h b/engines/hdb/ai.h
index 2e213ce..4ac3eae 100644
--- a/engines/hdb/ai.h
+++ b/engines/hdb/ai.h
@@ -25,6 +25,13 @@
 
 #include "common/system.h"
 
+#define STARS_MONKEYSTONE_7			0xfe257d	// magic value in the config file for the unlocking of the Monkeystone secret #7
+#define STARS_MONKEYSTONE_7_FAKE	0x11887e	// fake value that means it hasn't been unlocked
+#define STARS_MONKEYSTONE_14		0x3341fe	// <same> for the Monkeystone #14
+#define STARS_MONKEYSTONE_14_FAKE	0x1cefd0	// fake value that means it hasn't been unlocked
+#define STARS_MONKEYSTONE_21		0x77ace3	// <same> for the Monkeystone #21
+#define STARS_MONKEYSTONE_21_FAKE	0x3548fe	// fake value that means it hasn't been unlocked
+
 namespace HDB {
 
 enum {
diff --git a/engines/hdb/hdb.cpp b/engines/hdb/hdb.cpp
index 29869e2..72e1aa0 100644
--- a/engines/hdb/hdb.cpp
+++ b/engines/hdb/hdb.cpp
@@ -845,10 +845,11 @@ Common::Error HDBGame::run() {
 			_window->drawInventory();
 			_window->drawMessageBar();
 			_window->drawDeliveries();
+			debug(9, "STUB: Draw Try Again");
+			_window->drawPanicZone();
 			_window->drawTextOut();
 			_window->drawPause();
-
-			//_gfx->drawBonusStars();
+			_gfx->drawBonusStars();
 			_gfx->drawSnow();
 
 			if (_changeLevel == true) {
diff --git a/engines/hdb/menu.h b/engines/hdb/menu.h
index 4c30aeb..59650b6 100644
--- a/engines/hdb/menu.h
+++ b/engines/hdb/menu.h
@@ -25,13 +25,6 @@
 
 namespace HDB {
 
-#define STARS_MONKEYSTONE_7			0xfe257d	// magic value in the config file for the unlocking of the Monkeystone secret #7
-#define STARS_MONKEYSTONE_7_FAKE	0x11887e	// fake value that means it hasn't been unlocked
-#define STARS_MONKEYSTONE_14		0x3341fe	// <same> for the Monkeystone #14
-#define STARS_MONKEYSTONE_14_FAKE	0x1cefd0	// fake value that means it hasn't been unlocked
-#define STARS_MONKEYSTONE_21		0x77ace3	// <same> for the Monkeystone #21
-#define STARS_MONKEYSTONE_21_FAKE	0x3548fe	// fake value that means it hasn't been unlocked
-
 #define	CONFIG_MUSICVOL		"music_volume"
 #define	CONFIG_SOUNDVOL		"sound_volume"
 #define	CONFIG_MSTONE7		"hdb_memory_heap"


Commit: ee9de9157c078885e0886c117e3c12f631176624
    https://github.com/scummvm/scummvm/commit/ee9de9157c078885e0886c117e3c12f631176624
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:17+02:00

Commit Message:
HDB: Add Menu calls

Changed paths:
    engines/hdb/hdb.cpp
    engines/hdb/input.cpp


diff --git a/engines/hdb/hdb.cpp b/engines/hdb/hdb.cpp
index 72e1aa0..534c622 100644
--- a/engines/hdb/hdb.cpp
+++ b/engines/hdb/hdb.cpp
@@ -251,10 +251,10 @@ void HDBGame::paint() {
 
 	switch (_gameState) {
 	case GAME_TITLE:
-		debug(9, "STUB: MENU::DrawTitle required");
+		_menu->drawTitle();
 		break;
 	case GAME_MENU:
-		warning("STUB: MENU::DrawMenu required");
+		_menu->drawMenu();
 		break;
 	case GAME_PLAY:
 		_gfx->drawPointer();
diff --git a/engines/hdb/input.cpp b/engines/hdb/input.cpp
index 7f37b43..fda9431 100644
--- a/engines/hdb/input.cpp
+++ b/engines/hdb/input.cpp
@@ -66,7 +66,7 @@ void Input::setButtons(uint16 b) {
 		}
 
 		if (g_hdb->getGameState() == GAME_TITLE)
-			warning("STUB: setButtons: changeToMenu() required");
+			g_hdb->_menu->changeToMenu();
 		g_hdb->_sound->playSound(SND_MENU_BACKOUT);
 		g_hdb->changeGameState();
 	}
@@ -120,11 +120,11 @@ void Input::stylusDown(int x, int y) {
 
 	switch (gs) {
 	case GAME_TITLE:
-		warning("STUB: Menu: changeToMenu required");
+		g_hdb->_menu->changeToMenu();
 		g_hdb->changeGameState();
 		break;
 	case GAME_MENU:
-		warning("STUB: Menu: processInput required");
+		g_hdb->_menu->processInput(x, y);
 		break;
 	case GAME_PLAY:
 		// Is Player Dead? Click on TRY AGAIN
@@ -207,7 +207,7 @@ void Input::stylusMove(int x, int y) {
 		warning("STUB: stylusMove: Add GetDebug() check");
 		break;
 	case GAME_MENU:
-		warning("STUB: stylusMove: Menu::processInput() required");
+		g_hdb->_menu->processInput(x, y);
 		break;
 	default:
 		break;


Commit: b032068417a11599bbcca52ccef5cce04b789633
    https://github.com/scummvm/scummvm/commit/b032068417a11599bbcca52ccef5cce04b789633
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:17+02:00

Commit Message:
HDB: Add HDBGame::start() and remove AI::clearP...

...ersistent() placeholder

Changed paths:
    engines/hdb/ai-init.cpp
    engines/hdb/hdb.cpp
    engines/hdb/hdb.h
    engines/hdb/menu.cpp


diff --git a/engines/hdb/ai-init.cpp b/engines/hdb/ai-init.cpp
index 5eeff2b..95498dc 100644
--- a/engines/hdb/ai-init.cpp
+++ b/engines/hdb/ai-init.cpp
@@ -905,9 +905,6 @@ AI::AI() {
 	_triggerList = new Common::Array<Trigger *>;
 	_hereList = new Common::Array<HereT *>;
 
-	warning("REMOVE: Remove for final. Used here due to lack of a MENU");
-	_numGems = _numGooCups = _numMonkeystones = _numInventory = _numDeliveries = 0;
-
 	_stunAnim = 0;
 	_stunTimer = g_system->getMillis();
 }
@@ -1031,7 +1028,7 @@ bool AI::init() {
 }
 
 void AI::clearPersistent() {
-	_numGems = _numGooCups = _numMonkeystones = 0;
+	_numGems = _numGooCups = _numMonkeystones = _numInventory = _numDeliveries = 0;
 }
 
 const char *AI::funcLookUp(void(*function)(AIEntity *e)) {
diff --git a/engines/hdb/hdb.cpp b/engines/hdb/hdb.cpp
index 534c622..357aa98 100644
--- a/engines/hdb/hdb.cpp
+++ b/engines/hdb/hdb.cpp
@@ -167,6 +167,10 @@ void HDBGame::changeGameState() {
 	}
 }
 
+void HDBGame::start() {
+	_gameState = GAME_TITLE;
+}
+
 bool HDBGame::restartMap() {
 	if (!_currentMapname[0])
 		return false;
@@ -729,6 +733,8 @@ Common::Error HDBGame::run() {
 	initGraphics(kScreenWidth, kScreenHeight, &_format);
 	_console = new Console();
 
+	start();
+
 #if 0
 	Common::SeekableReadStream *titleStream = _fileMan->findFirstData("monkeylogoscreen", TYPE_PIC);
 	if (titleStream == NULL) {
diff --git a/engines/hdb/hdb.h b/engines/hdb/hdb.h
index 4e0ea0d..9ba967a 100644
--- a/engines/hdb/hdb.h
+++ b/engines/hdb/hdb.h
@@ -164,6 +164,7 @@ public:
 	void save(Common::OutSaveFile *out);
 	void loadSaveFile(Common::InSaveFile *in);
 
+	void start();
 	bool restartMap();
 	bool startMap(const char *name);
 
diff --git a/engines/hdb/menu.cpp b/engines/hdb/menu.cpp
index e03724f..11c8817 100644
--- a/engines/hdb/menu.cpp
+++ b/engines/hdb/menu.cpp
@@ -704,11 +704,6 @@ void Menu::freeMenu() {
 }
 
 bool Menu::startTitle() {
-	// Defaults the game into Action Mode
-	warning("REMOVE: Putting this here since Menu hasn't been implemented yet");
-	g_hdb->setActionMode(1);
-	g_hdb->setGameState(GAME_PLAY);
-
 	int i;
 
 	readConfig();


Commit: eb7e3582ab91cff34f364d205d34135b5568c00f
    https://github.com/scummvm/scummvm/commit/eb7e3582ab91cff34f364d205d34135b5568c00f
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:17+02:00

Commit Message:
HDB: Disable the command-line level-select

Changed paths:
    engines/hdb/hdb.cpp


diff --git a/engines/hdb/hdb.cpp b/engines/hdb/hdb.cpp
index 357aa98..5af3dff 100644
--- a/engines/hdb/hdb.cpp
+++ b/engines/hdb/hdb.cpp
@@ -755,6 +755,7 @@ Common::Error HDBGame::run() {
 	tile->load(tileStream);
 #endif
 
+#if 0
 	if (ConfMan.hasKey("boot_param")) {
 		char mapname[10];
 		int level = ConfMan.getInt("boot_param");
@@ -769,6 +770,7 @@ Common::Error HDBGame::run() {
 		if (!ConfMan.hasKey("save_slot") || (loadGameState(ConfMan.getInt("save_slot")).getCode() != Common::kNoError))
 			startMap("MAP00");
 	}
+#endif
 
 	//_window->openDialog("Sgt. Filibuster", 0, "You address me as 'sarge' or 'sergeant' or get your snappin' teeth kicked in! Got me?", 0, NULL);
 


Commit: d8f454dfe1bbc0490050710f2679b768338d74da
    https://github.com/scummvm/scummvm/commit/d8f454dfe1bbc0490050710f2679b768338d74da
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:17+02:00

Commit Message:
HDB: Initialize Map member variables

Changed paths:
    engines/hdb/map.cpp


diff --git a/engines/hdb/map.cpp b/engines/hdb/map.cpp
index fb84bc0..dd36d03 100644
--- a/engines/hdb/map.cpp
+++ b/engines/hdb/map.cpp
@@ -299,8 +299,11 @@ bool Map::load(Common::SeekableReadStream *stream) {
 	*/
 
 	_mapExplosions = new byte[_width * _height];
+	memset(_mapExplosions, 0, sizeof(_mapExplosions));
 	_mapExpBarrels = new byte[_width * _height];
+	memset(_mapExpBarrels, 0, sizeof(_mapExpBarrels));
 	_mapLaserBeams = new byte[_width * _height];
+	memset(_mapLaserBeams, 0, sizeof(_mapLaserBeams));
 
 	int sky = loadTiles();
 	g_hdb->_gfx->setSky(sky);


Commit: bcaf795b593279aef3faabaa3234d7b35c96f99c
    https://github.com/scummvm/scummvm/commit/bcaf795b593279aef3faabaa3234d7b35c96f99c
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:17+02:00

Commit Message:
HDB: Fix out-of-bounds access bug

Changed paths:
    engines/hdb/gfx.cpp


diff --git a/engines/hdb/gfx.cpp b/engines/hdb/gfx.cpp
index ddc397d..56e8fee 100644
--- a/engines/hdb/gfx.cpp
+++ b/engines/hdb/gfx.cpp
@@ -488,7 +488,7 @@ void Gfx::setup3DStarsLeft() {
 	for (int i = 0; i < kNum3DStars; i++) {
 		_stars3DSlow[i].x = g_hdb->_rnd->getRandomNumber(kScreenWidth);
 		_stars3DSlow[i].y = g_hdb->_rnd->getRandomNumber(kScreenHeight);
-		_stars3DSlow[i].speed = ((double) (1 + g_hdb->_rnd->getRandomNumber(5))) / 6.0;
+		_stars3DSlow[i].speed = ((double) (1 + g_hdb->_rnd->getRandomNumber(4))) / 6.0;
 		_stars3DSlow[i].color = (int) (_stars3DSlow[i].speed * 4.00);
 	}
 }


Commit: 8f83631a3b6eb5e86c3b1cd6708d7dfb652bb3c4
    https://github.com/scummvm/scummvm/commit/8f83631a3b6eb5e86c3b1cd6708d7dfb652bb3c4
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:18+02:00

Commit Message:
HDB: Add macros for RGB-565 conversions

Changed paths:
    engines/hdb/gfx.h


diff --git a/engines/hdb/gfx.h b/engines/hdb/gfx.h
index a097b6f..e384ac9 100644
--- a/engines/hdb/gfx.h
+++ b/engines/hdb/gfx.h
@@ -166,6 +166,20 @@ public:
 	void turnOnBonusStars(int which);
 	void drawBonusStars();
 
+	// Macro to convert RGB into 16-bit
+	uint16 rgbTo565(int r, int g, int b) {
+		return (uint16) (
+			((r & 0xf8) << 8) |
+			((g & 0xfc) << 3) |
+			((b & 0xf8) >> 3)
+		);
+	}
+
+	// Macros to get RGB from 565 short
+#define	getR( x )	( ( x & 0xf800 ) >> 8 )
+#define	getG( x )	( ( x & 0x07e0 ) >> 3 )
+#define	getB( x )	( ( x & 0x001f ) << 3 )
+
 private:
 	int _numTiles;
 	TileLookup *_tLookupArray;


Commit: abe99e332e776820867dab486a2930139c847493
    https://github.com/scummvm/scummvm/commit/abe99e332e776820867dab486a2930139c847493
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:18+02:00

Commit Message:
HDB: Unstub updateFade()

Changed paths:
    engines/hdb/gfx.cpp


diff --git a/engines/hdb/gfx.cpp b/engines/hdb/gfx.cpp
index 56e8fee..be96664 100644
--- a/engines/hdb/gfx.cpp
+++ b/engines/hdb/gfx.cpp
@@ -246,8 +246,98 @@ void Gfx::setFade(bool fadeIn, bool black, int steps) {
 }
 
 void Gfx::updateFade() {
-	_fadeInfo.active = false;
-	debug(9, "STUB: Gfx::updateFade incomplete");
+	uint r, g, b;
+	static int waitAFrame = 0;
+
+	if (!_fadeInfo.active && !_fadeInfo.stayFaded)
+		return;
+
+	Graphics::ManagedSurface fadeBuffer1, fadeBuffer2;
+	fadeBuffer1.create(kScreenWidth, kScreenHeight, g_hdb->_format);
+	fadeBuffer2.create(kScreenWidth, kScreenHeight, g_hdb->_format);
+
+	fadeBuffer2.blitFrom(_globalSurface);
+
+	do {
+		// Copy pristine copy of background to modification buffer
+		fadeBuffer1.blitFrom(fadeBuffer2);
+
+		// do the actual alphablending
+
+		uint16 *ptr, value;
+
+		if (!_fadeInfo.isBlack) {
+			// Black Fade
+
+			for (int y = 0; y < kScreenHeight; y++) {
+				ptr = (uint16 *)fadeBuffer1.getBasePtr(0, y);
+				for (int x = 0; x < kScreenWidth; x++) {
+					value = *ptr;
+					if (value) {
+						*ptr = rgbTo565(
+							(getR(value) * _fadeInfo.curStep) >> 8,
+							(getG(value) * _fadeInfo.curStep) >> 8,
+							(getB(value) * _fadeInfo.curStep) >> 8
+						);
+					}
+					ptr++;
+				}
+			}
+		} else {
+			// White Fade
+
+			for (int y = 0; y < kScreenHeight; y++) {
+				ptr = (uint16 *)fadeBuffer1.getBasePtr(0, y);
+				for (int x = 0; x < kScreenWidth; x++) {
+					value = *ptr;
+					r = getR(value);
+					g = getG(value);
+					b = getB(value);
+					r += (255 - r) * (256 - _fadeInfo.curStep) / 256;
+					g += (255 - g) * (256 - _fadeInfo.curStep) / 256;
+					b += (255 - b) * (256 - _fadeInfo.curStep) / 256;
+					*ptr = rgbTo565(r, g, b);
+					ptr++;
+				}
+			}
+		}
+
+		_globalSurface.blitFrom(fadeBuffer1);
+
+		// step the fading values to the next one and
+		// see if we're done yet
+		if (_fadeInfo.isFadeIn) {
+			if (_fadeInfo.active)
+				_fadeInfo.curStep += _fadeInfo.speed;
+
+			if (_fadeInfo.curStep > 255) {
+				_fadeInfo.curStep = 255;
+				_fadeInfo.active = false;
+				_fadeInfo.stayFaded = false;
+			}
+		} else {
+			if (_fadeInfo.active == true)
+				_fadeInfo.curStep -= _fadeInfo.speed;
+
+			if (_fadeInfo.curStep < 1) {
+				_fadeInfo.curStep = 0;
+				_fadeInfo.active = false;
+				_fadeInfo.stayFaded = false;
+			}
+		}
+
+		// make sure we wait one frame at least - some logic in the game
+		// doesn't draw the frame immediately
+		if (!waitAFrame) {
+			waitAFrame++;
+			return;
+		}
+
+		debug(9, "STUB: DirectX Flip");
+
+	} while (_fadeInfo.active);
+
+	waitAFrame = 0;			// reset counter
 }
 
 void Gfx::turnOnSnow() {


Commit: a7e17c07f7df65095c8c02a038204244d791fc39
    https://github.com/scummvm/scummvm/commit/a7e17c07f7df65095c8c02a038204244d791fc39
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:18+02:00

Commit Message:
HDB: Remove redundant warnings

Changed paths:
    engines/hdb/ai-funcs.cpp


diff --git a/engines/hdb/ai-funcs.cpp b/engines/hdb/ai-funcs.cpp
index 11b504a..e3de845 100644
--- a/engines/hdb/ai-funcs.cpp
+++ b/engines/hdb/ai-funcs.cpp
@@ -940,7 +940,6 @@ void AI::animateEntity(AIEntity *e) {
 			_laserRescan = true;
 			break;
 		default:
-			debug(9, "animateEntity: Unintended Type");
 			break;
 		}
 
@@ -983,7 +982,6 @@ void AI::animateEntity(AIEntity *e) {
 						hit = NULL;
 						break;
 					default:
-						debug(9, "animateEntity: Unintended type");
 						break;
 					}
 				if ((!hit && moveOK) || (bgTileFlags & kFlagPlayerDie))
@@ -995,7 +993,6 @@ void AI::animateEntity(AIEntity *e) {
 				}
 				break;
 			default:
-				debug(9, "animateEntity: Unintended type");
 				break;
 			}
 		} else if (e == _player)
@@ -1019,7 +1016,7 @@ void AI::animateEntity(AIEntity *e) {
 				case DIR_DOWN:	yv = 1;		break;
 				case DIR_LEFT:	xv = -1;	break;
 				case DIR_RIGHT: xv = 1;		break;
-				case DIR_NONE:	warning("animateEntity: DIR_NONE found"); break;
+				case DIR_NONE:	break;
 				}
 
 				bgTileFlags = g_hdb->_map->getMapBGTileFlags(e->tileX + xv, e->tileY + yv);
@@ -1076,7 +1073,6 @@ void AI::animateEntity(AIEntity *e) {
 				yOff = 0;
 				break;
 			case DIR_NONE:
-				warning("AI-FUNCS: animateEntity: DIR_NONE found");
 				break;
 			}
 			if ((e->tileX + xOff == _waypoints[_numWaypoints - 1].x &&
@@ -1148,7 +1144,7 @@ void AI::animateEntity(AIEntity *e) {
 						case DIR_DOWN:	e->goalY = ny;  e->xVel = 0; e->yVel =  kPlayerMoveSpeed; e->state = STATE_MOVEDOWN; break;
 						case DIR_LEFT:	e->goalX = nx;  e->yVel = 0; e->xVel = -kPlayerMoveSpeed; e->state = STATE_MOVELEFT; break;
 						case DIR_RIGHT: e->goalX = nx;  e->yVel = 0; e->xVel =  kPlayerMoveSpeed; e->state = STATE_MOVERIGHT; break;
-						case DIR_NONE:	warning("animateEntity: DIR_NONE found"); break;
+						case DIR_NONE:	break;
 						}
 						if (_playerRunning) {
 							e->xVel = e->xVel << 1;
@@ -1175,7 +1171,7 @@ void AI::animateEntity(AIEntity *e) {
 					_laserRescan = true;
 				break;
 			default:
-				debug(9, "animateEntity: Unintended State");
+				break;
 			}
 
 			// Checking at the Destination
@@ -1224,7 +1220,7 @@ void AI::animateEntity(AIEntity *e) {
 					case DIR_DOWN:	yv = 1; break;
 					case DIR_LEFT:	xv = -1; break;
 					case DIR_RIGHT: xv = 1; break;
-					case DIR_NONE:	warning("animateEntity: DIR_NONE found"); break;
+					case DIR_NONE:	break;
 					}
 
 					hit = findEntityIgnore(e->tileX + xv, e->tileY + yv, &_dummyLaser);


Commit: a869eb00a0d246db8add300e083d831b70dea8ab
    https://github.com/scummvm/scummvm/commit/a869eb00a0d246db8add300e083d831b70dea8ab
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:18+02:00

Commit Message:
HDB: Restore bootparam and save/load from the command line funcitonality

Changed paths:
    engines/hdb/hdb.cpp


diff --git a/engines/hdb/hdb.cpp b/engines/hdb/hdb.cpp
index 5af3dff..eb961f3 100644
--- a/engines/hdb/hdb.cpp
+++ b/engines/hdb/hdb.cpp
@@ -755,7 +755,6 @@ Common::Error HDBGame::run() {
 	tile->load(tileStream);
 #endif
 
-#if 0
 	if (ConfMan.hasKey("boot_param")) {
 		char mapname[10];
 		int level = ConfMan.getInt("boot_param");
@@ -766,11 +765,12 @@ Common::Error HDBGame::run() {
 		snprintf(mapname, 10, "MAP%02d", level);
 
 		startMap(mapname);
+
+		_gameState = GAME_PLAY;
 	} else {
-		if (!ConfMan.hasKey("save_slot") || (loadGameState(ConfMan.getInt("save_slot")).getCode() != Common::kNoError))
-			startMap("MAP00");
+		if (ConfMan.hasKey("save_slot") && loadGameState(ConfMan.getInt("save_slot")).getCode() == Common::kNoError)
+			_gameState = GAME_PLAY;
 	}
-#endif
 
 	//_window->openDialog("Sgt. Filibuster", 0, "You address me as 'sarge' or 'sergeant' or get your snappin' teeth kicked in! Got me?", 0, NULL);
 


Commit: 1874674364a4bf94a378e9009e10c9a8fa13525f
    https://github.com/scummvm/scummvm/commit/1874674364a4bf94a378e9009e10c9a8fa13525f
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:18+02:00

Commit Message:
HDB: More debug for save/load code

Changed paths:
    engines/hdb/saveload.cpp


diff --git a/engines/hdb/saveload.cpp b/engines/hdb/saveload.cpp
index 9c8186d..acda892 100644
--- a/engines/hdb/saveload.cpp
+++ b/engines/hdb/saveload.cpp
@@ -196,7 +196,7 @@ void AIEntity::save(Common::OutSaveFile *out) {
 	lookUp = g_hdb->_ai->funcLookUp(aiAction);
 	memset(&funcString, 0, 32);
 	if (!lookUp && aiAction)
-		error("AIEntity::save: No matching ACTION function for func-string");
+		error("AIEntity::save: No matching ACTION function for func-string for %s entity", AIType2Str(type));
 	if (lookUp)
 		strcpy(funcString, lookUp);
 	out->write(funcString, 32);
@@ -204,7 +204,7 @@ void AIEntity::save(Common::OutSaveFile *out) {
 	lookUp = g_hdb->_ai->funcLookUp(aiUse);
 	memset(&funcString, 0, 32);
 	if (!lookUp && aiUse)
-		error("AIEntity::save: No matching USE function for func-string");
+		error("AIEntity::save: No matching USE function for func-string for %s entity", AIType2Str(type));
 	if (lookUp)
 		strcpy(funcString, lookUp);
 	out->write(funcString, 32);
@@ -212,7 +212,7 @@ void AIEntity::save(Common::OutSaveFile *out) {
 	lookUp = g_hdb->_ai->funcLookUp(aiInit);
 	memset(&funcString, 0, 32);
 	if (!lookUp && aiInit)
-		error("AIEntity::save: No matching INIT function for func-string");
+		error("AIEntity::save: No matching INIT function for func-string for %s entity", AIType2Str(type));
 	if (lookUp)
 		strcpy(funcString, lookUp);
 	out->write(funcString, 32);
@@ -220,7 +220,7 @@ void AIEntity::save(Common::OutSaveFile *out) {
 	lookUp = g_hdb->_ai->funcLookUp(aiInit2);
 	memset(&funcString, 0, 32);
 	if (!lookUp && aiInit2)
-		error("AIEntity::save: No matching INIT2 function for func-string");
+		error("AIEntity::save: No matching INIT2 function for func-string for %s entity", AIType2Str(type));
 	if (lookUp)
 		strcpy(funcString, lookUp);
 	out->write(funcString, 32);
@@ -228,7 +228,7 @@ void AIEntity::save(Common::OutSaveFile *out) {
 	lookUp = g_hdb->_ai->funcLookUp((FuncPtr)aiDraw);
 	memset(&funcString, 0, 32);
 	if (!lookUp && aiDraw)
-		error("AIEntity::save: No matching DRAW function for func-string");
+		error("AIEntity::save: No matching DRAW function for func-string for %s entity", AIType2Str(type));
 	if (lookUp)
 		strcpy(funcString, lookUp);
 	out->write(funcString, 32);


Commit: 1f7e17921893d9eafd7524ad8aa8b2b63973af2c
    https://github.com/scummvm/scummvm/commit/1f7e17921893d9eafd7524ad8aa8b2b63973af2c
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:18+02:00

Commit Message:
HDB: Unstub drawSnow()

Changed paths:
    engines/hdb/gfx.cpp
    engines/hdb/gfx.h


diff --git a/engines/hdb/gfx.cpp b/engines/hdb/gfx.cpp
index be96664..db7ae18 100644
--- a/engines/hdb/gfx.cpp
+++ b/engines/hdb/gfx.cpp
@@ -130,14 +130,11 @@ bool Gfx::init() {
 	_showCursor = true;
 
 	// Load all 4 levels of star colors
-	_starField[0] = getPicture("pic_star64");
-	_starField[1] = getPicture("pic_star128");
-	_starField[2] = getPicture("pic_star192");
-	_starField[3] = getPicture("pic_star256");
-
-	/*
-		TODO: Load the snowflake
-	*/
+	_starField[0] = getPicture(PIC_STAR64);
+	_starField[1] = getPicture(PIC_STAR128);
+	_starField[2] = getPicture(PIC_STAR192);
+	_starField[3] = getPicture(PIC_STAR256);
+	_snowflake = getPicture(PIC_SNOWFLAKE);
 
 	_systemInit = true;
 	return true;
@@ -629,7 +626,21 @@ void Gfx::drawSky() {
 }
 
 void Gfx::drawSnow() {
-	debug(9, "STUB: Gfx::drawSnow()");
+	int		i;
+	if (_snowInfo.active == false)
+		return;
+
+	for (i = 0; i < MAX_SNOW; i++) {
+		_snowflake->drawMasked((int)_snowInfo.x[i], (int)_snowInfo.y[i]);
+		_snowInfo.x[i] += _snowXVList[_snowInfo.xvindex[i]++];
+		_snowInfo.y[i] += _snowInfo.yv[i];
+		if (_snowInfo.xvindex[i] == MAX_SNOW_XV)
+			_snowInfo.xvindex[i] = 0;
+		if (_snowInfo.x[i] < 0)
+			_snowInfo.x[i] = kScreenWidth - 1;
+		if (_snowInfo.y[i] > kScreenHeight - 1)
+			_snowInfo.y[i] = 0;
+	}
 }
 
 int Gfx::animateTile(int tileIndex) {
diff --git a/engines/hdb/gfx.h b/engines/hdb/gfx.h
index e384ac9..d0d9681 100644
--- a/engines/hdb/gfx.h
+++ b/engines/hdb/gfx.h
@@ -208,6 +208,8 @@ private:
 		int     xvindex[MAX_SNOW];
 	} _snowInfo;
 
+	int _snowXVList[13] = {0, -1, -1, -2, -2, -1, 0, 0, 0, -1, -2, -1, 0};
+
 	struct {
 		int x, y, speed;
 		uint16 color;
@@ -222,6 +224,7 @@ private:
 	int _tileSkyStarsLeft; // Left-scrolling stars, slow
 	int _tileSkyClouds; // Index of sky_stars tile
 	Picture *_starField[4];
+	Picture *_snowflake;
 	Picture *_skyClouds;
 
 	struct {


Commit: f27674199bb7c11974ddb1e77f630cbc516288cb
    https://github.com/scummvm/scummvm/commit/f27674199bb7c11974ddb1e77f630cbc516288cb
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:18+02:00

Commit Message:
HDB: Clear the Persistent variables

Changed paths:
    engines/hdb/hdb.cpp


diff --git a/engines/hdb/hdb.cpp b/engines/hdb/hdb.cpp
index eb961f3..826335d 100644
--- a/engines/hdb/hdb.cpp
+++ b/engines/hdb/hdb.cpp
@@ -763,7 +763,7 @@ Common::Error HDBGame::run() {
 			level = 1;
 
 		snprintf(mapname, 10, "MAP%02d", level);
-
+		_ai->clearPersistent();
 		startMap(mapname);
 
 		_gameState = GAME_PLAY;


Commit: 6c5193c71c80a29312661df160b82105da81d2f1
    https://github.com/scummvm/scummvm/commit/6c5193c71c80a29312661df160b82105da81d2f1
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:18+02:00

Commit Message:
HDB: Init _mstoneGfx and replace strings

Changed paths:
    engines/hdb/window.cpp


diff --git a/engines/hdb/window.cpp b/engines/hdb/window.cpp
index 643a11f..cf6b79b 100644
--- a/engines/hdb/window.cpp
+++ b/engines/hdb/window.cpp
@@ -28,49 +28,50 @@ bool Window::init() {
 
 	warning("STUB: Window::init: Incomplete");
 
-	_gfxTL = g_hdb->_gfx->loadPic("menu_back_topleft");
-	_gfxTM = g_hdb->_gfx->loadPic("menu_back_top");
-	_gfxTR = g_hdb->_gfx->loadPic("menu_back_topright");
+	_gfxTL = g_hdb->_gfx->loadPic(MENU_BACK_TOPLEFT);
+	_gfxTM = g_hdb->_gfx->loadPic(MENU_BACK_TOP);
+	_gfxTR = g_hdb->_gfx->loadPic(MENU_BACK_TOPRIGHT);
 
-	_gfxL = g_hdb->_gfx->loadPic("menu_back_left");
-	_gfxM = g_hdb->_gfx->loadPic("menu_back_middle");
-	_gfxR = g_hdb->_gfx->loadPic("menu_back_right");
+	_gfxL = g_hdb->_gfx->loadPic(MENU_BACK_LEFT);
+	_gfxM = g_hdb->_gfx->loadPic(MENU_BACK_MIDDLE);
+	_gfxR = g_hdb->_gfx->loadPic(MENU_BACK_RIGHT);
 
-	_gfxBL = g_hdb->_gfx->loadPic("menu_back_btmleft");
-	_gfxBM = g_hdb->_gfx->loadPic("menu_back_bottom");
-	_gfxBR = g_hdb->_gfx->loadPic("menu_back_btmright");
+	_gfxBL = g_hdb->_gfx->loadPic(MENU_BACK_BTMLEFT);
+	_gfxBM = g_hdb->_gfx->loadPic(MENU_BACK_BOTTOM);
+	_gfxBR = g_hdb->_gfx->loadPic(MENU_BACK_BTMRIGHT);
 
-	_gfxTitleL = g_hdb->_gfx->loadPic("menu_title_left");
-	_gfxTitleM = g_hdb->_gfx->loadPic("menu_title_mid");
-	_gfxTitleR = g_hdb->_gfx->loadPic("menu_title_right");
+	_gfxTitleL = g_hdb->_gfx->loadPic(MENU_TITLE_LEFT);
+	_gfxTitleM = g_hdb->_gfx->loadPic(MENU_TITLE_MID);
+	_gfxTitleR = g_hdb->_gfx->loadPic(MENU_TITLE_RIGHT);
 
-	_gGfxTL = g_hdb->_gfx->loadPic("g_menu_back_topleft");
-	_gGfxTM = g_hdb->_gfx->loadPic("g_menu_back_top");
-	_gGfxTR = g_hdb->_gfx->loadPic("g_menu_back_topright");
+	_gGfxTL = g_hdb->_gfx->loadPic(G_MENU_BACK_TOPLEFT);
+	_gGfxTM = g_hdb->_gfx->loadPic(G_MENU_BACK_TOP);
+	_gGfxTR = g_hdb->_gfx->loadPic(G_MENU_BACK_TOPRIGHT);
 
-	_gGfxL = g_hdb->_gfx->loadPic("g_menu_back_left");
-	_gGfxM = g_hdb->_gfx->loadPic("g_menu_back_middle");
-	_gGfxR = g_hdb->_gfx->loadPic("g_menu_back_right");
+	_gGfxL = g_hdb->_gfx->loadPic(G_MENU_BACK_LEFT);
+	_gGfxM = g_hdb->_gfx->loadPic(G_MENU_BACK_MIDDLE);
+	_gGfxR = g_hdb->_gfx->loadPic(G_MENU_BACK_RIGHT);
 
-	_gGfxBL = g_hdb->_gfx->loadPic("g_menu_back_btmleft");
-	_gGfxBM = g_hdb->_gfx->loadPic("g_menu_back_bottom");
-	_gGfxBR = g_hdb->_gfx->loadPic("g_menu_back_btmright");
+	_gGfxBL = g_hdb->_gfx->loadPic(G_MENU_BACK_BTMLEFT);
+	_gGfxBM = g_hdb->_gfx->loadPic(G_MENU_BACK_BOTTOM);
+	_gGfxBR = g_hdb->_gfx->loadPic(G_MENU_BACK_BTMRIGHT);
 
-	_gGfxTitleL = g_hdb->_gfx->loadPic("g_menu_title_left");
-	_gGfxTitleM = g_hdb->_gfx->loadPic("g_menu_title_mid");
-	_gGfxTitleR = g_hdb->_gfx->loadPic("g_menu_title_right");
+	_gGfxTitleL = g_hdb->_gfx->loadPic(G_MENU_TITLE_LEFT);
+	_gGfxTitleM = g_hdb->_gfx->loadPic(G_MENU_TITLE_MID);
+	_gGfxTitleR = g_hdb->_gfx->loadPic(G_MENU_TITLE_RIGHT);
 
-	_gfxIndent = g_hdb->_gfx->loadPic("menu_delivery_indentation");
-	_gfxArrowTo = g_hdb->_gfx->loadPic("menu_arrow_deliverto");
+	_gfxIndent = g_hdb->_gfx->loadPic(MENU_DELIVERY_INDENTATION);
+	_gfxArrowTo = g_hdb->_gfx->loadPic(MENU_ARROW_DELIVERTO);
 
 	_gfxTry = _gfxAgain = NULL; // They will be loaded when needed
 
-	_gfxInvSelect = g_hdb->_gfx->loadPic("inventory_normal");
-	_gfxHandright = g_hdb->_gfx->loadPic("menu_hand_pointright");
+	_gfxInvSelect = g_hdb->_gfx->loadPic(INVENTORY_NORMAL);
+	_gfxHandright = g_hdb->_gfx->loadPic(MENU_HAND_POINTRIGHT);
 
-	_gfxInfobar = g_hdb->_gfx->loadPic("pic_infobar");
-	_gfxDarken = g_hdb->_gfx->loadPic("screen_darken");
-	_gfxPausePlaque = g_hdb->_gfx->loadPic("pause_plaque");
+	_gfxInfobar = g_hdb->_gfx->loadPic(PIC_INFOBAR);
+	_gfxDarken = g_hdb->_gfx->loadPic(SCREEN_DARKEN);
+	_gfxPausePlaque = g_hdb->_gfx->loadPic(PAUSE_PLAQUE);
+	_mstoneGfx = g_hdb->_gfx->loadPic(MINI_MSTONE);
 
 	_infobarDimmed = 0;
 


Commit: 792333b6ccca0175bbb1bf8d2ecae359613e47c7
    https://github.com/scummvm/scummvm/commit/792333b6ccca0175bbb1bf8d2ecae359613e47c7
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:18+02:00

Commit Message:
HDB: Show cursor in the main menu

Changed paths:
    engines/hdb/hdb.cpp


diff --git a/engines/hdb/hdb.cpp b/engines/hdb/hdb.cpp
index 826335d..ebeb4ae 100644
--- a/engines/hdb/hdb.cpp
+++ b/engines/hdb/hdb.cpp
@@ -259,7 +259,7 @@ void HDBGame::paint() {
 		break;
 	case GAME_MENU:
 		_menu->drawMenu();
-		break;
+		// fall through
 	case GAME_PLAY:
 		_gfx->drawPointer();
 		break;


Commit: b052946c61a7810e81a12a5b7c1273e57823d3b1
    https://github.com/scummvm/scummvm/commit/b052946c61a7810e81a12a5b7c1273e57823d3b1
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:18+02:00

Commit Message:
HDB: Add mode-select to the level-select

Add +100 to the level num to access the level in
Action Mode

Changed paths:
    engines/hdb/hdb.cpp


diff --git a/engines/hdb/hdb.cpp b/engines/hdb/hdb.cpp
index ebeb4ae..d0b4b51 100644
--- a/engines/hdb/hdb.cpp
+++ b/engines/hdb/hdb.cpp
@@ -757,10 +757,22 @@ Common::Error HDBGame::run() {
 
 	if (ConfMan.hasKey("boot_param")) {
 		char mapname[10];
-		int level = ConfMan.getInt("boot_param");
+		int level = 0;
 
-		if (level > 30 || level < 0)
+		int arg = ConfMan.getInt("boot_param");
+
+		if (arg < 0 || arg > 130 || (30 < arg && arg < 100)) {
+			setActionMode(0);
 			level = 1;
+		} else if (100 <= arg && arg <= 130) {
+			setActionMode(1);
+			level = arg - 100;
+		} else if (0 <= arg && arg <= 30) {
+			setActionMode(0);
+			level = arg;
+		}
+
+		debug("Starting level %d in %s", level, getActionMode() ? "Action Mode" : "Puzzle Mode");
 
 		snprintf(mapname, 10, "MAP%02d", level);
 		_ai->clearPersistent();


Commit: 0bd8e53f88ef40318a90a0c8568d88762ee841a4
    https://github.com/scummvm/scummvm/commit/0bd8e53f88ef40318a90a0c8568d88762ee841a4
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:18+02:00

Commit Message:
HDB: Unstub DirectX Flip

Changed paths:
    engines/hdb/gfx.cpp


diff --git a/engines/hdb/gfx.cpp b/engines/hdb/gfx.cpp
index db7ae18..4b2f7b6 100644
--- a/engines/hdb/gfx.cpp
+++ b/engines/hdb/gfx.cpp
@@ -330,7 +330,8 @@ void Gfx::updateFade() {
 			return;
 		}
 
-		debug(9, "STUB: DirectX Flip");
+		g_system->updateScreen();
+		g_system->delayMillis(1000 / kGameFPS);
 
 	} while (_fadeInfo.active);
 


Commit: 190b550caaa8b5070e9fdda78555b30e1a340af3
    https://github.com/scummvm/scummvm/commit/190b550caaa8b5070e9fdda78555b30e1a340af3
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:18+02:00

Commit Message:
HDB: Replace original color functions

With the ones from Graphics::PixelFormat

Changed paths:
    engines/hdb/gfx.cpp
    engines/hdb/gfx.h


diff --git a/engines/hdb/gfx.cpp b/engines/hdb/gfx.cpp
index 4b2f7b6..1000d97 100644
--- a/engines/hdb/gfx.cpp
+++ b/engines/hdb/gfx.cpp
@@ -243,7 +243,7 @@ void Gfx::setFade(bool fadeIn, bool black, int steps) {
 }
 
 void Gfx::updateFade() {
-	uint r, g, b;
+	uint8 r, g, b;
 	static int waitAFrame = 0;
 
 	if (!_fadeInfo.active && !_fadeInfo.stayFaded)
@@ -271,11 +271,11 @@ void Gfx::updateFade() {
 				for (int x = 0; x < kScreenWidth; x++) {
 					value = *ptr;
 					if (value) {
-						*ptr = rgbTo565(
-							(getR(value) * _fadeInfo.curStep) >> 8,
-							(getG(value) * _fadeInfo.curStep) >> 8,
-							(getB(value) * _fadeInfo.curStep) >> 8
-						);
+						g_hdb->_format.colorToRGB(value, r, g, b);
+						r = (r * _fadeInfo.curStep) >> 8;
+						g = (g * _fadeInfo.curStep) >> 8;
+						b = (b * _fadeInfo.curStep) >> 8;
+						*ptr = g_hdb->_format.RGBToColor(r, g, b);
 					}
 					ptr++;
 				}
@@ -287,13 +287,11 @@ void Gfx::updateFade() {
 				ptr = (uint16 *)fadeBuffer1.getBasePtr(0, y);
 				for (int x = 0; x < kScreenWidth; x++) {
 					value = *ptr;
-					r = getR(value);
-					g = getG(value);
-					b = getB(value);
+					g_hdb->_format.colorToRGB(value, r, g, b);
 					r += (255 - r) * (256 - _fadeInfo.curStep) / 256;
 					g += (255 - g) * (256 - _fadeInfo.curStep) / 256;
 					b += (255 - b) * (256 - _fadeInfo.curStep) / 256;
-					*ptr = rgbTo565(r, g, b);
+					*ptr = g_hdb->_format.RGBToColor(r, g, b);
 					ptr++;
 				}
 			}
diff --git a/engines/hdb/gfx.h b/engines/hdb/gfx.h
index d0d9681..a9df0c3 100644
--- a/engines/hdb/gfx.h
+++ b/engines/hdb/gfx.h
@@ -166,20 +166,6 @@ public:
 	void turnOnBonusStars(int which);
 	void drawBonusStars();
 
-	// Macro to convert RGB into 16-bit
-	uint16 rgbTo565(int r, int g, int b) {
-		return (uint16) (
-			((r & 0xf8) << 8) |
-			((g & 0xfc) << 3) |
-			((b & 0xf8) >> 3)
-		);
-	}
-
-	// Macros to get RGB from 565 short
-#define	getR( x )	( ( x & 0xf800 ) >> 8 )
-#define	getG( x )	( ( x & 0x07e0 ) >> 3 )
-#define	getB( x )	( ( x & 0x001f ) << 3 )
-
 private:
 	int _numTiles;
 	TileLookup *_tLookupArray;


Commit: c5bc56b33109df027f231a4a590995994e833697
    https://github.com/scummvm/scummvm/commit/c5bc56b33109df027f231a4a590995994e833697
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:18+02:00

Commit Message:
HDB: Add Loading Screen

Changed paths:
    engines/hdb/gfx.cpp
    engines/hdb/gfx.h
    engines/hdb/hdb.cpp
    engines/hdb/hdb.h
    engines/hdb/map.cpp


diff --git a/engines/hdb/gfx.cpp b/engines/hdb/gfx.cpp
index 1000d97..9ba6040 100644
--- a/engines/hdb/gfx.cpp
+++ b/engines/hdb/gfx.cpp
@@ -199,6 +199,7 @@ void Gfx::fillScreen(uint32 color) {
 
 void Gfx::updateVideo() {
 	updateFade();
+	g_hdb->checkProgress();
 	debug(9, "STUB: Gfx::updateVideo incomplete");
 }
 
diff --git a/engines/hdb/gfx.h b/engines/hdb/gfx.h
index a9df0c3..28ebcba 100644
--- a/engines/hdb/gfx.h
+++ b/engines/hdb/gfx.h
@@ -42,7 +42,8 @@ enum {
 	kAnimFrameDelay = kGameFPS / 30,
 	kAnimSlowFrames = kAnimFrameDelay * 10,
 	kAnimMediumFrames = kAnimFrameDelay * 6,
-	kAnimFastFrames = kAnimFrameDelay * 2
+	kAnimFastFrames = kAnimFrameDelay * 2,
+	kProgressY = (kScreenHeight - 64)
 };
 
 class Tile;
diff --git a/engines/hdb/hdb.cpp b/engines/hdb/hdb.cpp
index d0b4b51..f4cc45f 100644
--- a/engines/hdb/hdb.cpp
+++ b/engines/hdb/hdb.cpp
@@ -118,6 +118,10 @@ bool HDBGame::init() {
 
 	_menu->init();
 
+	_progressGfx = _gfx->loadPic(PIC_LOADBAR);
+	_progressMarkGfx = _gfx->loadPic(PIC_LOADSTAR);
+	_logoGfx = NULL;
+
 	_changeLevel = false;
 	_changeMapname[0] = 0;
 	_loadInfo.active = _saveInfo.active = false;
@@ -127,6 +131,7 @@ bool HDBGame::init() {
 	_gameShutdown = false;
 	_pauseFlag = 0;
 	_systemInit = true;
+	_loadingScreenGfx = _gfx->loadPic(PIC_LOADSCREEN);
 
 	return true;
 }
@@ -264,7 +269,17 @@ void HDBGame::paint() {
 		_gfx->drawPointer();
 		break;
 	case GAME_LOADING:
-		warning("STUB: Gfx::DrawLoadingScreen required");
+		// clear video, then draw HDB logo
+		drawLoadingScreen();
+
+		// if the graphic has never been loaded, load it now and leave it in memory
+		if (!_logoGfx)
+			_logoGfx = _gfx->loadPic(TITLELOGO);
+		_logoGfx->drawMasked(kScreenWidth / 2 - _logoGfx->_width / 2, 10);
+
+		int	x = kScreenWidth / 2 - _progressGfx->_width / 2;
+		int pixels = _progressGfx->_width - _progressMarkGfx->_width;
+		_progressXOffset = (int)(((double)pixels / _progressMax) * (double)_progressCurrent) + x;
 		break;
 	}
 
@@ -670,6 +685,38 @@ void HDBGame::useEntity(AIEntity *e) {
 	}
 }
 
+void HDBGame::setupProgressBar(int maxCount) {
+	_progressMax = maxCount;
+	_progressCurrent = 0;
+	_progressActive = true;
+}
+
+void HDBGame::drawProgressBar() {
+	if (!_progressActive)
+		return;
+
+	GameState temp = _gameState;
+	_gameState = GAME_LOADING;
+	_gameState = temp;
+}
+
+void HDBGame::checkProgress() {
+	int x, i;
+
+	if (!_progressActive)
+		return;
+
+	x = kScreenWidth / 2 - _progressGfx->_width / 2;
+	_progressGfx->drawMasked(x, kProgressY);
+	for (i = x; i < _progressXOffset; i += _progressMarkGfx->_width)
+		_progressMarkGfx->drawMasked(i, kProgressY);
+	_progressMarkGfx->drawMasked(_progressXOffset, kProgressY);
+}
+
+void HDBGame::drawLoadingScreen() {
+	_loadingScreenGfx->draw(0, 0);
+}
+
 struct {
 	const char *fName, *printName;
 } mapNames[] = {
diff --git a/engines/hdb/hdb.h b/engines/hdb/hdb.h
index 9ba967a..739a00e 100644
--- a/engines/hdb/hdb.h
+++ b/engines/hdb/hdb.h
@@ -200,6 +200,18 @@ public:
 	void setTargetXY(int x, int y);
 	void useEntity(AIEntity *e);
 
+	void setupProgressBar(int maxCount);
+	void drawProgressBar();
+	void makeProgress() {
+		_progressCurrent++;
+		drawProgressBar();
+	}
+	void checkProgress();
+	void stopProgress() {
+		_progressActive = false;
+	}
+	void drawLoadingScreen();
+
 	int getActionMode() {
 		return _actionMode;
 	}
@@ -290,8 +302,15 @@ private:
 	bool _systemInit;
 	GameState _gameState;
 	int _actionMode; // 0 or 1
+
+	// Misc Variables
 	int _pauseFlag;
+
 	bool _cheating;
+	Picture *_progressGfx, *_progressMarkGfx;
+	Picture *_loadingScreenGfx, *_logoGfx;
+	bool _progressActive;
+	int _progressCurrent, _progressXOffset, _progressMax;
 
 	char _currentMapname[64];
 	char _lastMapname[64];
diff --git a/engines/hdb/map.cpp b/engines/hdb/map.cpp
index dd36d03..29183c8 100644
--- a/engines/hdb/map.cpp
+++ b/engines/hdb/map.cpp
@@ -572,8 +572,11 @@ bool Map::load(Common::SeekableReadStream *stream) {
 	};
 
 	// Scan all icons and init all Entities
-	warning("STUB: Map::load: SetupProgressBar");
+	g_hdb->setupProgressBar(_iconNum);
 	for (int i = 0; i < _iconNum; i++) {
+
+		g_hdb->makeProgress();
+
 		// Don't spawn Action Mode Entities in Puzzle Mode
 		if (!g_hdb->getActionMode()) {
 			switch (aiInfo[_iconList[i].icon].type) {
@@ -587,7 +590,7 @@ bool Map::load(Common::SeekableReadStream *stream) {
 			case ITEM_SLUGSLINGER:
 				continue;
 			default:
-				warning("MAP-LOADER: load: Unintended Type");
+				break;
 			}
 		}
 


Commit: 812a8c7c9dd7cf7d330580594c3c256224fcd429
    https://github.com/scummvm/scummvm/commit/812a8c7c9dd7cf7d330580594c3c256224fcd429
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:18+02:00

Commit Message:
HDB: Remove redundant warning

Changed paths:
    engines/hdb/input.cpp


diff --git a/engines/hdb/input.cpp b/engines/hdb/input.cpp
index fda9431..21267f5 100644
--- a/engines/hdb/input.cpp
+++ b/engines/hdb/input.cpp
@@ -188,7 +188,6 @@ void Input::stylusDown(int x, int y) {
 		g_hdb->setTargetXY(worldX, worldY);
 		break;
 	case GAME_LOADING:
-		debug(9, "stylusDown: GAME_LOADING found");
 		break;
 	}
 }


Commit: 24468bf630dbefb17d72211e5a8cbc67730dcd24
    https://github.com/scummvm/scummvm/commit/24468bf630dbefb17d72211e5a8cbc67730dcd24
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:18+02:00

Commit Message:
HDB: Fix warnings

Changed paths:
    engines/hdb/gfx.cpp
    engines/hdb/gfx.h
    engines/hdb/menu.cpp
    engines/hdb/menu.h


diff --git a/engines/hdb/gfx.cpp b/engines/hdb/gfx.cpp
index 9ba6040..999cf3e 100644
--- a/engines/hdb/gfx.cpp
+++ b/engines/hdb/gfx.cpp
@@ -625,6 +625,9 @@ void Gfx::drawSky() {
 	}
 }
 
+static const int snowXVList[13] = {0, -1, -1, -2, -2, -1, 0, 0, 0, -1, -2, -1, 0};
+
+
 void Gfx::drawSnow() {
 	int		i;
 	if (_snowInfo.active == false)
@@ -632,7 +635,7 @@ void Gfx::drawSnow() {
 
 	for (i = 0; i < MAX_SNOW; i++) {
 		_snowflake->drawMasked((int)_snowInfo.x[i], (int)_snowInfo.y[i]);
-		_snowInfo.x[i] += _snowXVList[_snowInfo.xvindex[i]++];
+		_snowInfo.x[i] += snowXVList[_snowInfo.xvindex[i]++];
 		_snowInfo.y[i] += _snowInfo.yv[i];
 		if (_snowInfo.xvindex[i] == MAX_SNOW_XV)
 			_snowInfo.xvindex[i] = 0;
diff --git a/engines/hdb/gfx.h b/engines/hdb/gfx.h
index 28ebcba..371174b 100644
--- a/engines/hdb/gfx.h
+++ b/engines/hdb/gfx.h
@@ -195,8 +195,6 @@ private:
 		int     xvindex[MAX_SNOW];
 	} _snowInfo;
 
-	int _snowXVList[13] = {0, -1, -1, -2, -2, -1, 0, 0, 0, -1, -2, -1, 0};
-
 	struct {
 		int x, y, speed;
 		uint16 color;
diff --git a/engines/hdb/menu.cpp b/engines/hdb/menu.cpp
index 11c8817..2c524fc 100644
--- a/engines/hdb/menu.cpp
+++ b/engines/hdb/menu.cpp
@@ -153,6 +153,17 @@ void Menu::writeConfig() {
 		ConfMan.set(CONFIG_CHEAT, "1");
 }
 
+static const char nebulaNames[kNebulaCount][32] = {
+	BACKSCROLL_PLANET1,
+	BACKSCROLL_PLANET2,
+	BACKSCROLL_PLANET3,
+	BACKSCROLL_PLANET4,
+	BACKSCROLL_PLANET5,
+	BACKSCROLL_GALAXY1,
+	BACKSCROLL_GALAXY2
+};
+
+
 void Menu::startMenu() {
 	int	i;
 
@@ -1183,7 +1194,7 @@ void Menu::processInput(int x, int y) {
 
 		int	xit = getMenuKey();
 
-		if (y >= kMenuExitY && x < kMenuExitXLeft || xit) {
+		if ((y >= kMenuExitY && x < kMenuExitXLeft) || xit) {
 			_menuActive = true;
 			_warpActive = false;
 			g_hdb->_sound->playSound(SND_MENU_BACKOUT);
diff --git a/engines/hdb/menu.h b/engines/hdb/menu.h
index 59650b6..0a0cb0d 100644
--- a/engines/hdb/menu.h
+++ b/engines/hdb/menu.h
@@ -229,16 +229,6 @@ public:
 
 	Star _fStars[kMaxStars];
 
-	char nebulaNames[kNebulaCount][32] = {
-		BACKSCROLL_PLANET1,
-		BACKSCROLL_PLANET2,
-		BACKSCROLL_PLANET3,
-		BACKSCROLL_PLANET4,
-		BACKSCROLL_PLANET5,
-		BACKSCROLL_GALAXY1,
-		BACKSCROLL_GALAXY2
-	};
-
 	int _menuKey;
 };
 


Commit: 9903b335e1f833539c6b58bb5811411e5f5bad49
    https://github.com/scummvm/scummvm/commit/9903b335e1f833539c6b58bb5811411e5f5bad49
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:18+02:00

Commit Message:
HDB: Proper memory handling for map features

Changed paths:
    engines/hdb/map.cpp


diff --git a/engines/hdb/map.cpp b/engines/hdb/map.cpp
index 29183c8..86bd03f 100644
--- a/engines/hdb/map.cpp
+++ b/engines/hdb/map.cpp
@@ -30,6 +30,11 @@ Map::Map() {
 	_animCycle = 0;
 
 	_numForegrounds = _numGratings = 0;
+
+	_mapExplosions = NULL;
+	_mapExpBarrels = NULL;
+	_mapLaserBeams = NULL;
+
 }
 
 Map::~Map() {
@@ -214,6 +219,14 @@ int Map::loadTiles() {
 
 void Map::restartSystem() {
 	warning("STUB: Map::restartSystem()");
+
+	free(_mapExplosions);
+	free(_mapExpBarrels);
+	free(_mapLaserBeams);
+
+	_mapExplosions = NULL;
+	_mapExpBarrels = NULL;
+	_mapLaserBeams = NULL;
 }
 
 bool Map::loadMap(char *name) {
@@ -298,12 +311,9 @@ bool Map::load(Common::SeekableReadStream *stream) {
 		TODO: Set the InMapName once its setup
 	*/
 
-	_mapExplosions = new byte[_width * _height];
-	memset(_mapExplosions, 0, sizeof(_mapExplosions));
-	_mapExpBarrels = new byte[_width * _height];
-	memset(_mapExpBarrels, 0, sizeof(_mapExpBarrels));
-	_mapLaserBeams = new byte[_width * _height];
-	memset(_mapLaserBeams, 0, sizeof(_mapLaserBeams));
+	_mapExplosions = (byte *)calloc(_width * _height, 1);
+	_mapExpBarrels = (byte *)calloc(_width * _height, 1);
+	_mapLaserBeams = (byte *)calloc(_width * _height, 1);
 
 	int sky = loadTiles();
 	g_hdb->_gfx->setSky(sky);


Commit: c0777f5a032a92d0c0c03f57504b02a40ef2a5e6
    https://github.com/scummvm/scummvm/commit/c0777f5a032a92d0c0c03f57504b02a40ef2a5e6
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:18+02:00

Commit Message:
HDB: Add missing paint() call

Changed paths:
    engines/hdb/hdb.cpp


diff --git a/engines/hdb/hdb.cpp b/engines/hdb/hdb.cpp
index f4cc45f..002e0cf 100644
--- a/engines/hdb/hdb.cpp
+++ b/engines/hdb/hdb.cpp
@@ -697,6 +697,7 @@ void HDBGame::drawProgressBar() {
 
 	GameState temp = _gameState;
 	_gameState = GAME_LOADING;
+	paint();
 	_gameState = temp;
 }
 


Commit: 0cd4f43862d2a419b2a730e87c63f3eff54652fb
    https://github.com/scummvm/scummvm/commit/0cd4f43862d2a419b2a730e87c63f3eff54652fb
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:18+02:00

Commit Message:
HDB: Unstub updateVideo()

Changed paths:
    engines/hdb/gfx.cpp


diff --git a/engines/hdb/gfx.cpp b/engines/hdb/gfx.cpp
index 999cf3e..00fa48b 100644
--- a/engines/hdb/gfx.cpp
+++ b/engines/hdb/gfx.cpp
@@ -198,9 +198,16 @@ void Gfx::fillScreen(uint32 color) {
 }
 
 void Gfx::updateVideo() {
+
+	uint32 timer = g_system->getMillis();
+
 	updateFade();
 	g_hdb->checkProgress();
 	debug(9, "STUB: Gfx::updateVideo incomplete");
+
+	warning("STUB: Blit the Backbuffer to the primary surface");
+
+	while (g_system->getMillis() - timer < 16) {};
 }
 
 void Gfx::drawPointer() {


Commit: 1feb91b2f8fd4b22ab6911466d136ea342e4c054
    https://github.com/scummvm/scummvm/commit/1feb91b2f8fd4b22ab6911466d136ea342e4c054
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:18+02:00

Commit Message:
HDB: Simplify bootparam processing

Changed paths:
    engines/hdb/hdb.cpp


diff --git a/engines/hdb/hdb.cpp b/engines/hdb/hdb.cpp
index 002e0cf..ad16393 100644
--- a/engines/hdb/hdb.cpp
+++ b/engines/hdb/hdb.cpp
@@ -805,20 +805,11 @@ Common::Error HDBGame::run() {
 
 	if (ConfMan.hasKey("boot_param")) {
 		char mapname[10];
-		int level = 0;
-
 		int arg = ConfMan.getInt("boot_param");
+		int actionMode = MIN(arg / 100, 1);
+		int level = MIN(arg % 100, 30);
 
-		if (arg < 0 || arg > 130 || (30 < arg && arg < 100)) {
-			setActionMode(0);
-			level = 1;
-		} else if (100 <= arg && arg <= 130) {
-			setActionMode(1);
-			level = arg - 100;
-		} else if (0 <= arg && arg <= 30) {
-			setActionMode(0);
-			level = arg;
-		}
+		setActionMode(actionMode);
 
 		debug("Starting level %d in %s", level, getActionMode() ? "Action Mode" : "Puzzle Mode");
 


Commit: c5d1ea304b38f22fc7927ef16875b1ef82036886
    https://github.com/scummvm/scummvm/commit/c5d1ea304b38f22fc7927ef16875b1ef82036886
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:18+02:00

Commit Message:
HDB: Unstubbing updateVideo()

Changed paths:
    engines/hdb/gfx.cpp
    engines/hdb/gfx.h
    engines/hdb/hdb.h


diff --git a/engines/hdb/gfx.cpp b/engines/hdb/gfx.cpp
index 00fa48b..19109c3 100644
--- a/engines/hdb/gfx.cpp
+++ b/engines/hdb/gfx.cpp
@@ -203,9 +203,18 @@ void Gfx::updateVideo() {
 
 	updateFade();
 	g_hdb->checkProgress();
-	debug(9, "STUB: Gfx::updateVideo incomplete");
 
-	warning("STUB: Blit the Backbuffer to the primary surface");
+	if (!g_hdb->_progressGfx)
+		return;
+
+	int left = kScreenWidth / 2 - g_hdb->_progressGfx->_width / 2;
+
+	Common::Rect clip(g_hdb->_progressGfx->getSurface()->getBounds());
+	clip.moveTo(left, kProgressY);
+	clip.clip(g_hdb->_gfx->_globalSurface.getBounds());
+	if (!clip.isEmpty()) {
+		g_system->copyRectToScreen(g_hdb->_gfx->_globalSurface.getBasePtr(clip.left, clip.top), g_hdb->_gfx->_globalSurface.pitch, clip.left, clip.top, clip.width(), clip.height());
+	}
 
 	while (g_system->getMillis() - timer < 16) {};
 }
diff --git a/engines/hdb/gfx.h b/engines/hdb/gfx.h
index 371174b..36204c5 100644
--- a/engines/hdb/gfx.h
+++ b/engines/hdb/gfx.h
@@ -257,12 +257,12 @@ public:
 
 	char *getName() { return _name; }
 
-private:
+	Graphics::ManagedSurface *getSurface() { return &_surface; }
 
+private:
 	char _name[64];
 
 	Graphics::ManagedSurface _surface;
-
 };
 
 class Tile {
diff --git a/engines/hdb/hdb.h b/engines/hdb/hdb.h
index 739a00e..b7f12a3 100644
--- a/engines/hdb/hdb.h
+++ b/engines/hdb/hdb.h
@@ -287,6 +287,11 @@ public:
 	bool _gameShutdown;
 	Graphics::PixelFormat _format;
 
+	Picture *_progressGfx, *_progressMarkGfx;
+	Picture *_loadingScreenGfx, *_logoGfx;
+	bool _progressActive;
+	int _progressCurrent, _progressXOffset, _progressMax;
+
 private:
 
 	uint32 _timePlayed;
@@ -305,12 +310,7 @@ private:
 
 	// Misc Variables
 	int _pauseFlag;
-
 	bool _cheating;
-	Picture *_progressGfx, *_progressMarkGfx;
-	Picture *_loadingScreenGfx, *_logoGfx;
-	bool _progressActive;
-	int _progressCurrent, _progressXOffset, _progressMax;
 
 	char _currentMapname[64];
 	char _lastMapname[64];


Commit: a35cf6cb93bf3b7ce4ab78ee85a00ac2186e688b
    https://github.com/scummvm/scummvm/commit/a35cf6cb93bf3b7ce4ab78ee85a00ac2186e688b
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:18+02:00

Commit Message:
HDB: Added SetDebug/GetDebug, no relevant functionality

Changed paths:
    engines/hdb/hdb.cpp
    engines/hdb/hdb.h


diff --git a/engines/hdb/hdb.cpp b/engines/hdb/hdb.cpp
index ad16393..da9107a 100644
--- a/engines/hdb/hdb.cpp
+++ b/engines/hdb/hdb.cpp
@@ -174,6 +174,8 @@ void HDBGame::changeGameState() {
 
 void HDBGame::start() {
 	_gameState = GAME_TITLE;
+
+	_debugFlag = 0;
 }
 
 bool HDBGame::restartMap() {
diff --git a/engines/hdb/hdb.h b/engines/hdb/hdb.h
index b7f12a3..549eed3 100644
--- a/engines/hdb/hdb.h
+++ b/engines/hdb/hdb.h
@@ -222,6 +222,7 @@ public:
 	void togglePause() {
 		_pauseFlag ^= 1;
 	}
+
 	int getPause() {
 		return _pauseFlag;
 	}
@@ -246,9 +247,12 @@ public:
 		return &_targetName;
 	}
 
+	int getDebug() { return _debugFlag; }
+	void setDebug(int flag) { _debugFlag = flag; }
+
 	bool isVoiceless() {
 		/*
-			FIXME: Add hyperspace-nv.mpc to gameDescriptions[] 
+			FIXME: Add hyperspace-nv.mpc to gameDescriptions[]
 			in detection.cpp, and add a flag check for it.
 			Until then, the voiceless version is unsupported.
 		*/
@@ -311,6 +315,7 @@ private:
 	// Misc Variables
 	int _pauseFlag;
 	bool _cheating;
+	int _debugFlag;
 
 	char _currentMapname[64];
 	char _lastMapname[64];


Commit: 2be5c59d952eb53748bf9977d53f0689ea93e53f
    https://github.com/scummvm/scummvm/commit/2be5c59d952eb53748bf9977d53f0689ea93e53f
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:18+02:00

Commit Message:
HDB: Complete checkPlayerTileCollision()

Changed paths:
    engines/hdb/ai-funcs.cpp


diff --git a/engines/hdb/ai-funcs.cpp b/engines/hdb/ai-funcs.cpp
index e3de845..4988974 100644
--- a/engines/hdb/ai-funcs.cpp
+++ b/engines/hdb/ai-funcs.cpp
@@ -2046,7 +2046,9 @@ AIEntity *AI::playerCollision(int topBorder, int bottomBorder, int leftBorder, i
 }
 
 bool AI::checkPlayerTileCollision(int x, int y) {
-	debug(9, "STUB: checkPlayerTileCollison: g_hdb->getDebug() required");
+	if (g_hdb->getDebug() == 2)
+		return false;
+
 	return (_player->tileX == x && _player->tileY == y);
 }
 


Commit: 35ead09d754916dc6505b2114d4859851bf89a24
    https://github.com/scummvm/scummvm/commit/35ead09d754916dc6505b2114d4859851bf89a24
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:18+02:00

Commit Message:
HDB: Complete AI::drawLevel2Ents()

Changed paths:
    engines/hdb/ai-funcs.cpp


diff --git a/engines/hdb/ai-funcs.cpp b/engines/hdb/ai-funcs.cpp
index 4988974..26ba651 100644
--- a/engines/hdb/ai-funcs.cpp
+++ b/engines/hdb/ai-funcs.cpp
@@ -1759,7 +1759,7 @@ void AI::drawEnts(int x, int y, int w, int h) {
 }
 
 void AI::drawLevel2Ents() {
-	int debugging = 0; //game.GetDebug(); // FIXME
+	int debugging = g_hdb->getDebug();
 
 	for (int i = 0; i < _numLevel2Ents; i++) {
 		// call custom drawing code?


Commit: f83f965462cf2de90915d516ac0dceff255c2ad9
    https://github.com/scummvm/scummvm/commit/f83f965462cf2de90915d516ac0dceff255c2ad9
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:18+02:00

Commit Message:
HDB: Complete AI::checkPlayerCollision()

Changed paths:
    engines/hdb/ai-funcs.cpp


diff --git a/engines/hdb/ai-funcs.cpp b/engines/hdb/ai-funcs.cpp
index 26ba651..3a3c50e 100644
--- a/engines/hdb/ai-funcs.cpp
+++ b/engines/hdb/ai-funcs.cpp
@@ -2053,7 +2053,9 @@ bool AI::checkPlayerTileCollision(int x, int y) {
 }
 
 bool AI::checkPlayerCollision(int x, int y, int border) {
-	debug(9, "STUB: checkPlayerCollison: g_hdb->getDebug() required");
+	if (g_hdb->getDebug() == 2 || !_player)
+		return false;
+
 	return (x > (_player->x - 32 + border) && x < (_player->x - 32 - border) && y >(_player->y - 32 + border) && y < (_player->y - 32 - border));
 }
 


Commit: 614fc61254785f95cb4f477732ed9dcaf1717ecf
    https://github.com/scummvm/scummvm/commit/614fc61254785f95cb4f477732ed9dcaf1717ecf
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:18+02:00

Commit Message:
HDB: Consistent memory management for map explosions

Changed paths:
    engines/hdb/map.cpp


diff --git a/engines/hdb/map.cpp b/engines/hdb/map.cpp
index 86bd03f..9a68c80 100644
--- a/engines/hdb/map.cpp
+++ b/engines/hdb/map.cpp
@@ -180,15 +180,15 @@ void Map::loadSaveFile(Common::InSaveFile *in) {
 	for (i = 0; i < _width * _height; i++)
 		_foreground[i] = in->readSint32LE();
 
-	_mapExplosions = new byte[_width * _height];
+	_mapExplosions = (byte *)malloc(_width * _height);
 	for (i = 0; i < _width * _height; i++)
 		_mapExplosions[i] = in->readByte();
 
-	_mapExpBarrels = new byte[_width * _height];
+	_mapExpBarrels = (byte *)malloc(_width * _height);
 	for (i = 0; i < _width * _height; i++)
 		_mapExpBarrels[i] = in->readByte();
 
-	_mapLaserBeams = new byte[_width * _height];
+	_mapLaserBeams = (byte *)malloc(_width * _height);
 	for (i = 0; i < _width * _height; i++)
 		_mapLaserBeams[i] = in->readByte();
 


Commit: 5fa5f6fb391449369e54836bf2c0f8e201a63691
    https://github.com/scummvm/scummvm/commit/5fa5f6fb391449369e54836bf2c0f8e201a63691
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:19+02:00

Commit Message:
HDB: Fix _mapLoaded flag handling

Changed paths:
    engines/hdb/map.cpp


diff --git a/engines/hdb/map.cpp b/engines/hdb/map.cpp
index 9a68c80..5f76a0d 100644
--- a/engines/hdb/map.cpp
+++ b/engines/hdb/map.cpp
@@ -34,7 +34,6 @@ Map::Map() {
 	_mapExplosions = NULL;
 	_mapExpBarrels = NULL;
 	_mapLaserBeams = NULL;
-
 }
 
 Map::~Map() {
@@ -227,6 +226,8 @@ void Map::restartSystem() {
 	_mapExplosions = NULL;
 	_mapExpBarrels = NULL;
 	_mapLaserBeams = NULL;
+
+	_mapLoaded = false;
 }
 
 bool Map::loadMap(char *name) {
@@ -242,10 +243,6 @@ bool Map::loadMap(char *name) {
 }
 
 bool Map::load(Common::SeekableReadStream *stream) {
-	if (_mapLoaded) {
-		return false;
-	}
-
 	debug(5, "map stream size: %d(%x)", stream->size(), stream->size());
 
 	// Load MSM data header


Commit: 62a6a3646322b4161233dee87270b27e316620bc
    https://github.com/scummvm/scummvm/commit/62a6a3646322b4161233dee87270b27e316620bc
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:19+02:00

Commit Message:
HDB: Complete Map::restartSystem()

Changed paths:
    engines/hdb/gfx.cpp
    engines/hdb/gfx.h
    engines/hdb/map.cpp


diff --git a/engines/hdb/gfx.cpp b/engines/hdb/gfx.cpp
index 19109c3..94b8922 100644
--- a/engines/hdb/gfx.cpp
+++ b/engines/hdb/gfx.cpp
@@ -406,7 +406,7 @@ Tile *Gfx::getTile(int index) {
 }
 
 void Gfx::emptyGfxCaches() {
-	warning("STUB: mptyGfxCaches()");
+	// We have plenty of memory, so do not do it
 }
 
 void Gfx::cacheTileSequence(int tileIndex, int count) {
@@ -510,6 +510,15 @@ Tile *Gfx::getTileGfx(const char *name, int32 size) {
 	return gc->tileGfx;
 }
 
+void Gfx::markGfxCacheFreeable() {
+	for (Common::Array<GfxCache *>::iterator it = _gfxCache->begin(); it != _gfxCache->end(); it++)
+		(*it)->loaded = -1;
+}
+
+void Gfx::markTileCacheFreeable() {
+	// we have plenty of memory, so do not do it
+}
+
 Picture *Gfx::getPicGfx(const char *name, int32 size) {
 	// Try to find graphic
 	for (Common::Array<GfxCache *>::iterator it = _gfxCache->begin(); it != _gfxCache->end(); it++) {
diff --git a/engines/hdb/gfx.h b/engines/hdb/gfx.h
index 36204c5..59d44fb 100644
--- a/engines/hdb/gfx.h
+++ b/engines/hdb/gfx.h
@@ -122,6 +122,8 @@ public:
 	Picture *getPicture(const char *name);
 
 	void emptyGfxCaches();
+	void markTileCacheFreeable();
+	void markGfxCacheFreeable();
 
 	// Returns: true->Tile, false->Pic
 	bool selectGfxType(const char *name);
diff --git a/engines/hdb/map.cpp b/engines/hdb/map.cpp
index 5f76a0d..8f53524 100644
--- a/engines/hdb/map.cpp
+++ b/engines/hdb/map.cpp
@@ -217,7 +217,22 @@ int Map::loadTiles() {
 }
 
 void Map::restartSystem() {
-	warning("STUB: Map::restartSystem()");
+	_listBGAnimFast.clear();
+	_listBGAnimMedium.clear();
+	_listBGAnimSlow.clear();
+	_listFGAnimFast.clear();
+	_listFGAnimMedium.clear();
+	_listFGAnimSlow.clear();
+
+	delete _background;
+	_background = NULL;
+	delete _foreground;
+	_foreground = NULL;
+	delete _iconList;
+	_iconList = NULL;
+
+	_width = _height = 0;
+	_animCycle = 0;
 
 	free(_mapExplosions);
 	free(_mapExpBarrels);
@@ -227,6 +242,10 @@ void Map::restartSystem() {
 	_mapExpBarrels = NULL;
 	_mapLaserBeams = NULL;
 
+	// mark all in-memory tiles as being in memory, but able to be freed
+	g_hdb->_gfx->markTileCacheFreeable();
+	g_hdb->_gfx->markGfxCacheFreeable();
+
 	_mapLoaded = false;
 }
 


Commit: 0a291d028cbc3f1ead687d69deb8e3569167c7ae
    https://github.com/scummvm/scummvm/commit/0a291d028cbc3f1ead687d69deb8e3569167c7ae
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:19+02:00

Commit Message:
HDB: Complete AI::restartSystem()

Changed paths:
    engines/hdb/ai-init.cpp
    engines/hdb/ai.h
    engines/hdb/map.cpp


diff --git a/engines/hdb/ai-init.cpp b/engines/hdb/ai-init.cpp
index 95498dc..7914d93 100644
--- a/engines/hdb/ai-init.cpp
+++ b/engines/hdb/ai-init.cpp
@@ -1058,35 +1058,72 @@ FuncPtr AI::funcLookUp(const char *function) {
 }
 
 void AI::restartSystem() {
-	warning("STUB: AI::restartSystem incomplete");
-
-	// Clear Player
+	/// init special player vars
 	_player = NULL;
-	_playerDead = false;
-	_playerInvisible = false;
-	_playerOnIce = false;
-	_playerEmerging = false;
+
+	// Clear the Action list
+	memset(_actions, 0, sizeof(_actions));
+
+	// Clear Teleporter list
+	memset(_teleporters, 0, sizeof(_teleporters));
+	_numTeleporters = 0;
+
+	// Clear the Auto-Action list
+	memset(_autoActions, 0, sizeof(_autoActions));
+
+	// Clear the Callback List
+	memset(_callbacks, 0, sizeof(_callbacks));
+
+	// Clear the Entity List
+	_ents->clear();
+
+	// Clear the Floats List
+	_floats->clear();
+
+	// Clear the Lua List
+	memset(_luaList, 0, sizeof(_luaList));
+	_numLuaList = 0;
+
+	// Clear Anim Targets List
+	_animTargets.clear();
+
+	// Clear ArrowPath List
+	_arrowPaths->clear();
+
+	// Clear Trigger List
+	_triggerList->clear();
+
+	// Clear Here List
+	_hereList->clear();
+
+	// Clear Bridges
+	memset(&_bridges[0], 0, sizeof(_bridges));
+	_numBridges = 0;
+
+	// Clear waypoints
+	memset(&_waypoints[0], 0, sizeof(_waypoints));
+	_numWaypoints = 0;
 
 	// Clean up Player Graphics Storage
-	memset(_horrible1Gfx, NULL, kMaxDeathFrames * sizeof(Tile *));
-	memset(_horrible2Gfx, NULL, kMaxDeathFrames * sizeof(Tile *));
-	memset(_horrible3Gfx, NULL, kMaxDeathFrames * sizeof(Tile *));
-	memset(_horrible4Gfx, NULL, kMaxDeathFrames * sizeof(Tile *));
-	memset(_plummetGfx, NULL, kMaxDeathFrames * sizeof(Tile *));
-	memset(_dyingGfx, NULL, kMaxDeathFrames * sizeof(Tile *));
-
-	memset(_pushdownGfx, NULL, kMaxAnimFrames * sizeof(Tile *));
-	memset(_pushupGfx, NULL, kMaxAnimFrames * sizeof(Tile *));
-	memset(_pushleftGfx, NULL, kMaxAnimFrames * sizeof(Tile *));
-	memset(_pushrightGfx, NULL, kMaxAnimFrames * sizeof(Tile *));
-	memset(_stunDownGfx, NULL, kMaxAnimFrames * sizeof(Tile *));
-	memset(_stunUpGfx, NULL, kMaxAnimFrames * sizeof(Tile *));
-	memset(_stunLeftGfx, NULL, kMaxAnimFrames * sizeof(Tile *));
-	memset(_stunRightGfx, NULL, kMaxAnimFrames * sizeof(Tile *));
-	memset(_slugDownGfx, NULL, kMaxAnimFrames * sizeof(Tile *));
-	memset(_slugUpGfx, NULL, kMaxAnimFrames * sizeof(Tile *));
-	memset(_slugLeftGfx, NULL, kMaxAnimFrames * sizeof(Tile *));
-	memset(_slugRightGfx, NULL, kMaxAnimFrames * sizeof(Tile *));
+	memset(_horrible1Gfx, 0, sizeof(_horrible1Gfx));
+	memset(_horrible2Gfx, 0, sizeof(_horrible2Gfx));
+	memset(_horrible3Gfx, 0, sizeof(_horrible3Gfx));
+	memset(_horrible4Gfx, 0, sizeof(_horrible4Gfx));
+	memset(_plummetGfx, 0, sizeof(_plummetGfx));
+	memset(_dyingGfx, 0, sizeof(_dyingGfx));
+
+	memset(_pushdownGfx, 0, sizeof(_pushdownGfx));
+	memset(_pushupGfx, 0, sizeof(_pushupGfx));
+	memset(_pushleftGfx, 0, sizeof(_pushleftGfx));
+	memset(_pushrightGfx, 0, sizeof(_pushrightGfx));
+	memset(_stunDownGfx, 0, sizeof(_stunDownGfx));
+	memset(_stunUpGfx, 0, sizeof(_stunUpGfx));
+	memset(_stunLeftGfx, 0, sizeof(_stunLeftGfx));
+	memset(_stunRightGfx, 0, sizeof(_stunRightGfx));
+	memset(_slugDownGfx, 0, sizeof(_slugDownGfx));
+	memset(_slugUpGfx, 0, sizeof(_slugUpGfx));
+	memset(_slugLeftGfx, 0, sizeof(_slugLeftGfx));
+	memset(_slugRightGfx, 0, sizeof(_slugRightGfx));
 
 	_horrible1Frames = _horrible2Frames = _horrible3Frames = _horrible4Frames = 0;
 	_plummetFrames = _dyingFrames = 0;
@@ -1101,10 +1138,24 @@ void AI::restartSystem() {
 		_clubRightFrames = 3;
 	}
 
-	memset(_clubDownGfx, NULL, kMaxAnimFrames * sizeof(Tile *));
-	memset(_clubUpGfx, NULL, kMaxAnimFrames * sizeof(Tile *));
-	memset(_clubLeftGfx, NULL, kMaxAnimFrames * sizeof(Tile *));
-	memset(_clubRightGfx, NULL, kMaxAnimFrames * sizeof(Tile *));
+	memset(_clubDownGfx, 0, sizeof(_clubDownGfx));
+	memset(_clubUpGfx, 0, sizeof(_clubUpGfx));
+	memset(_clubLeftGfx, 0, sizeof(_clubLeftGfx));
+	memset(_clubRightGfx, 0, sizeof(_clubRightGfx));
+
+	if (_weaponSelGfx)
+		_weaponSelGfx->free();
+
+	_playerDead = false;
+	_playerInvisible = false;
+	_playerOnIce = false;
+	_playerEmerging = false;
+
+	_weaponSelected = AI_NONE;
+	_weaponSelGfx = NULL;
+
+	// Clear Cinematic System
+	_cineActive = _cameraLock = _playerLock = _cineAborted = false;
 
 	int i;
 	if (_icepSnowballGfxDown) {
@@ -1162,6 +1213,24 @@ void AI::restartSystem() {
 			_gfxDragonBreathe[2] = NULL;
 	}
 
+	// PANIC ZONE gfx - see ya!
+	if (g_hdb->_window->_pzInfo.gfxPanic) {
+		g_hdb->_window->_pzInfo.gfxPanic->free();
+		g_hdb->_window->_pzInfo.gfxPanic = NULL;
+		g_hdb->_window->_pzInfo.gfxZone->free();
+		g_hdb->_window->_pzInfo.gfxZone = NULL;
+		g_hdb->_window->_pzInfo.gfxFace[0]->free();
+		g_hdb->_window->_pzInfo.gfxFace[0] = NULL;
+		g_hdb->_window->_pzInfo.gfxFace[1]->free();
+		g_hdb->_window->_pzInfo.gfxFace[1] = NULL;
+
+		for (i = 0; i < 10; i++) {
+			g_hdb->_window->_pzInfo.gfxNumber[i]->free();
+			g_hdb->_window->_pzInfo.gfxNumber[i] = NULL;
+		}
+	}
+	g_hdb->_window->_pzInfo.active = false;
+
 	// laser beams
 	if (_gfxLaserbeamUD[0]) {
 		for (i = 0; i < 4; i++) {
@@ -1181,52 +1250,6 @@ void AI::restartSystem() {
 		}
 	}
 
-	// Clear the Action list
-	memset(_actions, 0, sizeof(_actions));
-
-	// Clear Teleporter list
-	memset(_teleporters, 0, sizeof(_teleporters));
-	_numTeleporters = 0;
-
-	// Clear the Auto-Action list
-	memset(_autoActions, 0, sizeof(_autoActions));
-
-	// Clear the Callback List
-	memset(_callbacks, 0, sizeof(_callbacks));
-
-	// Clear the Entity List
-	_ents->clear();
-
-	// Clear the Floats List
-	_floats->clear();
-
-	// Clear the Lua List
-	memset(_luaList, 0, sizeof(_luaList));
-	_numLuaList = 0;
-
-	// Clear Anim Targets List
-	_animTargets.clear();
-
-	// Clear ArrowPath List
-	_arrowPaths->clear();
-
-	// Clear Trigger List
-	_triggerList->clear();
-
-	// Clear Here List
-	_hereList->clear();
-
-	// Clear Cinematic System
-	_cineActive = _cameraLock = _playerLock = _cineAborted = false;
-
-	// Clear waypoints
-	memset(&_waypoints[0], 0, sizeof(_waypoints));
-	_numWaypoints = 0;
-
-	// Clear Bridges
-	memset(&_bridges[0], 0, sizeof(_bridges));
-	_numBridges = 0;
-
 	// No Gate Puddles
 	_gatePuddles = 0;
 }
diff --git a/engines/hdb/ai.h b/engines/hdb/ai.h
index 4ac3eae..47c8f75 100644
--- a/engines/hdb/ai.h
+++ b/engines/hdb/ai.h
@@ -1140,6 +1140,9 @@ public:
 	uint16		_slugAttackFrames;
 	Picture		*_slugAttackGfx[kMaxAnimFrames];
 
+	Tile		*_weaponSelGfx;
+	AIType		_weaponSelected;
+
 	// Player Resources and Deliveries
 
 	int _numGems;
diff --git a/engines/hdb/map.cpp b/engines/hdb/map.cpp
index 8f53524..1a085f9 100644
--- a/engines/hdb/map.cpp
+++ b/engines/hdb/map.cpp
@@ -34,6 +34,10 @@ Map::Map() {
 	_mapExplosions = NULL;
 	_mapExpBarrels = NULL;
 	_mapLaserBeams = NULL;
+
+	_background = NULL;
+	_foreground = NULL;
+	_iconList = NULL;
 }
 
 Map::~Map() {


Commit: 8c48bf972d5b1ad8785b7bbf1a078156492f15fb
    https://github.com/scummvm/scummvm/commit/8c48bf972d5b1ad8785b7bbf1a078156492f15fb
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:19+02:00

Commit Message:
HDB: Fix Gfx::updateFade()

Changed paths:
    engines/hdb/gfx.cpp


diff --git a/engines/hdb/gfx.cpp b/engines/hdb/gfx.cpp
index 94b8922..855d699 100644
--- a/engines/hdb/gfx.cpp
+++ b/engines/hdb/gfx.cpp
@@ -345,6 +345,8 @@ void Gfx::updateFade() {
 			return;
 		}
 
+		g_system->copyRectToScreen(_globalSurface.getBasePtr(0, 0), _globalSurface.pitch, 0, 0, _globalSurface.w, _globalSurface.h);
+
 		g_system->updateScreen();
 		g_system->delayMillis(1000 / kGameFPS);
 


Commit: 74d0c5daed408c6ee709dffd62e921abcbb3a15f
    https://github.com/scummvm/scummvm/commit/74d0c5daed408c6ee709dffd62e921abcbb3a15f
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:19+02:00

Commit Message:
HDB: Fix Gfx::updateVideo()

Changed paths:
    engines/hdb/gfx.cpp


diff --git a/engines/hdb/gfx.cpp b/engines/hdb/gfx.cpp
index 855d699..cc78c49 100644
--- a/engines/hdb/gfx.cpp
+++ b/engines/hdb/gfx.cpp
@@ -198,9 +198,6 @@ void Gfx::fillScreen(uint32 color) {
 }
 
 void Gfx::updateVideo() {
-
-	uint32 timer = g_system->getMillis();
-
 	updateFade();
 	g_hdb->checkProgress();
 
@@ -215,8 +212,6 @@ void Gfx::updateVideo() {
 	if (!clip.isEmpty()) {
 		g_system->copyRectToScreen(g_hdb->_gfx->_globalSurface.getBasePtr(clip.left, clip.top), g_hdb->_gfx->_globalSurface.pitch, clip.left, clip.top, clip.width(), clip.height());
 	}
-
-	while (g_system->getMillis() - timer < 16) {};
 }
 
 void Gfx::drawPointer() {


Commit: ac50b10549479c980bf9f0bfceb9dd5b0a2fb5c3
    https://github.com/scummvm/scummvm/commit/ac50b10549479c980bf9f0bfceb9dd5b0a2fb5c3
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:19+02:00

Commit Message:
HDB: Fix getRandomNumber() usage in menu.cpp

Changed paths:
    engines/hdb/menu.cpp


diff --git a/engines/hdb/menu.cpp b/engines/hdb/menu.cpp
index 2c524fc..53ffcda 100644
--- a/engines/hdb/menu.cpp
+++ b/engines/hdb/menu.cpp
@@ -227,9 +227,9 @@ void Menu::startMenu() {
 	if (!_fStars[0].y) {
 		for (i = 0; i < kMaxStars; i++) {
 			_fStars[i].y = -30;
-			_fStars[i].x = g_hdb->_rnd->getRandomNumber(kScreenWidth);
-			_fStars[i].speed = g_hdb->_rnd->getRandomNumber(5) + 1;
-			_fStars[i].anim = g_hdb->_rnd->getRandomNumber(3);
+			_fStars[i].x = g_hdb->_rnd->getRandomNumber(kScreenWidth - 1);
+			_fStars[i].speed = g_hdb->_rnd->getRandomNumber(4) + 1;
+			_fStars[i].anim = g_hdb->_rnd->getRandomNumber(2);
 			_fStars[i].delay = 5;
 		}
 	}
@@ -240,10 +240,10 @@ void Menu::startMenu() {
 	if (!_nebulaY) {
 		g_hdb->_gfx->setup3DStars();	// setup the star info
 
-		_nebulaWhich = g_hdb->_rnd->getRandomNumber(kNebulaCount);
-		_nebulaX = g_hdb->_rnd->getRandomNumber(kScreenWidth) + 10;
+		_nebulaWhich = g_hdb->_rnd->getRandomNumber(kNebulaCount - 1);
+		_nebulaX = g_hdb->_rnd->getRandomNumber(kScreenWidth - 1) + 10;
 		_nebulaY = -20;
-		_nebulaYVel = g_hdb->_rnd->getRandomNumber(10) + 2;
+		_nebulaYVel = g_hdb->_rnd->getRandomNumber(9) + 2;
 	}
 
 	_optionsScrollX = kMenuX;
@@ -788,10 +788,10 @@ void Menu::drawTitle() {
 		_nebulaGfx[_nebulaWhich]->draw(_nebulaX, _nebulaY);
 		_nebulaY += _nebulaYVel;
 		if (_nebulaY > kScreenHeight + (kScreenHeight / 2)) {
-			_nebulaWhich = g_hdb->_rnd->getRandomNumber(kNebulaCount);
-			_nebulaX = g_hdb->_rnd->getRandomNumber(kScreenWidth) + 10;
+			_nebulaWhich = g_hdb->_rnd->getRandomNumber(kNebulaCount - 1);
+			_nebulaX = g_hdb->_rnd->getRandomNumber(kScreenWidth - 1) + 10;
 			_nebulaY = -11 * 8;
-			_nebulaYVel = g_hdb->_rnd->getRandomNumber(4) + 1;
+			_nebulaYVel = g_hdb->_rnd->getRandomNumber(3) + 1;
 			if (_nebulaWhich > 4)		// galaxy?
 				_nebulaYVel = 1;
 		}
@@ -892,10 +892,10 @@ void Menu::drawTitle() {
 			_rocketEx = 0;			// exhaust toggle
 			g_hdb->_gfx->setup3DStars();	// setup the star info
 
-			_nebulaWhich = g_hdb->_rnd->getRandomNumber(kNebulaCount);
-			_nebulaX = g_hdb->_rnd->getRandomNumber(kScreenWidth) + 10;
+			_nebulaWhich = g_hdb->_rnd->getRandomNumber(kNebulaCount - 1);
+			_nebulaX = g_hdb->_rnd->getRandomNumber(kScreenWidth - 1) + 10;
 			_nebulaY = -11 * 8;
-			_nebulaYVel = g_hdb->_rnd->getRandomNumber(10) + 2;
+			_nebulaYVel = g_hdb->_rnd->getRandomNumber(9) + 2;
 			if (_nebulaWhich > 4)		// galaxy?
 				_nebulaYVel = 1;
 		}
@@ -1265,10 +1265,10 @@ void Menu::drawNebula() {
 	_nebulaY += _nebulaYVel;
 
 	if (_nebulaY > kScreenHeight + (kScreenHeight / 2)) {
-		_nebulaWhich = g_hdb->_rnd->getRandomNumber(kNebulaCount);
-		_nebulaX = g_hdb->_rnd->getRandomNumber(kScreenWidth) + 10;
+		_nebulaWhich = g_hdb->_rnd->getRandomNumber(kNebulaCount - 1);
+		_nebulaX = g_hdb->_rnd->getRandomNumber(kScreenWidth - 1) + 10;
 		_nebulaY = -11 * 8;
-		_nebulaYVel = g_hdb->_rnd->getRandomNumber(4) + 1;
+		_nebulaYVel = g_hdb->_rnd->getRandomNumber(3) + 1;
 		if (_nebulaWhich > 4)		// galaxy?
 			_nebulaYVel = 1;
 	}
@@ -1281,8 +1281,8 @@ void Menu::drawNebula() {
 	for (i = 0; i < kMaxStars; i++) {
 		_fStars[i].y += _fStars[i].speed;
 		if (_fStars[i].y > kScreenHeight) {
-			_fStars[i].y = (g_hdb->_rnd->getRandomNumber(30) + 30) * -1;
-			_fStars[i].speed = g_hdb->_rnd->getRandomNumber(5) + 1;
+			_fStars[i].y = (g_hdb->_rnd->getRandomNumber(29) + 30) * -1;
+			_fStars[i].speed = g_hdb->_rnd->getRandomNumber(4) + 1;
 		}
 		if (_fStars[i].delay-- < 1) {
 			_fStars[i].delay = 5;


Commit: 8c19637727be1f8d38f59f7dac42f6f7fcac8fec
    https://github.com/scummvm/scummvm/commit/8c19637727be1f8d38f59f7dac42f6f7fcac8fec
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:19+02:00

Commit Message:
HDB: Fix getRandomNumber() usage

Changed paths:
    engines/hdb/ai-player.cpp


diff --git a/engines/hdb/ai-player.cpp b/engines/hdb/ai-player.cpp
index 56a08ed..a050892 100644
--- a/engines/hdb/ai-player.cpp
+++ b/engines/hdb/ai-player.cpp
@@ -599,7 +599,7 @@ void aiChickenAction(AIEntity *e) {
 
 	if (g_hdb->_map->checkEntOnScreen(e) && !delay) {
 		g_hdb->_sound->playSound(SND_CHICKEN_AMBIENT);
-		delay = g_hdb->_rnd->getRandomNumber(128) + 160;
+		delay = g_hdb->_rnd->getRandomNumber(127) + 160;
 		aiChickenUse(e);
 	}
 


Commit: ac9a62da03218318503cb1f13dfd0165389caf06
    https://github.com/scummvm/scummvm/commit/ac9a62da03218318503cb1f13dfd0165389caf06
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:19+02:00

Commit Message:
HDB: Fix getRandomNumber() usage

Changed paths:
    engines/hdb/gfx.cpp


diff --git a/engines/hdb/gfx.cpp b/engines/hdb/gfx.cpp
index cc78c49..d3a63a9 100644
--- a/engines/hdb/gfx.cpp
+++ b/engines/hdb/gfx.cpp
@@ -354,10 +354,10 @@ void Gfx::turnOnSnow() {
 	int		i;
 	_snowInfo.active = true;
 	for (i = 0; i < MAX_SNOW; i++) {
-		_snowInfo.x[i] = g_hdb->_rnd->getRandomNumber(kScreenWidth);
-		_snowInfo.y[i] = g_hdb->_rnd->getRandomNumber(kScreenHeight);
-		_snowInfo.yv[i] = g_hdb->_rnd->getRandomNumber(3) + 1;
-		_snowInfo.xvindex[i] = g_hdb->_rnd->getRandomNumber(MAX_SNOW_XV);
+		_snowInfo.x[i] = g_hdb->_rnd->getRandomNumber(kScreenWidth - 1);
+		_snowInfo.y[i] = g_hdb->_rnd->getRandomNumber(kScreenHeight - 1);
+		_snowInfo.yv[i] = g_hdb->_rnd->getRandomNumber(2) + 1;
+		_snowInfo.xvindex[i] = g_hdb->_rnd->getRandomNumber(MAX_SNOW_XV - 1);
 	}
 }
 
@@ -585,9 +585,9 @@ void Gfx::setSky(int skyIndex) {
 
 void Gfx::setup3DStars() {
 	for (int i = 0; i < kNum3DStars; i++) {
-		_stars3D[i].x = g_hdb->_rnd->getRandomNumber(kScreenWidth);
-		_stars3D[i].y = g_hdb->_rnd->getRandomNumber(kScreenHeight);
-		_stars3D[i].speed = g_hdb->_rnd->getRandomNumber(256);
+		_stars3D[i].x = g_hdb->_rnd->getRandomNumber(kScreenWidth - 1);
+		_stars3D[i].y = g_hdb->_rnd->getRandomNumber(kScreenHeight - 1);
+		_stars3D[i].speed = g_hdb->_rnd->getRandomNumber(255);
 		_stars3D[i].speed >>= 1;
 		_stars3D[i].color = _stars3D[i].speed / 64;
 	}
@@ -595,8 +595,8 @@ void Gfx::setup3DStars() {
 
 void Gfx::setup3DStarsLeft() {
 	for (int i = 0; i < kNum3DStars; i++) {
-		_stars3DSlow[i].x = g_hdb->_rnd->getRandomNumber(kScreenWidth);
-		_stars3DSlow[i].y = g_hdb->_rnd->getRandomNumber(kScreenHeight);
+		_stars3DSlow[i].x = g_hdb->_rnd->getRandomNumber(kScreenWidth - 1);
+		_stars3DSlow[i].y = g_hdb->_rnd->getRandomNumber(kScreenHeight - 1);
 		_stars3DSlow[i].speed = ((double) (1 + g_hdb->_rnd->getRandomNumber(4))) / 6.0;
 		_stars3DSlow[i].color = (int) (_stars3DSlow[i].speed * 4.00);
 	}


Commit: f8769966f161a2be413eeef01517d96005f61c84
    https://github.com/scummvm/scummvm/commit/f8769966f161a2be413eeef01517d96005f61c84
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:19+02:00

Commit Message:
HDB: Fix getRandomNumber usage

Changed paths:
    engines/hdb/window.cpp


diff --git a/engines/hdb/window.cpp b/engines/hdb/window.cpp
index cf6b79b..8df868e 100644
--- a/engines/hdb/window.cpp
+++ b/engines/hdb/window.cpp
@@ -1043,7 +1043,7 @@ void Window::drawDeliveries() {
 					if (!_dlvsInfo.go2) {
 						_dlvsInfo.go2 = true;
 						_dlvsInfo.delay2 = g_hdb->getTimeSlice() + 500;
-						g_hdb->_sound->playSound(crazySounds[g_hdb->_rnd->getRandomNumber(kNumCrazy)]);
+						g_hdb->_sound->playSound(crazySounds[g_hdb->_rnd->getRandomNumber(kNumCrazy - 1)]);
 					}
 				}
 			}
@@ -1057,7 +1057,7 @@ void Window::drawDeliveries() {
 					if (!_dlvsInfo.go3) {
 						_dlvsInfo.go3 = true;
 						_dlvsInfo.delay3 = g_hdb->getTimeSlice() + 500;
-						g_hdb->_sound->playSound(crazySounds[g_hdb->_rnd->getRandomNumber(kNumCrazy)]);
+						g_hdb->_sound->playSound(crazySounds[g_hdb->_rnd->getRandomNumber(kNumCrazy - 1)]);
 					}
 				}
 			}
@@ -1071,7 +1071,7 @@ void Window::drawDeliveries() {
 					g_hdb->_gfx->drawText("to ");
 					g_hdb->_gfx->drawText(d->destTextName);
 
-					g_hdb->_sound->playSound(crazySounds[g_hdb->_rnd->getRandomNumber(kNumCrazy)]);
+					g_hdb->_sound->playSound(crazySounds[g_hdb->_rnd->getRandomNumber(kNumCrazy - 1)]);
 					_dlvsInfo.animate = false;
 				}
 			}
@@ -1180,8 +1180,8 @@ void Window::drawPanicZone() {
 
 		// Move PANIC ZONE to screen center
 	case PANICZONE_START:
-		xx = g_hdb->_rnd->getRandomNumber(10) - 5;
-		yy = g_hdb->_rnd->getRandomNumber(10) - 5;
+		xx = g_hdb->_rnd->getRandomNumber(9) - 5;
+		yy = g_hdb->_rnd->getRandomNumber(9) - 5;
 		_pzInfo.x1 += _pzInfo.xv;
 		_pzInfo.y1++;
 		_pzInfo.x2 += _pzInfo.yv;
@@ -1195,8 +1195,8 @@ void Window::drawPanicZone() {
 		break;
 
 	case PANICZONE_TITLESTOP:
-		xx = g_hdb->_rnd->getRandomNumber(10) - 5;
-		yy = g_hdb->_rnd->getRandomNumber(10) - 5;
+		xx = g_hdb->_rnd->getRandomNumber(9) - 5;
+		yy = g_hdb->_rnd->getRandomNumber(9) - 5;
 		_pzInfo.gfxPanic->drawMasked(_pzInfo.x1 + xx, _pzInfo.y1 + yy);
 		_pzInfo.gfxZone->drawMasked(_pzInfo.x2 + yy, _pzInfo.y2 + xx);
 		_pzInfo.timer--;
@@ -1206,8 +1206,8 @@ void Window::drawPanicZone() {
 		break;
 
 	case PANICZONE_BLASTOFF:
-		xx = g_hdb->_rnd->getRandomNumber(10) - 5;
-		yy = g_hdb->_rnd->getRandomNumber(10) - 5;
+		xx = g_hdb->_rnd->getRandomNumber(9) - 5;
+		yy = g_hdb->_rnd->getRandomNumber(9) - 5;
 		_pzInfo.y1 -= 10;
 		_pzInfo.y2 += 10;
 		_pzInfo.gfxPanic->drawMasked(_pzInfo.x1 + xx, _pzInfo.y1 + yy);


Commit: 79a4a37e8d838b2ff683785f7c9009da38bbcc33
    https://github.com/scummvm/scummvm/commit/79a4a37e8d838b2ff683785f7c9009da38bbcc33
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:19+02:00

Commit Message:
HDB: Initialize Weapon Gfx

Changed paths:
    engines/hdb/ai-init.cpp


diff --git a/engines/hdb/ai-init.cpp b/engines/hdb/ai-init.cpp
index 7914d93..f4b96ce 100644
--- a/engines/hdb/ai-init.cpp
+++ b/engines/hdb/ai-init.cpp
@@ -1022,6 +1022,7 @@ bool AI::init() {
 	_dummyLaser.type = AI_LASERBEAM;
 	strcpy(_dummyPlayer.entityName, "Virtual Player");
 	_playerRunning = false;
+	_weaponSelGfx = NULL;
 
 	restartSystem();
 	return true;


Commit: e1fbaaea2b34e75918eaafad335bf50f39aa41c8
    https://github.com/scummvm/scummvm/commit/e1fbaaea2b34e75918eaafad335bf50f39aa41c8
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:19+02:00

Commit Message:
HDB: Add cinematic functions for Pic

Changed paths:
    engines/hdb/ai-cinematic.cpp
    engines/hdb/ai.h
    engines/hdb/lua-script.cpp


diff --git a/engines/hdb/ai-cinematic.cpp b/engines/hdb/ai-cinematic.cpp
index 24ecd29..5eafd47 100644
--- a/engines/hdb/ai-cinematic.cpp
+++ b/engines/hdb/ai-cinematic.cpp
@@ -65,6 +65,7 @@ static const char *cineTypeStr[] = {
 void AI::processCines() {
 
 	AIEntity *e;
+	Picture *p;
 	bool complete, bailOut;
 
 	if (!_cineActive) {
@@ -311,6 +312,49 @@ void AI::processCines() {
 					complete = true;
 			}
 			break;
+		case C_DRAWPIC:
+
+			if ((p = cineFindInBlitList(_cine[i]->id)) == NULL) {
+				p = g_hdb->_gfx->loadPic(_cine[i]->string);
+				cineAddToFreeList(p);
+				cineAddToBlitList(_cine[i]->id, p, (int)_cine[i]->x, (int)_cine[i]->y, false);
+			}
+			_cine[i]->pic = p;
+			_cine[i]->pic->draw((int)_cine[i]->x, (int)_cine[i]->y);
+			complete = true;
+			break;
+		case C_DRAWMASKEDPIC:
+
+			if ((p = cineFindInBlitList(_cine[i]->id)) == NULL) {
+				p = g_hdb->_gfx->loadPic(_cine[i]->string);
+				cineAddToFreeList(p);
+				cineAddToBlitList(_cine[i]->id, p, (int)_cine[i]->x, (int)_cine[i]->y, true);
+			}
+			_cine[i]->pic = p;
+			_cine[i]->pic->drawMasked((int)_cine[i]->x, (int)_cine[i]->y);
+			complete = true;
+			break;
+
+		case C_MOVEPIC:
+			if (!_cine[i]->start) {
+				Picture *pic = cineFindInBlitList(_cine[i]->id);
+				if (!pic) {
+					pic = g_hdb->_gfx->loadPic(_cine[i]->string);
+					cineAddToFreeList(pic);
+				} else
+					cineRemoveFromBlitList(_cine[i]->id);
+				_cine[i]->pic = pic;
+				_cine[i]->start = 1;
+			}
+
+			cineRemoveFromBlitList(_cine[i]->id);
+			_cine[i]->x += _cine[i]->xv;
+			_cine[i]->y += _cine[i]->yv;
+			cineAddToBlitList(_cine[i]->id, _cine[i]->pic, (int)_cine[i]->x, (int)_cine[i]->y, false);
+			if (abs((int)(_cine[i]->x - _cine[i]->x2)) <= 1 && abs((int)(_cine[i]->y - _cine[i]->y2)) <= 1)
+				complete = true;
+			break;
+
 		case C_MOVEMASKEDPIC:
 			if (!_cine[i]->start) {
 				Picture *pic = cineFindInBlitList(_cine[i]->id);
@@ -330,6 +374,7 @@ void AI::processCines() {
 			if (abs((int)(_cine[i]->x - _cine[i]->x2)) <= 1 && abs((int)(_cine[i]->y - _cine[i]->y2)) <= 1)
 				complete = true;
 			break;
+
 		case C_USEENTITY:
 			for (Common::Array<AIEntity *>::iterator it = _ents->begin(); it != _ents->end(); it++) {
 				if ((*it)->entityName && Common::matchString((*it)->entityName, _cine[i]->string, true)) {
@@ -676,6 +721,57 @@ void AI::cineCenterTextOut(const char *text, int y, int timer) {
 	_cine.push_back(cmd);
 }
 
+void AI::cineDrawPic(const char *id, const char *pic, int x, int y) {
+	if (!pic || !id) {
+		warning("cineDrawPic: Missing ID or PIC");
+		return;
+	}
+
+	CineCommand *cmd = new CineCommand;
+	cmd->x = x;
+	cmd->y = y;
+	cmd->string = pic;
+	cmd->id = id;
+	cmd->cmdType = C_DRAWPIC;
+	_cine.push_back(cmd);
+}
+
+void AI::cineDrawMaskedPic(const char *id, const char *pic, int x, int y) {
+	if (!pic || !id) {
+		warning("cineDrawMaskedPic: Missing ID or PIC");
+		return;
+	}
+
+	CineCommand *cmd = new CineCommand;
+	cmd->x = x;
+	cmd->y = y;
+	cmd->string = pic;
+	cmd->id = id;
+	cmd->cmdType = C_DRAWMASKEDPIC;
+	_cine.push_back(cmd);
+}
+
+void AI::cineMovePic(const char *id, const char *pic, int x1, int y1, int x2, int y2, int speed) {
+	if (!pic || !id) {
+		warning("cineMovePic: Missing ID or PIC");
+		return;
+	}
+
+	CineCommand *cmd = new CineCommand;
+	cmd->x = x1;
+	cmd->y = y1;
+	cmd->x2 = x2;
+	cmd->y2 = y2;
+	cmd->speed = speed;
+	cmd->xv = ((double)(x2-x1)) / (double)speed;
+	cmd->yv = ((double)(y2-y1)) / (double)speed;
+	cmd->start = 0;
+	cmd->string = pic;
+	cmd->id = id;
+	cmd->cmdType = C_MOVEPIC;
+	_cine.push_back(cmd);
+}
+
 void AI::cineMoveMaskedPic(const char *id, const char *pic, int x1, int y1, int x2, int y2, int speed) {
 	if (!pic || !id) {
 		warning("cineMoveMaskedPic: Missing ID or PIC");
diff --git a/engines/hdb/ai.h b/engines/hdb/ai.h
index 47c8f75..9c5acfc 100644
--- a/engines/hdb/ai.h
+++ b/engines/hdb/ai.h
@@ -992,6 +992,9 @@ public:
 	void cineDialog(const char *title, const char *string, int seconds);
 	void cineTextOut(const char *text, int x, int y, int timer);
 	void cineCenterTextOut(const char *text, int y, int timer);
+	void cineDrawPic(const char *id, const char *pic, int x, int y);
+	void cineDrawMaskedPic(const char *id, const char *pic, int x, int y);
+	void cineMovePic(const char *id, const char *pic, int x1, int y1, int x2, int y2, int speed);
 	void cineMoveMaskedPic(const char *id, const char *pic, int x1, int y1, int x2, int y2, int speed);
 	void cineUse(const char *entName);
 	void cinePlaySound(int index);
diff --git a/engines/hdb/lua-script.cpp b/engines/hdb/lua-script.cpp
index 37e4d6d..626272e 100644
--- a/engines/hdb/lua-script.cpp
+++ b/engines/hdb/lua-script.cpp
@@ -452,17 +452,59 @@ static int cineDialog(lua_State *L) {
 }
 
 static int cineDrawPic(lua_State *L) {
-	warning("STUB: CINE DRAW PIC");
+	const char *id = lua_tostring(L, 1);
+	const char *pic = lua_tostring(L, 2);
+	double x = lua_tonumber(L, 3);
+	double y = lua_tonumber(L, 3);
+
+	g_hdb->_lua->checkParameters("cineDrawPic", 4);
+
+	x += kCameraXOff;
+	y += kCameraYOff;
+
+	lua_pop(L, 4);
+	g_hdb->_ai->cineDrawPic(id, pic, (int)x, (int)y);
+
 	return 0;
 }
 
 static int cineDrawMaskedPic(lua_State *L) {
-	warning("STUB: CINE DRAW MASKED PIC");
+	const char *id = lua_tostring(L, 1);
+	const char *pic = lua_tostring(L, 2);
+	double x = lua_tonumber(L, 3);
+	double y = lua_tonumber(L, 3);
+
+	g_hdb->_lua->checkParameters("cineDrawMaskedPic", 4);
+
+	x += kCameraXOff;
+	y += kCameraYOff;
+
+	lua_pop(L, 4);
+	g_hdb->_ai->cineDrawMaskedPic(id, pic, (int)x, (int)y);
+
 	return 0;
 }
 
 static int cineMovePic(lua_State *L) {
-	warning("STUB: CINE MOVE PIC");
+	const char *id = lua_tostring(L, 1);
+	const char *pic = lua_tostring(L, 2);
+	double	x1 = lua_tonumber(L, 3);
+	double	y1 = lua_tonumber(L, 4);
+	double	x2 = lua_tonumber(L, 5);
+	double	y2 = lua_tonumber(L, 6);
+	double	speed = lua_tonumber(L, 7);
+
+	g_hdb->_lua->checkParameters("cineMovePic", 7);
+
+	x1 += kCameraXOff;
+	y1 += kCameraYOff;
+	x2 += kCameraXOff;
+	y2 += kCameraYOff;
+
+	lua_pop(L, 7);
+
+	g_hdb->_ai->cineMovePic(id, pic, (int)x1, (int)y1, (int)x2, (int)y2, (int)speed);
+
 	return 0;
 }
 


Commit: 2f893eeadd0b1a0129c88132afc5f49dacd55c13
    https://github.com/scummvm/scummvm/commit/2f893eeadd0b1a0129c88132afc5f49dacd55c13
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:19+02:00

Commit Message:
HDB: Add cineRemoveEntity()

Changed paths:
    engines/hdb/ai-cinematic.cpp
    engines/hdb/ai.h
    engines/hdb/lua-script.cpp


diff --git a/engines/hdb/ai-cinematic.cpp b/engines/hdb/ai-cinematic.cpp
index 5eafd47..e2ed00b 100644
--- a/engines/hdb/ai-cinematic.cpp
+++ b/engines/hdb/ai-cinematic.cpp
@@ -428,6 +428,12 @@ void AI::processCines() {
 			break;
 		}
 		break;
+		case C_REMOVEENTITY:
+			e = locateEntity(_cine[i]->string);
+			if (e)
+				removeEntity(e);
+			complete = true;
+			break;
 		case C_CLEAR_FG:
 			g_hdb->_map->setMapFGTileIndex((int)_cine[i]->x, (int)_cine[i]->y, -1);
 			g_hdb->_map->removeFGTileAnimation((int)_cine[i]->x, (int)_cine[i]->y);
@@ -687,6 +693,13 @@ void AI::cineSpawnEntity(AIType t, AIDir d, int x, int y, const char *func_init,
 	_cine.push_back(cmd);
 }
 
+void AI::cineRemoveEntity(const char *entName) {
+	CineCommand *cmd = new CineCommand;
+	cmd->string = entName;
+	cmd->cmdType = C_REMOVEENTITY;
+	_cine.push_back(cmd);
+}
+
 void AI::cineDialog(const char *title, const char *string, int seconds) {
 	CineCommand *cmd = new CineCommand;
 	cmd->title = title;
diff --git a/engines/hdb/ai.h b/engines/hdb/ai.h
index 9c5acfc..c63dfdd 100644
--- a/engines/hdb/ai.h
+++ b/engines/hdb/ai.h
@@ -986,6 +986,7 @@ public:
 	void cineMoveEntity(const char *entName, int x, int y, int level, int speed);
 	void cineSpawnEntity(AIType t, AIDir d, int x, int y, const char *func_init, const char *func_action,
 					const char *func_use, AIDir d2, int level, int value1, int value2);
+	void cineRemoveEntity(const char *entName);
 	void cineAnimEntity(const char *entName, AIState state, int loop);
 	void cineSetAnimFrame(const char *entName, AIState state, int frame);
 	void cineEntityFace(const char *luaName, double dir);
diff --git a/engines/hdb/lua-script.cpp b/engines/hdb/lua-script.cpp
index 626272e..01a3c7f 100644
--- a/engines/hdb/lua-script.cpp
+++ b/engines/hdb/lua-script.cpp
@@ -395,7 +395,13 @@ static int cineSetEntity(lua_State *L) {
 }
 
 static int cineRemoveEntity(lua_State *L) {
-	warning("STUB: CINE REMOVE ENTITY");
+	const char *entName = lua_tostring(L, 1);
+
+	g_hdb->_lua->checkParameters("cineRemoveEntity", 1);
+
+	lua_pop(L, 1);
+
+	g_hdb->_ai->cineRemoveEntity(entName);
 	return 0;
 }
 


Commit: e0f49e8aee8aa22c196969c27a99774f2e85f805
    https://github.com/scummvm/scummvm/commit/e0f49e8aee8aa22c196969c27a99774f2e85f805
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:19+02:00

Commit Message:
HDB: Add cineFunction()

Changed paths:
    engines/hdb/ai-cinematic.cpp
    engines/hdb/ai.h
    engines/hdb/lua-script.cpp


diff --git a/engines/hdb/ai-cinematic.cpp b/engines/hdb/ai-cinematic.cpp
index e2ed00b..f0ff15a 100644
--- a/engines/hdb/ai-cinematic.cpp
+++ b/engines/hdb/ai-cinematic.cpp
@@ -449,6 +449,10 @@ void AI::processCines() {
 			g_hdb->_map->addFGTileAnimation((int)_cine[i]->x, (int)_cine[i]->y);
 			complete = true;
 			break;
+		case C_FUNCTION:
+			g_hdb->_lua->callFunction(_cine[i]->title, 0);
+			complete = true;
+			break;
 		default:
 			warning("STUB: AI::PROCESSCINES incomplete for %d", _cine[i]->cmdType);
 			break;
@@ -872,4 +876,11 @@ void AI::cineSetForeground(int x, int y, int index) {
 	_cine.push_back(cmd);
 }
 
+void AI::cineFunction(const char *func) {
+	CineCommand *cmd = new CineCommand;
+	cmd->title = func;
+	cmd->cmdType = C_FUNCTION;
+	_cine.push_back(cmd);
+}
+
 } // End of Namespace
diff --git a/engines/hdb/ai.h b/engines/hdb/ai.h
index c63dfdd..3d20a1e 100644
--- a/engines/hdb/ai.h
+++ b/engines/hdb/ai.h
@@ -1005,6 +1005,7 @@ public:
 	void cineClearForeground(int x, int y);
 	void cineSetBackground(int x, int y, int index);
 	void cineSetForeground(int x, int y, int index);
+	void cineFunction(const char *func);
 
 	// Waypoint & Movement Functions
 	void lookAtXY(int x, int y);
diff --git a/engines/hdb/lua-script.cpp b/engines/hdb/lua-script.cpp
index 01a3c7f..06eb67b 100644
--- a/engines/hdb/lua-script.cpp
+++ b/engines/hdb/lua-script.cpp
@@ -602,7 +602,14 @@ static int cineSetBackground(lua_State *L) {
 }
 
 static int cineFunction(lua_State *L) {
-	warning("STUB: CINE FUNCTION");
+	const char *func = lua_tostring(L, 1);
+
+	g_hdb->_lua->checkParameters("cineFunction", 1);
+
+	lua_pop(L, 1);
+
+	g_hdb->_ai->cineFunction(func);
+
 	return 0;
 }
 


Commit: ff5b6d830a744b20c4a87db8e488443dd0b7c5ab
    https://github.com/scummvm/scummvm/commit/ff5b6d830a744b20c4a87db8e488443dd0b7c5ab
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:19+02:00

Commit Message:
HDB: Add _sound stubs

Changed paths:
    engines/hdb/sound.cpp
    engines/hdb/sound.h


diff --git a/engines/hdb/sound.cpp b/engines/hdb/sound.cpp
index d7967e2..bd31009 100644
--- a/engines/hdb/sound.cpp
+++ b/engines/hdb/sound.cpp
@@ -61,6 +61,16 @@ bool Sound::startMusic(SoundType song) {
 	return true;
 }
 
+bool Sound::fadeInMusic(SoundType song, int ramp) {
+	warning("STUB: Fade In Music");
+	return true;
+}
+
+void Sound::fadeOutMusic(int ramp) {
+	warning("STUB: Fade Out Music");
+	return;
+}
+
 bool Sound::songPlaying(SoundType song) {
 	warning("STUB: Check if Song is playing");
 	return true;
@@ -75,6 +85,11 @@ void Sound::stopMusic() {
 	debug(9, "STUB: Stop Music");
 }
 
+int Sound::registerSound(const char *name) {
+	debug(9, "STUB: Register Sound");
+	return 0;
+}
+
 bool Sound::freeSound(int index) {
 	debug(9, "STUB: Free Sound");
 	return true;
diff --git a/engines/hdb/sound.h b/engines/hdb/sound.h
index 895f6d9..3cbb5fb 100644
--- a/engines/hdb/sound.h
+++ b/engines/hdb/sound.h
@@ -1417,9 +1417,12 @@ public:
 	bool playSoundEx(int index, int channel, bool loop);
 	bool playVoice(int index, int actor);
 	bool startMusic(SoundType song);
+	bool fadeInMusic(SoundType song, int ramp);
+	void fadeOutMusic(int ramp);
+	void stopMusic();
 	bool songPlaying(SoundType song);
 	bool stopChannel(int channel);
-	void stopMusic();
+	int registerSound(const char *name);
 	bool freeSound(int index);
 
 	SoundType whatSongIsPlaying();


Commit: 4216aa965c6484081f4eb37081a25486fdbe0ebe
    https://github.com/scummvm/scummvm/commit/4216aa965c6484081f4eb37081a25486fdbe0ebe
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:19+02:00

Commit Message:
HDB: Unstub Sound Lua stubs

Changed paths:
    engines/hdb/lua-script.cpp


diff --git a/engines/hdb/lua-script.cpp b/engines/hdb/lua-script.cpp
index 06eb67b..c703c39 100644
--- a/engines/hdb/lua-script.cpp
+++ b/engines/hdb/lua-script.cpp
@@ -1100,37 +1100,85 @@ static int killTrigger(lua_State *L) {
 }
 
 static int startMusic(lua_State *L) {
-	warning("STUB: START MUSIC");
+	bool error;
+
+	double song = lua_tonumber(L, 1);
+	int s1 = (int)song;
+
+	g_hdb->_lua->checkParameters("startMusic", 1);
+
+	lua_pop(L, 1);
+	error = g_hdb->_sound->startMusic((SoundType)s1);
+
 	return 0;
 }
 
 static int fadeInMusic(lua_State *L) {
-	warning("STUB: FADE IN MUSIC");
+	bool error;
+
+	double song = lua_tonumber(L, 1);
+	int s1 = (int)song;
+	int ramp = (int)lua_tonumber(L, 2);
+	if (!ramp)
+		ramp = 1;
+
+	g_hdb->_lua->checkParameters("fadeInMusic", 2);
+
+	lua_pop(L, 2);
+	error = g_hdb->_sound->fadeInMusic((SoundType)s1, ramp);
+
 	return 0;
 }
 
 static int stopMusic(lua_State *L) {
-	warning("STUB: STOP MUSIC");
+	g_hdb->_sound->stopMusic();
 	return 0;
 }
 
 static int fadeOutMusic(lua_State *L) {
-	warning("STUB: FADE OUT MUSIC");
+	int ramp = (int)lua_tonumber(L, 1);
+	if (!ramp)
+		ramp = 1;
+
+	g_hdb->_lua->checkParameters("fadeOutMusic", 1);
+
+	lua_pop(L, 1);
+	g_hdb->_sound->fadeOutMusic(ramp);
+
 	return 0;
 }
 
 static int registerSound(lua_State *L) {
-	warning("STUB: REGISTER SOUND");
-	return 0;
+	const char *name = lua_tostring(L, 1);
+
+	g_hdb->_lua->checkParameters("registerSound", 1);
+
+	lua_pop(L, 1);
+	int index = g_hdb->_sound->registerSound(name);
+	lua_pushnumber(L, index);
+
+	return 1;
 }
 
 static int playSound(lua_State *L) {
-	warning("STUB: PLAY SOUND");
+	int index = (int)lua_tonumber(L, 1);
+
+	g_hdb->_lua->checkParameters("playSound", 1);
+
+	lua_pop(L, 1);
+	g_hdb->_sound->playSound(index);
+
 	return 0;
 }
 
 static int freeSound(lua_State *L) {
-	warning("STUB: FREE SOUND");
+	int index = (int)lua_tonumber(L, 1);
+
+	g_hdb->_lua->checkParameters("freeSound", 1);
+
+	lua_pop(L, 1);
+	g_hdb->_sound->freeSound(index);
+
 	return 0;
 }
 
@@ -1247,7 +1295,14 @@ static int setPointerState(lua_State *L) {
 }
 
 static int playVoice(lua_State *L) {
-	warning("STUB: PLAY VOICE");
+	double index = lua_tonumber(L, 1);
+	double actor = lua_tonumber(L, 2);
+
+	g_hdb->_lua->checkParameters("playVoice", 2);
+
+	lua_pop(L, 2);
+
+	g_hdb->_sound->playVoice((int)index, (int)actor);
 	return 0;
 }
 


Commit: f4e2fbcbc7fe2dbb184fa223df98328d0511caf4
    https://github.com/scummvm/scummvm/commit/f4e2fbcbc7fe2dbb184fa223df98328d0511caf4
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:19+02:00

Commit Message:
HDB: Add missing Gfx variable and Weapon functions

Changed paths:
    engines/hdb/ai.h


diff --git a/engines/hdb/ai.h b/engines/hdb/ai.h
index 3d20a1e..fcafdd8 100644
--- a/engines/hdb/ai.h
+++ b/engines/hdb/ai.h
@@ -899,6 +899,19 @@ public:
 
 	void movePlayer(uint16 buttons);
 	void playerUse();
+	void setPlayerWeapon(AIType w, Tile *gfx) {
+		_weaponSelected = w;
+		_weaponGfx = gfx;
+	}
+	AIType getPlayerWeapon() {
+		return _weaponSelected;
+	}
+	Tile *getPlayerWeaponGfx() {
+		return _weaponGfx;
+	}
+	Tile *getPlayerWeaponSelGfx() {
+		return _weaponSelGfx;
+	}
 
 	AIEntity *getPlayer() {
 		if (!_player)
@@ -1146,6 +1159,7 @@ public:
 	Picture		*_slugAttackGfx[kMaxAnimFrames];
 
 	Tile		*_weaponSelGfx;
+	Tile		*_weaponGfx;
 	AIType		_weaponSelected;
 
 	// Player Resources and Deliveries


Commit: fe09a9c09c4cd5fc4039ea0c40caa8e814ac179f
    https://github.com/scummvm/scummvm/commit/fe09a9c09c4cd5fc4039ea0c40caa8e814ac179f
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:19+02:00

Commit Message:
HDB: Initialize Weapon variables

Changed paths:
    engines/hdb/ai-init.cpp
    engines/hdb/ai-player.cpp


diff --git a/engines/hdb/ai-init.cpp b/engines/hdb/ai-init.cpp
index f4b96ce..64de429 100644
--- a/engines/hdb/ai-init.cpp
+++ b/engines/hdb/ai-init.cpp
@@ -1153,6 +1153,7 @@ void AI::restartSystem() {
 	_playerEmerging = false;
 
 	_weaponSelected = AI_NONE;
+	_weaponGfx = NULL;
 	_weaponSelGfx = NULL;
 
 	// Clear Cinematic System
diff --git a/engines/hdb/ai-player.cpp b/engines/hdb/ai-player.cpp
index a050892..7dbb1e8 100644
--- a/engines/hdb/ai-player.cpp
+++ b/engines/hdb/ai-player.cpp
@@ -55,56 +55,34 @@ void aiPlayerInit(AIEntity *e) {
 
 void aiPlayerInit2(AIEntity *e) {
 	if (!g_hdb->_ai->_clubUpGfx[0]) {
-		warning("STUB: weapon_sel_gfx uninitialized");
-		g_hdb->_ai->_clubUpGfx[0] = new Picture;
-		g_hdb->_ai->_clubUpGfx[0]->load(g_hdb->_fileMan->findFirstData("clubup1", TYPE_PIC));
-		g_hdb->_ai->_clubUpGfx[1] = new Picture;
-		g_hdb->_ai->_clubUpGfx[1]->load(g_hdb->_fileMan->findFirstData("clubup2", TYPE_PIC));
-		g_hdb->_ai->_clubUpGfx[2] = new Picture;
-		g_hdb->_ai->_clubUpGfx[2]->load(g_hdb->_fileMan->findFirstData("clubup3", TYPE_PIC));
-		g_hdb->_ai->_clubUpGfx[3] = new Picture;
-		g_hdb->_ai->_clubUpGfx[3]->load(g_hdb->_fileMan->findFirstData("clubup3", TYPE_PIC));
-
-		g_hdb->_ai->_clubDownGfx[0] = new Picture;
-		g_hdb->_ai->_clubDownGfx[0]->load(g_hdb->_fileMan->findFirstData("clubdown1", TYPE_PIC));
-		g_hdb->_ai->_clubDownGfx[1] = new Picture;
-		g_hdb->_ai->_clubDownGfx[1]->load(g_hdb->_fileMan->findFirstData("clubdown2", TYPE_PIC));
-		g_hdb->_ai->_clubDownGfx[2] = new Picture;
-		g_hdb->_ai->_clubDownGfx[2]->load(g_hdb->_fileMan->findFirstData("clubdown3", TYPE_PIC));
-		g_hdb->_ai->_clubDownGfx[3] = new Picture;
-		g_hdb->_ai->_clubDownGfx[3]->load(g_hdb->_fileMan->findFirstData("clubdown3", TYPE_PIC));
-
-		g_hdb->_ai->_clubLeftGfx[0] = new Picture;
-		g_hdb->_ai->_clubLeftGfx[0]->load(g_hdb->_fileMan->findFirstData("clubleft1", TYPE_PIC));
-		g_hdb->_ai->_clubLeftGfx[1] = new Picture;
-		g_hdb->_ai->_clubLeftGfx[1]->load(g_hdb->_fileMan->findFirstData("clubleft2", TYPE_PIC));
-		g_hdb->_ai->_clubLeftGfx[2] = new Picture;
-		g_hdb->_ai->_clubLeftGfx[2]->load(g_hdb->_fileMan->findFirstData("clubleft3", TYPE_PIC));
-		g_hdb->_ai->_clubLeftGfx[3] = new Picture;
-		g_hdb->_ai->_clubLeftGfx[3]->load(g_hdb->_fileMan->findFirstData("clubleft3", TYPE_PIC));
-
-		g_hdb->_ai->_clubRightGfx[0] = new Picture;
-		g_hdb->_ai->_clubRightGfx[0]->load(g_hdb->_fileMan->findFirstData("clubright1", TYPE_PIC));
-		g_hdb->_ai->_clubRightGfx[1] = new Picture;
-		g_hdb->_ai->_clubRightGfx[1]->load(g_hdb->_fileMan->findFirstData("clubright2", TYPE_PIC));
-		g_hdb->_ai->_clubRightGfx[2] = new Picture;
-		g_hdb->_ai->_clubRightGfx[2]->load(g_hdb->_fileMan->findFirstData("clubright3", TYPE_PIC));
-		g_hdb->_ai->_clubRightGfx[3] = new Picture;
-		g_hdb->_ai->_clubRightGfx[3]->load(g_hdb->_fileMan->findFirstData("clubright3", TYPE_PIC));
-
-		g_hdb->_ai->_clubUpFrames = 4;
-		g_hdb->_ai->_clubDownFrames = 4;
-		g_hdb->_ai->_clubLeftFrames = 4;
-		g_hdb->_ai->_clubRightFrames = 4;
-
-		g_hdb->_ai->_slugAttackGfx[0] = new Picture;
-		g_hdb->_ai->_slugAttackGfx[0]->load(g_hdb->_fileMan->findFirstData("slug_shot1", TYPE_PIC));
-		g_hdb->_ai->_slugAttackGfx[1] = new Picture;
-		g_hdb->_ai->_slugAttackGfx[1]->load(g_hdb->_fileMan->findFirstData("slug_shot2", TYPE_PIC));
-		g_hdb->_ai->_slugAttackGfx[2] = new Picture;
-		g_hdb->_ai->_slugAttackGfx[2]->load(g_hdb->_fileMan->findFirstData("slug_shot3", TYPE_PIC));
-		g_hdb->_ai->_slugAttackGfx[3] = new Picture;
-		g_hdb->_ai->_slugAttackGfx[3]->load(g_hdb->_fileMan->findFirstData("slug_shot4", TYPE_PIC));
+		g_hdb->_ai->_weaponSelGfx = g_hdb->_gfx->loadTile(TILE_WEAPON_EQUIPPED);
+		g_hdb->_ai->_clubUpGfx[0] = g_hdb->_gfx->loadPic(CLUBUP1);
+		g_hdb->_ai->_clubUpGfx[1] = g_hdb->_gfx->loadPic(CLUBUP2);
+		g_hdb->_ai->_clubUpGfx[2] = g_hdb->_gfx->loadPic(CLUBUP3);
+		g_hdb->_ai->_clubUpGfx[3] = g_hdb->_gfx->loadPic(CLUBUP3);
+
+		g_hdb->_ai->_clubDownGfx[0] = g_hdb->_gfx->loadPic(CLUBDOWN1);
+		g_hdb->_ai->_clubDownGfx[1] = g_hdb->_gfx->loadPic(CLUBDOWN2);
+		g_hdb->_ai->_clubDownGfx[2] = g_hdb->_gfx->loadPic(CLUBDOWN3);
+		g_hdb->_ai->_clubDownGfx[3] = g_hdb->_gfx->loadPic(CLUBDOWN3);
+
+		g_hdb->_ai->_clubLeftGfx[0] = g_hdb->_gfx->loadPic(CLUBLEFT1);
+		g_hdb->_ai->_clubLeftGfx[1] = g_hdb->_gfx->loadPic(CLUBLEFT2);
+		g_hdb->_ai->_clubLeftGfx[2] = g_hdb->_gfx->loadPic(CLUBLEFT3);
+		g_hdb->_ai->_clubLeftGfx[3] = g_hdb->_gfx->loadPic(CLUBLEFT3);
+
+		g_hdb->_ai->_clubRightGfx[0] = g_hdb->_gfx->loadPic(CLUBRIGHT1);
+		g_hdb->_ai->_clubRightGfx[1] = g_hdb->_gfx->loadPic(CLUBRIGHT2);
+		g_hdb->_ai->_clubRightGfx[2] = g_hdb->_gfx->loadPic(CLUBRIGHT3);
+		g_hdb->_ai->_clubRightGfx[3] = g_hdb->_gfx->loadPic(CLUBRIGHT3);
+
+		g_hdb->_ai->_clubUpFrames = g_hdb->_ai->_clubDownFrames =
+			g_hdb->_ai->_clubLeftFrames = g_hdb->_ai->_clubRightFrames = 4;
+
+		g_hdb->_ai->_slugAttackGfx[0] = g_hdb->_gfx->loadPic(SLUG_SHOT1);
+		g_hdb->_ai->_slugAttackGfx[1] = g_hdb->_gfx->loadPic(SLUG_SHOT2);
+		g_hdb->_ai->_slugAttackGfx[2] = g_hdb->_gfx->loadPic(SLUG_SHOT3);
+		g_hdb->_ai->_slugAttackGfx[3] = g_hdb->_gfx->loadPic(SLUG_SHOT4);
 
 		int32 size = g_hdb->_fileMan->getLength("shock_spark_sit01", TYPE_TILE32);
 		g_hdb->_ai->_stunLightningGfx[0] = g_hdb->_gfx->getTileGfx("shock_spark_sit01", size);


Commit: de7b30a23cdb90e0ed6e7c1373800f98df675cf1
    https://github.com/scummvm/scummvm/commit/de7b30a23cdb90e0ed6e7c1373800f98df675cf1
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:19+02:00

Commit Message:
HDB: Add queryInventoryTypeSlot()

Changed paths:
    engines/hdb/ai-inventory.cpp
    engines/hdb/ai.h


diff --git a/engines/hdb/ai-inventory.cpp b/engines/hdb/ai-inventory.cpp
index 8ed6e9e..a26610e 100644
--- a/engines/hdb/ai-inventory.cpp
+++ b/engines/hdb/ai-inventory.cpp
@@ -197,6 +197,18 @@ int AI::queryInventoryType(AIType which) {
 	return count;
 }
 
+int AI::queryInventoryTypeSlot(AIType which) {
+	int i;
+
+	if (!_numInventory)
+		return 0;
+
+	for (i = 0; i < _numInventory; i++)
+		if (_inventory[i].ent.type == which)
+			return i;
+	return -1;
+}
+
 bool AI::removeInvItemType(AIType which, int amount) {
 	int		i, j, found;
 
diff --git a/engines/hdb/ai.h b/engines/hdb/ai.h
index fcafdd8..f3802d5 100644
--- a/engines/hdb/ai.h
+++ b/engines/hdb/ai.h
@@ -1065,6 +1065,7 @@ public:
 	int queryInventory(const char *string);
 	bool removeInvItem(const char *string, int amount);
 	int queryInventoryType(AIType which);
+	int queryInventoryTypeSlot(AIType which);
 	bool removeInvItemType(AIType which, int amount);
 	bool addItemToInventory(AIType type, int amount, const char *funcInit, const char *funcAction, const char *funcUse);
 	void keepInvItem(AIType type);


Commit: cea99e3fcd8621b01fe089e65c9403e6365aa39a
    https://github.com/scummvm/scummvm/commit/cea99e3fcd8621b01fe089e65c9403e6365aa39a
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:19+02:00

Commit Message:
HDB: Unstub Weapon code from save/load

Changed paths:
    engines/hdb/ai-init.cpp


diff --git a/engines/hdb/ai-init.cpp b/engines/hdb/ai-init.cpp
index 64de429..dadca18 100644
--- a/engines/hdb/ai-init.cpp
+++ b/engines/hdb/ai-init.cpp
@@ -1264,7 +1264,7 @@ void AI::save(Common::OutSaveFile *out) {
 	out->writeByte(_playerOnIce);
 	out->writeByte(_playerEmerging);
 	out->writeByte(_playerRunning);
-	warning("STUB: Save whether weapon is selected");
+	out->writeSint32LE((int)_weaponSelected);
 
 	// Save Teleporters
 	for (i = 0; i < kMaxTeleporters; i++) {
@@ -1454,7 +1454,7 @@ void AI::loadSaveFile(Common::InSaveFile *in) {
 	_playerOnIce = in->readByte();
 	_playerEmerging = in->readByte();
 	_playerRunning = in->readByte();
-	warning("STUB: Load whether weapon is selected or not");
+	_weaponSelected = (AIType)in->readSint32LE();
 
 	// Load Teleporters
 	for (i = 0; i < kMaxTeleporters; i++) {
@@ -1698,7 +1698,13 @@ void AI::loadSaveFile(Common::InSaveFile *in) {
 	initAnimInfo();
 
 	// Set the Player weapon
-	warning("STUB: Set the Player weapon");
+	if (_weaponSelected != AI_NONE) {
+		int slot = queryInventoryTypeSlot(_weaponSelected);
+		if (slot != -1) {
+			Tile *gfx = getInvItemGfx(slot);
+			setPlayerWeapon(_weaponSelected, gfx);
+		}
+	}
 }
 
 void AI::initAnimInfo() {


Commit: 44ae2202aaf7f5f54ddd743d7494690afda3bcc3
    https://github.com/scummvm/scummvm/commit/44ae2202aaf7f5f54ddd743d7494690afda3bcc3
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:19+02:00

Commit Message:
HDB: Fix Lua Index

Changed paths:
    engines/hdb/lua-script.cpp


diff --git a/engines/hdb/lua-script.cpp b/engines/hdb/lua-script.cpp
index c703c39..3e55ed5 100644
--- a/engines/hdb/lua-script.cpp
+++ b/engines/hdb/lua-script.cpp
@@ -461,7 +461,7 @@ static int cineDrawPic(lua_State *L) {
 	const char *id = lua_tostring(L, 1);
 	const char *pic = lua_tostring(L, 2);
 	double x = lua_tonumber(L, 3);
-	double y = lua_tonumber(L, 3);
+	double y = lua_tonumber(L, 4);
 
 	g_hdb->_lua->checkParameters("cineDrawPic", 4);
 
@@ -478,7 +478,7 @@ static int cineDrawMaskedPic(lua_State *L) {
 	const char *id = lua_tostring(L, 1);
 	const char *pic = lua_tostring(L, 2);
 	double x = lua_tonumber(L, 3);
-	double y = lua_tonumber(L, 3);
+	double y = lua_tonumber(L, 4);
 
 	g_hdb->_lua->checkParameters("cineDrawMaskedPic", 4);
 


Commit: a5da708868db6ba1ac0821d3c03023d7d48525ee
    https://github.com/scummvm/scummvm/commit/a5da708868db6ba1ac0821d3c03023d7d48525ee
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:20+02:00

Commit Message:
HDB: Add Weapon Drawing and Equipping Code

Changed paths:
    engines/hdb/window.cpp
    engines/hdb/window.h


diff --git a/engines/hdb/window.cpp b/engines/hdb/window.cpp
index 8df868e..486f980 100644
--- a/engines/hdb/window.cpp
+++ b/engines/hdb/window.cpp
@@ -379,6 +379,37 @@ void Window::checkPause(int x, int y) {
 	}
 }
 
+void Window::drawWeapon() {
+}
+
+void Window::chooseWeapon(AIType wType) {
+	static	AIType lastWeaponSelected = AI_NONE;
+	Tile *gfx;
+	int	slot = g_hdb->_ai->queryInventoryTypeSlot(wType);
+
+	g_hdb->_sound->playSound(SND_MENU_SLIDER);
+
+	if (!g_hdb->getActionMode())
+		return;
+
+	gfx = g_hdb->_ai->getInvItemGfx(slot);
+
+	switch (wType) {
+	case ITEM_CLUB:
+	case ITEM_ROBOSTUNNER:
+	case ITEM_SLUGSLINGER:
+		g_hdb->_ai->setPlayerWeapon(wType, gfx);
+		if (wType == lastWeaponSelected)
+			return;
+		lastWeaponSelected = wType;
+		g_hdb->_sound->playSound(SND_MENU_ACCEPT);
+		return;
+	default:
+		break;
+	}
+	g_hdb->_sound->playSound(SND_CELLHOLDER_USE_REJECT);
+}
+
 void Window::closeAll() {
 	closeDialog();
 	closeDialogChoice();
@@ -450,8 +481,16 @@ void Window::drawDialog() {
 	_gfxBR->drawMasked(_gfxBL->_width + _gfxBM->_width, _gfxTL->_height + _gfxL->_height);
 #endif
 
-	if (g_hdb->getActionMode())
-		debug(9, "STUB: drawDialog: Draw Player Weapon");
+	if (g_hdb->getActionMode()) {
+		Tile *gfx2 = g_hdb->_ai->getPlayerWeaponGfx();
+		if (gfx2) {
+			int xOff = 40 * _pzInfo.active;
+			Tile *gfx = g_hdb->_ai->getPlayerWeaponSelGfx();
+			gfx->drawMasked(kWeaponX - xOff - 1, kWeaponY);
+			gfx2->drawMasked(kWeaponX - xOff, kWeaponY);
+			drawWeapon();
+		}
+	}
 
 	if (!_dialogInfo.active)
 		return;
@@ -939,10 +978,27 @@ void Window::checkInvSelect(int x, int y) {
 		_invWinInfo.selection = yc * kInvItemPerLine + xc;
 
 		// If this is a weapon, choose it
-		warning("STUB: checkInvSelect: ChooseWeapon() required");
+		AIType t = g_hdb->_ai->getInvItemType(_invWinInfo.selection);
+		switch (t) {
+		case ITEM_CLUB:
+		case ITEM_ROBOSTUNNER:
+		case ITEM_SLUGSLINGER:
+			chooseWeapon(t);
+			if (t == ITEM_CLUB)
+				g_hdb->_sound->playSound(SND_GET_CLUB);
+			else if (t == ITEM_ROBOSTUNNER)
+				g_hdb->_sound->playSound(SND_GET_STUNNER);
+			else if (t == ITEM_SLUGSLINGER)
+				g_hdb->_sound->playSound(SND_GET_SLUG);
+			return;
+		default:
+			break;
+		}
 
 		g_hdb->_sound->playSound(SND_POP);
 	}
+
+	return;
 }
 
 void Window::openDeliveries(bool animate) {
diff --git a/engines/hdb/window.h b/engines/hdb/window.h
index 21dd98d..5bc95fa 100644
--- a/engines/hdb/window.h
+++ b/engines/hdb/window.h
@@ -189,6 +189,10 @@ public:
 	void drawPause();
 	void checkPause(int x, int y);
 
+	// Weapon Functions
+	void drawWeapon();
+	void chooseWeapon(AIType wType);
+
 	// Dialog Functions
 
 	void openDialog(const char *title, int tileIndex, const char *string, int more, const char *luaMore);


Commit: 0c5f2f024382cdaa6bd372b8240446d2c7e34d89
    https://github.com/scummvm/scummvm/commit/0c5f2f024382cdaa6bd372b8240446d2c7e34d89
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:20+02:00

Commit Message:
HDB: Add Player Attacking code

Changed paths:
    engines/hdb/ai-funcs.cpp


diff --git a/engines/hdb/ai-funcs.cpp b/engines/hdb/ai-funcs.cpp
index 3a3c50e..dea37fe 100644
--- a/engines/hdb/ai-funcs.cpp
+++ b/engines/hdb/ai-funcs.cpp
@@ -2324,7 +2324,58 @@ void AI::movePlayer(uint16 buttons) {
 
 		if (g_hdb->getActionMode() && ((hit && attackable) || !hit)) {
 			// Attack
-			warning("STUB: movePlayer: Attack!");
+			if (_weaponSelected != AI_NONE && onEvenTile(_player->x, _player->y)) {
+				switch (_weaponSelected) {
+				case ITEM_CLUB: {
+					AIState club[5] = {STATE_NONE, STATE_ATK_CLUB_UP, STATE_ATK_CLUB_DOWN, STATE_ATK_CLUB_LEFT, STATE_ATK_CLUB_RIGHT};
+					_player->state = club[_player->dir];
+					_player->animFrame = 0;
+					_player->animDelay = _player->animCycle;
+					g_hdb->_sound->playSound(SND_CLUB_MISS);
+				}
+				break;
+
+				case ITEM_ROBOSTUNNER: {
+					// it costs 1 gem to attack!
+					if (!amt) {
+						g_hdb->_sound->playSound(SND_CELLHOLDER_USE_REJECT);
+						g_hdb->_window->openMessageBar("Recharging...", 1);
+						setGemAmount(1);
+						return;
+					}
+					setGemAmount(amt - 1);
+
+					AIState stun[5] = {STATE_NONE, STATE_ATK_STUN_UP, STATE_ATK_STUN_DOWN, STATE_ATK_STUN_LEFT, STATE_ATK_STUN_RIGHT};
+					_player->state = stun[_player->dir];
+					_player->animFrame = 0;
+					_player->animDelay = _player->animCycle;
+					_player->sequence = 1;
+				}
+				break;
+
+				case ITEM_SLUGSLINGER: {
+					// it costs 1 gem to attack!
+					if (!amt) {
+						g_hdb->_sound->playSound(SND_CELLHOLDER_USE_REJECT);
+						g_hdb->_window->openMessageBar("Recharging...", 1);
+						setGemAmount(1);
+						return;
+					}
+					setGemAmount(amt - 1);
+
+					AIState slug[5] = {STATE_NONE, STATE_ATK_SLUG_UP, STATE_ATK_SLUG_DOWN, STATE_ATK_SLUG_LEFT, STATE_ATK_SLUG_RIGHT};
+					_player->state = slug[_player->dir];
+					_player->animFrame = 0;
+					_player->animDelay = _player->animCycle;
+					spawn(AI_SLUG_ATTACK, _player->dir, _player->tileX, _player->tileY,
+						NULL, NULL, NULL, DIR_NONE, _player->level, 0, 0, 1);
+				}
+				break;
+
+				default:
+					break;
+				}	// switch
+			}
 			return;
 		}
 


Commit: d07dcd210cf1ec04aa7b4f3c76ac2b9f1af57af4
    https://github.com/scummvm/scummvm/commit/d07dcd210cf1ec04aa7b4f3c76ac2b9f1af57af4
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:20+02:00

Commit Message:
HDB: Add code to ready Weapon

Changed paths:
    engines/hdb/ai-inventory.cpp


diff --git a/engines/hdb/ai-inventory.cpp b/engines/hdb/ai-inventory.cpp
index a26610e..ff14f15 100644
--- a/engines/hdb/ai-inventory.cpp
+++ b/engines/hdb/ai-inventory.cpp
@@ -68,9 +68,9 @@ bool AI::addToInventory(AIEntity *e) {
 	case ITEM_CLUB:
 	case ITEM_ROBOSTUNNER:
 	case ITEM_SLUGSLINGER:
-		warning("STUB: addToInventory: Ready weapon");
+		g_hdb->_window->chooseWeapon(e->type);
 	default:
-		warning("AI-INVENTORY: addToInventory: Unintended Type");
+		break;
 	}
 
 	printYouGotMsg(e->printedName);


Commit: 9dec31c4586e2733cbe9fe6eb9f49673adfbd38b
    https://github.com/scummvm/scummvm/commit/9dec31c4586e2733cbe9fe6eb9f49673adfbd38b
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:20+02:00

Commit Message:
HDB: Unstub drawWaypoints()

Changed paths:
    engines/hdb/ai-waypoint.cpp


diff --git a/engines/hdb/ai-waypoint.cpp b/engines/hdb/ai-waypoint.cpp
index 9e16e13..4147354 100644
--- a/engines/hdb/ai-waypoint.cpp
+++ b/engines/hdb/ai-waypoint.cpp
@@ -523,14 +523,51 @@ Tile *AI::getStandFrameDir(AIEntity *e) {
 			return e->moverightGfx[0];
 		break;
 	case DIR_NONE:
-		warning("AI-WAYPOINT: getStandFrameDir: DIR_NONE found");
 		break;
 	}
 	return e->standdownGfx[0];
 }
 
 void AI::drawWayPoints() {
-	debug(9, "STUB: AI::drawWayPoints()");
+	int	i;
+	int	mapX, mapY;
+	static int anim = 0;
+	static uint32 delay = g_hdb->getTimeSlice();
+	static int alpha = 255;
+	static int aVel = -4;
+
+	g_hdb->_map->getMapXY(&mapX, &mapY);
+
+	for (i = 0; i < _numWaypoints; i++) {
+		int	x = _waypoints[i].x * kTileWidth;
+		int	y = _waypoints[i].y * kTileHeight;
+
+		if (x > mapX - 32 && (x < (mapX + kScreenWidth)) &&
+			y > mapY - 32 && (y < (mapY + kScreenHeight)))
+			_waypointGfx[anim]->drawMasked(x - mapX, y - mapY, alpha);
+	}
+
+	// vary the alpha blending
+	alpha = (alpha + aVel);
+	if (alpha < 64) {
+		alpha = 64;
+		aVel = -aVel;
+	}
+
+	if (alpha > 200) {
+		alpha = 200;
+		aVel = -aVel;
+	}
+
+	// don't animate every single game frame...
+	if (delay > g_hdb->getTimeSlice())
+		return;
+	delay = g_hdb->getTimeSlice() + 100;
+
+	// cycle the waypoint gfx animation
+	anim++;
+	if (anim == 4)
+		anim = 0;
 }
 
 } // End of Namespace


Commit: a745d45f380d9cd6a042171b8cb2ceabe1b62ce5
    https://github.com/scummvm/scummvm/commit/a745d45f380d9cd6a042171b8cb2ceabe1b62ce5
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:20+02:00

Commit Message:
HDB: Ignore the Controls Option

Changed paths:
    engines/hdb/menu.cpp


diff --git a/engines/hdb/menu.cpp b/engines/hdb/menu.cpp
index 53ffcda..99d9c77 100644
--- a/engines/hdb/menu.cpp
+++ b/engines/hdb/menu.cpp
@@ -467,13 +467,17 @@ void Menu::drawMenu() {
 			// title logo
 			_titleLogo->drawMasked(centerPic(_titleLogo), _rocketY + kMTitleY);
 			_menuBackoutGfx->drawMasked(kBackoutX, kBackoutY);
-			_controlButtonGfx->drawMasked(centerPic(_controlButtonGfx), kMControlsY);
+
+			// Ignore Controls Screen Button
+			//_controlButtonGfx->drawMasked(centerPic(_controlButtonGfx), kMControlsY);
 		} else if (_optionsActive == 2) {
 			//
 			// Draw CONTROLS screen
 			//
-				controlsDraw();
-				return;
+
+			// Ignore Controls Assignment
+			//controlsDraw();
+			return;
 		}
 	} else if (_gamefilesActive) {
 		//-------------------------------------------------------------------
@@ -1139,9 +1143,11 @@ void Menu::processInput(int x, int y) {
 		} else if (x >= (kScreenWidth / 2 - _controlButtonGfx->_width / 2) && x < (kScreenWidth / 2 + _controlButtonGfx->_width / 2) &&
 			y >= kMControlsY && y < kMControlsY + _controlButtonGfx->_height) {
 			// CONTROLS BUTTON!
-			_optionsActive = 2;
-			_clickDelay = 20;
-			g_hdb->_sound->playSound(SND_POP);
+
+			// Ignore Controls Button
+			//_optionsActive = 2;
+			//_clickDelay = 20;
+			//g_hdb->_sound->playSound(SND_POP);
 		}
 	} else if (_gamefilesActive) {
 		//-------------------------------------------------------------------


Commit: 2c40e1ae365578a1b6913dd72460fb8dba55090d
    https://github.com/scummvm/scummvm/commit/2c40e1ae365578a1b6913dd72460fb8dba55090d
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:20+02:00

Commit Message:
HDB: Fix loading Lua scripts

Changed paths:
    engines/hdb/lua-script.cpp


diff --git a/engines/hdb/lua-script.cpp b/engines/hdb/lua-script.cpp
index 3e55ed5..8302fca 100644
--- a/engines/hdb/lua-script.cpp
+++ b/engines/hdb/lua-script.cpp
@@ -1706,9 +1706,8 @@ void debugHook(lua_State *L, lua_Debug *ar) {
 }
 
 bool LuaScript::initScript(Common::SeekableReadStream *stream, const char *scriptName, int32 length) {
-
 	if (_systemInit) {
-		return false;
+		lua_close(_state);
 	}
 
 	// Initialize Lua Environment


Commit: 73414fdc4795f074ad3fe9023ca2695b17b1da0d
    https://github.com/scummvm/scummvm/commit/73414fdc4795f074ad3fe9023ca2695b17b1da0d
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:20+02:00

Commit Message:
HDB: Add _debugLogo

Changed paths:
    engines/hdb/hdb.cpp
    engines/hdb/hdb.h


diff --git a/engines/hdb/hdb.cpp b/engines/hdb/hdb.cpp
index da9107a..13d44f2 100644
--- a/engines/hdb/hdb.cpp
+++ b/engines/hdb/hdb.cpp
@@ -118,6 +118,7 @@ bool HDBGame::init() {
 
 	_menu->init();
 
+	_debugLogo = _gfx->loadTile("icon_debug_logo");
 	_progressGfx = _gfx->loadPic(PIC_LOADBAR);
 	_progressMarkGfx = _gfx->loadPic(PIC_LOADSTAR);
 	_logoGfx = NULL;
@@ -285,6 +286,13 @@ void HDBGame::paint() {
 		break;
 	}
 
+	// Draw FPS on Screen in Debug Mode
+	if (_debugFlag == 1) {
+		debug(9, "STUB: Requires StartTiming() and EndTiming()");
+	} else if (_debugFlag == 2) {
+		_debugLogo->drawMasked(kScreenWidth - 32, 0);
+	}
+
 	_gfx->updateVideo();
 }
 
diff --git a/engines/hdb/hdb.h b/engines/hdb/hdb.h
index 549eed3..cb6c1f1 100644
--- a/engines/hdb/hdb.h
+++ b/engines/hdb/hdb.h
@@ -316,6 +316,8 @@ private:
 	int _pauseFlag;
 	bool _cheating;
 	int _debugFlag;
+	Tile *_debugLogo;
+	int _dx, _dy;	// DEBUG : for dragging map
 
 	char _currentMapname[64];
 	char _lastMapname[64];


Commit: 469c2245b4080d75e46268d427ab13c39e8a8f36
    https://github.com/scummvm/scummvm/commit/469c2245b4080d75e46268d427ab13c39e8a8f36
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:20+02:00

Commit Message:
HDB: Add moveMap() and startMoveMap()

Changed paths:
    engines/hdb/hdb.cpp
    engines/hdb/hdb.h
    engines/hdb/map.h


diff --git a/engines/hdb/hdb.cpp b/engines/hdb/hdb.cpp
index 13d44f2..3c1930c 100644
--- a/engines/hdb/hdb.cpp
+++ b/engines/hdb/hdb.cpp
@@ -454,6 +454,32 @@ void HDBGame::setTargetXY(int x, int y) {
 	}
 }
 
+void HDBGame::startMoveMap(int x, int y) {
+	_dx = x;
+	_dy = y;
+}
+
+void HDBGame::moveMap(int x, int y) {
+	int	ox, oy;
+
+	g_hdb->_map->getMapXY(&ox, &oy);
+
+	ox += (_dx - x) / 8;
+	oy += (_dy - y) / 8;
+
+	if (ox < 0)
+		ox = 0;
+	else if (ox > g_hdb->_map->mapPixelWidth() - 240)
+		ox = g_hdb->_map->mapPixelWidth() - 240;
+
+	if (oy < 0)
+		oy = 0;
+	else if (oy > g_hdb->_map->mapPixelHeight() - 320)
+			oy = g_hdb->_map->mapPixelHeight() - 320;
+
+	g_hdb->_map->setMapXY(ox, oy);
+}
+
 // PLAYER is trying to use this entity
 void HDBGame::useEntity(AIEntity *e) {
 	warning("STUB: HDBGame::useEntity incomplete");
diff --git a/engines/hdb/hdb.h b/engines/hdb/hdb.h
index cb6c1f1..6de2809 100644
--- a/engines/hdb/hdb.h
+++ b/engines/hdb/hdb.h
@@ -196,6 +196,8 @@ public:
 	}
 	void changeGameState();
 	void paint();
+	void moveMap(int x, int y);	// Get Stylus Coords and Scroll
+	void startMoveMap(int x, int y);	// Start Dragging Map
 
 	void setTargetXY(int x, int y);
 	void useEntity(AIEntity *e);
diff --git a/engines/hdb/map.h b/engines/hdb/map.h
index 40191f7..1822c86 100644
--- a/engines/hdb/map.h
+++ b/engines/hdb/map.h
@@ -95,6 +95,12 @@ public:
 			return true;
 		return false;
 	}
+	int mapPixelWidth() {
+		return _width * kTileWidth;
+	}
+	int mapPixelHeight() {
+		return _height * kTileHeight;
+	}
 
 	uint32 getMapBGTileFlags(int x, int y);
 	uint32 getMapFGTileFlags(int x, int y);


Commit: b36569d201d45e65cabe3fc409a2de97dbaef00e
    https://github.com/scummvm/scummvm/commit/b36569d201d45e65cabe3fc409a2de97dbaef00e
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:20+02:00

Commit Message:
HDB: Add code to enable Debugging

Changed paths:
    engines/hdb/input.cpp


diff --git a/engines/hdb/input.cpp b/engines/hdb/input.cpp
index 21267f5..4b7ee6a 100644
--- a/engines/hdb/input.cpp
+++ b/engines/hdb/input.cpp
@@ -72,7 +72,22 @@ void Input::setButtons(uint16 b) {
 	}
 
 	// Debug Mode Cycling
-	debug(9, "STUB: setButtons: Check and set Debug Mode");
+	if ((_buttons & kButtonExit) && g_hdb->getCheatingOn()) {
+		int	debugFlag = g_hdb->getDebug();
+		debugFlag++;
+		if (debugFlag > 2)
+			debugFlag = 0;
+		g_hdb->setDebug(debugFlag);
+
+		if (debugFlag == 2)
+			g_hdb->_ai->clearWaypoints();
+
+		if (!debugFlag && g_hdb->getGameState() == GAME_PLAY) {
+			int	x, y;
+			g_hdb->_ai->getPlayerXY(&x, &y);
+			g_hdb->_map->centerMapXY(x + 16, y + 16);	// point to center of player
+		}
+	}
 
 	if (g_hdb->getGameState() == GAME_PLAY) {
 		// Is Player Dead? Click on TRY AGAIN


Commit: c31217f1ee471278115006afd6f6c6a5a8b95705
    https://github.com/scummvm/scummvm/commit/c31217f1ee471278115006afd6f6c6a5a8b95705
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:20+02:00

Commit Message:
HDB: Add Debug checks

Changed paths:
    engines/hdb/input.cpp
    engines/hdb/menu.cpp


diff --git a/engines/hdb/input.cpp b/engines/hdb/input.cpp
index 4b7ee6a..35346f5 100644
--- a/engines/hdb/input.cpp
+++ b/engines/hdb/input.cpp
@@ -173,7 +173,17 @@ void Input::stylusDown(int x, int y) {
 			return;
 
 		// Check for map dragging in debug Mode and place player there
-		warning("STUB: stylusDown: Check for Map dragging in Debug Mode");
+		if ((GAME_PLAY == g_hdb->getGameState()) && g_hdb->getDebug() == 2) {
+			int		mx, my;
+
+			g_hdb->_map->getMapXY(&mx, &my);
+			mx = ((mx + _stylusDownY) / kTileWidth) * kTileWidth;
+			my = ((my + _stylusDownY) / kTileHeight) * kTileHeight;
+			g_hdb->_ai->setPlayerXY(mx, my);
+
+			g_hdb->startMoveMap(x, y);
+			return;
+		}
 
 		// Clicked in the world
 		g_hdb->_map->getMapXY(&worldX, &worldY);
@@ -218,7 +228,8 @@ void Input::stylusMove(int x, int y) {
 
 	switch (g_hdb->getGameState()) {
 	case GAME_PLAY:
-		warning("STUB: stylusMove: Add GetDebug() check");
+		if (g_hdb->getDebug() == 2)
+			g_hdb->moveMap(x, y);
 		break;
 	case GAME_MENU:
 		g_hdb->_menu->processInput(x, y);
diff --git a/engines/hdb/menu.cpp b/engines/hdb/menu.cpp
index 99d9c77..d70642e 100644
--- a/engines/hdb/menu.cpp
+++ b/engines/hdb/menu.cpp
@@ -1220,7 +1220,8 @@ void Menu::processInput(int x, int y) {
 
 			_warpActive = map + 2;
 			g_hdb->paint();
-			debug(9, "STUB: Add Debug check");
+			if (g_hdb->getDebug())
+				g_hdb->_gfx->updateVideo();
 			_warpActive = 0;
 
 			if (map < 10)


Commit: a3ba287c1e45b39b9401601eaa04177cdf0b921c
    https://github.com/scummvm/scummvm/commit/a3ba287c1e45b39b9401601eaa04177cdf0b921c
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:20+02:00

Commit Message:
HDB: Add code for drawing Debug Mark

Changed paths:
    engines/hdb/ai-funcs.cpp


diff --git a/engines/hdb/ai-funcs.cpp b/engines/hdb/ai-funcs.cpp
index dea37fe..e5923ed 100644
--- a/engines/hdb/ai-funcs.cpp
+++ b/engines/hdb/ai-funcs.cpp
@@ -1647,6 +1647,7 @@ void AI::animEntFrames(AIEntity *e) {
 
 void AI::drawEnts(int x, int y, int w, int h) {
 
+	int debugFlag = g_hdb->getDebug();
 	static int stunAnim = 0;
 	static uint32 stunTimer = g_hdb->getTimeSlice();
 
@@ -1730,6 +1731,8 @@ void AI::drawEnts(int x, int y, int w, int h) {
 						debugN(5, "at %d %d", e->x, e->y);
 
 						e->draw->drawMasked(e->x - x + e->drawXOff, e->y - y + e->drawYOff);
+					} else if (debugFlag) {
+						_debugQMark->drawMasked(e->x - x, e->y - y);
 					} else {
 						debugN(5, "no draw function");
 					}
@@ -1759,7 +1762,7 @@ void AI::drawEnts(int x, int y, int w, int h) {
 }
 
 void AI::drawLevel2Ents() {
-	int debugging = g_hdb->getDebug();
+	int debugFlag = g_hdb->getDebug();
 
 	for (int i = 0; i < _numLevel2Ents; i++) {
 		// call custom drawing code?
@@ -1771,7 +1774,7 @@ void AI::drawLevel2Ents() {
 			debug(5, "AI::drawLevel2Ents: tile '%s' at %d,%d", _entsLevel2[i].draw->getName(), _entsLevel2[i].x, _entsLevel2[i].y);
 
 			_entsLevel2[i].draw->drawMasked(_entsLevel2[i].x, _entsLevel2[i].y);
-		} else if (debugging) {
+		} else if (debugFlag) {
 			_debugQMark->drawMasked(_entsLevel2[i].x, _entsLevel2[i].y );
 		}
 


Commit: 779f455292c5d1ec31df2c9962a8d56bbce280aa
    https://github.com/scummvm/scummvm/commit/779f455292c5d1ec31df2c9962a8d56bbce280aa
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:20+02:00

Commit Message:
HDB: Add temp variable to store Map name

Changed paths:
    engines/hdb/ai-cinematic.cpp


diff --git a/engines/hdb/ai-cinematic.cpp b/engines/hdb/ai-cinematic.cpp
index f0ff15a..414aa93 100644
--- a/engines/hdb/ai-cinematic.cpp
+++ b/engines/hdb/ai-cinematic.cpp
@@ -66,6 +66,7 @@ void AI::processCines() {
 
 	AIEntity *e;
 	Picture *p;
+	const char *title;
 	bool complete, bailOut;
 
 	if (!_cineActive) {
@@ -106,6 +107,7 @@ void AI::processCines() {
 				g_hdb->_lua->callFunction(func, 0);
 			break;
 		case C_STARTMAP:
+			title = _cine[i]->title;
 			cineFreeGfx();			// free all gfx alloc'ed during cine
 			_cineActive = false;
 			_playerLock = false;
@@ -118,7 +120,7 @@ void AI::processCines() {
 			// if cine is aborted and an abort function was specified, call it
 			if (_cineAborted && _cineAbortFunc)
 				g_hdb->_lua->callFunction(_cineAbortFunc, 0);
-			g_hdb->changeMap(_cine[i]->title);
+			g_hdb->changeMap(title);
 			return;
 			break;
 		case C_LOCKPLAYER:


Commit: 723b86e1cf0f5cf96495e543811c8002df762cd1
    https://github.com/scummvm/scummvm/commit/723b86e1cf0f5cf96495e543811c8002df762cd1
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:20+02:00

Commit Message:
HDB: Add cheating debug statment and remove...

redundant warnings

Changed paths:
    engines/hdb/ai-funcs.cpp
    engines/hdb/menu.cpp


diff --git a/engines/hdb/ai-funcs.cpp b/engines/hdb/ai-funcs.cpp
index e5923ed..218add0 100644
--- a/engines/hdb/ai-funcs.cpp
+++ b/engines/hdb/ai-funcs.cpp
@@ -471,7 +471,7 @@ void AI::stopEntity(AIEntity *e) {
 		e->state = STATE_FLOATING;
 		return;
 	default:
-		warning("AI-FUNCS: stopEntity: Unintended State");
+		break;
 	}
 
 	if (e->type != AI_DIVERTER) {
@@ -501,7 +501,7 @@ void AI::stopEntity(AIEntity *e) {
 				e->state = STATE_NONE;
 			break;
 		default:
-			warning("AI-FUNCS: stopEntity: DIR_NONE");
+			break;
 		}
 	}
 }
diff --git a/engines/hdb/menu.cpp b/engines/hdb/menu.cpp
index d70642e..29be8f1 100644
--- a/engines/hdb/menu.cpp
+++ b/engines/hdb/menu.cpp
@@ -126,6 +126,7 @@ void Menu::readConfig() {
 
 	if (ConfMan.hasKey(CONFIG_CHEAT)) {
 		g_hdb->setCheatingOn();
+		debug("Cheating enabled");
 	}
 
 	ConfMan.flushToDisk();


Commit: ed60dcd50607ecdd6c10eaedc477f4954c4361eb
    https://github.com/scummvm/scummvm/commit/ed60dcd50607ecdd6c10eaedc477f4954c4361eb
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:20+02:00

Commit Message:
HDB: Fix 3D stars left

Changed paths:
    engines/hdb/gfx.cpp


diff --git a/engines/hdb/gfx.cpp b/engines/hdb/gfx.cpp
index d3a63a9..e841381 100644
--- a/engines/hdb/gfx.cpp
+++ b/engines/hdb/gfx.cpp
@@ -618,7 +618,7 @@ void Gfx::draw3DStarsLeft() {
 	for (int i = 0; i < kNum3DStars; i++) {
 		_starField[_stars3DSlow[i].color]->drawMasked((int)_stars3DSlow[i].x, (int)_stars3DSlow[i].y);
 		_stars3DSlow[i].x -= _stars3DSlow[i].speed;
-		if (_stars3DSlow[i].x < kScreenWidth) {
+		if (_stars3DSlow[i].x < 0) {
 			_stars3DSlow[i].x = kScreenWidth - 1;
 		}
 	}


Commit: 6aa054fcacfd8f7c68e3131d8ef5905ee8478150
    https://github.com/scummvm/scummvm/commit/6aa054fcacfd8f7c68e3131d8ef5905ee8478150
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:20+02:00

Commit Message:
HDB: Unstub the TRY AGAIN screen

Changed paths:
    engines/hdb/hdb.cpp
    engines/hdb/input.cpp
    engines/hdb/window.cpp
    engines/hdb/window.h


diff --git a/engines/hdb/hdb.cpp b/engines/hdb/hdb.cpp
index 3c1930c..b0065b8 100644
--- a/engines/hdb/hdb.cpp
+++ b/engines/hdb/hdb.cpp
@@ -940,7 +940,7 @@ Common::Error HDBGame::run() {
 			_window->drawInventory();
 			_window->drawMessageBar();
 			_window->drawDeliveries();
-			debug(9, "STUB: Draw Try Again");
+			_window->drawTryAgain();
 			_window->drawPanicZone();
 			_window->drawTextOut();
 			_window->drawPause();
diff --git a/engines/hdb/input.cpp b/engines/hdb/input.cpp
index 35346f5..aef6ecf 100644
--- a/engines/hdb/input.cpp
+++ b/engines/hdb/input.cpp
@@ -92,7 +92,13 @@ void Input::setButtons(uint16 b) {
 	if (g_hdb->getGameState() == GAME_PLAY) {
 		// Is Player Dead? Click on TRY AGAIN
 		if (g_hdb->_ai->playerDead()) {
-			warning("STUB: TRY AGAIN is onscreen");
+			// TRY AGAIN is onscreen...
+			if (_buttons & kButtonB) {
+				if (g_hdb->loadGameState(kAutoSaveSlot).getCode() == Common::kNoError) {
+					g_hdb->_window->clearTryAgain();
+					g_hdb->setGameState(GAME_PLAY);
+				}
+			}
 			return;
 		}
 
@@ -144,7 +150,12 @@ void Input::stylusDown(int x, int y) {
 	case GAME_PLAY:
 		// Is Player Dead? Click on TRY AGAIN
 		if (g_hdb->_ai->playerDead()) {
-			warning("STUB: TRY AGAIN is onscreen");
+			if (y >= kTryRestartY && y <= kTryRestartY + 24) {
+				if (g_hdb->loadGameState(kAutoSaveSlot).getCode() == Common::kNoError) {
+					g_hdb->_window->clearTryAgain();
+					g_hdb->setGameState(GAME_PLAY);
+				}
+			}
 			return;
 		}
 
diff --git a/engines/hdb/window.cpp b/engines/hdb/window.cpp
index 486f980..2b1941b 100644
--- a/engines/hdb/window.cpp
+++ b/engines/hdb/window.cpp
@@ -1201,6 +1201,36 @@ void Window::checkDlvSelect(int x, int y) {
 	}
 }
 
+void Window::drawTryAgain() {
+	if (!g_hdb->_ai->playerDead())
+		return;
+
+	if (NULL == _gfxTry) {
+		_gfxTry = g_hdb->_gfx->loadPic(GAME_TRY);
+		_gfxAgain = g_hdb->_gfx->loadPic(GAME_AGAIN);
+		_gfxLevelRestart = g_hdb->_gfx->loadPic(GAME_TA_LEVELRESTART);
+
+		_tryAgainInfo.y1 = kTryY1;
+		_tryAgainInfo.y2 = kTryY2;
+		_tryAgainInfo.x1 = 480 / 2 - _gfxTry->_width / 2;;
+		_tryAgainInfo.x2 = 480 / 2 - _gfxAgain->_width / 2;
+	}
+
+	int xv = g_hdb->_rnd->getRandomNumber(3) - 2, yv = g_hdb->_rnd->getRandomNumber(3) - 2;
+
+	_gfxTry->drawMasked((int)_tryAgainInfo.x1 + xv, (int)_tryAgainInfo.y1 + yv);
+	_gfxAgain->drawMasked((int)_tryAgainInfo.x2 + yv, (int)_tryAgainInfo.y2 + xv);
+	_gfxLevelRestart->drawMasked((int)(480 / 2 - _gfxLevelRestart->_width + xv), kTryRestartY + yv);
+}
+
+void Window::clearTryAgain() {
+	_gfxTry->free();
+	_gfxAgain->free();
+	_gfxLevelRestart->free();
+
+	_gfxTry = _gfxAgain = _gfxLevelRestart = NULL;
+}
+
 void Window::loadPanicZoneGfx() {
 	_pzInfo.gfxPanic = g_hdb->_gfx->loadPic(PANIC_PANIC);
 	_pzInfo.gfxZone	= g_hdb->_gfx->loadPic(PANIC_ZONE);
diff --git a/engines/hdb/window.h b/engines/hdb/window.h
index 5bc95fa..e11b443 100644
--- a/engines/hdb/window.h
+++ b/engines/hdb/window.h
@@ -45,7 +45,10 @@ enum {
 	kPanicZoneFaceY = 5,
 	kNumCrazy = 37,
 	kTextOutCenterX = ((kScreenWidth - kTileWidth * 5) / 2),
-	kPauseY = (kScreenHeight / 2 - 64)
+	kPauseY = (kScreenHeight / 2 - 64),
+	kTryY1 = (kScreenHeight >> 2),	// TRY
+	kTryY2 = (kTryY1 + 32),			// AGAIN
+	kTryRestartY = ((kScreenHeight >> 2) * 3)	// (ok)
 };
 
 enum PZValue {
@@ -164,6 +167,15 @@ struct PanicZone {
 	}
 };
 
+struct TryAgainInfo {
+	double y1, y2;
+	double yv1, yv2;
+	double yv1v, yv2v;
+	double x1, x2;
+
+	TryAgainInfo() : y1(0), y2(0), yv1(0), yv2(0), yv1v(0), yv2v(0), x1(0), x2(0) {}
+};
+
 struct TOut {
 	char text[128];
 	int x, y;
@@ -255,6 +267,10 @@ public:
 	}
 	void checkDlvSelect(int x, int y);
 
+	// Try Again Functions
+	void drawTryAgain();
+	void clearTryAgain();
+
 	// Panic Zone Functions
 	void loadPanicZoneGfx();
 	void drawPanicZone();
@@ -292,6 +308,8 @@ private:
 	Common::Array<TOut *> _textOutList;
 	DlvsInfo _dlvsInfo;
 
+	TryAgainInfo _tryAgainInfo;
+
 	char _msgQueueStr[kMaxMsgQueue][128];
 	int _msgQueueWait[kMaxMsgQueue];
 	int _numMsgQueue;


Commit: eb9af0c7eecbfe65847837de03763352b244f5e1
    https://github.com/scummvm/scummvm/commit/eb9af0c7eecbfe65847837de03763352b244f5e1
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:20+02:00

Commit Message:
HDB: Fix getRandumNumber() usage in ai-bots.cpp

Changed paths:
    engines/hdb/ai-bots.cpp


diff --git a/engines/hdb/ai-bots.cpp b/engines/hdb/ai-bots.cpp
index 1541477..90f74b9 100644
--- a/engines/hdb/ai-bots.cpp
+++ b/engines/hdb/ai-bots.cpp
@@ -894,7 +894,7 @@ void aiMaintBotAction(AIEntity *e) {
 			switch (e->sequence) {
 			case 50:
 				if (e->onScreen && !e->int1) {
-					if (g_hdb->_rnd->getRandomNumber(2) & 1)
+					if (g_hdb->_rnd->getRandomNumber(1))
 						g_hdb->_sound->playSound(SND_MBOT_HMMM2);
 					else
 						g_hdb->_sound->playSound(SND_MBOT_HMMM);
@@ -974,11 +974,11 @@ void aiMaintBotAction(AIEntity *e) {
 				break;
 			// Decide direction and GO
 			case 0:
-				int dir = (g_hdb->_rnd->getRandomNumber(4)) + 1;
+				int dir = (g_hdb->_rnd->getRandomNumber(3)) + 1;
 				e->dir = dirList[dir];
 				g_hdb->_ai->findPath(e);
 				if (e->onScreen)
-					g_hdb->_sound->playSound(whistles[g_hdb->_rnd->getRandomNumber(3)]);
+					g_hdb->_sound->playSound(whistles[g_hdb->_rnd->getRandomNumber(2)]);
 				break;
 			}
 		}
@@ -1009,7 +1009,7 @@ void aiMaintBotAction(AIEntity *e) {
 				return;
 			} else if (ar->type == 1) {
 				g_hdb->_ai->findPath(e);
-				g_hdb->_sound->playSound(whistles[g_hdb->_rnd->getRandomNumber(3)]);
+				g_hdb->_sound->playSound(whistles[g_hdb->_rnd->getRandomNumber(2)]);
 			} else {
 				e->sequence = 64;
 				e->dir2 = e->dir;
@@ -1132,7 +1132,7 @@ void aiDeadEyeWalkInPlace(AIEntity *e) {
 	case 30:
 	case 20:
 	case 10:
-		dir = (AIDir)(g_hdb->_rnd->getRandomNumber(4) + 1);
+		dir = (AIDir)(g_hdb->_rnd->getRandomNumber(3) + 1);
 		s = state[dir];
 		e->dir = dir;
 		e->state = s;
@@ -1223,7 +1223,7 @@ void aiDeadEyeAction(AIEntity *e) {
 		case 30:
 		case 20:
 		case 10:
-			dir = (AIDir)(g_hdb->_rnd->getRandomNumber(4)+1);
+			dir = (AIDir)(g_hdb->_rnd->getRandomNumber(3)+1);
 			s = state[dir];
 			e->dir = dir;
 			e->state = s;
@@ -1237,8 +1237,8 @@ void aiDeadEyeAction(AIEntity *e) {
 			break;
 		case 0:
 			// Pick a random direction and random number of tiles in that direction
-			dir = (AIDir)(g_hdb->_rnd->getRandomNumber(4) + 1);
-			int walk = g_hdb->_rnd->getRandomNumber(5) + 1;
+			dir = (AIDir)(g_hdb->_rnd->getRandomNumber(3) + 1);
+			int walk = g_hdb->_rnd->getRandomNumber(4) + 1;
 			int xv, yv;
 
 			e->dir = dir;
@@ -1790,7 +1790,7 @@ void aiMeerkatAction(AIEntity *e) {
 			e->blinkFrames = 0;		// index into movement table...
 
 			// figure # of gems to take
-			e->special1Frames = g_hdb->_rnd->getRandomNumber(5) + 1;
+			e->special1Frames = g_hdb->_rnd->getRandomNumber(4) + 1;
 			int	amt = g_hdb->_ai->getGemAmount();
 			if (amt - e->special1Frames < 0)
 				e->special1Frames = amt;
@@ -1918,7 +1918,7 @@ void aiFatFrogAction(AIEntity *e) {
 		e->animFrame++;
 		if (e->animFrame == e->standdownFrames)
 			e->animFrame = 0;
-		if (!g_hdb->_rnd->getRandomNumber(30) && e->onScreen)
+		if (!g_hdb->_rnd->getRandomNumber(29) && e->onScreen)
 			g_hdb->_sound->playSound(SND_FROG_RIBBIT1);
 		break;
 
@@ -1937,7 +1937,7 @@ void aiFatFrogAction(AIEntity *e) {
 		e->animFrame++;
 		if (e->animFrame == e->standleftFrames)
 			e->animFrame = 0;
-		if (!g_hdb->_rnd->getRandomNumber(30) && e->onScreen)
+		if (!g_hdb->_rnd->getRandomNumber(29) && e->onScreen)
 			g_hdb->_sound->playSound(SND_FROG_RIBBIT2);
 		break;
 
@@ -1956,7 +1956,7 @@ void aiFatFrogAction(AIEntity *e) {
 		e->animFrame++;
 		if (e->animFrame == e->standrightFrames)
 			e->animFrame = 0;
-		if (!g_hdb->_rnd->getRandomNumber(30) && e->onScreen)
+		if (!g_hdb->_rnd->getRandomNumber(29) && e->onScreen)
 			g_hdb->_sound->playSound(SND_FROG_RIBBIT2);
 		break;
 
@@ -2220,11 +2220,11 @@ void aiGoodFairyAction(AIEntity *e) {
 		case 0:
 			{
 				// Create a GEM?
-				if (g_hdb->_rnd->getRandomNumber(100) > 98) {
+				if (g_hdb->_rnd->getRandomNumber(99) > 98) {
 					int	spawnOK;
 
 					// spawn a gem in a random direction
-					int	d = g_hdb->_rnd->getRandomNumber(4) + 1;
+					int	d = g_hdb->_rnd->getRandomNumber(3) + 1;
 					xv = xvAhead[d];
 					yv = yvAhead[d];
 
@@ -2251,9 +2251,9 @@ void aiGoodFairyAction(AIEntity *e) {
 				int	tries = 4;
 				do {
 					// pick a random direction, then a random # of tiles in that direction
-					int	 rnd = g_hdb->_rnd->getRandomNumber(4) + 1;
+					int	 rnd = g_hdb->_rnd->getRandomNumber(3) + 1;
 					AIDir d = (AIDir)rnd;
-					int	 walk = g_hdb->_rnd->getRandomNumber(5) + 1;
+					int	 walk = g_hdb->_rnd->getRandomNumber(4) + 1;
 					AIEntity *p = g_hdb->_ai->getPlayer();
 
 					// if player is within 3 tiles, move closer
@@ -2319,7 +2319,7 @@ void aiGoodFairyAction(AIEntity *e) {
 					uint32 bg_flags = g_hdb->_map->getMapBGTileFlags(e->tileX + e->value1, e->tileY + e->value2);
 					if (result && !hit && !(bg_flags & kFlagSpecial)) {
 						g_hdb->_ai->setEntityGoal(e, e->tileX + xv, e->tileY + yv);
-						if (e->onScreen && !g_hdb->_rnd->getRandomNumber(30))
+						if (e->onScreen && !g_hdb->_rnd->getRandomNumber(29))
 							g_hdb->_sound->playSound(SND_GOOD_FAERIE_AMBIENT);
 						g_hdb->_ai->animateEntity(e);
 						return;
@@ -2420,7 +2420,7 @@ void aiBadFairyAction(AIEntity *e) {
 		case 0:
 			{
 				// Create a GATE PUDDLE?
-				if (e->onScreen && (g_hdb->_rnd->getRandomNumber(100) > 90) && g_hdb->getActionMode() && (g_hdb->_ai->getGatePuddles() < kMaxGatePuddles)) {
+				if (e->onScreen && (g_hdb->_rnd->getRandomNumber(99) > 90) && g_hdb->getActionMode() && (g_hdb->_ai->getGatePuddles() < kMaxGatePuddles)) {
 					AIDir opposite[] = {DIR_NONE, DIR_DOWN, DIR_UP, DIR_RIGHT, DIR_LEFT};
 
 					if (e->onScreen)
@@ -2439,9 +2439,9 @@ void aiBadFairyAction(AIEntity *e) {
 				int	tries = 4;
 				do {
 					// pick a random direction, then a random # of tiles in that direction
-					int	rnd = g_hdb->_rnd->getRandomNumber(4) + 1;
+					int	rnd = g_hdb->_rnd->getRandomNumber(3) + 1;
 					AIDir d = (AIDir)rnd;
-					int	walk = g_hdb->_rnd->getRandomNumber(5) + 1;
+					int	walk = g_hdb->_rnd->getRandomNumber(4) + 1;
 					AIEntity *p = g_hdb->_ai->getPlayer();
 
 					e->dir = d;
@@ -2474,7 +2474,7 @@ void aiBadFairyAction(AIEntity *e) {
 					if (!hit && result && !(bg_flags & kFlagSpecial)) {
 						g_hdb->_ai->setEntityGoal(e, e->tileX + xv, e->tileY + yv);
 						g_hdb->_ai->animateEntity(e);
-						if (e->onScreen && !g_hdb->_rnd->getRandomNumber(20))
+						if (e->onScreen && !g_hdb->_rnd->getRandomNumber(19))
 							g_hdb->_sound->playSound(SND_BADFAIRY_AMBIENT);
 						return;
 					}
@@ -2614,7 +2614,7 @@ void aiGatePuddleAction(AIEntity *e) {
 			}
 		}
 	} else {
-		int rnd = g_hdb->_rnd->getRandomNumber(4) + 1;
+		int rnd = g_hdb->_rnd->getRandomNumber(3) + 1;
 		int move_ok = 0, nx, ny;
 
 		e->dir = (AIDir)rnd;
@@ -2766,7 +2766,7 @@ void aiIcePuffAction(AIEntity *e) {
 		case  8: e->draw = e->blinkGfx[1]; break;	// peek - looking
 		case  4: e->draw = e->blinkGfx[0]; break;	// peek - looking
 		case  3:
-			if (e->onScreen && !g_hdb->_rnd->getRandomNumber(6))
+			if (e->onScreen && !g_hdb->_rnd->getRandomNumber(5))
 				g_hdb->_sound->playSound(SND_ICEPUFF_WARNING);
 			break;
 		case  0: e->draw = e->blinkGfx[3];			// underground
@@ -2829,7 +2829,7 @@ void aiIcePuffAction(AIEntity *e) {
 		} else if (e->animFrame == e->special1Frames) {
 			e->state = STATE_ICEP_PEEK;
 			e->draw = e->blinkGfx[3];
-			e->sequence = g_hdb->_rnd->getRandomNumber(100) + 30;
+			e->sequence = g_hdb->_rnd->getRandomNumber(99) + 30;
 		}
 		break;
 
@@ -2850,7 +2850,7 @@ void aiIcePuffAction(AIEntity *e) {
 		} else if (e->animFrame == e->special1Frames) {
 			e->state = STATE_ICEP_PEEK;
 			e->draw = e->blinkGfx[3];
-			e->sequence = g_hdb->_rnd->getRandomNumber(100) + 30;
+			e->sequence = g_hdb->_rnd->getRandomNumber(99) + 30;
 		}
 		break;
 
@@ -2871,7 +2871,7 @@ void aiIcePuffAction(AIEntity *e) {
 		} else if (e->animFrame == e->special1Frames) {
 			e->state = STATE_ICEP_PEEK;
 			e->draw = e->blinkGfx[3];
-			e->sequence = g_hdb->_rnd->getRandomNumber(100) + 30;
+			e->sequence = g_hdb->_rnd->getRandomNumber(99) + 30;
 		}
 		break;
 


Commit: 72d2f01b935ff30bf1a847f9a36ba247e31d0bb7
    https://github.com/scummvm/scummvm/commit/72d2f01b935ff30bf1a847f9a36ba247e31d0bb7
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:20+02:00

Commit Message:
HDB: Unstub AI::init()

Changed paths:
    engines/hdb/ai-init.cpp


diff --git a/engines/hdb/ai-init.cpp b/engines/hdb/ai-init.cpp
index dadca18..e5f47ba 100644
--- a/engines/hdb/ai-init.cpp
+++ b/engines/hdb/ai-init.cpp
@@ -918,21 +918,15 @@ AI::~AI() {
 }
 
 bool AI::init() {
-	warning("STUB: AI::init incomplete");
 
-	_debugQMark = new Tile;
-	_debugQMark->load(g_hdb->_fileMan->findFirstData("icon_question_mark", TYPE_ICON32));
+	_debugQMark = g_hdb->_gfx->loadTile("icon_question_mark");
 
 	// Clear Waypoint list and load Waypoint graphics
 	_numWaypoints = 0;
-	_waypointGfx[0] = new Tile;
-	_waypointGfx[0]->load(g_hdb->_fileMan->findFirstData("icon_waypoint_select1", TYPE_ICON32));
-	_waypointGfx[1] = new Tile;
-	_waypointGfx[1]->load(g_hdb->_fileMan->findFirstData("icon_waypoint_select2", TYPE_ICON32));
-	_waypointGfx[2] = new Tile;
-	_waypointGfx[2]->load(g_hdb->_fileMan->findFirstData("icon_waypoint_select3", TYPE_ICON32));
-	_waypointGfx[3] = new Tile;
-	_waypointGfx[3]->load(g_hdb->_fileMan->findFirstData("icon_waypoint_select4", TYPE_ICON32));
+	_waypointGfx[0] = g_hdb->_gfx->loadTile("icon_waypoint_select1");
+	_waypointGfx[1] = g_hdb->_gfx->loadTile("icon_waypoint_select2");
+	_waypointGfx[2] = g_hdb->_gfx->loadTile("icon_waypoint_select3");
+	_waypointGfx[3] = g_hdb->_gfx->loadTile("icon_waypoint_select4");
 
 	// Setup Vars to reference SPECIAL Map Tiles
 	_useSwitchOff	= g_hdb->_gfx->getTileIndex("anim_t32_switch_off01");
@@ -1021,6 +1015,7 @@ bool AI::init() {
 	_dummyPlayer.type = AI_GUY;
 	_dummyLaser.type = AI_LASERBEAM;
 	strcpy(_dummyPlayer.entityName, "Virtual Player");
+	_numDeliveries = 0;
 	_playerRunning = false;
 	_weaponSelGfx = NULL;
 
@@ -1059,7 +1054,7 @@ FuncPtr AI::funcLookUp(const char *function) {
 }
 
 void AI::restartSystem() {
-	/// init special player vars
+	// init special player vars
 	_player = NULL;
 
 	// Clear the Action list


Commit: 56bbb34a3b4417ad024a567178e1b4cc3fe28f1e
    https://github.com/scummvm/scummvm/commit/56bbb34a3b4417ad024a567178e1b4cc3fe28f1e
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:20+02:00

Commit Message:
HDB: Add save/load for TryAgain data

Changed paths:
    engines/hdb/window.cpp


diff --git a/engines/hdb/window.cpp b/engines/hdb/window.cpp
index 2b1941b..e340198 100644
--- a/engines/hdb/window.cpp
+++ b/engines/hdb/window.cpp
@@ -26,8 +26,6 @@ namespace HDB {
 
 bool Window::init() {
 
-	warning("STUB: Window::init: Incomplete");
-
 	_gfxTL = g_hdb->_gfx->loadPic(MENU_BACK_TOPLEFT);
 	_gfxTM = g_hdb->_gfx->loadPic(MENU_BACK_TOP);
 	_gfxTR = g_hdb->_gfx->loadPic(MENU_BACK_TOPRIGHT);
@@ -203,7 +201,14 @@ void Window::save(Common::OutSaveFile *out) {
 	out->writeByte(_dlvsInfo.go3);
 
 	// Save Try Again Info
-	debug(9, "STUB: Save Try Again data");
+	out->writeDoubleLE(_tryAgainInfo.y1);
+	out->writeDoubleLE(_tryAgainInfo.y2);
+	out->writeDoubleLE(_tryAgainInfo.yv1);
+	out->writeDoubleLE(_tryAgainInfo.yv2);
+	out->writeDoubleLE(_tryAgainInfo.yv1v);
+	out->writeDoubleLE(_tryAgainInfo.yv2v);
+	out->writeDoubleLE(_tryAgainInfo.x1);
+	out->writeDoubleLE(_tryAgainInfo.x2);
 
 	// Save TextOut Info
 	out->writeUint32LE(_textOutList.size());
@@ -332,7 +337,14 @@ void Window::loadSaveFile(Common::InSaveFile *in) {
 	_dlvsInfo.go3 = in->readByte();
 
 	// Load Try Again Info
-	debug(9, "STUB: Load Try Again data");
+	_tryAgainInfo.y1 = in->readDoubleLE();
+	_tryAgainInfo.y2 = in->readDoubleLE();
+	_tryAgainInfo.yv1 = in->readDoubleLE();
+	_tryAgainInfo.yv2 = in->readDoubleLE();
+	_tryAgainInfo.yv1v = in->readDoubleLE();
+	_tryAgainInfo.yv2v = in->readDoubleLE();
+	_tryAgainInfo.x1 = in->readDoubleLE();
+	_tryAgainInfo.x2 = in->readDoubleLE();
 
 	// Load Textout Info
 	uint32 tsize = in->readUint32LE();
@@ -359,7 +371,7 @@ void Window::restartSystem() {
 	_dialogChoiceInfo.active = false;
 	_invWinInfo.active = false;
 	_dialogDelay = _invWinInfo.selection = 0;
-	_gemGfx = g_hdb->_gfx->loadTile("ent_gem_white_sit01");
+	_gemGfx = g_hdb->_gfx->loadTile(GEM_WHITE_GFX);
 	_infobarDimmed = 0;
 }
 


Commit: a484fe4353c96c6e0c27333c5d4ac932baf660a0
    https://github.com/scummvm/scummvm/commit/a484fe4353c96c6e0c27333c5d4ac932baf660a0
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:20+02:00

Commit Message:
HDB: Unstub redundant warnings

Changed paths:
    engines/hdb/hdb.cpp
    engines/hdb/menu.cpp


diff --git a/engines/hdb/hdb.cpp b/engines/hdb/hdb.cpp
index b0065b8..3f85cf6 100644
--- a/engines/hdb/hdb.cpp
+++ b/engines/hdb/hdb.cpp
@@ -482,7 +482,6 @@ void HDBGame::moveMap(int x, int y) {
 
 // PLAYER is trying to use this entity
 void HDBGame::useEntity(AIEntity *e) {
-	warning("STUB: HDBGame::useEntity incomplete");
 
 	AIEntity *p, temp;
 	bool added;
diff --git a/engines/hdb/menu.cpp b/engines/hdb/menu.cpp
index 29be8f1..9741506 100644
--- a/engines/hdb/menu.cpp
+++ b/engines/hdb/menu.cpp
@@ -1260,11 +1260,9 @@ void Menu::processInput(int x, int y) {
 }
 
 void Menu::controlsInput(int x, int y) {
-	warning("STUB: Menu: controlsInput");
 }
 
 void Menu::controlsDraw() {
-	warning("STUB: Menu: controlsDraw");
 }
 
 void Menu::drawNebula() {


Commit: f158aadfd1ac0db28cd759506690f523c77f1d3e
    https://github.com/scummvm/scummvm/commit/f158aadfd1ac0db28cd759506690f523c77f1d3e
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:20+02:00

Commit Message:
HDB: Add loadIcon() for TYPE_ICON32 loading

Changed paths:
    engines/hdb/gfx.cpp
    engines/hdb/gfx.h


diff --git a/engines/hdb/gfx.cpp b/engines/hdb/gfx.cpp
index e841381..4ff2e9d 100644
--- a/engines/hdb/gfx.cpp
+++ b/engines/hdb/gfx.cpp
@@ -379,6 +379,15 @@ Tile *Gfx::loadTile(const char *tileName) {
 	return tile;
 }
 
+Tile *Gfx::loadIcon(const char *tileName) {
+	Tile *tile = new Tile;
+	Common::SeekableReadStream *stream = g_hdb->_fileMan->findFirstData(tileName, TYPE_ICON32);
+	if (!stream)
+		return NULL;
+	tile->load(stream);
+	return tile;
+}
+
 Tile *Gfx::getTile(int index) {
 
 	if (index < 0 || index > _numTiles) {
diff --git a/engines/hdb/gfx.h b/engines/hdb/gfx.h
index 59d44fb..410b2f1 100644
--- a/engines/hdb/gfx.h
+++ b/engines/hdb/gfx.h
@@ -115,6 +115,7 @@ public:
 
 	Picture *loadPic(const char *picName);
 	Tile *loadTile(const char *tileName);
+	Tile *loadIcon(const char *tileName);
 
 	Tile *getTile(int index);
 	void cacheTileSequence(int index, int count);


Commit: fa7593d7d56af3ccf8a21656684e98f82ce5f4cb
    https://github.com/scummvm/scummvm/commit/fa7593d7d56af3ccf8a21656684e98f82ce5f4cb
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:20+02:00

Commit Message:
HDB: Fix Icon loading

Changed paths:
    engines/hdb/ai-init.cpp
    engines/hdb/hdb.cpp


diff --git a/engines/hdb/ai-init.cpp b/engines/hdb/ai-init.cpp
index e5f47ba..52b04ce 100644
--- a/engines/hdb/ai-init.cpp
+++ b/engines/hdb/ai-init.cpp
@@ -919,14 +919,14 @@ AI::~AI() {
 
 bool AI::init() {
 
-	_debugQMark = g_hdb->_gfx->loadTile("icon_question_mark");
+	_debugQMark = g_hdb->_gfx->loadIcon("icon_question_mark");
 
 	// Clear Waypoint list and load Waypoint graphics
 	_numWaypoints = 0;
-	_waypointGfx[0] = g_hdb->_gfx->loadTile("icon_waypoint_select1");
-	_waypointGfx[1] = g_hdb->_gfx->loadTile("icon_waypoint_select2");
-	_waypointGfx[2] = g_hdb->_gfx->loadTile("icon_waypoint_select3");
-	_waypointGfx[3] = g_hdb->_gfx->loadTile("icon_waypoint_select4");
+	_waypointGfx[0] = g_hdb->_gfx->loadIcon("icon_waypoint_select1");
+	_waypointGfx[1] = g_hdb->_gfx->loadIcon("icon_waypoint_select2");
+	_waypointGfx[2] = g_hdb->_gfx->loadIcon("icon_waypoint_select3");
+	_waypointGfx[3] = g_hdb->_gfx->loadIcon("icon_waypoint_select4");
 
 	// Setup Vars to reference SPECIAL Map Tiles
 	_useSwitchOff	= g_hdb->_gfx->getTileIndex("anim_t32_switch_off01");
diff --git a/engines/hdb/hdb.cpp b/engines/hdb/hdb.cpp
index 3f85cf6..27c4b33 100644
--- a/engines/hdb/hdb.cpp
+++ b/engines/hdb/hdb.cpp
@@ -118,7 +118,7 @@ bool HDBGame::init() {
 
 	_menu->init();
 
-	_debugLogo = _gfx->loadTile("icon_debug_logo");
+	_debugLogo = _gfx->loadIcon("icon_debug_logo");
 	_progressGfx = _gfx->loadPic(PIC_LOADBAR);
 	_progressMarkGfx = _gfx->loadPic(PIC_LOADSTAR);
 	_logoGfx = NULL;


Commit: 26210cfce662880ca5daeeab1f203e86cbbbae63
    https://github.com/scummvm/scummvm/commit/26210cfce662880ca5daeeab1f203e86cbbbae63
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:20+02:00

Commit Message:
HDB: Add drawDebugInfo()

Changed paths:
    engines/hdb/gfx.cpp
    engines/hdb/gfx.h


diff --git a/engines/hdb/gfx.cpp b/engines/hdb/gfx.cpp
index 4ff2e9d..56dc8fe 100644
--- a/engines/hdb/gfx.cpp
+++ b/engines/hdb/gfx.cpp
@@ -986,6 +986,32 @@ void Gfx::drawBonusStars() {
 	}
 }
 
+void Gfx::drawDebugInfo(Tile *_debugLogo, int fps) {
+	int x, y;
+	AIEntity *p;
+	char buff[64];
+
+	_debugLogo->drawMasked(kScreenWidth - 32, 0);
+
+	// Draw  FPS
+	setCursor(0, 0);
+	sprintf(buff, "FPS: %d", fps);
+	drawText(buff);
+
+	// Draw Player Info
+	setCursor(0, 16);
+	g_hdb->_ai->getPlayerXY(&x, &y);
+	sprintf(buff, "Player X: %d, Y: %d", x / kTileWidth, y / kTileHeight);
+	drawText(buff);
+
+	setCursor(0, 32);
+	p = g_hdb->_ai->getPlayer();
+	if (p) {
+		sprintf(buff, "Player height level: %d", p->level);
+		drawText(buff);
+	}
+}
+
 Picture::Picture() : _width(0), _height(0), _name("") {
 	_surface.create(_width, _height, g_hdb->_format);
 }
diff --git a/engines/hdb/gfx.h b/engines/hdb/gfx.h
index 410b2f1..119c568 100644
--- a/engines/hdb/gfx.h
+++ b/engines/hdb/gfx.h
@@ -170,6 +170,8 @@ public:
 	void turnOnBonusStars(int which);
 	void drawBonusStars();
 
+	void drawDebugInfo(Tile *_debugLogo, int fps);
+
 private:
 	int _numTiles;
 	TileLookup *_tLookupArray;


Commit: 68b2e9adff5eb3dda5cb8bf788264b08a900e7cb
    https://github.com/scummvm/scummvm/commit/68b2e9adff5eb3dda5cb8bf788264b08a900e7cb
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:20+02:00

Commit Message:
HDB: Count FPS and print onto screen

Changed paths:
    engines/hdb/gfx.cpp
    engines/hdb/hdb.cpp
    engines/hdb/hdb.h


diff --git a/engines/hdb/gfx.cpp b/engines/hdb/gfx.cpp
index 56dc8fe..5719b8c 100644
--- a/engines/hdb/gfx.cpp
+++ b/engines/hdb/gfx.cpp
@@ -343,6 +343,11 @@ void Gfx::updateFade() {
 		g_system->copyRectToScreen(_globalSurface.getBasePtr(0, 0), _globalSurface.pitch, 0, 0, _globalSurface.w, _globalSurface.h);
 
 		g_system->updateScreen();
+		if (g_hdb->getDebug()) {
+			g_hdb->_frames.push_back(g_system->getMillis());
+			while (g_hdb->_frames[0] < g_system->getMillis() - 1000)
+				g_hdb->_frames.remove_at(0);
+		}
 		g_system->delayMillis(1000 / kGameFPS);
 
 	} while (_fadeInfo.active);
diff --git a/engines/hdb/hdb.cpp b/engines/hdb/hdb.cpp
index 27c4b33..4bbff5b 100644
--- a/engines/hdb/hdb.cpp
+++ b/engines/hdb/hdb.cpp
@@ -288,7 +288,7 @@ void HDBGame::paint() {
 
 	// Draw FPS on Screen in Debug Mode
 	if (_debugFlag == 1) {
-		debug(9, "STUB: Requires StartTiming() and EndTiming()");
+		_gfx->drawDebugInfo(_debugLogo, _frames.size());
 	} else if (_debugFlag == 2) {
 		_debugLogo->drawMasked(kScreenWidth - 32, 0);
 	}
@@ -973,6 +973,11 @@ Common::Error HDBGame::run() {
 		paint();
 
 		g_system->updateScreen();
+		if (g_hdb->getDebug()) {
+			g_hdb->_frames.push_back(g_system->getMillis());
+			while (g_hdb->_frames[0] < g_system->getMillis() - 1000)
+				g_hdb->_frames.remove_at(0);
+		}
 		g_system->delayMillis(1000 / kGameFPS);
 	}
 
diff --git a/engines/hdb/hdb.h b/engines/hdb/hdb.h
index 6de2809..f1efd10 100644
--- a/engines/hdb/hdb.h
+++ b/engines/hdb/hdb.h
@@ -298,6 +298,9 @@ public:
 	bool _progressActive;
 	int _progressCurrent, _progressXOffset, _progressMax;
 
+	// FPS Variables
+	Common::Array<uint32> _frames;
+
 private:
 
 	uint32 _timePlayed;


Commit: 4876064372a8e639c2dedda6845ebd2afec92bd9
    https://github.com/scummvm/scummvm/commit/4876064372a8e639c2dedda6845ebd2afec92bd9
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:21+02:00

Commit Message:
HDB: Unstub the Quit functionality

Changed paths:
    engines/hdb/hdb.cpp
    engines/hdb/hdb.h
    engines/hdb/input.cpp
    engines/hdb/menu.cpp


diff --git a/engines/hdb/hdb.cpp b/engines/hdb/hdb.cpp
index 4bbff5b..47e1175 100644
--- a/engines/hdb/hdb.cpp
+++ b/engines/hdb/hdb.cpp
@@ -87,6 +87,11 @@ HDBGame::~HDBGame() {
 	DebugMan.clearAllDebugChannels();
 }
 
+bool HDBGame::hasFeature(Engine::EngineFeature f) const {
+	warning("FIXME: quitGame() exits the application, instead of RTL");
+	return (f == kSupportsRTL);
+}
+
 bool HDBGame::init() {
 	/*
 		Game Subsystem Initializations
@@ -871,9 +876,6 @@ Common::Error HDBGame::run() {
 		Common::Event event;
 		while (g_system->getEventManager()->pollEvent(event)) {
 			switch (event.type) {
-			case Common::EVENT_QUIT:
-			case Common::EVENT_RTL:
-				break;
 			case Common::EVENT_MOUSEMOVE:
 				_input->updateMouse(event.mouse.x, event.mouse.y);
 				break;
diff --git a/engines/hdb/hdb.h b/engines/hdb/hdb.h
index f1efd10..77e7610 100644
--- a/engines/hdb/hdb.h
+++ b/engines/hdb/hdb.h
@@ -131,6 +131,8 @@ public:
 	HDBGame(OSystem *syst, const ADGameDescription *gameDesc);
 	~HDBGame();
 
+	virtual bool hasFeature(Engine::EngineFeature f) const;
+
 	virtual Common::Error run();
 
 	// Detection related members;
diff --git a/engines/hdb/input.cpp b/engines/hdb/input.cpp
index aef6ecf..a49e6a2 100644
--- a/engines/hdb/input.cpp
+++ b/engines/hdb/input.cpp
@@ -319,7 +319,10 @@ void Input::updateMouseButtons(int l, int m, int r) {
 
 void Input::updateKeys(Common::Event event, bool keyDown) {
 
-	debug(9, "STUB: updateKeys: Check for Quit key");
+	if (keyDown && event.kbd.keycode == _keyQuit) {
+		g_hdb->quitGame();
+		return;
+	}
 
 	uint16 buttons = getButtons();
 
diff --git a/engines/hdb/menu.cpp b/engines/hdb/menu.cpp
index 9741506..6ea70ea 100644
--- a/engines/hdb/menu.cpp
+++ b/engines/hdb/menu.cpp
@@ -1253,7 +1253,7 @@ void Menu::processInput(int x, int y) {
 		} else if (_quitTimer < g_hdb->getTimeSlice()) {
 			if (x >= kQuitYesX1 && x <= kQuitYesX2 && y > kQuitYesY1 && y < kQuitYesY2) {
 				writeConfig();
-				warning("STUB: End game: Call Destroy()");
+				g_hdb->quitGame();
 			}
 		}
 	}


Commit: 462d48a901c3edc76bc117fed60606da5f06cc2d
    https://github.com/scummvm/scummvm/commit/462d48a901c3edc76bc117fed60606da5f06cc2d
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:21+02:00

Commit Message:
HDB: Unstub TODOs

Changed paths:
    engines/hdb/hdb.cpp
    engines/hdb/lua-script.cpp
    engines/hdb/map.cpp


diff --git a/engines/hdb/hdb.cpp b/engines/hdb/hdb.cpp
index 47e1175..cbba9af 100644
--- a/engines/hdb/hdb.cpp
+++ b/engines/hdb/hdb.cpp
@@ -142,15 +142,6 @@ bool HDBGame::init() {
 	return true;
 }
 
-/*
-	Changes the current GameState to the next one.
-	Game State Transitions are deterministic: each state can
-	only a particular state. The next state is held in gameState.
-
-	TODO: All the functionality hasn't been implemented yet since
-	their subsystems are incomplete. This section needs to be periodically
-	updated as soon as the subsytems are improved.
-*/
 void HDBGame::changeGameState() {
 
 	switch (_gameState) {
diff --git a/engines/hdb/lua-script.cpp b/engines/hdb/lua-script.cpp
index 8302fca..5c1f123 100644
--- a/engines/hdb/lua-script.cpp
+++ b/engines/hdb/lua-script.cpp
@@ -1745,10 +1745,7 @@ bool LuaScript::initScript(Common::SeekableReadStream *stream, const char *scrip
 	lua_pushnumber(_state, 480 - 14);
 	lua_setglobal(_state, "BOTTOM_Y");
 
-	/*
-		TODO: Load the sound names and entity
-		spawn names into Lua once they are implemented.
-	*/
+	warning("STUB: Stick Sound Names into Lua");
 
 	// Set the Entity Spawn Names  in Lua
 	int j = 0;
diff --git a/engines/hdb/map.cpp b/engines/hdb/map.cpp
index 1a085f9..fbaa4c9 100644
--- a/engines/hdb/map.cpp
+++ b/engines/hdb/map.cpp
@@ -323,13 +323,7 @@ bool Map::load(Common::SeekableReadStream *stream) {
 		_iconList[i].value2 = stream->readUint16LE();
 	}
 
-	/*
-		TODO: Add the InfoList when it comes up
-	*/
-
-	/*
-		TODO: Set the InMapName once its setup
-	*/
+	g_hdb->setInMapName(_name);
 
 	_mapExplosions = (byte *)calloc(_width * _height, 1);
 	_mapExpBarrels = (byte *)calloc(_width * _height, 1);


Commit: 6fdd336ae4a4cae45976fd4087fdb7071ea5a8fc
    https://github.com/scummvm/scummvm/commit/6fdd336ae4a4cae45976fd4087fdb7071ea5a8fc
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:21+02:00

Commit Message:
HDB: Move HDBGame::hasFeature() to detection.cpp for consistency

Changed paths:
    engines/hdb/detection.cpp
    engines/hdb/hdb.cpp


diff --git a/engines/hdb/detection.cpp b/engines/hdb/detection.cpp
index a63b85f..b8bf22e 100644
--- a/engines/hdb/detection.cpp
+++ b/engines/hdb/detection.cpp
@@ -116,6 +116,11 @@ bool HDBMetaEngine::hasFeature(MetaEngineFeature f) const {
 		(f == kSupportsLoadingDuringStartup);
 }
 
+bool HDB::HDBGame::hasFeature(Engine::EngineFeature f) const {
+	warning("FIXME: quitGame() exits the application, instead of RTL");
+	return (f == kSupportsRTL);
+}
+
 int HDBMetaEngine::getMaximumSaveSlot() const { return 9; }
 
 bool HDBMetaEngine::createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const {
diff --git a/engines/hdb/hdb.cpp b/engines/hdb/hdb.cpp
index cbba9af..677b397 100644
--- a/engines/hdb/hdb.cpp
+++ b/engines/hdb/hdb.cpp
@@ -87,11 +87,6 @@ HDBGame::~HDBGame() {
 	DebugMan.clearAllDebugChannels();
 }
 
-bool HDBGame::hasFeature(Engine::EngineFeature f) const {
-	warning("FIXME: quitGame() exits the application, instead of RTL");
-	return (f == kSupportsRTL);
-}
-
 bool HDBGame::init() {
 	/*
 		Game Subsystem Initializations


Commit: 6789a868f0f390534ad0ce282344266e032a5f0a
    https://github.com/scummvm/scummvm/commit/6789a868f0f390534ad0ce282344266e032a5f0a
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:21+02:00

Commit Message:
HDB: Fix copy-paste error in AI::legalMove()

This led to inability to move over entities on level2 while they're on level1

Changed paths:
    engines/hdb/ai-funcs.cpp


diff --git a/engines/hdb/ai-funcs.cpp b/engines/hdb/ai-funcs.cpp
index 218add0..38df8ce 100644
--- a/engines/hdb/ai-funcs.cpp
+++ b/engines/hdb/ai-funcs.cpp
@@ -1962,15 +1962,16 @@ AIEntity *AI::legalMove(int tileX, int tileY, int level, int *result) {
 	uint32 fgFlags = g_hdb->_map->getMapFGTileFlags(tileX, tileY);
 	AIEntity *hit = findEntity(tileX, tileY);
 
-	if (hit && hit->state != STATE_FLOATING)
+	if (hit && hit->state != STATE_FLOATING) {
 		// If player and entity are not at the same level, are they on stairs?
 		if (hit->level != level) {
 			if (level == 1 && !(bgFlags & kFlagStairTop)) {
 				hit = NULL;
-			} else if (level == 1 && !(bgFlags & kFlagStairBot)) {
+			} else if (level == 2 && !(bgFlags & kFlagStairBot)) {
 				hit = NULL;
 			}
 		}
+	}
 
 	if (level == 1) {
 		if (bgFlags & kFlagSolid) {


Commit: b5b2a113ff3daf3e64227c068c3e38dbdcf3dd7c
    https://github.com/scummvm/scummvm/commit/b5b2a113ff3daf3e64227c068c3e38dbdcf3dd7c
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:21+02:00

Commit Message:
HDB: Fix bug from the original

Changed paths:
    engines/hdb/ai-waypoint.cpp


diff --git a/engines/hdb/ai-waypoint.cpp b/engines/hdb/ai-waypoint.cpp
index 4147354..dac3328 100644
--- a/engines/hdb/ai-waypoint.cpp
+++ b/engines/hdb/ai-waypoint.cpp
@@ -39,7 +39,7 @@ void AI::addWaypoint(int px, int py, int x, int y, int level) {
 	int ny = y;
 	if (!_numWaypoints) {
 		// if player is already moving and this is the first waypoint, forget it.
-		// player is using the keyboard and must be fully stopped before laying 
+		// player is using the keyboard and must be fully stopped before laying
 		// the first waypoint
 		if (_player->goalX)
 			return;
@@ -327,7 +327,7 @@ void AI::addWaypoint(int px, int py, int x, int y, int level) {
 		if (nx == px && ny == py)
 			return;
 
-		// make sure potential waypoint isn't on other waypoints!			
+		// make sure potential waypoint isn't on other waypoints!
 		for (i = 0; i < _numWaypoints; i++)
 			if (_waypoints[i].x == nx && _waypoints[i].y == ny)
 				return;
@@ -429,7 +429,7 @@ bool AI::traceStraightPath(int x1, int y1, int *x2, int *y2, int *level) {
 				// if it's blocking, is it rad or plasma? (might be melted stuff on it)
 				if (!ok) {
 					ok = ((flags & kFlagPlasmaFloor) == kFlagPlasmaFloor) +
-						((flags & kFlagPlasmaFloor) == kFlagRadFloor);
+						((flags & kFlagRadFloor) == kFlagRadFloor);
 					e = findEntity(x1, y1);
 					if (e && g_hdb->_ai->walkThroughEnt(e->type))
 						entOK = 1;


Commit: 944dbab7d6dccab8f84cddf78c49846b66776343
    https://github.com/scummvm/scummvm/commit/944dbab7d6dccab8f84cddf78c49846b66776343
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:21+02:00

Commit Message:
HDB: Fix warning

Changed paths:
    engines/hdb/ai-player.cpp


diff --git a/engines/hdb/ai-player.cpp b/engines/hdb/ai-player.cpp
index 7dbb1e8..ba887db 100644
--- a/engines/hdb/ai-player.cpp
+++ b/engines/hdb/ai-player.cpp
@@ -521,6 +521,7 @@ void aiGemAttackAction(AIEntity *e) {
 				case AI_DRAGON:
 					g_hdb->_sound->playSound(SND_CLUB_HIT_FLESH);
 					aiDragonWake(hit);
+					// fallthrough
 				default:
 					g_hdb->_ai->addAnimateTarget(e->x, e->y, 0, 3, ANIM_NORMAL, false, false, GEM_FLASH);
 					g_hdb->_sound->playSound(SND_CLUB_HIT_FLESH);


Commit: ffe310343316e1ef1c47f6f6a969f5c7ec291e36
    https://github.com/scummvm/scummvm/commit/ffe310343316e1ef1c47f6f6a969f5c7ec291e36
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:21+02:00

Commit Message:
HDB: Fix warning

Changed paths:
    engines/hdb/ai-lists.cpp


diff --git a/engines/hdb/ai-lists.cpp b/engines/hdb/ai-lists.cpp
index a8e6511..c272df7 100644
--- a/engines/hdb/ai-lists.cpp
+++ b/engines/hdb/ai-lists.cpp
@@ -520,7 +520,7 @@ bool AI::activateAction(AIEntity *e, int x, int y, int targetX, int targetY) {
 	if ( tileIndex == _templeTouchpOn )
 		success = useTouchplateOn( e, x, y, targetX, targetY, _templeTouchpOff );
 
-		return success;
+	return success;
 }
 
 bool AI::checkAutoList(AIEntity *e, int x, int y) {


Commit: a98e2a8e6df549816e815497f8e60f976fe8f055
    https://github.com/scummvm/scummvm/commit/a98e2a8e6df549816e815497f8e60f976fe8f055
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:21+02:00

Commit Message:
JANITORIAL: Fix code formatting

Changed paths:
    engines/hdb/ai-lists.cpp


diff --git a/engines/hdb/ai-lists.cpp b/engines/hdb/ai-lists.cpp
index c272df7..39b3970 100644
--- a/engines/hdb/ai-lists.cpp
+++ b/engines/hdb/ai-lists.cpp
@@ -412,113 +412,80 @@ bool AI::activateAction(AIEntity *e, int x, int y, int targetX, int targetY) {
 		tileIndex = g_hdb->_map->getMapBGTileIndex(x, y);
 
 	// Check which tile is going to activate
-	if ( tileIndex == _useSwitchOff || tileIndex == _useSwitchOff + 1 )
-		success = useSwitch( e, x, y, targetX, targetY, _useSwitchOn );
-	else
-	if ( tileIndex == _useSwitchOn )
-		success = useSwitchOn( e, x, y, targetX, targetY, _useSwitchOff );
-	else
+	if (tileIndex == _useSwitchOff || tileIndex == _useSwitchOff + 1)
+		success = useSwitch(e, x, y, targetX, targetY, _useSwitchOn);
+	else if (tileIndex == _useSwitchOn)
+		success = useSwitchOn(e, x, y, targetX, targetY, _useSwitchOff);
 	//-------------------------------------------------------------------
-	if ( tileIndex == _useHandswitchOff || tileIndex == _useHandswitchOff + 1 )
-		success = useSwitch( e, x, y, targetX, targetY, _useHandswitchOn );
-	else
-	if ( tileIndex == _useHandswitchOn )
-		success = useSwitchOn( e, x, y, targetX, targetY, _useHandswitchOff );
-	else
+	else if (tileIndex == _useHandswitchOff || tileIndex == _useHandswitchOff + 1)
+		success = useSwitch(e, x, y, targetX, targetY, _useHandswitchOn);
+	else if (tileIndex == _useHandswitchOn)
+		success = useSwitchOn(e, x, y, targetX, targetY, _useHandswitchOff);
 	//-------------------------------------------------------------------
-	if ( tileIndex == _kcHolderWhiteOff || tileIndex == _kcHolderWhiteOff + 1 )
-		success = useLockedSwitch( e, x, y, targetX, targetY, _kcHolderWhiteOn, ITEM_KEYCARD_WHITE, "I need a White Keycard." );
-	else
-	if ( tileIndex == _kcHolderWhiteOn )
-		success = useLockedSwitchOn( e, x, y, targetX, targetY, _kcHolderWhiteOff, ITEM_KEYCARD_WHITE );
-	else
-	if ( tileIndex == _kcHolderBlueOff || tileIndex == _kcHolderBlueOff + 1 )
-		success = useLockedSwitch( e, x, y, targetX, targetY, _kcHolderBlueOn, ITEM_KEYCARD_BLUE, "I need a Blue Keycard." );
-	else
-	if ( tileIndex == _kcHolderBlueOn )
-		success = useLockedSwitchOn( e, x, y, targetX, targetY, _kcHolderBlueOff, ITEM_KEYCARD_BLUE );
-	else
-	if ( tileIndex == _kcHolderRedOff || tileIndex == _kcHolderRedOff + 1 )
-		success = useLockedSwitch( e, x, y, targetX, targetY, _kcHolderRedOn, ITEM_KEYCARD_RED, "I need a Red Keycard." );
-	else
-	if ( tileIndex == _kcHolderRedOn )
-		success = useLockedSwitchOn( e, x, y, targetX, targetY, _kcHolderRedOff, ITEM_KEYCARD_RED );
-	else
-	if ( tileIndex == _kcHolderGreenOff || tileIndex == _kcHolderGreenOff + 1 )
-		success = useLockedSwitch( e, x, y, targetX, targetY, _kcHolderGreenOn, ITEM_KEYCARD_GREEN, "I need a Green Keycard." );
-	else
-	if ( tileIndex == _kcHolderGreenOn )
-		success = useLockedSwitchOn( e, x, y, targetX, targetY, _kcHolderGreenOff, ITEM_KEYCARD_GREEN );
-	else
-	if ( tileIndex == _kcHolderPurpleOff || tileIndex == _kcHolderPurpleOff + 1 )
-		success = useLockedSwitch( e, x, y, targetX, targetY, _kcHolderPurpleOn, ITEM_KEYCARD_PURPLE, "I need a Purple Keycard." );
-	else
-	if ( tileIndex == _kcHolderPurpleOn )
-		success = useLockedSwitchOn( e, x, y, targetX, targetY, _kcHolderPurpleOff, ITEM_KEYCARD_PURPLE );
-	else
-	if ( tileIndex == _kcHolderBlackOff || tileIndex == _kcHolderBlackOff + 1 )
-		success = useLockedSwitch( e, x, y, targetX, targetY, _kcHolderBlackOn, ITEM_KEYCARD_BLACK, "I need a Black Keycard." );
-	else
-	if ( tileIndex == _kcHolderBlackOn )
-		success = useLockedSwitchOn( e, x, y, targetX, targetY, _kcHolderBlackOff, ITEM_KEYCARD_BLACK );
-	else
+	else if (tileIndex == _kcHolderWhiteOff || tileIndex == _kcHolderWhiteOff + 1)
+		success = useLockedSwitch(e, x, y, targetX, targetY, _kcHolderWhiteOn, ITEM_KEYCARD_WHITE, "I need a White Keycard.");
+	else if (tileIndex == _kcHolderWhiteOn)
+		success = useLockedSwitchOn(e, x, y, targetX, targetY, _kcHolderWhiteOff, ITEM_KEYCARD_WHITE);
+	else if (tileIndex == _kcHolderBlueOff || tileIndex == _kcHolderBlueOff + 1)
+		success = useLockedSwitch(e, x, y, targetX, targetY, _kcHolderBlueOn, ITEM_KEYCARD_BLUE, "I need a Blue Keycard.");
+	else if (tileIndex == _kcHolderBlueOn)
+		success = useLockedSwitchOn(e, x, y, targetX, targetY, _kcHolderBlueOff, ITEM_KEYCARD_BLUE);
+	else if (tileIndex == _kcHolderRedOff || tileIndex == _kcHolderRedOff + 1)
+		success = useLockedSwitch(e, x, y, targetX, targetY, _kcHolderRedOn, ITEM_KEYCARD_RED, "I need a Red Keycard.");
+	else if (tileIndex == _kcHolderRedOn)
+		success = useLockedSwitchOn(e, x, y, targetX, targetY, _kcHolderRedOff, ITEM_KEYCARD_RED);
+	else if (tileIndex == _kcHolderGreenOff || tileIndex == _kcHolderGreenOff + 1)
+		success = useLockedSwitch(e, x, y, targetX, targetY, _kcHolderGreenOn, ITEM_KEYCARD_GREEN, "I need a Green Keycard.");
+	else if (tileIndex == _kcHolderGreenOn)
+		success = useLockedSwitchOn(e, x, y, targetX, targetY, _kcHolderGreenOff, ITEM_KEYCARD_GREEN);
+	else if (tileIndex == _kcHolderPurpleOff || tileIndex == _kcHolderPurpleOff + 1)
+		success = useLockedSwitch(e, x, y, targetX, targetY, _kcHolderPurpleOn, ITEM_KEYCARD_PURPLE, "I need a Purple Keycard.");
+	else if (tileIndex == _kcHolderPurpleOn)
+		success = useLockedSwitchOn(e, x, y, targetX, targetY, _kcHolderPurpleOff, ITEM_KEYCARD_PURPLE);
+	else if (tileIndex == _kcHolderBlackOff || tileIndex == _kcHolderBlackOff + 1)
+		success = useLockedSwitch(e, x, y, targetX, targetY, _kcHolderBlackOn, ITEM_KEYCARD_BLACK, "I need a Black Keycard.");
+	else if (tileIndex == _kcHolderBlackOn)
+		success = useLockedSwitchOn(e, x, y, targetX, targetY, _kcHolderBlackOff, ITEM_KEYCARD_BLACK);
 	//-------------------------------------------------------------------
-	if ( tileIndex == _useSwitch2Off || tileIndex == _useSwitch2Off + 1 )
-		success = useSwitch2( e, x, y, targetX, targetY );
-	else
-	if ( tileIndex == _useHolderEmpty || tileIndex == _useHolderEmpty + 1 )
-		success = useCellHolder( e, x, y, targetX, targetY );
-	else
+	else if (tileIndex == _useSwitch2Off || tileIndex == _useSwitch2Off + 1)
+		success = useSwitch2(e, x, y, targetX, targetY);
+	else if (tileIndex == _useHolderEmpty || tileIndex == _useHolderEmpty + 1)
+		success = useCellHolder(e, x, y, targetX, targetY);
 	//-------------------------------------------------------------------
-	if ( tileIndex == _targetDoorN || tileIndex == _targetDoorN + 3 )
-		success = useAutoDoorOpenClose( e, x, y );
-	else
-	if ( tileIndex == _targetDoorP || tileIndex == _targetDoorP + 3 )
-		success = useDoorOpenCloseBot( e, x, y );
-	else
-	if ( tileIndex == _targetDoorS || tileIndex == _targetDoorS + 3 )
-		success = useDoorOpenCloseBot( e, x, y );
-	else
-	if ( tileIndex == _targetDoorNv || tileIndex == _targetDoorNv + 3 )
-		success = useAutoDoorOpenClose( e, x, y );
-	else
-	if ( tileIndex == _targetDoorPv || tileIndex == _targetDoorPv + 3 )
-		success = useDoorOpenCloseBot( e, x, y );
-	else
-	if ( tileIndex == _targetDoorSv || tileIndex == _targetDoorSv + 3 )
-		success = useDoorOpenCloseBot( e, x, y );
-	else
+	else if (tileIndex == _targetDoorN || tileIndex == _targetDoorN + 3)
+		success = useAutoDoorOpenClose(e, x, y);
+	else if (tileIndex == _targetDoorP || tileIndex == _targetDoorP + 3)
+		success = useDoorOpenCloseBot(e, x, y);
+	else if (tileIndex == _targetDoorS || tileIndex == _targetDoorS + 3)
+		success = useDoorOpenCloseBot(e, x, y);
+	else if (tileIndex == _targetDoorNv || tileIndex == _targetDoorNv + 3)
+		success = useAutoDoorOpenClose(e, x, y);
+	else if (tileIndex == _targetDoorPv || tileIndex == _targetDoorPv + 3)
+		success = useDoorOpenCloseBot(e, x, y);
+	else if (tileIndex == _targetDoorSv || tileIndex == _targetDoorSv + 3)
+		success = useDoorOpenCloseBot(e, x, y);
 	//-------------------------------------------------------------------
-	if ( tileIndex == _targetDoorN || tileIndex == _targetDoor2N + 3 )
-		success = useAutoDoorOpenClose( e, x, y );
-	else
-	if ( tileIndex == _targetDoorP || tileIndex == _targetDoor2P + 3 )
-		success = useDoorOpenCloseBot( e, x, y );
-	else
-	if ( tileIndex == _targetDoorS || tileIndex == _targetDoor2S + 3 )
-		success = useDoorOpenCloseBot( e, x, y );
-	else
-	if ( tileIndex == _targetDoorNv || tileIndex == _targetDoor2Nv + 3 )
-		success = useAutoDoorOpenClose( e, x, y );
-	else
-	if ( tileIndex == _targetDoorPv || tileIndex == _targetDoor2Pv + 3 )
-		success = useDoorOpenCloseBot( e, x, y );
-	else
-	if ( tileIndex == _targetDoorSv || tileIndex == _targetDoor2Sv + 3 )
-		success = useDoorOpenCloseBot( e, x, y );
-	else
+	else if (tileIndex == _targetDoorN || tileIndex == _targetDoor2N + 3)
+		success = useAutoDoorOpenClose(e, x, y);
+	else if (tileIndex == _targetDoorP || tileIndex == _targetDoor2P + 3)
+		success = useDoorOpenCloseBot(e, x, y);
+	else if (tileIndex == _targetDoorS || tileIndex == _targetDoor2S + 3)
+		success = useDoorOpenCloseBot(e, x, y);
+	else if (tileIndex == _targetDoorNv || tileIndex == _targetDoor2Nv + 3)
+		success = useAutoDoorOpenClose(e, x, y);
+	else if (tileIndex == _targetDoorPv || tileIndex == _targetDoor2Pv + 3)
+		success = useDoorOpenCloseBot(e, x, y);
+	else if (tileIndex == _targetDoorSv || tileIndex == _targetDoor2Sv + 3)
+		success = useDoorOpenCloseBot(e, x, y);
 	//-------------------------------------------------------------------
-	if ( tileIndex == _touchplateOff )
-		success = useTouchplate( e, x, y, targetX, targetY, _touchplateOn );
-	else
-	if ( tileIndex == _touchplateOn )
-		success = useTouchplateOn( e, x, y, targetX, targetY, _touchplateOff );
-	else
-	if ( tileIndex == _templeTouchpOff )
-		success = useTouchplate( e, x, y, targetX, targetY, _templeTouchpOn );
-	else
-	if ( tileIndex == _templeTouchpOn )
-		success = useTouchplateOn( e, x, y, targetX, targetY, _templeTouchpOff );
+	else if (tileIndex == _touchplateOff)
+		success = useTouchplate(e, x, y, targetX, targetY, _touchplateOn);
+	else if (tileIndex == _touchplateOn)
+		success = useTouchplateOn(e, x, y, targetX, targetY, _touchplateOff);
+	else if (tileIndex == _templeTouchpOff)
+		success = useTouchplate(e, x, y, targetX, targetY, _templeTouchpOn);
+	else if (tileIndex == _templeTouchpOn)
+		success = useTouchplateOn(e, x, y, targetX, targetY, _templeTouchpOff);
 
 	return success;
 }


Commit: a1645e29583e1f6b4dab26fb6fc49cadc0c0cad1
    https://github.com/scummvm/scummvm/commit/a1645e29583e1f6b4dab26fb6fc49cadc0c0cad1
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:21+02:00

Commit Message:
HDB: Fix warning

Changed paths:
    engines/hdb/ai-funcs.cpp


diff --git a/engines/hdb/ai-funcs.cpp b/engines/hdb/ai-funcs.cpp
index 38df8ce..af55d86 100644
--- a/engines/hdb/ai-funcs.cpp
+++ b/engines/hdb/ai-funcs.cpp
@@ -874,8 +874,9 @@ void AI::stunEnemy(AIEntity *e, int time) {
 		case AI_BOOMBARREL:
 			g_hdb->_sound->playSound(SND_CLUB_HIT_METAL);
 			break;
-		case AI_CHICKEN:	// Fall through
+		case AI_CHICKEN:
 			g_hdb->_sound->playSound(SND_CHICKEN_DEATH);
+			// fallthrough
 		default:
 			warning("STUB: stunEnemy: MetalOrFleshSnd");
 			break;


Commit: fe0082b4d6e79ba788a0c72e04e911b5011ffc0e
    https://github.com/scummvm/scummvm/commit/fe0082b4d6e79ba788a0c72e04e911b5011ffc0e
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:21+02:00

Commit Message:
HDB: Fix warnings

Changed paths:
    engines/hdb/ai-bots.cpp


diff --git a/engines/hdb/ai-bots.cpp b/engines/hdb/ai-bots.cpp
index 90f74b9..2234bc5 100644
--- a/engines/hdb/ai-bots.cpp
+++ b/engines/hdb/ai-bots.cpp
@@ -721,6 +721,7 @@ void aiRailRiderOnAction(AIEntity *e) {
 	case -1:
 		if (!p->goalX)
 			e->sequence = 1; // Boarded yet?
+		// fallthrough
 	// Cycle Animation Frames
 	case 3:
 		if (e->animDelay-- > 0)
@@ -740,6 +741,7 @@ void aiRailRiderOnAction(AIEntity *e) {
 		g_hdb->_sound->playSound(SND_RAILRIDER_TASTE);
 		e->sequence = 2;
 		e->value1 = 0;
+		// fallthrough
 
 	// New RailRider gfx
 	// Move the RailRider


Commit: 505bd8b927773a42a0fbdae8a5e598263a4863ea
    https://github.com/scummvm/scummvm/commit/505bd8b927773a42a0fbdae8a5e598263a4863ea
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:21+02:00

Commit Message:
HDB: Fix warning

Changed paths:
    engines/hdb/ai-waypoint.cpp


diff --git a/engines/hdb/ai-waypoint.cpp b/engines/hdb/ai-waypoint.cpp
index dac3328..cbc9e9e 100644
--- a/engines/hdb/ai-waypoint.cpp
+++ b/engines/hdb/ai-waypoint.cpp
@@ -398,7 +398,7 @@ bool AI::traceStraightPath(int x1, int y1, int *x2, int *y2, int *level) {
 			// if it's blocking, is it rad or plasma? (might be melted stuff on it)
 			if (!ok) {
 				ok = ((flags & kFlagPlasmaFloor) == kFlagPlasmaFloor) +
-					((flags & kFlagPlasmaFloor) == kFlagRadFloor);
+					((flags & kFlagRadFloor) == kFlagRadFloor);
 				e = findEntity(x1, y1);
 				if (e && g_hdb->_ai->walkThroughEnt(e->type))
 					entOK = 1;


Commit: 55a650d5feadb5913e4bc7fa35a2d45852dc7d05
    https://github.com/scummvm/scummvm/commit/55a650d5feadb5913e4bc7fa35a2d45852dc7d05
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:21+02:00

Commit Message:
HDB: Fix data type

Changed paths:
    engines/hdb/ai.h


diff --git a/engines/hdb/ai.h b/engines/hdb/ai.h
index f3802d5..b7c5c08 100644
--- a/engines/hdb/ai.h
+++ b/engines/hdb/ai.h
@@ -413,7 +413,7 @@ struct AIEntity {
 	int16		xVel, yVel;								// movement values
 	uint16		tileX, tileY;
 	uint16		goalX, goalY;							// where we're trying to go - TILE COORDS
-	uint16		touchpX, touchpY, touchpTile, touchpWait;		// ACTION index a touchplate is using, which you're on
+	int16		touchpX, touchpY, touchpTile, touchpWait;		// ACTION index a touchplate is using, which you're on
 	uint32		stunnedWait;							// if we're stunned, this is the delay before being normal again
 	int16		sequence;								// to use for specially-coded sequences
 	char		entityName[32];						// the name of the entity, as registered by the Lua init function for the entity


Commit: 39bbc59cb559c55b88ebb4c7a67e5505577d0209
    https://github.com/scummvm/scummvm/commit/39bbc59cb559c55b88ebb4c7a67e5505577d0209
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:21+02:00

Commit Message:
HDB: Fix data types in AIEntity

Changed paths:
    engines/hdb/ai.h


diff --git a/engines/hdb/ai.h b/engines/hdb/ai.h
index b7c5c08..f240007 100644
--- a/engines/hdb/ai.h
+++ b/engines/hdb/ai.h
@@ -402,26 +402,26 @@ struct AIEntity {
 	char		luaFuncInit[32];						// Lua function for Init (always called after entity's init). These are ptrs into the map header.
 	char		luaFuncAction[32];						// Lua function for Action
 	char		luaFuncUse[32];							// Lua function for Use
-	uint16		level;									// which floor level we're on
-	uint16		value1, value2;							// extra values we might need
+	int16		level;									// which floor level we're on
+	int16		value1, value2;							// extra values we might need
 	AIDir		dir2;									// this is from TED
 
-	uint16		x, y;
+	int16		x, y;
 	int16		drawXOff, drawYOff;					// might need a drawing offset
-	uint16		onScreen;								// FLAG: is this entity onscreen?
-	uint16		moveSpeed;								// movement speed of this entity
+	int16		onScreen;								// FLAG: is this entity onscreen?
+	int16		moveSpeed;								// movement speed of this entity
 	int16		xVel, yVel;								// movement values
-	uint16		tileX, tileY;
-	uint16		goalX, goalY;							// where we're trying to go - TILE COORDS
+	int16		tileX, tileY;
+	int16		goalX, goalY;							// where we're trying to go - TILE COORDS
 	int16		touchpX, touchpY, touchpTile, touchpWait;		// ACTION index a touchplate is using, which you're on
-	uint32		stunnedWait;							// if we're stunned, this is the delay before being normal again
+	int32		stunnedWait;							// if we're stunned, this is the delay before being normal again
 	int16		sequence;								// to use for specially-coded sequences
 	char		entityName[32];						// the name of the entity, as registered by the Lua init function for the entity
 	char		printedName[32];						// the name of the entity/item, the way it should be printed
 
-	uint16		animFrame;								// which frame we're on
-	uint16		animDelay;								// changes every frame; based on anim_cycle at start
-	uint16		animCycle;								// delay between frame animations
+	int16		animFrame;								// which frame we're on
+	int16		animDelay;								// changes every frame; based on anim_cycle at start
+	int16		animCycle;								// delay between frame animations
 
 	union {
 		uint16 blinkFrames;
@@ -435,28 +435,28 @@ struct AIEntity {
 	};
 	Tile *special1Gfx[kMaxAnimFrames];
 
-	uint16		standdownFrames;
+	int16		standdownFrames;
 	Tile		*standdownGfx[kMaxAnimFrames];
 
-	uint16		standupFrames;
+	int16		standupFrames;
 	Tile		*standupGfx[kMaxAnimFrames];
 
-	uint16		standleftFrames;
+	int16		standleftFrames;
 	Tile		*standleftGfx[kMaxAnimFrames];
 
-	uint16		standrightFrames;
+	int16		standrightFrames;
 	Tile		*standrightGfx[kMaxAnimFrames];
 
-	uint16		moveupFrames;
+	int16		moveupFrames;
 	Tile		*moveupGfx[kMaxAnimFrames];
 
-	uint16		movedownFrames;
+	int16		movedownFrames;
 	Tile		*movedownGfx[kMaxAnimFrames];
 
-	uint16		moveleftFrames;
+	int16		moveleftFrames;
 	Tile		*moveleftGfx[kMaxAnimFrames];
 
-	uint16		moverightFrames;
+	int16		moverightFrames;
 	Tile		*moverightGfx[kMaxAnimFrames];
 
 	AIEntity() {


Commit: bfa2d11a1d44e8572ad7ee3b316ba98ec5ba3307
    https://github.com/scummvm/scummvm/commit/bfa2d11a1d44e8572ad7ee3b316ba98ec5ba3307
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:21+02:00

Commit Message:
HDB: Fix warning

Changed paths:
    engines/hdb/hdb.cpp


diff --git a/engines/hdb/hdb.cpp b/engines/hdb/hdb.cpp
index 677b397..d52c227 100644
--- a/engines/hdb/hdb.cpp
+++ b/engines/hdb/hdb.cpp
@@ -744,7 +744,7 @@ void HDBGame::drawLoadingScreen() {
 	_loadingScreenGfx->draw(0, 0);
 }
 
-struct {
+struct MapName {
 	const char *fName, *printName;
 } mapNames[] = {
 	{	"MAP00",			"HDS Colby Jack" },


Commit: 17e2c05417921f91851afda608bc99506a71673e
    https://github.com/scummvm/scummvm/commit/17e2c05417921f91851afda608bc99506a71673e
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:21+02:00

Commit Message:
HDB: Fix warning

Changed paths:
    engines/hdb/lua-script.cpp


diff --git a/engines/hdb/lua-script.cpp b/engines/hdb/lua-script.cpp
index 5c1f123..dc402e7 100644
--- a/engines/hdb/lua-script.cpp
+++ b/engines/hdb/lua-script.cpp
@@ -1594,7 +1594,7 @@ struct NumberInit {
 	{ STATE_DOLLYUSERIGHT,	"STATE_DOLLYUSERIGHT"	},
 	{ STATE_YELL,			"STATE_YELL"			},
 
-	{ NULL, NULL }
+	{ STATE_NONE, NULL }
 };
 
 struct FuncInit {


Commit: ea2f09b2560ffef5f9e81453f5d9a5d0f0d87af0
    https://github.com/scummvm/scummvm/commit/ea2f09b2560ffef5f9e81453f5d9a5d0f0d87af0
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:21+02:00

Commit Message:
COMMON: Restored functionaluty of Lua print

Changed paths:
    common/lua/lbaselib.cpp


diff --git a/common/lua/lbaselib.cpp b/common/lua/lbaselib.cpp
index ec04497..22af019 100644
--- a/common/lua/lbaselib.cpp
+++ b/common/lua/lbaselib.cpp
@@ -5,6 +5,8 @@
 */
 
 
+#define FORBIDDEN_SYMBOL_EXCEPTION_fputs
+#define FORBIDDEN_SYMBOL_EXCEPTION_stdout
 
 #include "common/util.h"
 
@@ -37,8 +39,11 @@ static int luaB_print (lua_State *L) {
     if (s == NULL)
       return luaL_error(L, LUA_QL("tostring") " must return a string to "
                            LUA_QL("print"));
+    if (i>1) fputs("\t", stdout);
+    fputs(s, stdout);
     lua_pop(L, 1);  /* pop result */
   }
+  fputs("\n", stdout);
   return 0;
 }
 


Commit: e0cb401bc2c3fa3c74cd2342e13529254c816626
    https://github.com/scummvm/scummvm/commit/e0cb401bc2c3fa3c74cd2342e13529254c816626
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:21+02:00

Commit Message:
HDB: Added more debug output to script compilation

Changed paths:
    engines/hdb/lua-script.cpp


diff --git a/engines/hdb/lua-script.cpp b/engines/hdb/lua-script.cpp
index dc402e7..c930d48 100644
--- a/engines/hdb/lua-script.cpp
+++ b/engines/hdb/lua-script.cpp
@@ -2025,6 +2025,11 @@ void LuaScript::addPatches(Common::String &chunk, const char *scriptName) {
 
 	if (applied)
 		debug(1, "Applied %d patches to %s", applied, scriptName);
+
+	if (gDebugLevel > 3) {
+		warning(">>>>>>>>>>> SCRIPT: %s", scriptName);
+		chunk += "\nfor i,v in pairs(_G) do if type(v) == 'function' then print(i) end end";
+	}
 }
 
 void LuaScript::checkParameters(const char *func, int params) {


Commit: 6d83d2ea724801ef5661f79bdec5e48eff5ada30
    https://github.com/scummvm/scummvm/commit/6d83d2ea724801ef5661f79bdec5e48eff5ada30
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:21+02:00

Commit Message:
HDB: Added more stuff to cheat for MAP00

Changed paths:
    engines/hdb/hdb.cpp


diff --git a/engines/hdb/hdb.cpp b/engines/hdb/hdb.cpp
index d52c227..94abb7b 100644
--- a/engines/hdb/hdb.cpp
+++ b/engines/hdb/hdb.cpp
@@ -197,6 +197,8 @@ bool HDBGame::restartMap() {
 		Common::String patch("KillTrigger( \"mannyquest\" )");
 
 		_lua->executeChunk(patch, "MAP00 patch");
+
+		_ai->addItemToInventory(ITEM_CELL, 1, 0, 0, 0);
 	}
 #endif
 


Commit: dda8c8137579b007d1aaeebc426bd4f942054b35
    https://github.com/scummvm/scummvm/commit/dda8c8137579b007d1aaeebc426bd4f942054b35
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:21+02:00

Commit Message:
HDB: Added (commented out) debug case for _use functions

Changed paths:
    engines/hdb/lua-script.cpp


diff --git a/engines/hdb/lua-script.cpp b/engines/hdb/lua-script.cpp
index c930d48..797e030 100644
--- a/engines/hdb/lua-script.cpp
+++ b/engines/hdb/lua-script.cpp
@@ -1885,8 +1885,26 @@ void LuaScript::invokeLuaFunction(char *luaFunc, int x, int y, int value1, int v
 
 	lua_getglobal(_state, luaFunc);
 	type = lua_type(_state, 1);
+
+#if 0
+	if (!strcmp(luaFunc, "ferretbed_use")) {
+		const char *t = lua_typename(_state, type);
+		warning("type: %s", t);
+		Common::String a("print(ferretbed_init(50, 30, 0, 0))");
+
+		executeChunk(a, "debug");
+
+//		a = "print('woo') for i,v in pairs(_G) do if type(v) == 'function' then print(i) end end";
+//		a = "print(ferretbed_use())";
+
+		executeChunk(a, "debug");
+
+		lua_printstack(_state);
+	}
+#endif
+
 	if (type != LUA_TFUNCTION) {
-		warning("Function '%s' doesn't exist", luaFunc);
+		warning("Function '%s' doesn't exist (%d)", luaFunc, type);
 	} else {
 		lua_pushnumber(_state, x);
 		lua_pushnumber(_state, y);


Commit: 49b0f7c6d21c8c94bdac3963c181ebc7f4e5ccb8
    https://github.com/scummvm/scummvm/commit/49b0f7c6d21c8c94bdac3963c181ebc7f4e5ccb8
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:21+02:00

Commit Message:
HDB: Normalised usage of _systemInit for Lua

Changed paths:
    engines/hdb/lua-script.cpp


diff --git a/engines/hdb/lua-script.cpp b/engines/hdb/lua-script.cpp
index 797e030..1160d00 100644
--- a/engines/hdb/lua-script.cpp
+++ b/engines/hdb/lua-script.cpp
@@ -86,10 +86,12 @@ bool LuaScript::loadLua(const char *name) {
 	if (luaStream == NULL) {
 		warning("The %s MPC entry can't be found", name);
 
+		_systemInit = false;
+
 		return false;
 	}
 
-	initScript(luaStream, name, luaLength);
+	_systemInit = initScript(luaStream, name, luaLength);
 
 	return true;
 }
@@ -1706,7 +1708,7 @@ void debugHook(lua_State *L, lua_Debug *ar) {
 }
 
 bool LuaScript::initScript(Common::SeekableReadStream *stream, const char *scriptName, int32 length) {
-	if (_systemInit) {
+	if (_state != NULL) {
 		lua_close(_state);
 	}
 
@@ -1718,8 +1720,6 @@ bool LuaScript::initScript(Common::SeekableReadStream *stream, const char *scrip
 	}
 	luaL_openlibs(_state);
 
-	_systemInit = true;
-
 	// Register Extensions
 	for (int i = 0; luaFuncs[i].luaName; i++) {
 		lua_register(_state, luaFuncs[i].luaName, luaFuncs[i].function);
@@ -1915,11 +1915,6 @@ void LuaScript::invokeLuaFunction(char *luaFunc, int x, int y, int value1, int v
 }
 
 bool LuaScript::executeMPC(Common::SeekableReadStream *stream, const char *name, const char *scriptName, int32 length) {
-
-	if (!_systemInit) {
-		return false;
-	}
-
 	char *chunk = new char[length + 1];
 	stream->read((void *)chunk, length);
 	chunk[length] = '\0'; // be on the safe side
@@ -1946,11 +1941,6 @@ bool LuaScript::executeMPC(Common::SeekableReadStream *stream, const char *name,
 }
 
 bool LuaScript::executeFile(const Common::String &filename) {
-
-	if (!_systemInit) {
-		return false;
-	}
-
 	Common::File *file = new Common::File;
 
 	if (!file->open(filename)) {
@@ -1982,11 +1972,6 @@ bool LuaScript::executeFile(const Common::String &filename) {
 }
 
 bool LuaScript::executeChunk(Common::String &chunk, const Common::String &chunkName) const {
-
-	if (!_systemInit) {
-		return false;
-	}
-
 	// Compile Chunk
 	if (luaL_loadbuffer(_state, chunk.c_str(), chunk.size(), chunkName.c_str())) {
 		error("Couldn't compile \"%s\": %s", chunkName.c_str(), lua_tostring(_state, -1));


Commit: 2bb172a58614359ed720b24ba49e9b6c288b3d39
    https://github.com/scummvm/scummvm/commit/2bb172a58614359ed720b24ba49e9b6c288b3d39
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:21+02:00

Commit Message:
HDB: Filter out more Lua globals from the save

Changed paths:
    engines/hdb/lua-script.cpp


diff --git a/engines/hdb/lua-script.cpp b/engines/hdb/lua-script.cpp
index 1160d00..23b1011 100644
--- a/engines/hdb/lua-script.cpp
+++ b/engines/hdb/lua-script.cpp
@@ -44,7 +44,7 @@ struct ScriptPatch {
 	{"GLOBAL.LUA", "for i,v in globals() do", "for i,v in pairs(_G) do"},
 	{"GLOBAL.LUA", "return gsub( s, \"\\n\", \"\\\\\\n\" )", "return string.gsub( s, \"\\n\", \"\\\\\\n\" )"},
 	{"GLOBAL.LUA", "for i,v in t do", "for i,v in pairs(t) do"},
-	{"GLOBAL.LUA", "if type(v) == 'userdata' or type(v) == 'function' then return end", "if type(v) == 'userdata' or type(v) == 'function' or i == 'package' or i == 'os' or i == 'io' or i == 'string' or i == 'table' then return end" }, // Line 16
+	{"GLOBAL.LUA", "if type(v) == 'userdata' or type(v) == 'function' then return end", "if type(v) == 'userdata' or type(v) == 'function' or i == 'package' or i == 'os' or i == 'io' or i == 'string' or i == 'table' or i == 'debug' or i == 'math' or i == 'coroutine' then return end" }, // Line 16
 	{"GLOBAL.LUA", "for npcname,npcdata in npcs do", "for npcname,npcdata in pairs(npcs) do"}, // Line 66
 	{"GLOBAL.LUA", "for dlgname,dlgdata in npcdata.dialog do", "for dlgname,dlgdata in pairs(npcdata.dialog) do"}, // Line 67
 	{"GLOBAL.LUA", "s = format( \"npcs.%s.dialog.%s.counter", "s = string.format( \"npcs.%s.dialog.%s.counter"}, // Line 68


Commit: 345830222d0311d2f72cd932884838976687c6fa
    https://github.com/scummvm/scummvm/commit/345830222d0311d2f72cd932884838976687c6fa
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:21+02:00

Commit Message:
HDB: Fix Lua execution at game restore

Changed paths:
    engines/hdb/lua-script.cpp


diff --git a/engines/hdb/lua-script.cpp b/engines/hdb/lua-script.cpp
index 23b1011..b82b7af 100644
--- a/engines/hdb/lua-script.cpp
+++ b/engines/hdb/lua-script.cpp
@@ -186,10 +186,6 @@ void LuaScript::loadSaveFile(Common::InSaveFile *in, const char *fName) {
 		in->read(_globals[i]->string, 32);
 	}
 
-	// Error handling function to be executed after the function is put on the stack
-	lua_rawgeti(_state, LUA_REGISTRYINDEX, _pcallErrorhandlerRegistryIndex);
-	lua_insert(_state, -2);
-
 	lua_getglobal(_state, "LoadState");
 	lua_pushstring(_state, fName);
 


Commit: 2909d9a9a0e11b39a77632dcf82c709304aa098a
    https://github.com/scummvm/scummvm/commit/2909d9a9a0e11b39a77632dcf82c709304aa098a
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:22+02:00

Commit Message:
HDB: Move save filename generation to genSaveFileName()

Changed paths:
    engines/hdb/hdb.h
    engines/hdb/lua-script.cpp
    engines/hdb/lua-script.h
    engines/hdb/menu.cpp
    engines/hdb/saveload.cpp


diff --git a/engines/hdb/hdb.h b/engines/hdb/hdb.h
index 77e7610..3b42c26 100644
--- a/engines/hdb/hdb.h
+++ b/engines/hdb/hdb.h
@@ -180,6 +180,8 @@ public:
 	void saveGame(Common::OutSaveFile *out);
 	void loadGame(Common::InSaveFile *in);
 
+	Common::String genSaveFileName(uint slot, bool lua);
+
 	void saveWhenReady(int slot) {
 		_saveInfo.active = true;
 		_saveInfo.slot = slot;
diff --git a/engines/hdb/lua-script.cpp b/engines/hdb/lua-script.cpp
index b82b7af..1b62081 100644
--- a/engines/hdb/lua-script.cpp
+++ b/engines/hdb/lua-script.cpp
@@ -154,7 +154,7 @@ void LuaScript::purgeGlobals() {
 	_globals.clear();
 }
 
-void LuaScript::save(Common::OutSaveFile *out, const char *targetName, int slot) {
+void LuaScript::save(Common::OutSaveFile *out, int slot) {
 	out->writeUint32LE(_globals.size());
 
 	// Save Globals
@@ -165,7 +165,7 @@ void LuaScript::save(Common::OutSaveFile *out, const char *targetName, int slot)
 		out->write(_globals[i]->string, 32);
 	}
 
-	Common::String saveLuaName = Common::String::format("%s.l.%03d", targetName, slot);
+	Common::String saveLuaName = g_hdb->genSaveFileName(slot, true);
 	lua_printstack(_state);
 	lua_getglobal(_state, "SaveState");
 
diff --git a/engines/hdb/lua-script.h b/engines/hdb/lua-script.h
index 5124ac2..4dab94e 100644
--- a/engines/hdb/lua-script.h
+++ b/engines/hdb/lua-script.h
@@ -59,7 +59,7 @@ public:
 	void saveGlobalString(const char *global, const char *string);
 	void loadGlobal(const char *global);
 	void purgeGlobals();
-	void save(Common::OutSaveFile *out, const char *targetName, int slot);
+	void save(Common::OutSaveFile *out, int slot);
 	void loadSaveFile(Common::InSaveFile *in, const char *fName);
 
 	bool init();
diff --git a/engines/hdb/menu.cpp b/engines/hdb/menu.cpp
index 6ea70ea..ade6156 100644
--- a/engines/hdb/menu.cpp
+++ b/engines/hdb/menu.cpp
@@ -928,15 +928,11 @@ void Menu::drawTitle() {
 }
 
 void Menu::fillSavegameSlots() {
-	int i;
-	int max = kNumSaveSlots;
-
-	Common::InSaveFile *in;
 	Common::String saveGameFile;
 
-	for (i = 0; i < max; i++) {
-		saveGameFile = Common::String::format("%s.%03d", g_hdb->getTargetName()->c_str(), i);
-		in = g_system->getSavefileManager()->openForLoading(saveGameFile);
+	for (int i = 0; i < kNumSaveSlots; i++) {
+		saveGameFile = g_hdb->genSaveFileName(i, false);
+		Common::InSaveFile *in = g_system->getSavefileManager()->openForLoading(saveGameFile);
 
 		if (!in) {
 			memset(&_saveGames[i], 0, sizeof(Save));
diff --git a/engines/hdb/saveload.cpp b/engines/hdb/saveload.cpp
index acda892..5c59619 100644
--- a/engines/hdb/saveload.cpp
+++ b/engines/hdb/saveload.cpp
@@ -32,7 +32,7 @@ Common::Error HDBGame::saveGameState(int slot, const Common::String &desc) {
 
 	Common::OutSaveFile *out;
 
-	Common::String saveFileName = Common::String::format("%s.%03d", _targetName.c_str(), slot);
+	Common::String saveFileName = genSaveFileName(slot, false);
 	if (!(out = _saveFileMan->openForSaving(saveFileName)))
 		error("Unable to open save file");
 
@@ -45,7 +45,7 @@ Common::Error HDBGame::saveGameState(int slot, const Common::String &desc) {
 
 	// Actual Save Data
 	saveGame(out);
-	_lua->save(out, _targetName.c_str(), slot);
+	_lua->save(out, slot);
 
 	out->finalize();
 	if (out->err())
@@ -59,7 +59,7 @@ Common::Error HDBGame::saveGameState(int slot, const Common::String &desc) {
 Common::Error HDBGame::loadGameState(int slot) {
 	Common::InSaveFile *in;
 
-	Common::String saveFileName = Common::String::format("%s.%03d", _targetName.c_str(), slot);
+	Common::String saveFileName = genSaveFileName(slot, false);
 	if (!(in = _saveFileMan->openForLoading(saveFileName))) {
 		warning("missing savegame file %s", saveFileName.c_str());
 		if (g_hdb->_map->isLoaded())
@@ -76,7 +76,7 @@ Common::Error HDBGame::loadGameState(int slot) {
 
 	_lua->loadLua(_currentLuaName); // load the Lua code FIRST! (if no file, it's ok)
 
-	saveFileName = Common::String::format("%s.l.%03d", _targetName.c_str(), slot);
+	saveFileName = genSaveFileName(slot, true);
 	_lua->loadSaveFile(in, saveFileName.c_str());
 
 	delete in;
@@ -340,5 +340,12 @@ void AIEntity::load(Common::InSaveFile *in) {
 	aiDraw = drawf;
 }
 
+Common::String HDBGame::genSaveFileName(uint slot, bool lua) {
+	if (!lua)
+		return Common::String::format("%s.%03d", _targetName.c_str(), slot);
+
+	return Common::String::format("%s.l.%03d", _targetName.c_str(), slot);
+}
+
 
 } // End of Namespace


Commit: e1c616e06f200d275ff1cf725971f98056bf1a23
    https://github.com/scummvm/scummvm/commit/e1c616e06f200d275ff1cf725971f98056bf1a23
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:22+02:00

Commit Message:
HDB: Rename saves as in the original

Changed paths:
    engines/hdb/saveload.cpp


diff --git a/engines/hdb/saveload.cpp b/engines/hdb/saveload.cpp
index 5c59619..548f68c 100644
--- a/engines/hdb/saveload.cpp
+++ b/engines/hdb/saveload.cpp
@@ -30,6 +30,21 @@ Common::Error HDBGame::saveGameState(int slot, const Common::String &desc) {
 	if (!g_hdb->_map->isLoaded())
 		return Common::kCreatingFileFailed;
 
+	// If it is autosave, push down all saves
+	if (slot == 0) {
+		Common::String nameFrom;
+		Common::String nameTo;
+		for (int i = kNumSaveSlots - 2; i >= 0; i--) {
+			nameFrom = genSaveFileName(i, false);
+			nameTo = genSaveFileName(i + 1, false);
+			_saveFileMan->renameSavefile(nameFrom, nameTo);
+
+			nameFrom = genSaveFileName(i, true);
+			nameTo = genSaveFileName(i + 1, true);
+			_saveFileMan->renameSavefile(nameFrom, nameTo);
+		}
+	}
+
 	Common::OutSaveFile *out;
 
 	Common::String saveFileName = genSaveFileName(slot, false);


Commit: 74931e720508c978bc6d035466f74c6125ce6762
    https://github.com/scummvm/scummvm/commit/74931e720508c978bc6d035466f74c6125ce6762
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:22+02:00

Commit Message:
HDB: Add destructor to AIEntity and AnimTarget

Changed paths:
    engines/hdb/ai.h


diff --git a/engines/hdb/ai.h b/engines/hdb/ai.h
index f240007..8b25008 100644
--- a/engines/hdb/ai.h
+++ b/engines/hdb/ai.h
@@ -546,6 +546,57 @@ struct AIEntity {
 			moverightGfx[i] = new Tile;
 		}
 	}
+	~AIEntity() {
+		blinkFrames = 0;
+		for (int i = 0; i < kMaxAnimFrames; i++) {
+			delete blinkGfx[i];
+		}
+
+		special1Frames = 0;
+		for (int i = 0; i < kMaxAnimFrames; i++) {
+			delete special1Gfx[i];
+		}
+
+		standdownFrames = 0;
+		for (int i = 0; i < kMaxAnimFrames; i++) {
+			delete standdownGfx[i];
+		}
+
+		standupFrames = 0;
+		for (int i = 0; i < kMaxAnimFrames; i++) {
+			delete standupGfx[i];
+		}
+
+		standleftFrames = 0;
+		for (int i = 0; i < kMaxAnimFrames; i++) {
+			delete standleftGfx[i];
+		}
+
+		standrightFrames = 0;
+		for (int i = 0; i < kMaxAnimFrames; i++) {
+			delete standrightGfx[i];
+		}
+
+		movedownFrames = 0;
+		for (int i = 0; i < kMaxAnimFrames; i++) {
+			delete movedownGfx[i];
+		}
+
+		moveupFrames = 0;
+		for (int i = 0; i < kMaxAnimFrames; i++) {
+			delete moveupGfx[i];
+		}
+
+		moveleftFrames = 0;
+		for (int i = 0; i < kMaxAnimFrames; i++) {
+			delete moveleftGfx[i];
+		}
+
+		moverightFrames = 0;
+		for (int i = 0; i < kMaxAnimFrames; i++) {
+			delete moverightGfx[i];
+		}
+	}
 
 	void save(Common::OutSaveFile *out);
 	void load(Common::InSaveFile *in);
@@ -597,6 +648,12 @@ struct AnimTarget {
 			gfxList[i] = new Tile;
 		}
 	}
+
+	~AnimTarget() {
+		for (int i = 0; i < kMaxAnimTFrames; i++) {
+			delete gfxList[i];
+		}
+	}
 };
 
 struct InvEnt {


Commit: 5cf1f6a2f9834c8f52bd8e376140ef9882654324
    https://github.com/scummvm/scummvm/commit/5cf1f6a2f9834c8f52bd8e376140ef9882654324
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:22+02:00

Commit Message:
HDB: Fix switches

Changed paths:
    engines/hdb/ai-init.cpp


diff --git a/engines/hdb/ai-init.cpp b/engines/hdb/ai-init.cpp
index 52b04ce..95d4359 100644
--- a/engines/hdb/ai-init.cpp
+++ b/engines/hdb/ai-init.cpp
@@ -979,8 +979,8 @@ bool AI::init() {
 	_blockpole		= g_hdb->_gfx->getTileIndex("t32_blockpole_1");
 	_useTeleporter	= g_hdb->_gfx->getTileIndex("anim_t32_teleporter1");
 
-	_useSwitchOff	= g_hdb->_gfx->getTileIndex("t32_temple_touchplate_on");
-	_useSwitchOff	= g_hdb->_gfx->getTileIndex("t32_temple_touchplate_off");
+	_templeTouchpOn	 = g_hdb->_gfx->getTileIndex("t32_temple_touchplate_on");
+	_templeTouchpOff = g_hdb->_gfx->getTileIndex("t32_temple_touchplate_off");
 
 	_kcHolderWhiteOff	= g_hdb->_gfx->getTileIndex("anim_t32_kcholder_white_off1");
 	_kcHolderWhiteOn	= g_hdb->_gfx->getTileIndex("t32_kcholder_white_on");


Commit: 9ab298748e15aff4c1c015d2a1590611e75ecece
    https://github.com/scummvm/scummvm/commit/9ab298748e15aff4c1c015d2a1590611e75ecece
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:22+02:00

Commit Message:
HDB: Fix flag checking across the engien

Changed paths:
    engines/hdb/ai-funcs.cpp
    engines/hdb/map.cpp


diff --git a/engines/hdb/ai-funcs.cpp b/engines/hdb/ai-funcs.cpp
index af55d86..761be53 100644
--- a/engines/hdb/ai-funcs.cpp
+++ b/engines/hdb/ai-funcs.cpp
@@ -948,7 +948,7 @@ void AI::animateEntity(AIEntity *e) {
 		bgTileFlags = g_hdb->_map->getMapBGTileFlags(e->tileX, e->tileY);
 		fgTileFlags = g_hdb->_map->getMapFGTileFlags(e->tileX, e->tileY);
 
-		if (e->level == 1 ? (bgTileFlags & kFlagIce) : ((bgTileFlags & kFlagIce) && !(fgTileFlags & kFlagGrating))) {
+		if (e->level == 1 ? ((bgTileFlags & kFlagIce) == kFlagIce) : (((bgTileFlags & kFlagIce) == kFlagIce) && !(fgTileFlags & kFlagGrating))) {
 			int xva[] = {9, 0, 0, -1, 1}, yva[] = {9, -1, 1, 0, 0};
 			int nx, ny, moveOK = 0;
 			AIEntity *hit;
@@ -1042,9 +1042,9 @@ void AI::animateEntity(AIEntity *e) {
 		bgTileFlags = g_hdb->_map->getMapBGTileFlags(cx, cy);
 		fgTileFlags = g_hdb->_map->getMapFGTileFlags(cx, cy);
 		if ((bgTileFlags & kFlagPlayerDie) && !(checkFloating(cx, cy)) && !(fgTileFlags & kFlagGrating)) {
-			if (bgTileFlags & kFlagEnergyFloor)
+			if ((bgTileFlags & kFlagEnergyFloor) == kFlagEnergyFloor)
 				killPlayer(DEATH_SHOCKED);
-			else if ((bgTileFlags & kFlagPlasmaFloor) || (bgTileFlags & kFlagRadFloor))
+			else if (((bgTileFlags & kFlagPlasmaFloor) == kFlagPlasmaFloor) || ((bgTileFlags & kFlagRadFloor) == kFlagRadFloor))
 				killPlayer(DEATH_FRIED);
 			else
 				killPlayer(DEATH_NORMAL);
@@ -1189,7 +1189,7 @@ void AI::animateEntity(AIEntity *e) {
 				// If it is a light barrel on a melting floor
 				// If it is supposed to slide across the floor
 				// If it is being pushed on a floating entity, don't float it
-				if (flags & kFlagSlime) {
+				if ((flags & kFlagSlime) == kFlagSlime) {
 					// unless its a Heavy Barrel in which case it floats in slime
 					if ((e->type == AI_CRATE || e->type == AI_HEAVYBARREL) && !checkFloating(e->tileX, e->tileY)) {
 						addAnimateTarget(e->x, e->y, 0, 3, ANIM_NORMAL, false, false, GROUP_SLIME_SPLASH_SIT);
@@ -1227,7 +1227,7 @@ void AI::animateEntity(AIEntity *e) {
 					hit = findEntityIgnore(e->tileX + xv, e->tileY + yv, &_dummyLaser);
 					if (!hit) {
 						e->state = STATE_SLIDING;
-						if (flags & kFlagAnimFast)
+						if ((flags & kFlagAnimFast) == kFlagAnimFast)
 							e->moveSpeed = kPlayerMoveSpeed << 1;
 						else if (flags & kFlagAnimSlow)
 							e->moveSpeed = kPlayerMoveSpeed >> 1;
@@ -1274,7 +1274,7 @@ void AI::animateEntity(AIEntity *e) {
 					}
 
 					if (!checkFloating(e->tileX + xv, e->tileY + yv)) {
-						if (flags & kFlagAnimFast)
+						if ((flags & kFlagAnimFast) == kFlagAnimFast)
 							e->moveSpeed = kPlayerMoveSpeed << 1;
 						else if (flags & kFlagAnimMedium)
 							e->moveSpeed = kPlayerMoveSpeed;
@@ -1319,7 +1319,7 @@ void AI::animateEntity(AIEntity *e) {
 			} else if (((flags = g_hdb->_map->getMapBGTileFlags(e->tileX, e->tileY)) & kFlagWater) && (e->type == AI_MAGIC_EGG || e->type == AI_ICE_BLOCK)) {
 				// And no foreground tile is there
 				if (g_hdb->_map->getMapFGTileIndex(e->tileX, e->tileY) < 0 && !checkFloating(e->tileX, e->tileY)) {
-					if (flags & kFlagSlime) {
+					if ((flags & kFlagSlime) == kFlagSlime) {
 						// Evaporates in Slime
 						addAnimateTarget(e->x, e->y, 0, 3, ANIM_NORMAL, false, false, GROUP_STEAM_PUFF_SIT);
 						removeEntity(e);
diff --git a/engines/hdb/map.cpp b/engines/hdb/map.cpp
index fbaa4c9..b209332 100644
--- a/engines/hdb/map.cpp
+++ b/engines/hdb/map.cpp
@@ -1021,11 +1021,11 @@ void Map::addFGTileAnimation(int x, int y) {
 	uint32 flags = tile->_flags;
 
 	// FOREGROUND
-	if (flags & kFlagAnimFast) {
+	if ((flags & kFlagAnimFast) == kFlagAnimFast) {
 		_listFGAnimFast.push_back(i);
-	} else if (flags & kFlagAnimSlow) {
+	} else if ((flags & kFlagAnimSlow) == kFlagAnimSlow) {
 		_listFGAnimSlow.push_back(i);
-	} else if (flags & kFlagAnimMedium) {
+	} else if ((flags & kFlagAnimMedium) == kFlagAnimMedium) {
 		_listFGAnimMedium.push_back(i);
 	}
 }


Commit: e74bdbf410152bf4610844369dc44358ce429882
    https://github.com/scummvm/scummvm/commit/e74bdbf410152bf4610844369dc44358ce429882
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:22+02:00

Commit Message:
HDB: Fix uninitalised reads

Changed paths:
    engines/hdb/gfx.cpp


diff --git a/engines/hdb/gfx.cpp b/engines/hdb/gfx.cpp
index 5719b8c..f9534ea 100644
--- a/engines/hdb/gfx.cpp
+++ b/engines/hdb/gfx.cpp
@@ -33,6 +33,9 @@ Gfx::Gfx() {
 	_sines = new Common::SineTable(360);
 	_cosines = new Common::CosineTable(360);
 	_systemInit = false;
+
+	memset(&_fadeInfo, 0, sizeof(_fadeInfo));
+	memset(&_snowInfo, 0, sizeof(_snowInfo));
 }
 
 Gfx::~Gfx() {
@@ -199,11 +202,12 @@ void Gfx::fillScreen(uint32 color) {
 
 void Gfx::updateVideo() {
 	updateFade();
-	g_hdb->checkProgress();
 
 	if (!g_hdb->_progressGfx)
 		return;
 
+	g_hdb->checkProgress();
+
 	int left = kScreenWidth / 2 - g_hdb->_progressGfx->_width / 2;
 
 	Common::Rect clip(g_hdb->_progressGfx->getSurface()->getBounds());


Commit: d80023c737d68495bc40233af7466a81fafd1989
    https://github.com/scummvm/scummvm/commit/d80023c737d68495bc40233af7466a81fafd1989
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:22+02:00

Commit Message:
HDB: Fix delete mismatch

Changed paths:
    engines/hdb/map.cpp


diff --git a/engines/hdb/map.cpp b/engines/hdb/map.cpp
index b209332..7846575 100644
--- a/engines/hdb/map.cpp
+++ b/engines/hdb/map.cpp
@@ -228,11 +228,11 @@ void Map::restartSystem() {
 	_listFGAnimMedium.clear();
 	_listFGAnimSlow.clear();
 
-	delete _background;
+	delete[] _background;
 	_background = NULL;
-	delete _foreground;
+	delete[] _foreground;
 	_foreground = NULL;
-	delete _iconList;
+	delete[] _iconList;
 	_iconList = NULL;
 
 	_width = _height = 0;


Commit: ac61b7ef9ccf58a7b56dcad1aa4e28fed1b07534
    https://github.com/scummvm/scummvm/commit/ac61b7ef9ccf58a7b56dcad1aa4e28fed1b07534
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:22+02:00

Commit Message:
HDB: Fix warning

Changed paths:
    engines/hdb/ai-funcs.cpp


diff --git a/engines/hdb/ai-funcs.cpp b/engines/hdb/ai-funcs.cpp
index 761be53..25fd043 100644
--- a/engines/hdb/ai-funcs.cpp
+++ b/engines/hdb/ai-funcs.cpp
@@ -1883,7 +1883,7 @@ void AI::moveEnts() {
 			if (!e->stunnedWait)
 				e->aiAction(e);
 			else {
-				if (e->stunnedWait < g_hdb->getTimeSlice())
+				if (e->stunnedWait < (int32)g_hdb->getTimeSlice())
 					e->stunnedWait = 0;
 			}
 		}


Commit: 14dbbdd852b6af56f509474df3d122ee04968526
    https://github.com/scummvm/scummvm/commit/14dbbdd852b6af56f509474df3d122ee04968526
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:22+02:00

Commit Message:
HDB: Fix _fontSurfaces memory leak

Changed paths:
    engines/hdb/gfx.cpp


diff --git a/engines/hdb/gfx.cpp b/engines/hdb/gfx.cpp
index f9534ea..2593198 100644
--- a/engines/hdb/gfx.cpp
+++ b/engines/hdb/gfx.cpp
@@ -42,6 +42,8 @@ Gfx::~Gfx() {
 	delete _gfxCache;
 	delete _sines;
 	delete _cosines;
+	for (int i = 0; i < _fontHeader.numChars; i++)
+		_fontSurfaces[i].free();
 	_globalSurface.free();
 }
 


Commit: be1fcc2fa87f555840acfa2395071c8ccc9b61ef
    https://github.com/scummvm/scummvm/commit/be1fcc2fa87f555840acfa2395071c8ccc9b61ef
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:22+02:00

Commit Message:
HDB: Fix GfxCache memory leak

Changed paths:
    engines/hdb/gfx.cpp


diff --git a/engines/hdb/gfx.cpp b/engines/hdb/gfx.cpp
index 2593198..8b2ac3d 100644
--- a/engines/hdb/gfx.cpp
+++ b/engines/hdb/gfx.cpp
@@ -39,6 +39,8 @@ Gfx::Gfx() {
 }
 
 Gfx::~Gfx() {
+	for (uint i = 0; i < _gfxCache->size(); i++)
+		delete _gfxCache->operator[](i);
 	delete _gfxCache;
 	delete _sines;
 	delete _cosines;


Commit: 0c71ae212105ccbc59045cf319d5ca64b882ae2d
    https://github.com/scummvm/scummvm/commit/0c71ae212105ccbc59045cf319d5ca64b882ae2d
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:22+02:00

Commit Message:
HDB: Fix uninitialised variables

Changed paths:
    engines/hdb/ai-init.cpp
    engines/hdb/hdb.cpp
    engines/hdb/map.cpp
    engines/hdb/menu.cpp


diff --git a/engines/hdb/ai-init.cpp b/engines/hdb/ai-init.cpp
index 95d4359..dbdd244 100644
--- a/engines/hdb/ai-init.cpp
+++ b/engines/hdb/ai-init.cpp
@@ -907,6 +907,11 @@ AI::AI() {
 
 	_stunAnim = 0;
 	_stunTimer = g_system->getMillis();
+
+	_clubDownFrames = 0;
+	_clubUpFrames = 0;
+	_clubLeftFrames = 0;
+	_clubRightFrames = 0;
 }
 
 AI::~AI() {
diff --git a/engines/hdb/hdb.cpp b/engines/hdb/hdb.cpp
index 94abb7b..e7c808a 100644
--- a/engines/hdb/hdb.cpp
+++ b/engines/hdb/hdb.cpp
@@ -64,6 +64,8 @@ HDBGame::HDBGame(OSystem *syst, const ADGameDescription *gameDesc) : Engine(syst
 
 	_timePlayed = _timeSlice = _prevTimeSlice = _timeSeconds = _tiempo = 0;
 
+	_progressActive = false;
+
 	_monkeystone7 = STARS_MONKEYSTONE_7_FAKE;
 	_monkeystone14 = STARS_MONKEYSTONE_14_FAKE;
 	_monkeystone21 = STARS_MONKEYSTONE_21_FAKE;
diff --git a/engines/hdb/map.cpp b/engines/hdb/map.cpp
index 7846575..195b673 100644
--- a/engines/hdb/map.cpp
+++ b/engines/hdb/map.cpp
@@ -794,6 +794,7 @@ bool Map::load(Common::SeekableReadStream *stream) {
 	}
 
 	g_hdb->_ai->initAllEnts();
+	g_hdb->stopProgress();
 
 	_mapLoaded = true;
 
diff --git a/engines/hdb/menu.cpp b/engines/hdb/menu.cpp
index ade6156..654f51d 100644
--- a/engines/hdb/menu.cpp
+++ b/engines/hdb/menu.cpp
@@ -40,6 +40,8 @@ bool Menu::init() {
 	_sayHDB = false;
 	_menuKey = 0;
 
+	_nextScreen = 0;
+
 	_nebulaY = 0;		// Used as a flag
 	_fStars[0].y = 0;	// Used as a flag
 


Commit: d3ad2ed14aa6ec6495f858a849a5346beda911ff
    https://github.com/scummvm/scummvm/commit/d3ad2ed14aa6ec6495f858a849a5346beda911ff
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:22+02:00

Commit Message:
HDB: Fix memory leak in Player Graphics

Changed paths:
    engines/hdb/ai-init.cpp


diff --git a/engines/hdb/ai-init.cpp b/engines/hdb/ai-init.cpp
index dbdd244..9c7aea4 100644
--- a/engines/hdb/ai-init.cpp
+++ b/engines/hdb/ai-init.cpp
@@ -920,6 +920,16 @@ AI::~AI() {
 	delete _arrowPaths;
 	delete _triggerList;
 	delete _hereList;
+
+	memset(&_inventory, 0, sizeof(InvEnt) * kMaxInventory);
+
+	// Free Player Graphics
+
+	memset(_clubDownGfx, 0, sizeof(_clubDownGfx));
+	memset(_clubUpGfx, 0, sizeof(_clubUpGfx));
+	memset(_clubLeftGfx, 0, sizeof(_clubLeftGfx));
+	memset(_clubRightGfx, 0, sizeof(_clubRightGfx));
+	memset(_slugAttackGfx, 0, sizeof(_slugAttackGfx));
 }
 
 bool AI::init() {


Commit: ff2c6fe30a7aba9021f10abb64483a0c1857c077
    https://github.com/scummvm/scummvm/commit/ff2c6fe30a7aba9021f10abb64483a0c1857c077
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:22+02:00

Commit Message:
HDB: More var initialisation

Changed paths:
    engines/hdb/ai-init.cpp
    engines/hdb/gfx.cpp
    engines/hdb/map.cpp


diff --git a/engines/hdb/ai-init.cpp b/engines/hdb/ai-init.cpp
index 9c7aea4..ec6403a 100644
--- a/engines/hdb/ai-init.cpp
+++ b/engines/hdb/ai-init.cpp
@@ -948,8 +948,8 @@ bool AI::init() {
 	_useSwitchOn	= g_hdb->_gfx->getTileIndex("t32_switch_on");
 	_useSwitch2Off	= g_hdb->_gfx->getTileIndex("anim_t32_1switch_off01");
 	_useSwitch2On	= g_hdb->_gfx->getTileIndex("t32_1switch_on");
-//	_useHandswitchOn	= g_hdb->_gfx->getTileIndex("t32_ship_handswitch_on");
-//	_useHandswitchOff	= g_hdb->_gfx->getTileIndex("anim_t32_ship_handswitch_off1");
+	_useHandswitchOn	= g_hdb->_gfx->getTileIndex("t32_ship_handswitch_on");
+	_useHandswitchOff	= g_hdb->_gfx->getTileIndex("anim_t32_ship_handswitch_off1");
 	_useHolderEmpty	= g_hdb->_gfx->getTileIndex("anim_t32_holder_empty1");
 	_useHolderFull	= g_hdb->_gfx->getTileIndex("t32_holder_full");
 	_useMailsorter	= g_hdb->_gfx->getTileIndex("anim_t32_mailsort1");
diff --git a/engines/hdb/gfx.cpp b/engines/hdb/gfx.cpp
index 8b2ac3d..b497b53 100644
--- a/engines/hdb/gfx.cpp
+++ b/engines/hdb/gfx.cpp
@@ -34,8 +34,11 @@ Gfx::Gfx() {
 	_cosines = new Common::CosineTable(360);
 	_systemInit = false;
 
+	_numTiles = 0;
+
 	memset(&_fadeInfo, 0, sizeof(_fadeInfo));
 	memset(&_snowInfo, 0, sizeof(_snowInfo));
+	memset(&_skyTiles, 0, sizeof(_skyTiles));
 }
 
 Gfx::~Gfx() {
@@ -574,7 +577,7 @@ int Gfx::isSky(int index) {
 	}
 
 	for (int i = 0; i < kMaxSkies; i++) {
-		if(_skyTiles[i] == index) {
+		if (_skyTiles[i] == index) {
 			return i + 1; // The skyTiles are indexed from 1. 0 => No Sky tile
 		}
 	}
diff --git a/engines/hdb/map.cpp b/engines/hdb/map.cpp
index 195b673..a17b0db 100644
--- a/engines/hdb/map.cpp
+++ b/engines/hdb/map.cpp
@@ -1169,7 +1169,7 @@ bool Map::checkXYOnScreen(int x, int y) {
 }
 
 bool Map::checkOneTileExistInRange(int tileIndex, int count) {
-	for (int i = 0; i < _width*_height; i++) {
+	for (int i = 0; i < _width * _height; i++) {
 		if (_background[i] >= tileIndex && _background[i] < tileIndex + count)
 			return true;
 		if (_foreground[i] >= tileIndex && _foreground[i] < tileIndex + count)


Commit: d706fbf22e7399944c480339ec3a023d47dffb1a
    https://github.com/scummvm/scummvm/commit/d706fbf22e7399944c480339ec3a023d47dffb1a
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:22+02:00

Commit Message:
HDB: Fix memory leaks

Changed paths:
    engines/hdb/file-manager.cpp
    engines/hdb/file-manager.h
    engines/hdb/gfx.cpp
    engines/hdb/map.cpp


diff --git a/engines/hdb/file-manager.cpp b/engines/hdb/file-manager.cpp
index 0bc22fb..e58838d 100644
--- a/engines/hdb/file-manager.cpp
+++ b/engines/hdb/file-manager.cpp
@@ -31,6 +31,10 @@ FileMan::FileMan() {
 	_mpcFile = new Common::File;
 }
 
+FileMan::~FileMan() {
+	delete _mpcFile;
+}
+
 bool FileMan::openMPC(const Common::String &filename) {
 	uint32 offset;
 
diff --git a/engines/hdb/file-manager.h b/engines/hdb/file-manager.h
index 740bf4d..a83512e 100644
--- a/engines/hdb/file-manager.h
+++ b/engines/hdb/file-manager.h
@@ -64,6 +64,7 @@ private:
 public:
 
 	FileMan();
+	~FileMan();
 
 	struct {
 		uint32 id;
diff --git a/engines/hdb/gfx.cpp b/engines/hdb/gfx.cpp
index b497b53..54746c3 100644
--- a/engines/hdb/gfx.cpp
+++ b/engines/hdb/gfx.cpp
@@ -45,6 +45,8 @@ Gfx::~Gfx() {
 	for (uint i = 0; i < _gfxCache->size(); i++)
 		delete _gfxCache->operator[](i);
 	delete _gfxCache;
+	for (uint i = 0; i < _charInfoBlocks.size(); i++)
+		delete _charInfoBlocks[i];
 	delete _sines;
 	delete _cosines;
 	for (int i = 0; i < _fontHeader.numChars; i++)
diff --git a/engines/hdb/map.cpp b/engines/hdb/map.cpp
index a17b0db..66fc9ab 100644
--- a/engines/hdb/map.cpp
+++ b/engines/hdb/map.cpp
@@ -41,6 +41,9 @@ Map::Map() {
 }
 
 Map::~Map() {
+	free(_mapExplosions);
+	free(_mapExpBarrels);
+	free(_mapLaserBeams);
 }
 
 void Map::save(Common::OutSaveFile *out) {


Commit: f5aff6c72def2c688621220684fc12e664c643bd
    https://github.com/scummvm/scummvm/commit/f5aff6c72def2c688621220684fc12e664c643bd
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:22+02:00

Commit Message:
HDB: Fix memset()

Changed paths:
    engines/hdb/ai-init.cpp


diff --git a/engines/hdb/ai-init.cpp b/engines/hdb/ai-init.cpp
index ec6403a..7ece2ab 100644
--- a/engines/hdb/ai-init.cpp
+++ b/engines/hdb/ai-init.cpp
@@ -1630,7 +1630,7 @@ void AI::loadSaveFile(Common::InSaveFile *in) {
 		_animTargets[i]->animFrame = in->readUint16LE();
 		_animTargets[i]->killAuto = in->readByte();
 		_animTargets[i]->inMap = in->readByte();
-		memset(_animTargets[i]->gfxList, 0, kMaxAnimTFrames);
+		memset(_animTargets[i]->gfxList, 0, kMaxAnimTFrames * sizeof(Tile *));
 	}
 
 	// Load ArrowPaths


Commit: 8825980e1f35cbe76cb7f8c2c0b079ec114bdbcb
    https://github.com/scummvm/scummvm/commit/8825980e1f35cbe76cb7f8c2c0b079ec114bdbcb
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:22+02:00

Commit Message:
HDB: Remove redundant custom free() function

Changed paths:
    engines/hdb/ai-init.cpp
    engines/hdb/gfx.cpp
    engines/hdb/gfx.h
    engines/hdb/hdb.cpp
    engines/hdb/menu.cpp
    engines/hdb/menu.h
    engines/hdb/window.cpp
    engines/hdb/window.h


diff --git a/engines/hdb/ai-init.cpp b/engines/hdb/ai-init.cpp
index 7ece2ab..4753047 100644
--- a/engines/hdb/ai-init.cpp
+++ b/engines/hdb/ai-init.cpp
@@ -1155,7 +1155,7 @@ void AI::restartSystem() {
 	memset(_clubRightGfx, 0, sizeof(_clubRightGfx));
 
 	if (_weaponSelGfx)
-		_weaponSelGfx->free();
+		delete _weaponSelGfx;
 
 	_playerDead = false;
 	_playerInvisible = false;
@@ -1171,73 +1171,73 @@ void AI::restartSystem() {
 
 	int i;
 	if (_icepSnowballGfxDown) {
-		_icepSnowballGfxDown->free();
+		delete _icepSnowballGfxDown;
 		_icepSnowballGfxDown = NULL;
 	}
 	if (_icepSnowballGfxLeft) {
-		_icepSnowballGfxLeft->free();
+		delete _icepSnowballGfxLeft;
 		_icepSnowballGfxLeft = NULL;
 	}
 	if (_icepSnowballGfxRight) {
-		_icepSnowballGfxRight->free();
+		delete _icepSnowballGfxRight;
 		_icepSnowballGfxRight = NULL;
 	}
 
 	if (_tileFroglickMiddleUD) {
-		_tileFroglickMiddleUD->free();
+		delete _tileFroglickMiddleUD;
 		_tileFroglickMiddleUD = NULL;
 	}
 	if (_tileFroglickWiggleUD[0]) {
 		for (i = 0; i < 3; i++) {
-			_tileFroglickWiggleUD[i]->free();
+			delete _tileFroglickWiggleUD[i];
 			_tileFroglickWiggleUD[i] = NULL;
 		}
 	}
 
 	if (_tileFroglickMiddleLR) {
-		_tileFroglickMiddleLR->free();
+		delete _tileFroglickMiddleLR;
 		_tileFroglickMiddleLR = NULL;
 	}
 	if (_tileFroglickWiggleLeft[0]) {
 		for (i = 0; i < 3; i++) {
-			_tileFroglickWiggleLeft[i]->free();
+			delete _tileFroglickWiggleLeft[i];
 			_tileFroglickWiggleLeft[i] = NULL;
 		}
 	}
 	if (_tileFroglickWiggleRight[0]) {
 		for (i = 0; i < 3; i++) {
-			_tileFroglickWiggleRight[i]->free();
+			delete _tileFroglickWiggleRight[i];
 			_tileFroglickWiggleRight[i] = NULL;
 		}
 	}
 
 	// dragon!  see ya!
 	if (_gfxDragonAsleep) {
-		_gfxDragonAsleep->free();
+		delete _gfxDragonAsleep;
 		_gfxDragonAsleep = NULL;
-		_gfxDragonFlap[0]->free();
-		_gfxDragonFlap[1]->free();
+		delete _gfxDragonFlap[0];
+		delete _gfxDragonFlap[1];
 		_gfxDragonFlap[0] = _gfxDragonFlap[1] = NULL;
-		_gfxDragonBreathe[0]->free();
-		_gfxDragonBreathe[1]->free();
-		_gfxDragonBreathe[2]->free();
+		delete _gfxDragonBreathe[0];
+		delete _gfxDragonBreathe[1];
+		delete _gfxDragonBreathe[2];
 		_gfxDragonBreathe[0] = _gfxDragonBreathe[1] =
 			_gfxDragonBreathe[2] = NULL;
 	}
 
 	// PANIC ZONE gfx - see ya!
 	if (g_hdb->_window->_pzInfo.gfxPanic) {
-		g_hdb->_window->_pzInfo.gfxPanic->free();
+		delete g_hdb->_window->_pzInfo.gfxPanic;
 		g_hdb->_window->_pzInfo.gfxPanic = NULL;
-		g_hdb->_window->_pzInfo.gfxZone->free();
+		delete g_hdb->_window->_pzInfo.gfxZone;
 		g_hdb->_window->_pzInfo.gfxZone = NULL;
-		g_hdb->_window->_pzInfo.gfxFace[0]->free();
+		delete g_hdb->_window->_pzInfo.gfxFace[0];
 		g_hdb->_window->_pzInfo.gfxFace[0] = NULL;
-		g_hdb->_window->_pzInfo.gfxFace[1]->free();
+		delete g_hdb->_window->_pzInfo.gfxFace[1];
 		g_hdb->_window->_pzInfo.gfxFace[1] = NULL;
 
 		for (i = 0; i < 10; i++) {
-			g_hdb->_window->_pzInfo.gfxNumber[i]->free();
+			delete g_hdb->_window->_pzInfo.gfxNumber[i];
 			g_hdb->_window->_pzInfo.gfxNumber[i] = NULL;
 		}
 	}
@@ -1246,12 +1246,12 @@ void AI::restartSystem() {
 	// laser beams
 	if (_gfxLaserbeamUD[0]) {
 		for (i = 0; i < 4; i++) {
-			_gfxLaserbeamUD[i]->free();
-			_gfxLaserbeamUDTop[i]->free();
-			_gfxLaserbeamUDBottom[i]->free();
-			_gfxLaserbeamLR[i]->free();
-			_gfxLaserbeamLRLeft[i]->free();
-			_gfxLaserbeamLRRight[i]->free();
+			delete _gfxLaserbeamUD[i];
+			delete _gfxLaserbeamUDTop[i];
+			delete _gfxLaserbeamUDBottom[i];
+			delete _gfxLaserbeamLR[i];
+			delete _gfxLaserbeamLRLeft[i];
+			delete _gfxLaserbeamLRRight[i];
 
 			_gfxLaserbeamUD[i] = NULL;
 			_gfxLaserbeamUDTop[i] = NULL;
diff --git a/engines/hdb/gfx.cpp b/engines/hdb/gfx.cpp
index 54746c3..b493bb6 100644
--- a/engines/hdb/gfx.cpp
+++ b/engines/hdb/gfx.cpp
@@ -998,8 +998,8 @@ void Gfx::drawBonusStars() {
 	// timed out?
 	if (_starsInfo.totalTime < g_hdb->getTimeSlice()) {
 		_starsInfo.active = false;
-		_starsInfo.gfx[0]->free();
-		_starsInfo.gfx[1]->free();
+		delete _starsInfo.gfx[0];
+		delete _starsInfo.gfx[1];
 		_starsInfo.gfx[0] = _starsInfo.gfx[1] = 0;
 	}
 }
@@ -1088,10 +1088,6 @@ int Picture::drawMasked(int x, int y, int alpha) {
 	return 0;
 }
 
-void Picture::free() {
-	_surface.free();
-}
-
 Tile::Tile() : _flags(0), _name("") {
 	_surface.create(32, 32, g_hdb->_format);
 }
@@ -1146,8 +1142,4 @@ int Tile::drawMasked(int x, int y, int alpha) {
 	return 0;
 }
 
-void Tile::free() {
-	_surface.free();
-}
-
 }
diff --git a/engines/hdb/gfx.h b/engines/hdb/gfx.h
index 119c568..ce6ceb6 100644
--- a/engines/hdb/gfx.h
+++ b/engines/hdb/gfx.h
@@ -256,7 +256,6 @@ public:
 	Graphics::Surface load(Common::SeekableReadStream *stream);
 	int draw(int x, int y);
 	int drawMasked(int x, int y, int alpha = 0xff);
-	void free();
 
 	int _width, _height;
 
@@ -279,7 +278,6 @@ public:
 	Graphics::Surface load(Common::SeekableReadStream *stream);
 	int draw(int x, int y);
 	int drawMasked(int x, int y, int alpha = 0xff);
-	void free();
 
 	uint32 _flags;
 
diff --git a/engines/hdb/hdb.cpp b/engines/hdb/hdb.cpp
index e7c808a..c5b91bb 100644
--- a/engines/hdb/hdb.cpp
+++ b/engines/hdb/hdb.cpp
@@ -86,6 +86,12 @@ HDBGame::~HDBGame() {
 	delete _window;
 	delete _rnd;
 
+	delete _progressGfx;
+	delete _progressMarkGfx;
+	delete _loadingScreenGfx;
+	if (_logoGfx)
+		delete _logoGfx;
+
 	DebugMan.clearAllDebugChannels();
 }
 
diff --git a/engines/hdb/menu.cpp b/engines/hdb/menu.cpp
index 654f51d..a3c6b8e 100644
--- a/engines/hdb/menu.cpp
+++ b/engines/hdb/menu.cpp
@@ -25,6 +25,10 @@
 
 namespace HDB {
 
+Menu::~Menu() {
+	freeMenu();
+}
+
 bool Menu::init() {
 	_starWarp = 0;
 	_rocketEx = 0;
@@ -599,125 +603,125 @@ void Menu::freeMenu() {
 
 	// title sequence stuff
 	if (_titleScreen)
-		_titleScreen->free();
+		delete _titleScreen;
 	_titleScreen = NULL;
 	if (_oohOohGfx)
-		_oohOohGfx->free();
+		delete _oohOohGfx;
 	_oohOohGfx = NULL;
 
 	if (_newGfx)
-		_newGfx->free();
+		delete _newGfx;
 	_newGfx = NULL;
 	if (_loadGfx)
-		_loadGfx->free();
+		delete _loadGfx;
 	_loadGfx = NULL;
 	if (_optionsGfx)
-		_optionsGfx->free();
+		delete _optionsGfx;
 	_optionsGfx = NULL;
 	if (_quitGfx)
-		_quitGfx->free();
+		delete _quitGfx;
 	_quitGfx = NULL;
 	if (_resumeGfx)
-		_resumeGfx->free();
+		delete _resumeGfx;
 	_resumeGfx = NULL;
 	if (_slotGfx)
-		_slotGfx->free();
+		delete _slotGfx;
 	_slotGfx = NULL;
 	if (_rocketMain)
-		_rocketMain->free();
+		delete _rocketMain;
 	_rocketMain = NULL;
 	if (_rocketSecond)
-		_rocketSecond->free();
+		delete _rocketSecond;
 	_rocketSecond = NULL;
 	if (_rocketEx1)
-		_rocketEx1->free();
+		delete _rocketEx1;
 	_rocketEx1 = NULL;
 	if (_rocketEx2)
-		_rocketEx2->free();
+		delete _rocketEx2;
 	_rocketEx2 = NULL;
 	if (_titleLogo)
-		_titleLogo->free();
+		delete _titleLogo;
 	_titleLogo = NULL;
 
 	if (_hdbLogoScreen)
-		_hdbLogoScreen->free();
+		delete _hdbLogoScreen;
 	_hdbLogoScreen = NULL;
 
 	if (_nebulaGfx[0])
 		for (i = 0; i < kNebulaCount; i++) {
-			_nebulaGfx[i]->free();
+			delete _nebulaGfx[i];
 			_nebulaGfx[i] = NULL;
 		}
 
 	if (_sliderLeft)
-		_sliderLeft->free();
+		delete _sliderLeft;
 	_sliderLeft = NULL;
 	if (_sliderMid)
-		_sliderMid->free();
+		delete _sliderMid;
 	_sliderMid = NULL;
 	if (_sliderRight)
-		_sliderRight->free();
+		delete _sliderRight;
 	_sliderRight = NULL;
 	if (_sliderKnob)
-		_sliderKnob->free();
+		delete _sliderKnob;
 	_sliderKnob = NULL;
 	if (_modePuzzleGfx)
-		_modePuzzleGfx->free();
+		delete _modePuzzleGfx;
 	_modePuzzleGfx = NULL;
 	if (_modeActionGfx)
-		_modeActionGfx->free();
+		delete _modeActionGfx;
 	_modeActionGfx = NULL;
 	if (_modeLoadGfx)
-		_modeLoadGfx->free();
+		delete _modeLoadGfx;
 	_modeLoadGfx = NULL;
 	if (_modeSaveGfx)
-		_modeSaveGfx->free();
+		delete _modeSaveGfx;
 	_modeSaveGfx = NULL;
 	if (_menuBackoutGfx)
-		_menuBackoutGfx->free();
+		delete _menuBackoutGfx;
 	_menuBackoutGfx = NULL;
 
 	if (_controlButtonGfx)
-		_controlButtonGfx->free();
+		delete _controlButtonGfx;
 	_controlButtonGfx = NULL;
 
 	if (_controlsGfx)
-		_controlsGfx->free();
+		delete _controlsGfx;
 	_controlsGfx = NULL;
 
 	if (_vortexian[0]) {
-		_vortexian[0]->free();
-		_vortexian[1]->free();
-		_vortexian[2]->free();
+		delete _vortexian[0];
+		delete _vortexian[1];
+		delete _vortexian[2];
 		_vortexian[0] = _vortexian[1] = _vortexian[2] = NULL;
 	}
 
 	if (_star[0]) {
-		_star[0]->free();
-		_star[1]->free();
-		_star[2]->free();
+		delete _star[0];
+		delete _star[1];
+		delete _star[2];
 		_star[0] = _star[1] = _star[2] = NULL;
 	}
 
 	// secret stars
 	if (_starRedGfx[0]) {
-		_starRedGfx[0]->free();
-		_starRedGfx[1]->free();
-		_starGreenGfx[0]->free();
-		_starGreenGfx[1]->free();
-		_starBlueGfx[0]->free();
-		_starBlueGfx[1]->free();
+		delete _starRedGfx[0];
+		delete _starRedGfx[1];
+		delete _starGreenGfx[0];
+		delete _starGreenGfx[1];
+		delete _starBlueGfx[0];
+		delete _starBlueGfx[1];
 		_starRedGfx[0] = _starRedGfx[1] = NULL;
 		_starGreenGfx[0] = _starGreenGfx[1] = NULL;
 		_starBlueGfx[0] = _starBlueGfx[1] = NULL;
 	}
 
 	if (_versionGfx)
-		_versionGfx->free();
+		delete _versionGfx;
 	_versionGfx = NULL;
 
 	if (_warpGfx)
-		_warpGfx->free();
+		delete _warpGfx;
 	_warpGfx = NULL;
 }
 
@@ -1243,7 +1247,7 @@ void Menu::processInput(int x, int y) {
 
 		if ((x >= kQuitNoX1 && x <= kQuitNoX2 && y > kQuitNoY1 && y < kQuitNoY2 && _quitTimer < g_hdb->getTimeSlice()) || xit) {
 			g_hdb->_sound->playSound(SND_MENU_BACKOUT);
-			_quitScreen->free();
+			delete _quitScreen;
 			_quitScreen = NULL;
 
 			_menuActive = true;
diff --git a/engines/hdb/menu.h b/engines/hdb/menu.h
index 0a0cb0d..006ee7a 100644
--- a/engines/hdb/menu.h
+++ b/engines/hdb/menu.h
@@ -152,6 +152,8 @@ struct Star {
 class Menu {
 public:
 
+	~Menu();
+
 	bool init();
 
 	void readConfig();
diff --git a/engines/hdb/window.cpp b/engines/hdb/window.cpp
index e340198..b3e4b19 100644
--- a/engines/hdb/window.cpp
+++ b/engines/hdb/window.cpp
@@ -24,6 +24,53 @@
 
 namespace HDB {
 
+Window::~Window() {
+	delete _gfxTL;
+	delete _gfxTM;
+	delete _gfxTR;
+
+	delete _gfxL;
+	delete _gfxM;
+	delete _gfxR;
+
+	delete _gfxBL;
+	delete _gfxBM;
+	delete _gfxBR;
+
+	delete _gfxTitleL;
+	delete _gfxTitleM;
+	delete _gfxTitleR;
+
+	delete _gGfxTL;
+	delete _gGfxTM;
+	delete _gGfxTR;
+
+	delete _gGfxL;
+	delete _gGfxM;
+	delete _gGfxR;
+
+	delete _gGfxBL;
+	delete _gGfxBM;
+	delete _gGfxBR;
+
+	delete _gGfxTitleL;
+	delete _gGfxTitleM;
+	delete _gGfxTitleR;
+
+	delete _gfxIndent;
+	delete _gfxArrowTo;
+
+	delete _gfxInvSelect;
+	delete _gfxHandright;
+
+	delete _gfxInfobar;
+	delete _gfxDarken;
+	delete _gfxPausePlaque;
+	delete _mstoneGfx;
+
+	delete _gemGfx;
+}
+
 bool Window::init() {
 
 	_gfxTL = g_hdb->_gfx->loadPic(MENU_BACK_TOPLEFT);
@@ -1236,9 +1283,9 @@ void Window::drawTryAgain() {
 }
 
 void Window::clearTryAgain() {
-	_gfxTry->free();
-	_gfxAgain->free();
-	_gfxLevelRestart->free();
+	delete _gfxTry;
+	delete _gfxAgain;
+	delete _gfxLevelRestart;
 
 	_gfxTry = _gfxAgain = _gfxLevelRestart = NULL;
 }
diff --git a/engines/hdb/window.h b/engines/hdb/window.h
index e11b443..dac81e2 100644
--- a/engines/hdb/window.h
+++ b/engines/hdb/window.h
@@ -189,6 +189,8 @@ struct TOut {
 class Window {
 public:
 
+	~Window();
+
 	bool init();
 	void save(Common::OutSaveFile *out);
 	void loadSaveFile(Common::InSaveFile *in);


Commit: b90f0e143fb9ea0ee25b399d50e0de0e504eb54c
    https://github.com/scummvm/scummvm/commit/b90f0e143fb9ea0ee25b399d50e0de0e504eb54c
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:22+02:00

Commit Message:
HDB: Remove redundant FileMan function

Changed paths:
    engines/hdb/file-manager.cpp


diff --git a/engines/hdb/file-manager.cpp b/engines/hdb/file-manager.cpp
index e58838d..e28f19f 100644
--- a/engines/hdb/file-manager.cpp
+++ b/engines/hdb/file-manager.cpp
@@ -197,21 +197,4 @@ Common::Array<const char *> *FileMan::findFiles(const char *string, DataType typ
 	return result;
 }
 
-#if 0
-MPCEntry **FileMan::findNextData(MPCIterator begin) {
-	Common::String fileString;
-
-	for (MPCIterator it = begin+1; it != _dir.end(); it++) {
-		fileString = (*it)->filename;
-		if (fileString.contains((*begin)->filename)) {
-			if ((*it)->type == (*begin)->type) {
-				return it;
-			}
-		}
-	}
-	return NULL;
-}
-
-#endif
-
 } // End of Namespace HDB


Commit: 7709b2828b0148ed6662da891c493d73d95c25de
    https://github.com/scummvm/scummvm/commit/7709b2828b0148ed6662da891c493d73d95c25de
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:22+02:00

Commit Message:
HDB: Fix memory leaks with FileMan::findFiles()

Changed paths:
    engines/hdb/ai-funcs.cpp
    engines/hdb/gfx.cpp


diff --git a/engines/hdb/ai-funcs.cpp b/engines/hdb/ai-funcs.cpp
index 25fd043..5c8f929 100644
--- a/engines/hdb/ai-funcs.cpp
+++ b/engines/hdb/ai-funcs.cpp
@@ -409,6 +409,8 @@ bool AI::cacheEntGfx(AIEntity *e, bool init) {
 					}
 				}
 				j++;
+
+				delete gfxFiles;
 			}
 
 			e->aiInit = aiEntList[i].initFunc;
diff --git a/engines/hdb/gfx.cpp b/engines/hdb/gfx.cpp
index b493bb6..de89707 100644
--- a/engines/hdb/gfx.cpp
+++ b/engines/hdb/gfx.cpp
@@ -76,24 +76,25 @@ bool Gfx::init() {
 
 	// Setup Tile Lookup Array
 	_tLookupArray = new TileLookup[_numTiles];
-	Common::Array<const char *> tileData = *g_hdb->_fileMan->findFiles("t32_", TYPE_TILE32);
+	Common::Array<const char *> *tileData = g_hdb->_fileMan->findFiles("t32_", TYPE_TILE32);
 
-	assert((uint)_numTiles == tileData.size());
+	assert((uint)_numTiles == tileData->size());
 
 	int index = 0, skyIndex = 0;
 	for (; index < _numTiles; index++) {
-		_tLookupArray[index].filename = tileData[index];
+		_tLookupArray[index].filename = tileData->operator[](index);
 		_tLookupArray[index].tData = NULL;
 		_tLookupArray[index].skyIndex = 0;
 		_tLookupArray[index].animIndex = index;
 		// Check if the loaded Tile is a Sky Tile
-		if (strstr(tileData[index], "sky") && (skyIndex < kMaxSkies)) {
+		if (strstr(tileData->operator[](index), "sky") && (skyIndex < kMaxSkies)) {
 			_tLookupArray[index].skyIndex = skyIndex + 1;
 			_skyTiles[skyIndex] = index;
 			skyIndex++;
 		}
 	}
 
+	delete tileData;
 
 	// Add Animating Tile Info
 	int found = -1;


Commit: adb43a79b7ee01cda7c33f48d778fc9b57358716
    https://github.com/scummvm/scummvm/commit/adb43a79b7ee01cda7c33f48d778fc9b57358716
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:22+02:00

Commit Message:
HDB: Fix memory leaks in AI lists

Changed paths:
    engines/hdb/ai-init.cpp


diff --git a/engines/hdb/ai-init.cpp b/engines/hdb/ai-init.cpp
index 4753047..5a71b4b 100644
--- a/engines/hdb/ai-init.cpp
+++ b/engines/hdb/ai-init.cpp
@@ -915,10 +915,25 @@ AI::AI() {
 }
 
 AI::~AI() {
+	for (uint i = 0; i < _ents->size(); i++) {
+		delete _ents->operator[](i);
+	}
 	delete _ents;
+	for (uint i = 0; i < _floats->size(); i++) {
+		delete _floats->operator[](i);
+	}
 	delete _floats;
+	for (uint i = 0; i < _arrowPaths->size(); i++) {
+		delete _arrowPaths->operator[](i);
+	}
 	delete _arrowPaths;
+	for (uint i = 0; i < _triggerList->size(); i++) {
+		delete _triggerList->operator[](i);
+	}
 	delete _triggerList;
+	for (uint i = 0; i < _hereList->size(); i++) {
+		delete _hereList->operator[](i);
+	}
 	delete _hereList;
 
 	memset(&_inventory, 0, sizeof(InvEnt) * kMaxInventory);
@@ -930,6 +945,12 @@ AI::~AI() {
 	memset(_clubLeftGfx, 0, sizeof(_clubLeftGfx));
 	memset(_clubRightGfx, 0, sizeof(_clubRightGfx));
 	memset(_slugAttackGfx, 0, sizeof(_slugAttackGfx));
+
+	// Free AnimTargets
+
+	for (uint i = 0; i < _animTargets.size(); i++) {
+		delete _animTargets[i];
+	}
 }
 
 bool AI::init() {


Commit: e9e654d7db8c6b865c6f168f6f35663af85fce85
    https://github.com/scummvm/scummvm/commit/e9e654d7db8c6b865c6f168f6f35663af85fce85
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:22+02:00

Commit Message:
HDB: Convert _surface from struct to pointer

Changed paths:
    engines/hdb/gfx.cpp
    engines/hdb/gfx.h


diff --git a/engines/hdb/gfx.cpp b/engines/hdb/gfx.cpp
index de89707..942fd1d 100644
--- a/engines/hdb/gfx.cpp
+++ b/engines/hdb/gfx.cpp
@@ -1032,14 +1032,16 @@ void Gfx::drawDebugInfo(Tile *_debugLogo, int fps) {
 }
 
 Picture::Picture() : _width(0), _height(0), _name("") {
-	_surface.create(_width, _height, g_hdb->_format);
+	_surface = NULL;
 }
 
 Picture::~Picture() {
-	_surface.free();
+	if (_surface)
+		_surface->free();
+	_surface = NULL;
 }
 
-Graphics::Surface Picture::load(Common::SeekableReadStream *stream) {
+Graphics::ManagedSurface *Picture::load(Common::SeekableReadStream *stream) {
 	_width = stream->readUint32LE();
 	_height = stream->readUint32LE();
 	stream->read(_name, 64);
@@ -1047,13 +1049,14 @@ Graphics::Surface Picture::load(Common::SeekableReadStream *stream) {
 	debug(8, "Picture: _width: %d, _height: %d", _width, _height);
 	debug(8, "Picture: _name: %s", _name);
 
-	_surface.create(_width, _height, g_hdb->_format);
+	_surface = new Graphics::ManagedSurface;
+	_surface->create(_width, _height, g_hdb->_format);
 	stream->readUint32LE(); // Skip Win32 Surface
 
 	uint16 *ptr;
 
 	for (int y = 0; y < _height; y++) {
-		ptr = (uint16 *)_surface.getBasePtr(0, y);
+		ptr = (uint16 *)_surface->getBasePtr(0, y);
 		for (int x = 0; x < _width; x++) {
 			*ptr = TO_LE_16(stream->readUint16LE());
 			ptr++;
@@ -1064,9 +1067,9 @@ Graphics::Surface Picture::load(Common::SeekableReadStream *stream) {
 }
 
 int Picture::draw(int x, int y) {
-	g_hdb->_gfx->_globalSurface.blitFrom(_surface, Common::Point(x, y));
+	g_hdb->_gfx->_globalSurface.blitFrom(*_surface, Common::Point(x, y));
 
-	Common::Rect clip(_surface.getBounds());
+	Common::Rect clip(_surface->getBounds());
 	clip.moveTo(x, y);
 	clip.clip(g_hdb->_gfx->_globalSurface.getBounds());
 	if (!clip.isEmpty()) {
@@ -1077,9 +1080,9 @@ int Picture::draw(int x, int y) {
 }
 
 int Picture::drawMasked(int x, int y, int alpha) {
-	g_hdb->_gfx->_globalSurface.transBlitFrom(_surface, Common::Point(x, y), 0xf81f, false, 0, alpha & 0xff);
+	g_hdb->_gfx->_globalSurface.transBlitFrom(*_surface, Common::Point(x, y), 0xf81f, false, 0, alpha & 0xff);
 
-	Common::Rect clip(_surface.getBounds());
+	Common::Rect clip(_surface->getBounds());
 	clip.moveTo(x, y);
 	clip.clip(g_hdb->_gfx->_globalSurface.getBounds());
 	if (!clip.isEmpty()) {
@@ -1089,25 +1092,26 @@ int Picture::drawMasked(int x, int y, int alpha) {
 	return 0;
 }
 
-Tile::Tile() : _flags(0), _name("") {
-	_surface.create(32, 32, g_hdb->_format);
-}
+Tile::Tile() : _flags(0), _name(""), _surface(NULL) {}
 
 Tile::~Tile() {
-	_surface.free();
+	if (_surface)
+		_surface->free();
+	_surface = NULL;
 }
 
-Graphics::Surface Tile::load(Common::SeekableReadStream *stream) {
+Graphics::ManagedSurface *Tile::load(Common::SeekableReadStream *stream) {
 	_flags = stream->readUint32LE();
 	stream->read(_name, 64);
 
-	_surface.create(32, 32, g_hdb->_format);
+	_surface = new Graphics::ManagedSurface;
+	_surface->create(32, 32, g_hdb->_format);
 	stream->readUint32LE(); // Skip Win32 Surface
 
 	uint16 *ptr;
 
 	for (uint y = 0; y < 32; y++) {
-		ptr = (uint16 *)_surface.getBasePtr(0, y);
+		ptr = (uint16 *)_surface->getBasePtr(0, y);
 		for (uint x = 0; x < 32; x++) {
 			*ptr = TO_LE_16(stream->readUint16LE());
 			ptr++;
@@ -1118,9 +1122,9 @@ Graphics::Surface Tile::load(Common::SeekableReadStream *stream) {
 }
 
 int Tile::draw(int x, int y) {
-	g_hdb->_gfx->_globalSurface.blitFrom(_surface, Common::Point(x, y));
+	g_hdb->_gfx->_globalSurface.blitFrom(*_surface, Common::Point(x, y));
 
-	Common::Rect clip(_surface.getBounds());
+	Common::Rect clip(_surface->getBounds());
 	clip.moveTo(x, y);
 	clip.clip(g_hdb->_gfx->_globalSurface.getBounds());
 	if (!clip.isEmpty()) {
@@ -1131,9 +1135,9 @@ int Tile::draw(int x, int y) {
 }
 
 int Tile::drawMasked(int x, int y, int alpha) {
-	g_hdb->_gfx->_globalSurface.transBlitFrom(_surface, Common::Point(x, y), 0xf81f, false, 0, alpha & 0xff);
+	g_hdb->_gfx->_globalSurface.transBlitFrom(*_surface, Common::Point(x, y), 0xf81f, false, 0, alpha & 0xff);
 
-	Common::Rect clip(_surface.getBounds());
+	Common::Rect clip(_surface->getBounds());
 	clip.moveTo(x, y);
 	clip.clip(g_hdb->_gfx->_globalSurface.getBounds());
 	if (!clip.isEmpty()) {
diff --git a/engines/hdb/gfx.h b/engines/hdb/gfx.h
index ce6ceb6..1c993ec 100644
--- a/engines/hdb/gfx.h
+++ b/engines/hdb/gfx.h
@@ -253,7 +253,7 @@ public:
 	Picture();
 	~Picture();
 
-	Graphics::Surface load(Common::SeekableReadStream *stream);
+	Graphics::ManagedSurface *load(Common::SeekableReadStream *stream);
 	int draw(int x, int y);
 	int drawMasked(int x, int y, int alpha = 0xff);
 
@@ -261,12 +261,12 @@ public:
 
 	char *getName() { return _name; }
 
-	Graphics::ManagedSurface *getSurface() { return &_surface; }
+	Graphics::ManagedSurface *getSurface() { return _surface; }
 
 private:
 	char _name[64];
 
-	Graphics::ManagedSurface _surface;
+	Graphics::ManagedSurface *_surface;
 };
 
 class Tile {
@@ -275,7 +275,7 @@ public:
 	Tile();
 	~Tile();
 
-	Graphics::Surface load(Common::SeekableReadStream *stream);
+	Graphics::ManagedSurface *load(Common::SeekableReadStream *stream);
 	int draw(int x, int y);
 	int drawMasked(int x, int y, int alpha = 0xff);
 
@@ -285,7 +285,7 @@ public:
 private:
 	char _name[64];
 
-	Graphics::ManagedSurface _surface;
+	Graphics::ManagedSurface *_surface;
 };
 
 } // End of Namespace HDB


Commit: 161f9e67070f38906cd62b7db65d1d6cf2802823
    https://github.com/scummvm/scummvm/commit/161f9e67070f38906cd62b7db65d1d6cf2802823
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:23+02:00

Commit Message:
HDB: NULL each tile after calling destructor

Changed paths:
    engines/hdb/ai-init.cpp
    engines/hdb/ai.h
    engines/hdb/gfx.cpp
    engines/hdb/gfx.h
    engines/hdb/hdb.cpp


diff --git a/engines/hdb/ai-init.cpp b/engines/hdb/ai-init.cpp
index 5a71b4b..c0c85e7 100644
--- a/engines/hdb/ai-init.cpp
+++ b/engines/hdb/ai-init.cpp
@@ -946,6 +946,31 @@ AI::~AI() {
 	memset(_clubRightGfx, 0, sizeof(_clubRightGfx));
 	memset(_slugAttackGfx, 0, sizeof(_slugAttackGfx));
 
+	// Clean up Player Graphics Storage
+	memset(_horrible1Gfx, 0, sizeof(_horrible1Gfx));
+	memset(_horrible2Gfx, 0, sizeof(_horrible2Gfx));
+	memset(_horrible3Gfx, 0, sizeof(_horrible3Gfx));
+	memset(_horrible4Gfx, 0, sizeof(_horrible4Gfx));
+	memset(_plummetGfx, 0, sizeof(_plummetGfx));
+	memset(_dyingGfx, 0, sizeof(_dyingGfx));
+
+	memset(_pushdownGfx, 0, sizeof(_pushdownGfx));
+	memset(_pushupGfx, 0, sizeof(_pushupGfx));
+	memset(_pushleftGfx, 0, sizeof(_pushleftGfx));
+	memset(_pushrightGfx, 0, sizeof(_pushrightGfx));
+	memset(_stunDownGfx, 0, sizeof(_stunDownGfx));
+	memset(_stunUpGfx, 0, sizeof(_stunUpGfx));
+	memset(_stunLeftGfx, 0, sizeof(_stunLeftGfx));
+	memset(_stunRightGfx, 0, sizeof(_stunRightGfx));
+	memset(_slugDownGfx, 0, sizeof(_slugDownGfx));
+	memset(_slugUpGfx, 0, sizeof(_slugUpGfx));
+	memset(_slugLeftGfx, 0, sizeof(_slugLeftGfx));
+	memset(_slugRightGfx, 0, sizeof(_slugRightGfx));
+
+	memset(_waypointGfx, 0, sizeof(_waypointGfx));
+	delete _debugQMark;
+	_debugQMark = NULL;
+
 	// Free AnimTargets
 
 	for (uint i = 0; i < _animTargets.size(); i++) {
diff --git a/engines/hdb/ai.h b/engines/hdb/ai.h
index 8b25008..533d431 100644
--- a/engines/hdb/ai.h
+++ b/engines/hdb/ai.h
@@ -550,51 +550,61 @@ struct AIEntity {
 		blinkFrames = 0;
 		for (int i = 0; i < kMaxAnimFrames; i++) {
 			delete blinkGfx[i];
+			blinkGfx[i] = NULL;
 		}
 
 		special1Frames = 0;
 		for (int i = 0; i < kMaxAnimFrames; i++) {
 			delete special1Gfx[i];
+			special1Gfx[i] = NULL;
 		}
 
 		standdownFrames = 0;
 		for (int i = 0; i < kMaxAnimFrames; i++) {
 			delete standdownGfx[i];
+			standdownGfx[i] = NULL;
 		}
 
 		standupFrames = 0;
 		for (int i = 0; i < kMaxAnimFrames; i++) {
 			delete standupGfx[i];
+			standupGfx[i] = NULL;
 		}
 
 		standleftFrames = 0;
 		for (int i = 0; i < kMaxAnimFrames; i++) {
 			delete standleftGfx[i];
+			standleftGfx[i] = NULL;
 		}
 
 		standrightFrames = 0;
 		for (int i = 0; i < kMaxAnimFrames; i++) {
 			delete standrightGfx[i];
+			standrightGfx[i] = NULL;
 		}
 
 		movedownFrames = 0;
 		for (int i = 0; i < kMaxAnimFrames; i++) {
 			delete movedownGfx[i];
+			movedownGfx[i] = NULL;
 		}
 
 		moveupFrames = 0;
 		for (int i = 0; i < kMaxAnimFrames; i++) {
 			delete moveupGfx[i];
+			moveupGfx[i] = NULL;
 		}
 
 		moveleftFrames = 0;
 		for (int i = 0; i < kMaxAnimFrames; i++) {
 			delete moveleftGfx[i];
+			moveleftGfx[i] = NULL;
 		}
 
 		moverightFrames = 0;
 		for (int i = 0; i < kMaxAnimFrames; i++) {
 			delete moverightGfx[i];
+			moverightGfx[i] = NULL;
 		}
 	}
 
@@ -652,6 +662,7 @@ struct AnimTarget {
 	~AnimTarget() {
 		for (int i = 0; i < kMaxAnimTFrames; i++) {
 			delete gfxList[i];
+			gfxList[i] = NULL;
 		}
 	}
 };
@@ -680,6 +691,12 @@ struct DlvEnt {
 		destTextName[0] = 0;
 		destGfxName[0] = 0;
 	}
+	~DlvEnt() {
+		delete itemGfx;
+		itemGfx = NULL;
+		delete destGfx;
+		destGfx = NULL;
+	}
 };
 
 struct Waypoint {
diff --git a/engines/hdb/gfx.cpp b/engines/hdb/gfx.cpp
index 942fd1d..de89707 100644
--- a/engines/hdb/gfx.cpp
+++ b/engines/hdb/gfx.cpp
@@ -1032,16 +1032,14 @@ void Gfx::drawDebugInfo(Tile *_debugLogo, int fps) {
 }
 
 Picture::Picture() : _width(0), _height(0), _name("") {
-	_surface = NULL;
+	_surface.create(_width, _height, g_hdb->_format);
 }
 
 Picture::~Picture() {
-	if (_surface)
-		_surface->free();
-	_surface = NULL;
+	_surface.free();
 }
 
-Graphics::ManagedSurface *Picture::load(Common::SeekableReadStream *stream) {
+Graphics::Surface Picture::load(Common::SeekableReadStream *stream) {
 	_width = stream->readUint32LE();
 	_height = stream->readUint32LE();
 	stream->read(_name, 64);
@@ -1049,14 +1047,13 @@ Graphics::ManagedSurface *Picture::load(Common::SeekableReadStream *stream) {
 	debug(8, "Picture: _width: %d, _height: %d", _width, _height);
 	debug(8, "Picture: _name: %s", _name);
 
-	_surface = new Graphics::ManagedSurface;
-	_surface->create(_width, _height, g_hdb->_format);
+	_surface.create(_width, _height, g_hdb->_format);
 	stream->readUint32LE(); // Skip Win32 Surface
 
 	uint16 *ptr;
 
 	for (int y = 0; y < _height; y++) {
-		ptr = (uint16 *)_surface->getBasePtr(0, y);
+		ptr = (uint16 *)_surface.getBasePtr(0, y);
 		for (int x = 0; x < _width; x++) {
 			*ptr = TO_LE_16(stream->readUint16LE());
 			ptr++;
@@ -1067,9 +1064,9 @@ Graphics::ManagedSurface *Picture::load(Common::SeekableReadStream *stream) {
 }
 
 int Picture::draw(int x, int y) {
-	g_hdb->_gfx->_globalSurface.blitFrom(*_surface, Common::Point(x, y));
+	g_hdb->_gfx->_globalSurface.blitFrom(_surface, Common::Point(x, y));
 
-	Common::Rect clip(_surface->getBounds());
+	Common::Rect clip(_surface.getBounds());
 	clip.moveTo(x, y);
 	clip.clip(g_hdb->_gfx->_globalSurface.getBounds());
 	if (!clip.isEmpty()) {
@@ -1080,9 +1077,9 @@ int Picture::draw(int x, int y) {
 }
 
 int Picture::drawMasked(int x, int y, int alpha) {
-	g_hdb->_gfx->_globalSurface.transBlitFrom(*_surface, Common::Point(x, y), 0xf81f, false, 0, alpha & 0xff);
+	g_hdb->_gfx->_globalSurface.transBlitFrom(_surface, Common::Point(x, y), 0xf81f, false, 0, alpha & 0xff);
 
-	Common::Rect clip(_surface->getBounds());
+	Common::Rect clip(_surface.getBounds());
 	clip.moveTo(x, y);
 	clip.clip(g_hdb->_gfx->_globalSurface.getBounds());
 	if (!clip.isEmpty()) {
@@ -1092,26 +1089,25 @@ int Picture::drawMasked(int x, int y, int alpha) {
 	return 0;
 }
 
-Tile::Tile() : _flags(0), _name(""), _surface(NULL) {}
+Tile::Tile() : _flags(0), _name("") {
+	_surface.create(32, 32, g_hdb->_format);
+}
 
 Tile::~Tile() {
-	if (_surface)
-		_surface->free();
-	_surface = NULL;
+	_surface.free();
 }
 
-Graphics::ManagedSurface *Tile::load(Common::SeekableReadStream *stream) {
+Graphics::Surface Tile::load(Common::SeekableReadStream *stream) {
 	_flags = stream->readUint32LE();
 	stream->read(_name, 64);
 
-	_surface = new Graphics::ManagedSurface;
-	_surface->create(32, 32, g_hdb->_format);
+	_surface.create(32, 32, g_hdb->_format);
 	stream->readUint32LE(); // Skip Win32 Surface
 
 	uint16 *ptr;
 
 	for (uint y = 0; y < 32; y++) {
-		ptr = (uint16 *)_surface->getBasePtr(0, y);
+		ptr = (uint16 *)_surface.getBasePtr(0, y);
 		for (uint x = 0; x < 32; x++) {
 			*ptr = TO_LE_16(stream->readUint16LE());
 			ptr++;
@@ -1122,9 +1118,9 @@ Graphics::ManagedSurface *Tile::load(Common::SeekableReadStream *stream) {
 }
 
 int Tile::draw(int x, int y) {
-	g_hdb->_gfx->_globalSurface.blitFrom(*_surface, Common::Point(x, y));
+	g_hdb->_gfx->_globalSurface.blitFrom(_surface, Common::Point(x, y));
 
-	Common::Rect clip(_surface->getBounds());
+	Common::Rect clip(_surface.getBounds());
 	clip.moveTo(x, y);
 	clip.clip(g_hdb->_gfx->_globalSurface.getBounds());
 	if (!clip.isEmpty()) {
@@ -1135,9 +1131,9 @@ int Tile::draw(int x, int y) {
 }
 
 int Tile::drawMasked(int x, int y, int alpha) {
-	g_hdb->_gfx->_globalSurface.transBlitFrom(*_surface, Common::Point(x, y), 0xf81f, false, 0, alpha & 0xff);
+	g_hdb->_gfx->_globalSurface.transBlitFrom(_surface, Common::Point(x, y), 0xf81f, false, 0, alpha & 0xff);
 
-	Common::Rect clip(_surface->getBounds());
+	Common::Rect clip(_surface.getBounds());
 	clip.moveTo(x, y);
 	clip.clip(g_hdb->_gfx->_globalSurface.getBounds());
 	if (!clip.isEmpty()) {
diff --git a/engines/hdb/gfx.h b/engines/hdb/gfx.h
index 1c993ec..ce6ceb6 100644
--- a/engines/hdb/gfx.h
+++ b/engines/hdb/gfx.h
@@ -253,7 +253,7 @@ public:
 	Picture();
 	~Picture();
 
-	Graphics::ManagedSurface *load(Common::SeekableReadStream *stream);
+	Graphics::Surface load(Common::SeekableReadStream *stream);
 	int draw(int x, int y);
 	int drawMasked(int x, int y, int alpha = 0xff);
 
@@ -261,12 +261,12 @@ public:
 
 	char *getName() { return _name; }
 
-	Graphics::ManagedSurface *getSurface() { return _surface; }
+	Graphics::ManagedSurface *getSurface() { return &_surface; }
 
 private:
 	char _name[64];
 
-	Graphics::ManagedSurface *_surface;
+	Graphics::ManagedSurface _surface;
 };
 
 class Tile {
@@ -275,7 +275,7 @@ public:
 	Tile();
 	~Tile();
 
-	Graphics::ManagedSurface *load(Common::SeekableReadStream *stream);
+	Graphics::Surface load(Common::SeekableReadStream *stream);
 	int draw(int x, int y);
 	int drawMasked(int x, int y, int alpha = 0xff);
 
@@ -285,7 +285,7 @@ public:
 private:
 	char _name[64];
 
-	Graphics::ManagedSurface *_surface;
+	Graphics::ManagedSurface _surface;
 };
 
 } // End of Namespace HDB
diff --git a/engines/hdb/hdb.cpp b/engines/hdb/hdb.cpp
index c5b91bb..49a2f99 100644
--- a/engines/hdb/hdb.cpp
+++ b/engines/hdb/hdb.cpp
@@ -87,10 +87,15 @@ HDBGame::~HDBGame() {
 	delete _rnd;
 
 	delete _progressGfx;
+	_progressGfx = NULL;
 	delete _progressMarkGfx;
+	_progressMarkGfx = NULL;
 	delete _loadingScreenGfx;
-	if (_logoGfx)
+	_loadingScreenGfx = NULL;
+	if (_logoGfx) {
 		delete _logoGfx;
+		_logoGfx = NULL;
+	}
 
 	DebugMan.clearAllDebugChannels();
 }


Commit: 7b78aa5e9f19e30e92988c274f973029c827e2c5
    https://github.com/scummvm/scummvm/commit/7b78aa5e9f19e30e92988c274f973029c827e2c5
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:23+02:00

Commit Message:
HDB: Fix double free() and meaningless 'new' allocations

Changed paths:
    engines/hdb/ai.h


diff --git a/engines/hdb/ai.h b/engines/hdb/ai.h
index 533d431..aa47996 100644
--- a/engines/hdb/ai.h
+++ b/engines/hdb/ai.h
@@ -498,115 +498,56 @@ struct AIEntity {
 
 		blinkFrames = 0;
 		for (int i = 0; i < kMaxAnimFrames; i++) {
-			blinkGfx[i] = new Tile;
-		}
-
-		special1Frames = 0;
-		for (int i = 0; i < kMaxAnimFrames; i++) {
-			special1Gfx[i] = new Tile;
-		}
-
-		standdownFrames = 0;
-		for (int i = 0; i < kMaxAnimFrames; i++) {
-			standdownGfx[i] = new Tile;
-		}
-
-		standupFrames = 0;
-		for (int i = 0; i < kMaxAnimFrames; i++) {
-			standupGfx[i] = new Tile;
-		}
-
-		standleftFrames = 0;
-		for (int i = 0; i < kMaxAnimFrames; i++) {
-			standleftGfx[i] = new Tile;
-		}
-
-		standrightFrames = 0;
-		for (int i = 0; i < kMaxAnimFrames; i++) {
-			standrightGfx[i] = new Tile;
-		}
-
-		movedownFrames = 0;
-		for (int i = 0; i < kMaxAnimFrames; i++) {
-			movedownGfx[i] = new Tile;
-		}
-
-		moveupFrames = 0;
-		for (int i = 0; i < kMaxAnimFrames; i++) {
-			moveupGfx[i] = new Tile;
-		}
-
-		moveleftFrames = 0;
-		for (int i = 0; i < kMaxAnimFrames; i++) {
-			moveleftGfx[i] = new Tile;
-		}
-
-		moverightFrames = 0;
-		for (int i = 0; i < kMaxAnimFrames; i++) {
-			moverightGfx[i] = new Tile;
-		}
-	}
-	~AIEntity() {
-		blinkFrames = 0;
-		for (int i = 0; i < kMaxAnimFrames; i++) {
-			delete blinkGfx[i];
 			blinkGfx[i] = NULL;
 		}
 
 		special1Frames = 0;
 		for (int i = 0; i < kMaxAnimFrames; i++) {
-			delete special1Gfx[i];
 			special1Gfx[i] = NULL;
 		}
 
 		standdownFrames = 0;
 		for (int i = 0; i < kMaxAnimFrames; i++) {
-			delete standdownGfx[i];
 			standdownGfx[i] = NULL;
 		}
 
 		standupFrames = 0;
 		for (int i = 0; i < kMaxAnimFrames; i++) {
-			delete standupGfx[i];
 			standupGfx[i] = NULL;
 		}
 
 		standleftFrames = 0;
 		for (int i = 0; i < kMaxAnimFrames; i++) {
-			delete standleftGfx[i];
 			standleftGfx[i] = NULL;
 		}
 
 		standrightFrames = 0;
 		for (int i = 0; i < kMaxAnimFrames; i++) {
-			delete standrightGfx[i];
 			standrightGfx[i] = NULL;
 		}
 
 		movedownFrames = 0;
 		for (int i = 0; i < kMaxAnimFrames; i++) {
-			delete movedownGfx[i];
 			movedownGfx[i] = NULL;
 		}
 
 		moveupFrames = 0;
 		for (int i = 0; i < kMaxAnimFrames; i++) {
-			delete moveupGfx[i];
 			moveupGfx[i] = NULL;
 		}
 
 		moveleftFrames = 0;
 		for (int i = 0; i < kMaxAnimFrames; i++) {
-			delete moveleftGfx[i];
 			moveleftGfx[i] = NULL;
 		}
 
 		moverightFrames = 0;
 		for (int i = 0; i < kMaxAnimFrames; i++) {
-			delete moverightGfx[i];
 			moverightGfx[i] = NULL;
 		}
 	}
+	~AIEntity() {
+	}
 
 	void save(Common::OutSaveFile *out);
 	void load(Common::InSaveFile *in);


Commit: fa71ee9034cd497bb6f5733c7641ef05ce10126b
    https://github.com/scummvm/scummvm/commit/fa71ee9034cd497bb6f5733c7641ef05ce10126b
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:23+02:00

Commit Message:
HDB: Fix memory leaks due to findFirstData()

Changed paths:
    engines/hdb/file-manager.cpp
    engines/hdb/gfx.cpp
    engines/hdb/hdb.cpp
    engines/hdb/lua-script.cpp
    engines/hdb/map.cpp


diff --git a/engines/hdb/file-manager.cpp b/engines/hdb/file-manager.cpp
index e28f19f..295999a 100644
--- a/engines/hdb/file-manager.cpp
+++ b/engines/hdb/file-manager.cpp
@@ -128,7 +128,7 @@ Common::SeekableReadStream *FileMan::findFirstData(const char *string, DataType
 
 	// Load corresponding file into a buffer
 	_mpcFile->seek(file->offset);
-	byte *buffer = new byte[file->ulength];
+	byte *buffer = (byte *)malloc(file->ulength * sizeof(byte));
 
 	_mpcFile->read(buffer, file->ulength);
 
diff --git a/engines/hdb/gfx.cpp b/engines/hdb/gfx.cpp
index de89707..bc6046d 100644
--- a/engines/hdb/gfx.cpp
+++ b/engines/hdb/gfx.cpp
@@ -386,6 +386,7 @@ Picture *Gfx::loadPic(const char *picName) {
 	if (!stream)
 		return NULL;
 	pic->load(stream);
+	delete stream;
 	return pic;
 }
 
@@ -395,6 +396,7 @@ Tile *Gfx::loadTile(const char *tileName) {
 	if (!stream)
 		return NULL;
 	tile->load(stream);
+	delete stream;
 	return tile;
 }
 
@@ -404,6 +406,7 @@ Tile *Gfx::loadIcon(const char *tileName) {
 	if (!stream)
 		return NULL;
 	tile->load(stream);
+	delete stream;
 	return tile;
 }
 
@@ -424,6 +427,7 @@ Tile *Gfx::getTile(int index) {
 		Common::SeekableReadStream *stream = g_hdb->_fileMan->findFirstData(_tLookupArray[index].filename, TYPE_TILE32);
 		Tile *tile = new Tile;
 		tile->load(stream);
+		delete stream;
 		_tLookupArray[index].tData = tile;
 	}
 
@@ -455,6 +459,7 @@ Picture *Gfx::getPicture(const char *name) {
 	Common::SeekableReadStream *stream = g_hdb->_fileMan->findFirstData(name, TYPE_PIC);
 	Picture *picture = new Picture;
 	picture->load(stream);
+	delete stream;
 	return picture;
 }
 
@@ -523,6 +528,7 @@ Tile *Gfx::getTileGfx(const char *name, int32 size) {
 
 	Tile *gfxTile = new Tile;
 	gfxTile->load(stream);
+	delete stream;
 
 	gc->tileGfx = gfxTile;
 	if (size == -1)
@@ -562,6 +568,7 @@ Picture *Gfx::getPicGfx(const char *name, int32 size) {
 
 	Picture *gfxPic = new Picture;
 	gfxPic->load(stream);
+	delete stream;
 
 	gc->picGfx = gfxPic;
 	if (size == -1)
@@ -753,6 +760,7 @@ bool Gfx::loadFont(const char *string) {
 
 	// Loading _fontGfx
 	_fontGfx = stream->readUint16LE();
+	delete stream;
 
 	return true;
 }
diff --git a/engines/hdb/hdb.cpp b/engines/hdb/hdb.cpp
index 49a2f99..f7c2c64 100644
--- a/engines/hdb/hdb.cpp
+++ b/engines/hdb/hdb.cpp
@@ -833,6 +833,7 @@ Common::Error HDBGame::run() {
 
 	Picture *titlePic = new Picture;
 	titlePic->load(titleStream);
+	delete titleStream;
 
 	Common::SeekableReadStream *tileStream = _fileMan->findFirstData("t32_ground1", TYPE_TILE32);
 	if (tileStream == NULL) {
@@ -842,6 +843,7 @@ Common::Error HDBGame::run() {
 
 	Tile *tile = new Tile;
 	tile->load(tileStream);
+	delete tileStream;
 #endif
 
 	if (ConfMan.hasKey("boot_param")) {
diff --git a/engines/hdb/lua-script.cpp b/engines/hdb/lua-script.cpp
index 1b62081..54cd2c9 100644
--- a/engines/hdb/lua-script.cpp
+++ b/engines/hdb/lua-script.cpp
@@ -66,6 +66,8 @@ LuaScript::~LuaScript() {
 	if (_state) {
 		lua_close(_state);
 	}
+	if (_globalLuaStream)
+		delete _globalLuaStream;
 }
 
 bool LuaScript::init() {
@@ -92,6 +94,7 @@ bool LuaScript::loadLua(const char *name) {
 	}
 
 	_systemInit = initScript(luaStream, name, luaLength);
+	delete luaStream;
 
 	return true;
 }
diff --git a/engines/hdb/map.cpp b/engines/hdb/map.cpp
index 66fc9ab..450f182 100644
--- a/engines/hdb/map.cpp
+++ b/engines/hdb/map.cpp
@@ -264,6 +264,7 @@ bool Map::loadMap(char *name) {
 	}
 
 	load(mapStream);
+	delete mapStream;
 
 	return true;
 }


Commit: 5363b38fe51b45ecd07ee9d87933ab33c65984b2
    https://github.com/scummvm/scummvm/commit/5363b38fe51b45ecd07ee9d87933ab33c65984b2
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:23+02:00

Commit Message:
HDB: Delete Player Graphics in destructor

Changed paths:
    engines/hdb/ai-init.cpp
    engines/hdb/hdb.cpp


diff --git a/engines/hdb/ai-init.cpp b/engines/hdb/ai-init.cpp
index c0c85e7..6a470aa 100644
--- a/engines/hdb/ai-init.cpp
+++ b/engines/hdb/ai-init.cpp
@@ -939,21 +939,31 @@ AI::~AI() {
 	memset(&_inventory, 0, sizeof(InvEnt) * kMaxInventory);
 
 	// Free Player Graphics
+	for (int i = 0; i < 8; i++) {
+		delete _clubDownGfx[i];
+		delete _clubUpGfx[i];
+		delete _clubLeftGfx[i];
+		delete _clubRightGfx[i];
+		delete _slugAttackGfx[i];
+		delete _pushdownGfx[i];
+		delete _pushupGfx[i];
+		delete _pushleftGfx[i];
+		delete _pushrightGfx[i];
+		delete _stunDownGfx[i];
+		delete _stunUpGfx[i];
+		delete _stunLeftGfx[i];
+		delete _stunRightGfx[i];
+		delete _slugDownGfx[i];
+		delete _slugUpGfx[i];
+		delete _slugLeftGfx[i];
+		delete _slugRightGfx[i];
+	}
 
 	memset(_clubDownGfx, 0, sizeof(_clubDownGfx));
 	memset(_clubUpGfx, 0, sizeof(_clubUpGfx));
 	memset(_clubLeftGfx, 0, sizeof(_clubLeftGfx));
 	memset(_clubRightGfx, 0, sizeof(_clubRightGfx));
 	memset(_slugAttackGfx, 0, sizeof(_slugAttackGfx));
-
-	// Clean up Player Graphics Storage
-	memset(_horrible1Gfx, 0, sizeof(_horrible1Gfx));
-	memset(_horrible2Gfx, 0, sizeof(_horrible2Gfx));
-	memset(_horrible3Gfx, 0, sizeof(_horrible3Gfx));
-	memset(_horrible4Gfx, 0, sizeof(_horrible4Gfx));
-	memset(_plummetGfx, 0, sizeof(_plummetGfx));
-	memset(_dyingGfx, 0, sizeof(_dyingGfx));
-
 	memset(_pushdownGfx, 0, sizeof(_pushdownGfx));
 	memset(_pushupGfx, 0, sizeof(_pushupGfx));
 	memset(_pushleftGfx, 0, sizeof(_pushleftGfx));
@@ -967,6 +977,25 @@ AI::~AI() {
 	memset(_slugLeftGfx, 0, sizeof(_slugLeftGfx));
 	memset(_slugRightGfx, 0, sizeof(_slugRightGfx));
 
+	// Free Player Death Graphics
+	for (int i = 0; i < 12; i++) {
+		delete _horrible1Gfx[i];
+		delete _horrible2Gfx[i];
+		delete _horrible3Gfx[i];
+		delete _horrible4Gfx[i];
+		delete _plummetGfx[i];
+		delete _dyingGfx[i];
+	}
+
+	memset(_horrible1Gfx, 0, sizeof(_horrible1Gfx));
+	memset(_horrible2Gfx, 0, sizeof(_horrible2Gfx));
+	memset(_horrible3Gfx, 0, sizeof(_horrible3Gfx));
+	memset(_horrible4Gfx, 0, sizeof(_horrible4Gfx));
+	memset(_plummetGfx, 0, sizeof(_plummetGfx));
+	memset(_dyingGfx, 0, sizeof(_dyingGfx));
+
+	for (int i = 0; i < 4; i++)
+		delete _waypointGfx[i];
 	memset(_waypointGfx, 0, sizeof(_waypointGfx));
 	delete _debugQMark;
 	_debugQMark = NULL;
diff --git a/engines/hdb/hdb.cpp b/engines/hdb/hdb.cpp
index f7c2c64..25b8604 100644
--- a/engines/hdb/hdb.cpp
+++ b/engines/hdb/hdb.cpp
@@ -96,6 +96,8 @@ HDBGame::~HDBGame() {
 		delete _logoGfx;
 		_logoGfx = NULL;
 	}
+	delete _debugLogo;
+	_debugLogo = NULL;
 
 	DebugMan.clearAllDebugChannels();
 }


Commit: ea77240d4e85873fd5f006b10981509156ddba73
    https://github.com/scummvm/scummvm/commit/ea77240d4e85873fd5f006b10981509156ddba73
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:23+02:00

Commit Message:
HDB: Fix memory leak due to removed animTargets

Changed paths:
    engines/hdb/ai-lists.cpp


diff --git a/engines/hdb/ai-lists.cpp b/engines/hdb/ai-lists.cpp
index 39b3970..2b122f4 100644
--- a/engines/hdb/ai-lists.cpp
+++ b/engines/hdb/ai-lists.cpp
@@ -128,6 +128,7 @@ void AI::animateTargets() {
 				if (at->killAuto)
 					autoDeactivate(at->x, at->y);
 
+				delete _animTargets[i];
 				_animTargets.remove_at(i);
 				i--;
 				continue;


Commit: 8d9004e43268109394059ff267cce9983c4f5346
    https://github.com/scummvm/scummvm/commit/8d9004e43268109394059ff267cce9983c4f5346
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:23+02:00

Commit Message:
HDB: Fix memory leaks when stream is returned NULL

Changed paths:
    engines/hdb/gfx.cpp
    engines/hdb/hdb.cpp
    engines/hdb/lua-script.cpp
    engines/hdb/map.cpp


diff --git a/engines/hdb/gfx.cpp b/engines/hdb/gfx.cpp
index bc6046d..8c7cb05 100644
--- a/engines/hdb/gfx.cpp
+++ b/engines/hdb/gfx.cpp
@@ -383,8 +383,10 @@ void Gfx::turnOnSnow() {
 Picture *Gfx::loadPic(const char *picName) {
 	Picture *pic = new Picture;
 	Common::SeekableReadStream *stream = g_hdb->_fileMan->findFirstData(picName, TYPE_PIC);
-	if (!stream)
+	if (!stream) {
+		delete stream;
 		return NULL;
+	}
 	pic->load(stream);
 	delete stream;
 	return pic;
@@ -393,8 +395,10 @@ Picture *Gfx::loadPic(const char *picName) {
 Tile *Gfx::loadTile(const char *tileName) {
 	Tile *tile = new Tile;
 	Common::SeekableReadStream *stream = g_hdb->_fileMan->findFirstData(tileName, TYPE_TILE32);
-	if (!stream)
+	if (!stream) {
+		delete stream;
 		return NULL;
+	}
 	tile->load(stream);
 	delete stream;
 	return tile;
@@ -403,8 +407,10 @@ Tile *Gfx::loadTile(const char *tileName) {
 Tile *Gfx::loadIcon(const char *tileName) {
 	Tile *tile = new Tile;
 	Common::SeekableReadStream *stream = g_hdb->_fileMan->findFirstData(tileName, TYPE_ICON32);
-	if (!stream)
+	if (!stream) {
+		delete stream;
 		return NULL;
+	}
 	tile->load(stream);
 	delete stream;
 	return tile;
@@ -709,8 +715,10 @@ int Gfx::animateTile(int tileIndex) {
 
 bool Gfx::loadFont(const char *string) {
 	Common::SeekableReadStream *stream = g_hdb->_fileMan->findFirstData(string, TYPE_FONT);
-	if (!stream)
+	if (!stream) {
+		delete stream;
 		return false;
+	}
 
 	// Loading _fontHeader
 	_fontHeader.type = (int)stream->readUint32LE();
diff --git a/engines/hdb/hdb.cpp b/engines/hdb/hdb.cpp
index 25b8604..3419ac6 100644
--- a/engines/hdb/hdb.cpp
+++ b/engines/hdb/hdb.cpp
@@ -830,6 +830,7 @@ Common::Error HDBGame::run() {
 	Common::SeekableReadStream *titleStream = _fileMan->findFirstData("monkeylogoscreen", TYPE_PIC);
 	if (titleStream == NULL) {
 		debug("The TitleScreen MPC entry can't be found.");
+		delete titleStream;
 		return Common::kReadingFailed;
 	}
 
@@ -840,6 +841,7 @@ Common::Error HDBGame::run() {
 	Common::SeekableReadStream *tileStream = _fileMan->findFirstData("t32_ground1", TYPE_TILE32);
 	if (tileStream == NULL) {
 		debug("The t32_shipwindow_lr MPC entry can't be found.");
+		delete tileStream;
 		return Common::kReadingFailed;
 	}
 
diff --git a/engines/hdb/lua-script.cpp b/engines/hdb/lua-script.cpp
index 54cd2c9..5c2906b 100644
--- a/engines/hdb/lua-script.cpp
+++ b/engines/hdb/lua-script.cpp
@@ -90,6 +90,7 @@ bool LuaScript::loadLua(const char *name) {
 
 		_systemInit = false;
 
+		delete luaStream;
 		return false;
 	}
 
diff --git a/engines/hdb/map.cpp b/engines/hdb/map.cpp
index 450f182..e1d21c4 100644
--- a/engines/hdb/map.cpp
+++ b/engines/hdb/map.cpp
@@ -260,6 +260,7 @@ bool Map::loadMap(char *name) {
 	Common::SeekableReadStream *mapStream = g_hdb->_fileMan->findFirstData(name, TYPE_BINARY);
 	if (mapStream == NULL) {
 		warning("The %s MPC entry can't be found", name);
+		delete mapStream;
 		return false;
 	}
 


Commit: fd91bb7f59ba6ac1b3be7bc245bc25042a05a464
    https://github.com/scummvm/scummvm/commit/fd91bb7f59ba6ac1b3be7bc245bc25042a05a464
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:23+02:00

Commit Message:
HDB: Fix more memory leaks

Changed paths:
    engines/hdb/file-manager.cpp
    engines/hdb/gfx.cpp
    engines/hdb/map.cpp


diff --git a/engines/hdb/file-manager.cpp b/engines/hdb/file-manager.cpp
index 295999a..d75c112 100644
--- a/engines/hdb/file-manager.cpp
+++ b/engines/hdb/file-manager.cpp
@@ -29,6 +29,8 @@ namespace HDB {
 
 FileMan::FileMan() {
 	_mpcFile = new Common::File;
+	for (uint i = 0; i < _dir.size(); i++)
+		delete _dir[i];
 }
 
 FileMan::~FileMan() {
diff --git a/engines/hdb/gfx.cpp b/engines/hdb/gfx.cpp
index 8c7cb05..94c46bd 100644
--- a/engines/hdb/gfx.cpp
+++ b/engines/hdb/gfx.cpp
@@ -52,6 +52,13 @@ Gfx::~Gfx() {
 	for (int i = 0; i < _fontHeader.numChars; i++)
 		_fontSurfaces[i].free();
 	_globalSurface.free();
+	delete[] _tLookupArray;
+	for (int i = 0; i < 8; i++)
+		delete _mousePointer[i];
+	for (int i = 0; i < 4; i++)
+		delete _starField[i];
+	delete _snowflake;
+	delete _skyClouds;
 }
 
 bool Gfx::init() {
diff --git a/engines/hdb/map.cpp b/engines/hdb/map.cpp
index e1d21c4..ca8e2a2 100644
--- a/engines/hdb/map.cpp
+++ b/engines/hdb/map.cpp
@@ -41,6 +41,10 @@ Map::Map() {
 }
 
 Map::~Map() {
+	delete[] _background;
+	delete[] _foreground;
+	delete[] _iconList;
+
 	free(_mapExplosions);
 	free(_mapExpBarrels);
 	free(_mapLaserBeams);


Commit: 05cb55b8883fdf4f6a44f285d29716d2d17da9c2
    https://github.com/scummvm/scummvm/commit/05cb55b8883fdf4f6a44f285d29716d2d17da9c2
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:23+02:00

Commit Message:
HDB: Delete Cached gfx data in one place

Changed paths:
    engines/hdb/ai-init.cpp
    engines/hdb/ai.h
    engines/hdb/gfx.cpp
    engines/hdb/gfx.h


diff --git a/engines/hdb/ai-init.cpp b/engines/hdb/ai-init.cpp
index 6a470aa..bc6ebee 100644
--- a/engines/hdb/ai-init.cpp
+++ b/engines/hdb/ai-init.cpp
@@ -940,23 +940,7 @@ AI::~AI() {
 
 	// Free Player Graphics
 	for (int i = 0; i < 8; i++) {
-		delete _clubDownGfx[i];
-		delete _clubUpGfx[i];
-		delete _clubLeftGfx[i];
-		delete _clubRightGfx[i];
 		delete _slugAttackGfx[i];
-		delete _pushdownGfx[i];
-		delete _pushupGfx[i];
-		delete _pushleftGfx[i];
-		delete _pushrightGfx[i];
-		delete _stunDownGfx[i];
-		delete _stunUpGfx[i];
-		delete _stunLeftGfx[i];
-		delete _stunRightGfx[i];
-		delete _slugDownGfx[i];
-		delete _slugUpGfx[i];
-		delete _slugLeftGfx[i];
-		delete _slugRightGfx[i];
 	}
 
 	memset(_clubDownGfx, 0, sizeof(_clubDownGfx));
@@ -977,16 +961,6 @@ AI::~AI() {
 	memset(_slugLeftGfx, 0, sizeof(_slugLeftGfx));
 	memset(_slugRightGfx, 0, sizeof(_slugRightGfx));
 
-	// Free Player Death Graphics
-	for (int i = 0; i < 12; i++) {
-		delete _horrible1Gfx[i];
-		delete _horrible2Gfx[i];
-		delete _horrible3Gfx[i];
-		delete _horrible4Gfx[i];
-		delete _plummetGfx[i];
-		delete _dyingGfx[i];
-	}
-
 	memset(_horrible1Gfx, 0, sizeof(_horrible1Gfx));
 	memset(_horrible2Gfx, 0, sizeof(_horrible2Gfx));
 	memset(_horrible3Gfx, 0, sizeof(_horrible3Gfx));
diff --git a/engines/hdb/ai.h b/engines/hdb/ai.h
index aa47996..83fe88b 100644
--- a/engines/hdb/ai.h
+++ b/engines/hdb/ai.h
@@ -633,9 +633,7 @@ struct DlvEnt {
 		destGfxName[0] = 0;
 	}
 	~DlvEnt() {
-		delete itemGfx;
 		itemGfx = NULL;
-		delete destGfx;
 		destGfx = NULL;
 	}
 };
diff --git a/engines/hdb/gfx.cpp b/engines/hdb/gfx.cpp
index 94c46bd..94ba77b 100644
--- a/engines/hdb/gfx.cpp
+++ b/engines/hdb/gfx.cpp
@@ -42,8 +42,14 @@ Gfx::Gfx() {
 }
 
 Gfx::~Gfx() {
-	for (uint i = 0; i < _gfxCache->size(); i++)
-		delete _gfxCache->operator[](i);
+	for (uint i = 0; i < _gfxCache->size(); i++) {
+		GfxCache *cache = _gfxCache->operator[](i);
+		if (cache->status)
+			delete cache->picGfx;
+		else
+			delete cache->tileGfx;
+		delete cache;
+	}
 	delete _gfxCache;
 	for (uint i = 0; i < _charInfoBlocks.size(); i++)
 		delete _charInfoBlocks[i];
@@ -544,6 +550,7 @@ Tile *Gfx::getTileGfx(const char *name, int32 size) {
 	delete stream;
 
 	gc->tileGfx = gfxTile;
+	gc->status = false;
 	if (size == -1)
 		size = g_hdb->_fileMan->getLength(name, TYPE_TILE32);
 	gc->size = size;
@@ -584,6 +591,7 @@ Picture *Gfx::getPicGfx(const char *name, int32 size) {
 	delete stream;
 
 	gc->picGfx = gfxPic;
+	gc->status = true;
 	if (size == -1)
 		size = g_hdb->_fileMan->getLength(name, TYPE_PIC);
 	gc->size = size;
diff --git a/engines/hdb/gfx.h b/engines/hdb/gfx.h
index ce6ceb6..73fb92a 100644
--- a/engines/hdb/gfx.h
+++ b/engines/hdb/gfx.h
@@ -60,6 +60,7 @@ struct TileLookup {
 
 struct GfxCache {
 	char name[32];
+	bool status;	// false = tileGfx, true = picGfx
 	union {
 		Tile *tileGfx;
 		Picture *picGfx;
@@ -67,7 +68,7 @@ struct GfxCache {
 	uint32 size;
 	int16 loaded;
 
-	GfxCache() : tileGfx(NULL), size(0), loaded(0) { name[0] = 0; }
+	GfxCache() : status(false), tileGfx(NULL), size(0), loaded(0) { name[0] = 0; }
 };
 
 struct FontInfo {


Commit: a8d277be183a2d41b9dd10b3b8b23ef1ddb8d65e
    https://github.com/scummvm/scummvm/commit/a8d277be183a2d41b9dd10b3b8b23ef1ddb8d65e
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:23+02:00

Commit Message:
HDB: Fix delete command for _dir

Changed paths:
    engines/hdb/file-manager.cpp


diff --git a/engines/hdb/file-manager.cpp b/engines/hdb/file-manager.cpp
index d75c112..7e1e68e 100644
--- a/engines/hdb/file-manager.cpp
+++ b/engines/hdb/file-manager.cpp
@@ -29,12 +29,12 @@ namespace HDB {
 
 FileMan::FileMan() {
 	_mpcFile = new Common::File;
-	for (uint i = 0; i < _dir.size(); i++)
-		delete _dir[i];
 }
 
 FileMan::~FileMan() {
 	delete _mpcFile;
+	for (uint i = 0; i < _dir.size(); i++)
+		delete _dir[i];
 }
 
 bool FileMan::openMPC(const Common::String &filename) {


Commit: ecefec2f77a2c2af6b956d3f35869605b5aff62d
    https://github.com/scummvm/scummvm/commit/ecefec2f77a2c2af6b956d3f35869605b5aff62d
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:23+02:00

Commit Message:
HDB: Add _animTiles to fix memory leaks

Changed paths:
    engines/hdb/ai-funcs.cpp
    engines/hdb/ai-init.cpp
    engines/hdb/ai.h
    engines/hdb/gfx.cpp
    engines/hdb/hdb.cpp


diff --git a/engines/hdb/ai-funcs.cpp b/engines/hdb/ai-funcs.cpp
index 5c8f929..02c6941 100644
--- a/engines/hdb/ai-funcs.cpp
+++ b/engines/hdb/ai-funcs.cpp
@@ -681,6 +681,7 @@ int AI::checkForTouchplate(int x, int y) {
 void AI::removeEntity(AIEntity *e) {
 	for (uint i = 0; i < _ents->size(); i++)
 		if (_ents->operator[](i) == e) {
+			delete _ents->operator[](i);
 			_ents->remove_at(i);
 			return;
 		}
diff --git a/engines/hdb/ai-init.cpp b/engines/hdb/ai-init.cpp
index bc6ebee..e69fbc7 100644
--- a/engines/hdb/ai-init.cpp
+++ b/engines/hdb/ai-init.cpp
@@ -941,6 +941,15 @@ AI::~AI() {
 	// Free Player Graphics
 	for (int i = 0; i < 8; i++) {
 		delete _slugAttackGfx[i];
+		_slugAttackGfx[i] = NULL;
+	}
+	if (_weaponSelGfx) {
+		delete _weaponSelGfx;
+		_weaponSelGfx = NULL;
+	}
+	if (_weaponGfx) {
+		delete _weaponGfx;
+		_weaponGfx = NULL;
 	}
 
 	memset(_clubDownGfx, 0, sizeof(_clubDownGfx));
@@ -979,6 +988,9 @@ AI::~AI() {
 	for (uint i = 0; i < _animTargets.size(); i++) {
 		delete _animTargets[i];
 	}
+
+	// Free Animating Tiles
+	freeAnimInfo();
 }
 
 bool AI::init() {
@@ -1768,13 +1780,13 @@ void AI::loadSaveFile(Common::InSaveFile *in) {
 
 void AI::initAnimInfo() {
 	if (g_hdb->_map->checkOneTileExistInRange(_useSwitchOff, 2))
-		g_hdb->_gfx->getTile(_useSwitchOn);
+		_animTiles.push_back(g_hdb->_gfx->getTile(_useSwitchOn));
 	if (g_hdb->_map->checkOneTileExistInRange(_useSwitch2Off, 2))
-		g_hdb->_gfx->getTile(_useSwitch2On);
+		_animTiles.push_back(g_hdb->_gfx->getTile(_useSwitch2On));
 	if (g_hdb->_map->checkOneTileExistInRange(_useHolderEmpty, 2))
-		g_hdb->_gfx->getTile(_useHolderFull);
+		_animTiles.push_back(g_hdb->_gfx->getTile(_useHolderFull));
 	if (g_hdb->_map->checkOneTileExistInRange(_useHandswitchOff, 2))
-		g_hdb->_gfx->getTile(_useHandswitchOn);
+		_animTiles.push_back(g_hdb->_gfx->getTile(_useHandswitchOn));
 
 	if (g_hdb->_map->checkOneTileExistInRange(_targetDoorN, 4))
 		g_hdb->_gfx->cacheTileSequence(_targetDoorN, 4);
@@ -1848,17 +1860,22 @@ void AI::initAnimInfo() {
 		g_hdb->_gfx->cacheTileSequence(_blockpole, 4);
 
 	if (g_hdb->_map->checkOneTileExistInRange(_kcHolderWhiteOff, 2))
-		g_hdb->_gfx->getTile(_kcHolderWhiteOn);
+		_animTiles.push_back(g_hdb->_gfx->getTile(_kcHolderWhiteOn));
 	if (g_hdb->_map->checkOneTileExistInRange(_kcHolderBlueOff, 2))
-		g_hdb->_gfx->getTile(_kcHolderBlueOn);
+		_animTiles.push_back(g_hdb->_gfx->getTile(_kcHolderBlueOn));
 	if (g_hdb->_map->checkOneTileExistInRange(_kcHolderRedOff, 2))
-		g_hdb->_gfx->getTile(_kcHolderRedOn);
+		_animTiles.push_back(g_hdb->_gfx->getTile(_kcHolderRedOn));
 	if (g_hdb->_map->checkOneTileExistInRange(_kcHolderGreenOff, 2))
-		g_hdb->_gfx->getTile(_kcHolderGreenOn);
+		_animTiles.push_back(g_hdb->_gfx->getTile(_kcHolderGreenOn));
 	if (g_hdb->_map->checkOneTileExistInRange(_kcHolderPurpleOff, 2))
-		g_hdb->_gfx->getTile(_kcHolderPurpleOn);
+		_animTiles.push_back(g_hdb->_gfx->getTile(_kcHolderPurpleOn));
 	if (g_hdb->_map->checkOneTileExistInRange(_kcHolderBlackOff, 2))
-		g_hdb->_gfx->getTile(_kcHolderBlackOn);
+		_animTiles.push_back(g_hdb->_gfx->getTile(_kcHolderBlackOn));
+}
+
+void AI::freeAnimInfo() {
+	for (uint i = 0; i < _animTiles.size(); i++)
+		delete _animTiles[i];
 }
 
 const char *AITypeStr[] = {
diff --git a/engines/hdb/ai.h b/engines/hdb/ai.h
index 83fe88b..df888b1 100644
--- a/engines/hdb/ai.h
+++ b/engines/hdb/ai.h
@@ -821,6 +821,7 @@ public:
 	void save(Common::OutSaveFile *out);
 	void loadSaveFile(Common::InSaveFile *in);
 	void initAnimInfo();
+	void freeAnimInfo();
 
 	// Entity Functions
 	AIEntity *spawn(AIType type, AIDir dir, int x, int y, const char *funcInit, const char *funcAction, const char *funcUse, AIDir dir2, int level, int value1, int value2, int callInit);
@@ -1327,6 +1328,8 @@ public:
 	Tile *_gfxLaserbeamLRLeft[4];
 	Tile *_gfxLaserbeamLRRight[4];
 
+	Common::Array<Tile *> _animTiles;
+
 private:
 
 	// Action Functions
diff --git a/engines/hdb/gfx.cpp b/engines/hdb/gfx.cpp
index 94ba77b..5ebffe2 100644
--- a/engines/hdb/gfx.cpp
+++ b/engines/hdb/gfx.cpp
@@ -459,7 +459,7 @@ void Gfx::emptyGfxCaches() {
 
 void Gfx::cacheTileSequence(int tileIndex, int count) {
 	for (int i = tileIndex; i < tileIndex + count; i++)
-		getTile(i);
+		g_hdb->_ai->_animTiles.push_back(getTile(i));
 }
 
 int Gfx::getTileIndex(const char *name) {
diff --git a/engines/hdb/hdb.cpp b/engines/hdb/hdb.cpp
index 3419ac6..c8b0185 100644
--- a/engines/hdb/hdb.cpp
+++ b/engines/hdb/hdb.cpp
@@ -79,6 +79,7 @@ HDBGame::~HDBGame() {
 	delete _fileMan;
 	delete _gfx;
 	delete _lua;
+	delete _menu;
 	delete _map;
 	delete _ai;
 	delete _input;


Commit: d0248243d2cbb9729ee6f6367784d8fd6be2c719
    https://github.com/scummvm/scummvm/commit/d0248243d2cbb9729ee6f6367784d8fd6be2c719
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:23+02:00

Commit Message:
HDB: Refactor getPicGfx(), getTileGfx() and fix...

... memory leaks

Changed paths:
    engines/hdb/ai-player.cpp
    engines/hdb/gfx.cpp


diff --git a/engines/hdb/ai-player.cpp b/engines/hdb/ai-player.cpp
index ba887db..25f3712 100644
--- a/engines/hdb/ai-player.cpp
+++ b/engines/hdb/ai-player.cpp
@@ -56,25 +56,25 @@ void aiPlayerInit(AIEntity *e) {
 void aiPlayerInit2(AIEntity *e) {
 	if (!g_hdb->_ai->_clubUpGfx[0]) {
 		g_hdb->_ai->_weaponSelGfx = g_hdb->_gfx->loadTile(TILE_WEAPON_EQUIPPED);
-		g_hdb->_ai->_clubUpGfx[0] = g_hdb->_gfx->loadPic(CLUBUP1);
-		g_hdb->_ai->_clubUpGfx[1] = g_hdb->_gfx->loadPic(CLUBUP2);
-		g_hdb->_ai->_clubUpGfx[2] = g_hdb->_gfx->loadPic(CLUBUP3);
-		g_hdb->_ai->_clubUpGfx[3] = g_hdb->_gfx->loadPic(CLUBUP3);
-
-		g_hdb->_ai->_clubDownGfx[0] = g_hdb->_gfx->loadPic(CLUBDOWN1);
-		g_hdb->_ai->_clubDownGfx[1] = g_hdb->_gfx->loadPic(CLUBDOWN2);
-		g_hdb->_ai->_clubDownGfx[2] = g_hdb->_gfx->loadPic(CLUBDOWN3);
-		g_hdb->_ai->_clubDownGfx[3] = g_hdb->_gfx->loadPic(CLUBDOWN3);
-
-		g_hdb->_ai->_clubLeftGfx[0] = g_hdb->_gfx->loadPic(CLUBLEFT1);
-		g_hdb->_ai->_clubLeftGfx[1] = g_hdb->_gfx->loadPic(CLUBLEFT2);
-		g_hdb->_ai->_clubLeftGfx[2] = g_hdb->_gfx->loadPic(CLUBLEFT3);
-		g_hdb->_ai->_clubLeftGfx[3] = g_hdb->_gfx->loadPic(CLUBLEFT3);
-
-		g_hdb->_ai->_clubRightGfx[0] = g_hdb->_gfx->loadPic(CLUBRIGHT1);
-		g_hdb->_ai->_clubRightGfx[1] = g_hdb->_gfx->loadPic(CLUBRIGHT2);
-		g_hdb->_ai->_clubRightGfx[2] = g_hdb->_gfx->loadPic(CLUBRIGHT3);
-		g_hdb->_ai->_clubRightGfx[3] = g_hdb->_gfx->loadPic(CLUBRIGHT3);
+		g_hdb->_ai->_clubUpGfx[0] = g_hdb->_gfx->getPicGfx(CLUBUP1, -1);
+		g_hdb->_ai->_clubUpGfx[1] = g_hdb->_gfx->getPicGfx(CLUBUP2, -1);
+		g_hdb->_ai->_clubUpGfx[2] = g_hdb->_gfx->getPicGfx(CLUBUP3, -1);
+		g_hdb->_ai->_clubUpGfx[3] = g_hdb->_gfx->getPicGfx(CLUBUP3, -1);
+
+		g_hdb->_ai->_clubDownGfx[0] = g_hdb->_gfx->getPicGfx(CLUBDOWN1, -1);
+		g_hdb->_ai->_clubDownGfx[1] = g_hdb->_gfx->getPicGfx(CLUBDOWN2, -1);
+		g_hdb->_ai->_clubDownGfx[2] = g_hdb->_gfx->getPicGfx(CLUBDOWN3, -1);
+		g_hdb->_ai->_clubDownGfx[3] = g_hdb->_gfx->getPicGfx(CLUBDOWN3, -1);
+
+		g_hdb->_ai->_clubLeftGfx[0] = g_hdb->_gfx->getPicGfx(CLUBLEFT1, -1);
+		g_hdb->_ai->_clubLeftGfx[1] = g_hdb->_gfx->getPicGfx(CLUBLEFT2, -1);
+		g_hdb->_ai->_clubLeftGfx[2] = g_hdb->_gfx->getPicGfx(CLUBLEFT3, -1);
+		g_hdb->_ai->_clubLeftGfx[3] = g_hdb->_gfx->getPicGfx(CLUBLEFT3, -1);
+
+		g_hdb->_ai->_clubRightGfx[0] = g_hdb->_gfx->getPicGfx(CLUBRIGHT1, -1);
+		g_hdb->_ai->_clubRightGfx[1] = g_hdb->_gfx->getPicGfx(CLUBRIGHT2, -1);
+		g_hdb->_ai->_clubRightGfx[2] = g_hdb->_gfx->getPicGfx(CLUBRIGHT3, -1);
+		g_hdb->_ai->_clubRightGfx[3] = g_hdb->_gfx->getPicGfx(CLUBRIGHT3, -1);
 
 		g_hdb->_ai->_clubUpFrames = g_hdb->_ai->_clubDownFrames =
 			g_hdb->_ai->_clubLeftFrames = g_hdb->_ai->_clubRightFrames = 4;
diff --git a/engines/hdb/gfx.cpp b/engines/hdb/gfx.cpp
index 5ebffe2..d3e5e75 100644
--- a/engines/hdb/gfx.cpp
+++ b/engines/hdb/gfx.cpp
@@ -542,14 +542,7 @@ Tile *Gfx::getTileGfx(const char *name, int32 size) {
 
 	GfxCache *gc = new GfxCache;
 	strcpy(gc->name, name);
-
-	Common::SeekableReadStream *stream = g_hdb->_fileMan->findFirstData(name, TYPE_TILE32);
-
-	Tile *gfxTile = new Tile;
-	gfxTile->load(stream);
-	delete stream;
-
-	gc->tileGfx = gfxTile;
+	gc->tileGfx = loadTile(name);
 	gc->status = false;
 	if (size == -1)
 		size = g_hdb->_fileMan->getLength(name, TYPE_TILE32);
@@ -583,14 +576,7 @@ Picture *Gfx::getPicGfx(const char *name, int32 size) {
 
 	GfxCache *gc = new GfxCache;
 	strcpy(gc->name, name);
-
-	Common::SeekableReadStream *stream = g_hdb->_fileMan->findFirstData(name, TYPE_TILE32);
-
-	Picture *gfxPic = new Picture;
-	gfxPic->load(stream);
-	delete stream;
-
-	gc->picGfx = gfxPic;
+	gc->picGfx = loadPic(name);
 	gc->status = true;
 	if (size == -1)
 		size = g_hdb->_fileMan->getLength(name, TYPE_PIC);


Commit: 62a33b13991c87bf2c513ff1920231134f68224c
    https://github.com/scummvm/scummvm/commit/62a33b13991c87bf2c513ff1920231134f68224c
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:23+02:00

Commit Message:
HDB: Delete all _tTileLookupArray values at once

Changed paths:
    engines/hdb/ai-init.cpp
    engines/hdb/ai.h
    engines/hdb/gfx.cpp
    engines/hdb/menu.cpp


diff --git a/engines/hdb/ai-init.cpp b/engines/hdb/ai-init.cpp
index e69fbc7..0471a05 100644
--- a/engines/hdb/ai-init.cpp
+++ b/engines/hdb/ai-init.cpp
@@ -988,9 +988,6 @@ AI::~AI() {
 	for (uint i = 0; i < _animTargets.size(); i++) {
 		delete _animTargets[i];
 	}
-
-	// Free Animating Tiles
-	freeAnimInfo();
 }
 
 bool AI::init() {
@@ -1780,13 +1777,13 @@ void AI::loadSaveFile(Common::InSaveFile *in) {
 
 void AI::initAnimInfo() {
 	if (g_hdb->_map->checkOneTileExistInRange(_useSwitchOff, 2))
-		_animTiles.push_back(g_hdb->_gfx->getTile(_useSwitchOn));
+		g_hdb->_gfx->getTile(_useSwitchOn);
 	if (g_hdb->_map->checkOneTileExistInRange(_useSwitch2Off, 2))
-		_animTiles.push_back(g_hdb->_gfx->getTile(_useSwitch2On));
+		g_hdb->_gfx->getTile(_useSwitch2On);
 	if (g_hdb->_map->checkOneTileExistInRange(_useHolderEmpty, 2))
-		_animTiles.push_back(g_hdb->_gfx->getTile(_useHolderFull));
+		g_hdb->_gfx->getTile(_useHolderFull);
 	if (g_hdb->_map->checkOneTileExistInRange(_useHandswitchOff, 2))
-		_animTiles.push_back(g_hdb->_gfx->getTile(_useHandswitchOn));
+		g_hdb->_gfx->getTile(_useHandswitchOn);
 
 	if (g_hdb->_map->checkOneTileExistInRange(_targetDoorN, 4))
 		g_hdb->_gfx->cacheTileSequence(_targetDoorN, 4);
@@ -1860,22 +1857,17 @@ void AI::initAnimInfo() {
 		g_hdb->_gfx->cacheTileSequence(_blockpole, 4);
 
 	if (g_hdb->_map->checkOneTileExistInRange(_kcHolderWhiteOff, 2))
-		_animTiles.push_back(g_hdb->_gfx->getTile(_kcHolderWhiteOn));
+		g_hdb->_gfx->getTile(_kcHolderWhiteOn);
 	if (g_hdb->_map->checkOneTileExistInRange(_kcHolderBlueOff, 2))
-		_animTiles.push_back(g_hdb->_gfx->getTile(_kcHolderBlueOn));
+		g_hdb->_gfx->getTile(_kcHolderBlueOn);
 	if (g_hdb->_map->checkOneTileExistInRange(_kcHolderRedOff, 2))
-		_animTiles.push_back(g_hdb->_gfx->getTile(_kcHolderRedOn));
+		g_hdb->_gfx->getTile(_kcHolderRedOn);
 	if (g_hdb->_map->checkOneTileExistInRange(_kcHolderGreenOff, 2))
-		_animTiles.push_back(g_hdb->_gfx->getTile(_kcHolderGreenOn));
+		g_hdb->_gfx->getTile(_kcHolderGreenOn);
 	if (g_hdb->_map->checkOneTileExistInRange(_kcHolderPurpleOff, 2))
-		_animTiles.push_back(g_hdb->_gfx->getTile(_kcHolderPurpleOn));
+		g_hdb->_gfx->getTile(_kcHolderPurpleOn);
 	if (g_hdb->_map->checkOneTileExistInRange(_kcHolderBlackOff, 2))
-		_animTiles.push_back(g_hdb->_gfx->getTile(_kcHolderBlackOn));
-}
-
-void AI::freeAnimInfo() {
-	for (uint i = 0; i < _animTiles.size(); i++)
-		delete _animTiles[i];
+		g_hdb->_gfx->getTile(_kcHolderBlackOn);
 }
 
 const char *AITypeStr[] = {
diff --git a/engines/hdb/ai.h b/engines/hdb/ai.h
index df888b1..83fe88b 100644
--- a/engines/hdb/ai.h
+++ b/engines/hdb/ai.h
@@ -821,7 +821,6 @@ public:
 	void save(Common::OutSaveFile *out);
 	void loadSaveFile(Common::InSaveFile *in);
 	void initAnimInfo();
-	void freeAnimInfo();
 
 	// Entity Functions
 	AIEntity *spawn(AIType type, AIDir dir, int x, int y, const char *funcInit, const char *funcAction, const char *funcUse, AIDir dir2, int level, int value1, int value2, int callInit);
@@ -1328,8 +1327,6 @@ public:
 	Tile *_gfxLaserbeamLRLeft[4];
 	Tile *_gfxLaserbeamLRRight[4];
 
-	Common::Array<Tile *> _animTiles;
-
 private:
 
 	// Action Functions
diff --git a/engines/hdb/gfx.cpp b/engines/hdb/gfx.cpp
index d3e5e75..e60a7ba 100644
--- a/engines/hdb/gfx.cpp
+++ b/engines/hdb/gfx.cpp
@@ -58,6 +58,10 @@ Gfx::~Gfx() {
 	for (int i = 0; i < _fontHeader.numChars; i++)
 		_fontSurfaces[i].free();
 	_globalSurface.free();
+	for (int i = 0; i < _numTiles; i++) {
+		delete _tLookupArray[i].tData;
+		_tLookupArray[i].tData = NULL;
+	}
 	delete[] _tLookupArray;
 	for (int i = 0; i < 8; i++)
 		delete _mousePointer[i];
@@ -459,7 +463,7 @@ void Gfx::emptyGfxCaches() {
 
 void Gfx::cacheTileSequence(int tileIndex, int count) {
 	for (int i = tileIndex; i < tileIndex + count; i++)
-		g_hdb->_ai->_animTiles.push_back(getTile(i));
+		getTile(i);
 }
 
 int Gfx::getTileIndex(const char *name) {
diff --git a/engines/hdb/menu.cpp b/engines/hdb/menu.cpp
index a3c6b8e..ffcf673 100644
--- a/engines/hdb/menu.cpp
+++ b/engines/hdb/menu.cpp
@@ -680,6 +680,9 @@ void Menu::freeMenu() {
 	if (_menuBackoutGfx)
 		delete _menuBackoutGfx;
 	_menuBackoutGfx = NULL;
+	if (_menuBackspaceGfx)
+		delete _menuBackspaceGfx;
+	_menuBackspaceGfx = NULL;
 
 	if (_controlButtonGfx)
 		delete _controlButtonGfx;


Commit: ae1f4efeb58d195acde7185fa4f71100449966be
    https://github.com/scummvm/scummvm/commit/ae1f4efeb58d195acde7185fa4f71100449966be
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:23+02:00

Commit Message:
HDB: Fix memory leaks in Menu

Changed paths:
    engines/hdb/menu.cpp
    engines/hdb/window.cpp


diff --git a/engines/hdb/menu.cpp b/engines/hdb/menu.cpp
index ffcf673..8d82283 100644
--- a/engines/hdb/menu.cpp
+++ b/engines/hdb/menu.cpp
@@ -27,6 +27,21 @@ namespace HDB {
 
 Menu::~Menu() {
 	freeMenu();
+
+	delete _gCheckEmpty;
+	delete _gCheckOff;
+	delete _gCheckOn;
+	delete _gCheckLeft;
+	delete _gCheckRight;
+
+	delete _contArrowUp;
+	delete _contArrowDown;
+	delete _contArrowLeft;
+	delete _contArrowRight;
+	delete _contAssign;
+
+	delete _warpPlaque;
+	delete _hdbLogoScreen;
 }
 
 bool Menu::init() {
diff --git a/engines/hdb/window.cpp b/engines/hdb/window.cpp
index b3e4b19..28faa21 100644
--- a/engines/hdb/window.cpp
+++ b/engines/hdb/window.cpp
@@ -418,6 +418,8 @@ void Window::restartSystem() {
 	_dialogChoiceInfo.active = false;
 	_invWinInfo.active = false;
 	_dialogDelay = _invWinInfo.selection = 0;
+	if (_gemGfx)
+		delete _gemGfx;
 	_gemGfx = g_hdb->_gfx->loadTile(GEM_WHITE_GFX);
 	_infobarDimmed = 0;
 }


Commit: bba1fa849bf88164f905ad5a017a9be51683610e
    https://github.com/scummvm/scummvm/commit/bba1fa849bf88164f905ad5a017a9be51683610e
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:23+02:00

Commit Message:
HDB: Fix loading

Changed paths:
    engines/hdb/ai-init.cpp
    engines/hdb/lua-script.cpp


diff --git a/engines/hdb/ai-init.cpp b/engines/hdb/ai-init.cpp
index 0471a05..23cfe2d 100644
--- a/engines/hdb/ai-init.cpp
+++ b/engines/hdb/ai-init.cpp
@@ -1677,24 +1677,29 @@ void AI::loadSaveFile(Common::InSaveFile *in) {
 	}
 
 	// Load AnimTargets
-	_animTargets.resize(in->readUint32LE());
-	for (i = 0; (uint)i < _animTargets.size(); i++) {
-		_animTargets[i]->x = in->readUint16LE();
-		_animTargets[i]->y = in->readUint16LE();
-		_animTargets[i]->start = in->readUint16LE();
-		_animTargets[i]->end = in->readUint16LE();
-		_animTargets[i]->vel = in->readSint16LE();
-		_animTargets[i]->animCycle = in->readUint16LE();
-		_animTargets[i]->animFrame = in->readUint16LE();
-		_animTargets[i]->killAuto = in->readByte();
-		_animTargets[i]->inMap = in->readByte();
-		memset(_animTargets[i]->gfxList, 0, kMaxAnimTFrames * sizeof(Tile *));
+	uint32 animTsize = in->readUint32LE();
+	_animTargets.clear();
+	for (i = 0; i < animTsize; i++) {
+		AnimTarget *a = new AnimTarget;
+
+		a->x = in->readUint16LE();
+		a->y = in->readUint16LE();
+		a->start = in->readUint16LE();
+		a->end = in->readUint16LE();
+		a->vel = in->readSint16LE();
+		a->animCycle = in->readUint16LE();
+		a->animFrame = in->readUint16LE();
+		a->killAuto = in->readByte();
+		a->inMap = in->readByte();
+		memset(a->gfxList, 0, kMaxAnimTFrames * sizeof(Tile *));
+
+		_animTargets.push_back(a);
 	}
 
 	// Load ArrowPaths
 
-	uint32 arrowPathSIze = in->readUint32LE();
-	for (i = 0; (uint)i < arrowPathSIze; i++) {
+	uint32 arrowPathSize = in->readUint32LE();
+	for (i = 0; (uint)i < arrowPathSize; i++) {
 		ArrowPath *arrowPath = new ArrowPath;
 
 		arrowPath->type = in->readUint16LE();
@@ -1706,11 +1711,15 @@ void AI::loadSaveFile(Common::InSaveFile *in) {
 	}
 
 	// Load HereT List
-	_hereList->resize(in->readUint32LE());
-	for (i = 0; (uint)i < _hereList->size(); i++) {
-		_hereList->operator[](i)->x = in->readUint16LE();
-		_hereList->operator[](i)->y = in->readUint16LE();
-		in->read(_hereList->operator[](i)->entName, 32);
+	uint32 hereSize = in->readUint32LE();
+	_hereList->clear();
+	for (i = 0; i < hereSize; i++) {
+		HereT *h = new HereT;
+		h->x = in->readUint16LE();
+		h->y = in->readUint16LE();
+		in->read(h->entName, 32);
+
+		_hereList->push_back(h);
 	}
 
 	// Load Triggers
diff --git a/engines/hdb/lua-script.cpp b/engines/hdb/lua-script.cpp
index 5c2906b..f9e8452 100644
--- a/engines/hdb/lua-script.cpp
+++ b/engines/hdb/lua-script.cpp
@@ -182,12 +182,16 @@ void LuaScript::loadSaveFile(Common::InSaveFile *in, const char *fName) {
 	_globals.clear();
 
 	// Start reading globals
-	_globals.resize(in->readUint32LE());
-	for (uint i = 0; i < _globals.size(); i++) {
-		in->read(_globals[i]->global, 32);
-		_globals[i]->valueOrString = in->readSint32LE();
-		_globals[i]->value = in->readDoubleLE();
-		in->read(_globals[i]->string, 32);
+	uint32 globalsSize = in->readUint32LE();
+	for (uint i = 0; i < globalsSize; i++) {
+		Global *g = new Global;
+
+		in->read(g->global, 32);
+		g->valueOrString = in->readSint32LE();
+		g->value = in->readDoubleLE();
+		in->read(g->string, 32);
+
+		_globals.push_back(g);
 	}
 
 	lua_getglobal(_state, "LoadState");


Commit: cea2285db1bd87864639271ec8555d50d0908f3b
    https://github.com/scummvm/scummvm/commit/cea2285db1bd87864639271ec8555d50d0908f3b
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:23+02:00

Commit Message:
HDB: Remove redundant frees

ManagedSurface takes care of freeing itself

Changed paths:
    engines/hdb/gfx.cpp


diff --git a/engines/hdb/gfx.cpp b/engines/hdb/gfx.cpp
index e60a7ba..05adecb 100644
--- a/engines/hdb/gfx.cpp
+++ b/engines/hdb/gfx.cpp
@@ -1057,7 +1057,6 @@ Picture::Picture() : _width(0), _height(0), _name("") {
 }
 
 Picture::~Picture() {
-	_surface.free();
 }
 
 Graphics::Surface Picture::load(Common::SeekableReadStream *stream) {
@@ -1115,7 +1114,6 @@ Tile::Tile() : _flags(0), _name("") {
 }
 
 Tile::~Tile() {
-	_surface.free();
 }
 
 Graphics::Surface Tile::load(Common::SeekableReadStream *stream) {


Commit: 927770f34b6a15bf1c125ee2e1d668e8577169db
    https://github.com/scummvm/scummvm/commit/927770f34b6a15bf1c125ee2e1d668e8577169db
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:23+02:00

Commit Message:
HDB: Initialise class variables

Changed paths:
    engines/hdb/ai-init.cpp
    engines/hdb/menu.cpp
    engines/hdb/menu.h


diff --git a/engines/hdb/ai-init.cpp b/engines/hdb/ai-init.cpp
index 23cfe2d..73987c7 100644
--- a/engines/hdb/ai-init.cpp
+++ b/engines/hdb/ai-init.cpp
@@ -912,6 +912,43 @@ AI::AI() {
 	_clubUpFrames = 0;
 	_clubLeftFrames = 0;
 	_clubRightFrames = 0;
+
+	memset(&_inventory, 0, sizeof(InvEnt) * kMaxInventory);
+
+	// Free Player Graphics
+	for (int i = 0; i < 8; i++)
+		_slugAttackGfx[i] = NULL;
+
+	_weaponSelGfx = NULL;
+	_weaponGfx = NULL;
+
+	memset(_clubDownGfx, 0, sizeof(_clubDownGfx));
+	memset(_clubUpGfx, 0, sizeof(_clubUpGfx));
+	memset(_clubLeftGfx, 0, sizeof(_clubLeftGfx));
+	memset(_clubRightGfx, 0, sizeof(_clubRightGfx));
+	memset(_slugAttackGfx, 0, sizeof(_slugAttackGfx));
+	memset(_pushdownGfx, 0, sizeof(_pushdownGfx));
+	memset(_pushupGfx, 0, sizeof(_pushupGfx));
+	memset(_pushleftGfx, 0, sizeof(_pushleftGfx));
+	memset(_pushrightGfx, 0, sizeof(_pushrightGfx));
+	memset(_stunDownGfx, 0, sizeof(_stunDownGfx));
+	memset(_stunUpGfx, 0, sizeof(_stunUpGfx));
+	memset(_stunLeftGfx, 0, sizeof(_stunLeftGfx));
+	memset(_stunRightGfx, 0, sizeof(_stunRightGfx));
+	memset(_slugDownGfx, 0, sizeof(_slugDownGfx));
+	memset(_slugUpGfx, 0, sizeof(_slugUpGfx));
+	memset(_slugLeftGfx, 0, sizeof(_slugLeftGfx));
+	memset(_slugRightGfx, 0, sizeof(_slugRightGfx));
+
+	memset(_horrible1Gfx, 0, sizeof(_horrible1Gfx));
+	memset(_horrible2Gfx, 0, sizeof(_horrible2Gfx));
+	memset(_horrible3Gfx, 0, sizeof(_horrible3Gfx));
+	memset(_horrible4Gfx, 0, sizeof(_horrible4Gfx));
+	memset(_plummetGfx, 0, sizeof(_plummetGfx));
+	memset(_dyingGfx, 0, sizeof(_dyingGfx));
+
+	memset(_waypointGfx, 0, sizeof(_waypointGfx));
+	_debugQMark = NULL;
 }
 
 AI::~AI() {
@@ -952,31 +989,6 @@ AI::~AI() {
 		_weaponGfx = NULL;
 	}
 
-	memset(_clubDownGfx, 0, sizeof(_clubDownGfx));
-	memset(_clubUpGfx, 0, sizeof(_clubUpGfx));
-	memset(_clubLeftGfx, 0, sizeof(_clubLeftGfx));
-	memset(_clubRightGfx, 0, sizeof(_clubRightGfx));
-	memset(_slugAttackGfx, 0, sizeof(_slugAttackGfx));
-	memset(_pushdownGfx, 0, sizeof(_pushdownGfx));
-	memset(_pushupGfx, 0, sizeof(_pushupGfx));
-	memset(_pushleftGfx, 0, sizeof(_pushleftGfx));
-	memset(_pushrightGfx, 0, sizeof(_pushrightGfx));
-	memset(_stunDownGfx, 0, sizeof(_stunDownGfx));
-	memset(_stunUpGfx, 0, sizeof(_stunUpGfx));
-	memset(_stunLeftGfx, 0, sizeof(_stunLeftGfx));
-	memset(_stunRightGfx, 0, sizeof(_stunRightGfx));
-	memset(_slugDownGfx, 0, sizeof(_slugDownGfx));
-	memset(_slugUpGfx, 0, sizeof(_slugUpGfx));
-	memset(_slugLeftGfx, 0, sizeof(_slugLeftGfx));
-	memset(_slugRightGfx, 0, sizeof(_slugRightGfx));
-
-	memset(_horrible1Gfx, 0, sizeof(_horrible1Gfx));
-	memset(_horrible2Gfx, 0, sizeof(_horrible2Gfx));
-	memset(_horrible3Gfx, 0, sizeof(_horrible3Gfx));
-	memset(_horrible4Gfx, 0, sizeof(_horrible4Gfx));
-	memset(_plummetGfx, 0, sizeof(_plummetGfx));
-	memset(_dyingGfx, 0, sizeof(_dyingGfx));
-
 	for (int i = 0; i < 4; i++)
 		delete _waypointGfx[i];
 	memset(_waypointGfx, 0, sizeof(_waypointGfx));
diff --git a/engines/hdb/menu.cpp b/engines/hdb/menu.cpp
index 8d82283..6e98900 100644
--- a/engines/hdb/menu.cpp
+++ b/engines/hdb/menu.cpp
@@ -25,26 +25,7 @@
 
 namespace HDB {
 
-Menu::~Menu() {
-	freeMenu();
-
-	delete _gCheckEmpty;
-	delete _gCheckOff;
-	delete _gCheckOn;
-	delete _gCheckLeft;
-	delete _gCheckRight;
-
-	delete _contArrowUp;
-	delete _contArrowDown;
-	delete _contArrowLeft;
-	delete _contArrowRight;
-	delete _contAssign;
-
-	delete _warpPlaque;
-	delete _hdbLogoScreen;
-}
-
-bool Menu::init() {
+Menu::Menu() {
 	_starWarp = 0;
 	_rocketEx = 0;
 	_titleActive = false;
@@ -70,6 +51,87 @@ bool Menu::init() {
 	_keyAssignRight = Common::KEYCODE_RIGHT;
 	_keyAssignUse = Common::KEYCODE_RETURN;
 
+	_gCheckEmpty = NULL;
+	_gCheckOff = NULL;
+	_gCheckOn = NULL;
+	_gCheckLeft = NULL;
+	_gCheckRight = NULL;
+
+	_contArrowUp = NULL;
+	_contArrowDown = NULL;
+	_contArrowLeft = NULL;
+	_contArrowRight = NULL;
+	_contAssign = NULL;
+
+	_waitingForKey = false;
+	_warpPlaque = NULL;
+	_hdbLogoScreen = NULL;
+
+	_titleScreen = NULL;
+	_oohOohGfx = NULL;
+	_newGfx = NULL;
+	_loadGfx = NULL;
+	_optionsGfx = NULL;
+	_quitGfx = NULL;
+	_resumeGfx = NULL;
+	_slotGfx = NULL;
+	_rocketMain = NULL;
+	_rocketSecond = NULL;
+	_rocketEx1 = NULL;
+	_rocketEx2 = NULL;
+	_titleLogo = NULL;
+	_hdbLogoScreen = NULL;
+	for (int i = 0; i < kNebulaCount; i++)
+		_nebulaGfx[i] = NULL;
+
+	_sliderLeft = NULL;
+	_sliderMid = NULL;
+	_sliderRight = NULL;
+	_sliderKnob = NULL;
+	_modePuzzleGfx = NULL;
+	_modeActionGfx = NULL;
+	_modeLoadGfx = NULL;
+	_modeSaveGfx = NULL;
+	_menuBackoutGfx = NULL;
+	_menuBackspaceGfx = NULL;
+
+	_controlButtonGfx = NULL;
+
+	_controlsGfx = NULL;
+
+	_vortexian[0] = _vortexian[1] = _vortexian[2] = NULL;
+
+	_star[0] = _star[1] = _star[2] = NULL;
+
+	// secret stars
+	_starRedGfx[0] = _starRedGfx[1] = NULL;
+	_starGreenGfx[0] = _starGreenGfx[1] = NULL;
+	_starBlueGfx[0] = _starBlueGfx[1] = NULL;
+
+	_versionGfx = NULL;
+	_warpGfx = NULL;
+}
+
+Menu::~Menu() {
+	freeMenu();
+
+	delete _gCheckEmpty;
+	delete _gCheckOff;
+	delete _gCheckOn;
+	delete _gCheckLeft;
+	delete _gCheckRight;
+
+	delete _contArrowUp;
+	delete _contArrowDown;
+	delete _contArrowLeft;
+	delete _contArrowRight;
+	delete _contAssign;
+
+	delete _warpPlaque;
+	delete _hdbLogoScreen;
+}
+
+bool Menu::init() {
 	_gCheckEmpty = g_hdb->_gfx->loadPic(G_CHECK_EMPTY);
 	_gCheckOff = g_hdb->_gfx->loadPic(G_CHECK_OFF);
 	_gCheckOn = g_hdb->_gfx->loadPic(G_CHECK_ON);
@@ -82,7 +144,6 @@ bool Menu::init() {
 	_contArrowRight = g_hdb->_gfx->loadPic(CTRL_ARROWRIGHT);
 	_contAssign = g_hdb->_gfx->loadPic(CTRL_ASSIGN);
 
-	_waitingForKey = false;
 	_warpPlaque = g_hdb->_gfx->loadPic(WARP_PLAQUE);
 	_hdbLogoScreen = g_hdb->_gfx->loadPic(TITLESCREEN);
 
diff --git a/engines/hdb/menu.h b/engines/hdb/menu.h
index 006ee7a..a17d2cb 100644
--- a/engines/hdb/menu.h
+++ b/engines/hdb/menu.h
@@ -152,6 +152,7 @@ struct Star {
 class Menu {
 public:
 
+	Menu();
 	~Menu();
 
 	bool init();


Commit: 8a80cc77e931fff438e14f05db527d2efc9d372d
    https://github.com/scummvm/scummvm/commit/8a80cc77e931fff438e14f05db527d2efc9d372d
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:24+02:00

Commit Message:
HDB: Add warnings

Changed paths:
    engines/hdb/input.cpp
    engines/hdb/menu.cpp
    engines/hdb/window.h


diff --git a/engines/hdb/input.cpp b/engines/hdb/input.cpp
index a49e6a2..b8f9660 100644
--- a/engines/hdb/input.cpp
+++ b/engines/hdb/input.cpp
@@ -49,9 +49,6 @@ bool Input::init() {
 
 void Input::setButtons(uint16 b) {
 	static int changeState = 0;
-	static int drawDlg = 0;
-	static int quit = 0;
-	static int debugOn = 0;
 
 	_buttons = b;
 	if (!b)
diff --git a/engines/hdb/menu.cpp b/engines/hdb/menu.cpp
index 6e98900..83bfdbd 100644
--- a/engines/hdb/menu.cpp
+++ b/engines/hdb/menu.cpp
@@ -514,7 +514,6 @@ void Menu::drawMenu() {
 			//
 			// Options menu content
 			//
-			static	int		hand_off, hand_yvel = 1;
 
 			drawNebula();
 			_optionsGfx->drawMasked(centerPic(_optionsGfx), _oBannerY);
@@ -836,7 +835,6 @@ bool Menu::startTitle() {
 }
 
 void Menu::drawTitle() {
-	static int	line;
 	static uint32 time;
 
 	//sound.UpdateMusic();
diff --git a/engines/hdb/window.h b/engines/hdb/window.h
index dac81e2..e230477 100644
--- a/engines/hdb/window.h
+++ b/engines/hdb/window.h
@@ -325,10 +325,8 @@ private:
 	Picture *_gGfxL, *_gGfxM, *_gGfxR;
 	Picture *_gGfxBL, *_gGfxBM, *_gGfxBR;
 	Picture *_gGfxTitleL, *_gGfxTitleM, *_gGfxTitleR;
-	Picture *_gfxResources, *_gfxDeliveries;
 	Picture *_gfxIndent, *_gfxArrowTo, *_gfxHandright;
 	Picture *_gfxTry, *_gfxAgain, *_gfxInvSelect;
-	Tile *_gfxMonkeystone;
 	Picture *_gfxLevelRestart, *_gfxPausePlaque;
 	Tile *_gemGfx;
 	Picture *_mstoneGfx;


Commit: 72dbb6074dc3f9f8537a9d98596bb0a4298c7a8c
    https://github.com/scummvm/scummvm/commit/72dbb6074dc3f9f8537a9d98596bb0a4298c7a8c
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:24+02:00

Commit Message:
HDB: Fix uninitialized read

Changed paths:
    engines/hdb/window.cpp


diff --git a/engines/hdb/window.cpp b/engines/hdb/window.cpp
index 28faa21..343f3eb 100644
--- a/engines/hdb/window.cpp
+++ b/engines/hdb/window.cpp
@@ -130,6 +130,8 @@ bool Window::init() {
 	_dlvsInfo.x = (kScreenWidth - _gfxInfobar->_width) + 16;
 	_dlvsInfo.y = 272;
 
+	_gemGfx = NULL;
+
 	restartSystem();
 
 	return true;


Commit: 9e1f792751eeba9606a566447d1a7ac6008fb65a
    https://github.com/scummvm/scummvm/commit/9e1f792751eeba9606a566447d1a7ac6008fb65a
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:24+02:00

Commit Message:
HDB: Differentiate Debug messages

Changed paths:
    engines/hdb/lua-script.cpp


diff --git a/engines/hdb/lua-script.cpp b/engines/hdb/lua-script.cpp
index f9e8452..cb55176 100644
--- a/engines/hdb/lua-script.cpp
+++ b/engines/hdb/lua-script.cpp
@@ -1872,7 +1872,7 @@ bool LuaScript::callFunction(const char *name, int returns) {
 	lua_getglobal(_state, name);
 
 	if (lua_pcall(_state, 0, returns, -2)) {
-		error("An error occured while executing \"%s\": %s.", name, lua_tostring(_state, -1));
+		error("callFunction: An error occured while executing \"%s\": %s.", name, lua_tostring(_state, -1));
 		lua_pop(_state, -1);
 
 		return false;
@@ -1990,7 +1990,7 @@ bool LuaScript::executeChunk(Common::String &chunk, const Common::String &chunkN
 
 	// Execute Chunk
 	if (lua_pcall(_state, 0, 0, -2)) {
-		error("An error occured while executing \"%s\": %s.", chunkName.c_str(), lua_tostring(_state, -1));
+		error("executeChunk: An error occured while executing \"%s\": %s.", chunkName.c_str(), lua_tostring(_state, -1));
 		lua_pop(_state, -1);
 
 		return false;


Commit: 1b6b2a96a06d84cd8c2c162101ee94b221552413
    https://github.com/scummvm/scummvm/commit/1b6b2a96a06d84cd8c2c162101ee94b221552413
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:24+02:00

Commit Message:
HDB: Fix warnings

Changed paths:
    engines/hdb/ai-init.cpp


diff --git a/engines/hdb/ai-init.cpp b/engines/hdb/ai-init.cpp
index 73987c7..61cbafc 100644
--- a/engines/hdb/ai-init.cpp
+++ b/engines/hdb/ai-init.cpp
@@ -1691,7 +1691,7 @@ void AI::loadSaveFile(Common::InSaveFile *in) {
 	// Load AnimTargets
 	uint32 animTsize = in->readUint32LE();
 	_animTargets.clear();
-	for (i = 0; i < animTsize; i++) {
+	for (uint32 j = 0; j < animTsize; j++) {
 		AnimTarget *a = new AnimTarget;
 
 		a->x = in->readUint16LE();
@@ -1725,7 +1725,7 @@ void AI::loadSaveFile(Common::InSaveFile *in) {
 	// Load HereT List
 	uint32 hereSize = in->readUint32LE();
 	_hereList->clear();
-	for (i = 0; i < hereSize; i++) {
+	for (uint32 j = 0; j < hereSize; j++) {
 		HereT *h = new HereT;
 		h->x = in->readUint16LE();
 		h->y = in->readUint16LE();


Commit: 31ec40a91a16c501c39cbed8fd1d16cd042e4458
    https://github.com/scummvm/scummvm/commit/31ec40a91a16c501c39cbed8fd1d16cd042e4458
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:24+02:00

Commit Message:
HDB: Fix checkActionList()

Changed paths:
    engines/hdb/ai-lists.cpp
    engines/hdb/ai.h


diff --git a/engines/hdb/ai-lists.cpp b/engines/hdb/ai-lists.cpp
index 2b122f4..f3b087e 100644
--- a/engines/hdb/ai-lists.cpp
+++ b/engines/hdb/ai-lists.cpp
@@ -259,14 +259,14 @@ int AI::checkFairystones(int tileX, int tileY) {
 
 // Add an action location to the list of possible actions
 // Each action must be paired with another of the same number
-void AI::addToActionList(int actionIndex, int x, int y, char *luaFuncInt, char *luaFuncUse) {
+void AI::addToActionList(int actionIndex, int x, int y, char *luaFuncInit, char *luaFuncUse) {
 
 	if (!_actions[actionIndex].x1) {
 		_actions[actionIndex].x1 = x;
 		_actions[actionIndex].y1 = y;
-		if (luaFuncInt[0] != '*')
-			strcpy(_actions[actionIndex].luaFuncInit, luaFuncInt);
-		if (luaFuncInt[0] != '*')
+		if (luaFuncInit[0] != '*')
+			strcpy(_actions[actionIndex].luaFuncInit, luaFuncInit);
+		if (luaFuncUse[0] != '*')
 			strcpy(_actions[actionIndex].luaFuncUse, luaFuncUse);
 
 		if (_actions[actionIndex].luaFuncInit[0]) {
@@ -280,9 +280,9 @@ void AI::addToActionList(int actionIndex, int x, int y, char *luaFuncInt, char *
 	if (!_actions[actionIndex].x2) {
 		_actions[actionIndex].x2 = x;
 		_actions[actionIndex].y2 = y;
-		if (luaFuncInt[0] != '*')
-			strcpy(_actions[actionIndex].luaFuncInit, luaFuncInt);
-		if (luaFuncInt[0] != '*')
+		if (luaFuncInit[0] != '*')
+			strcpy(_actions[actionIndex].luaFuncInit, luaFuncInit);
+		if (luaFuncUse[0] != '*')
 			strcpy(_actions[actionIndex].luaFuncUse, luaFuncUse);
 
 		if (_actions[actionIndex].luaFuncInit[0]) {
@@ -328,8 +328,10 @@ bool AI::checkActionList(AIEntity *e, int x, int y, bool lookAndGrab) {
 				_actions[i].x1 = _actions[i].y1 = _actions[i].x2 = _actions[i].y2 = 0;
 
 				// Call Lua Use function if it exists
-				if (_actions[i].luaFuncUse[0])
+				if (_actions[i].luaFuncUse[0]) {
 					g_hdb->_lua->callFunction(_actions[i].luaFuncUse, 0);
+				}
+
 			} else if (e == _player && !checkForTouchplate(x, y))
 				addWaypoint(e->tileX, e->tileY, x, y, e->level);
 
diff --git a/engines/hdb/ai.h b/engines/hdb/ai.h
index 83fe88b..bb86222 100644
--- a/engines/hdb/ai.h
+++ b/engines/hdb/ai.h
@@ -881,7 +881,7 @@ public:
 	bool checkActionList(AIEntity *e, int x, int y, bool lookAndGrab);
 	void addToHereList(const char *entName, int x, int y);
 	HereT *findHere(int x, int y);
-	void addToAutoList(int x, int y, const char *luaFuncInt, const char *luaFuncUse);
+	void addToAutoList(int x, int y, const char *luaFuncInit, const char *luaFuncUse);
 	void autoDeactivate(int x, int y);
 	bool activateAction(AIEntity *e, int x, int y, int targetX, int targetY);
 	bool checkAutoList(AIEntity *e, int x, int y);


Commit: 9d45057630a7351afb642a8bce96bfaa86dc4aa2
    https://github.com/scummvm/scummvm/commit/9d45057630a7351afb642a8bce96bfaa86dc4aa2
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:24+02:00

Commit Message:
HDB: Add Debug Output for Actions List

Changed paths:
    engines/hdb/hdb.cpp
    engines/hdb/saveload.cpp


diff --git a/engines/hdb/hdb.cpp b/engines/hdb/hdb.cpp
index c8b0185..d2b874b 100644
--- a/engines/hdb/hdb.cpp
+++ b/engines/hdb/hdb.cpp
@@ -238,6 +238,14 @@ bool HDBGame::restartMap() {
 
 	warning("STUB: Cheating - Lua Validation");
 
+	debug(1, "Action List Info:");
+	for (int k = 0; k < 20; k++) {
+		debug(1, "Action %d: entityName: %s", k, _ai->_actions[k].entityName);
+		debug(1, "Action %d: x1: %d, y1: %d", k, _ai->_actions[k].x1, _ai->_actions[k].y1);
+		debug(1, "Action %d: x2: %d, y2: %d", k, _ai->_actions[k].x2, _ai->_actions[k].y2);
+		debug(1, "Action %d: luaFuncInit: %s, luaFuncUse: %s", k, _ai->_actions[k].luaFuncInit, _ai->_actions[k].luaFuncUse);
+	}
+
 	return true;
 }
 
diff --git a/engines/hdb/saveload.cpp b/engines/hdb/saveload.cpp
index 548f68c..1c385b7 100644
--- a/engines/hdb/saveload.cpp
+++ b/engines/hdb/saveload.cpp
@@ -104,6 +104,14 @@ Common::Error HDBGame::loadGameState(int slot) {
 	if (!_ai->cinematicsActive())
 		_gfx->turnOffFade();
 
+	debug(1, "Action List Info:");
+	for (int k = 0; k < 20; k++) {
+		debug(1, "Action %d: entityName: %s", k, _ai->_actions[k].entityName);
+		debug(1, "Action %d: x1: %d, y1: %d", k, _ai->_actions[k].x1, _ai->_actions[k].y1);
+		debug(1, "Action %d: x2: %d, y2: %d", k, _ai->_actions[k].x2, _ai->_actions[k].y2);
+		debug(1, "Action %d: luaFuncInit: %s, luaFuncUse: %s", k, _ai->_actions[k].luaFuncInit, _ai->_actions[k].luaFuncUse);
+	}
+
 	return Common::kNoError;
 }
 


Commit: 6d3856cd9405eb9246c53ce2d345e6b59bd316da
    https://github.com/scummvm/scummvm/commit/6d3856cd9405eb9246c53ce2d345e6b59bd316da
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:24+02:00

Commit Message:
HDB: Add Patches for Map10

Changed paths:
    engines/hdb/lua-script.cpp


diff --git a/engines/hdb/lua-script.cpp b/engines/hdb/lua-script.cpp
index cb55176..3f49df9 100644
--- a/engines/hdb/lua-script.cpp
+++ b/engines/hdb/lua-script.cpp
@@ -54,6 +54,8 @@ struct ScriptPatch {
 	{"MAP01.LUA", "if( covert_index < getn(covert_dialog) ) then", "if( covert_index < #covert_dialog ) then"},
 	{"MAP01.LUA", "if( chiste_index < getn( chiste_dialog ) )then", "if( covert_index < #covert_dialog ) then"},
 	{"MAP01.LUA", "strsub(", "string.sub("}, // line 23
+	{"MAP10.LUA", "emptybed_use( %x, %y, %v1, %v2 )", "emptybed_use( x, y, v1, v2 )"},
+	{"MAP10.LUA", "if( getn( beds ) == 0 ) then", "if( #beds == 0 ) then"},
 	{NULL, NULL, NULL},
 };
 


Commit: c10034df933b4213ff89bc28757d64831d8c5873
    https://github.com/scummvm/scummvm/commit/c10034df933b4213ff89bc28757d64831d8c5873
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:24+02:00

Commit Message:
HDB: Fix warning

Changed paths:
    engines/hdb/ai-init.cpp


diff --git a/engines/hdb/ai-init.cpp b/engines/hdb/ai-init.cpp
index 61cbafc..b0e27f3 100644
--- a/engines/hdb/ai-init.cpp
+++ b/engines/hdb/ai-init.cpp
@@ -1524,7 +1524,7 @@ void AI::save(Common::OutSaveFile *out) {
 }
 
 void AI::loadSaveFile(Common::InSaveFile *in) {
-	int i, j;
+	int i;
 
 	// Clean everything out
 	restartSystem();
@@ -1666,7 +1666,7 @@ void AI::loadSaveFile(Common::InSaveFile *in) {
 
 		// Clear out all ptrs in entity before writing out
 
-		for (j = 0; j < kMaxAnimFrames; j++)
+		for (int j = 0; j < kMaxAnimFrames; j++)
 			temp->blinkGfx[j] = temp->movedownGfx[j] = temp->moveupGfx[j] =
 			temp->moveleftGfx[j] = temp->moverightGfx[j] = temp->standdownGfx[j] =
 			temp->standupGfx[j] = temp->standleftGfx[j] = temp->standrightGfx[j] =


Commit: f02bc1da84a722d74835ff289babd8ee4713ca08
    https://github.com/scummvm/scummvm/commit/f02bc1da84a722d74835ff289babd8ee4713ca08
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:24+02:00

Commit Message:
HDB: Add Lua Patch for Map11

Changed paths:
    engines/hdb/lua-script.cpp


diff --git a/engines/hdb/lua-script.cpp b/engines/hdb/lua-script.cpp
index 3f49df9..eb62114 100644
--- a/engines/hdb/lua-script.cpp
+++ b/engines/hdb/lua-script.cpp
@@ -56,6 +56,7 @@ struct ScriptPatch {
 	{"MAP01.LUA", "strsub(", "string.sub("}, // line 23
 	{"MAP10.LUA", "emptybed_use( %x, %y, %v1, %v2 )", "emptybed_use( x, y, v1, v2 )"},
 	{"MAP10.LUA", "if( getn( beds ) == 0 ) then", "if( #beds == 0 ) then"},
+	{"MAP11.LUA", "mapstring = strsub( LASTMAP, 1, 5 )", "mapstring = string.sub( LASTMAP, 1, 5 )"},
 	{NULL, NULL, NULL},
 };
 


Commit: ada43165a17ae817c94e9d84e49be6d05235b99f
    https://github.com/scummvm/scummvm/commit/ada43165a17ae817c94e9d84e49be6d05235b99f
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:24+02:00

Commit Message:
HDB: Animate Bridges

Changed paths:
    engines/hdb/hdb.cpp


diff --git a/engines/hdb/hdb.cpp b/engines/hdb/hdb.cpp
index d2b874b..8eb06c1 100644
--- a/engines/hdb/hdb.cpp
+++ b/engines/hdb/hdb.cpp
@@ -929,6 +929,7 @@ Common::Error HDBGame::run() {
 
 			if (!_pauseFlag) {
 				_ai->moveEnts();
+				_ai->animateBridges();
 				_ai->processCallbackList();
 			}
 


Commit: 442835b55573855a9aac8495388ec8406c130fd3
    https://github.com/scummvm/scummvm/commit/442835b55573855a9aac8495388ec8406c130fd3
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:24+02:00

Commit Message:
HDB: Added script patch from MAP21.LUA

Changed paths:
    engines/hdb/lua-script.cpp


diff --git a/engines/hdb/lua-script.cpp b/engines/hdb/lua-script.cpp
index eb62114..26cd388 100644
--- a/engines/hdb/lua-script.cpp
+++ b/engines/hdb/lua-script.cpp
@@ -57,7 +57,8 @@ struct ScriptPatch {
 	{"MAP10.LUA", "emptybed_use( %x, %y, %v1, %v2 )", "emptybed_use( x, y, v1, v2 )"},
 	{"MAP10.LUA", "if( getn( beds ) == 0 ) then", "if( #beds == 0 ) then"},
 	{"MAP11.LUA", "mapstring = strsub( LASTMAP, 1, 5 )", "mapstring = string.sub( LASTMAP, 1, 5 )"},
-	{NULL, NULL, NULL},
+	{"MAP21.LUA", "mapstring = strsub( LASTMAP, 1, 5 )", "mapstring = string.sub( LASTMAP, 1, 5 )"}, // line 105
+	{NULL, NULL, NULL}
 };
 
 LuaScript::LuaScript() {


Commit: 22a9c9ef5cd2d4ba914771e649872e70479dbaa2
    https://github.com/scummvm/scummvm/commit/22a9c9ef5cd2d4ba914771e649872e70479dbaa2
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:24+02:00

Commit Message:
HDB: Added line references to the script patches

Changed paths:
    engines/hdb/lua-script.cpp


diff --git a/engines/hdb/lua-script.cpp b/engines/hdb/lua-script.cpp
index 26cd388..cd2bf0b 100644
--- a/engines/hdb/lua-script.cpp
+++ b/engines/hdb/lua-script.cpp
@@ -34,29 +34,29 @@ struct ScriptPatch {
 	const char *search;
 	const char *replace;
 } scriptPatches[] = {
-	{"GLOBAL.LUA", "for i,npc in npcs do", "for i,npc in pairs(npcs) do"},
-	{"GLOBAL.LUA", "setglobal( npcdef.codename..\"_init\", function() return NPC_Init( %npcdef ) end )", "_G[npcdef.codename .. \"_init\"] = function() return NPC_Init( npcdef ) end"},
-	{"GLOBAL.LUA", "setglobal( npcdef.codename..\"_use\", function(x, y, v1, v2) return NPC_Use( %npcdef, x, y, v1, v2 ) end )", "_G[npcdef.codename .. \"_use\"] = function(x, y, v1, v2) return NPC_Use( npcdef, x, y, v1, v2 ) end"},
-	{"GLOBAL.LUA", "if( dtable.counter < getn(dtable) ) then", "if( dtable.counter < #dtable ) then"},
-	{"GLOBAL.LUA", "if( getglobal( \"map\"..tostring(v1)..\"_complete\" ) ) then", "if( _G[\"map\"..tostring(v1)..\"_complete\"] ) then"},
-	{"GLOBAL.LUA", "closefunc = getglobal( npcdef.codename..\"_use\" )", "closefunc = _G[npcdef.codename..\"_use\"]"},
+	{"GLOBAL.LUA", "for i,npc in npcs do", "for i,npc in pairs(npcs) do"}, // 323
+	{"GLOBAL.LUA", "setglobal( npcdef.codename..\"_init\", function() return NPC_Init( %npcdef ) end )", "_G[npcdef.codename .. \"_init\"] = function() return NPC_Init( npcdef ) end"}, // line 317
+	{"GLOBAL.LUA", "setglobal( npcdef.codename..\"_use\", function(x, y, v1, v2) return NPC_Use( %npcdef, x, y, v1, v2 ) end )", "_G[npcdef.codename .. \"_use\"] = function(x, y, v1, v2) return NPC_Use( npcdef, x, y, v1, v2 ) end"}, // line 318
+	{"GLOBAL.LUA", "if( dtable.counter < getn(dtable) ) then", "if( dtable.counter < #dtable ) then"}, // line 254
+	{"GLOBAL.LUA", "if( getglobal( \"map\"..tostring(v1)..\"_complete\" ) ) then", "if( _G[\"map\"..tostring(v1)..\"_complete\"] ) then"}, // line 219
+	{"GLOBAL.LUA", "closefunc = getglobal( npcdef.codename..\"_use\" )", "closefunc = _G[npcdef.codename..\"_use\"]"}, // line 272
 	{"GLOBAL.LUA", "strsub(", "string.sub("}, // line 15
-	{"GLOBAL.LUA", "for i,v in globals() do", "for i,v in pairs(_G) do"},
-	{"GLOBAL.LUA", "return gsub( s, \"\\n\", \"\\\\\\n\" )", "return string.gsub( s, \"\\n\", \"\\\\\\n\" )"},
-	{"GLOBAL.LUA", "for i,v in t do", "for i,v in pairs(t) do"},
+	{"GLOBAL.LUA", "for i,v in globals() do", "for i,v in pairs(_G) do"}, // line 52
+	{"GLOBAL.LUA", "return gsub( s, \"\\n\", \"\\\\\\n\" )", "return string.gsub( s, \"\\n\", \"\\\\\\n\" )"}, // line 10
+	{"GLOBAL.LUA", "for i,v in t do", "for i,v in pairs(t) do"},  // line 43
 	{"GLOBAL.LUA", "if type(v) == 'userdata' or type(v) == 'function' then return end", "if type(v) == 'userdata' or type(v) == 'function' or i == 'package' or i == 'os' or i == 'io' or i == 'string' or i == 'table' or i == 'debug' or i == 'math' or i == 'coroutine' then return end" }, // Line 16
 	{"GLOBAL.LUA", "for npcname,npcdata in npcs do", "for npcname,npcdata in pairs(npcs) do"}, // Line 66
 	{"GLOBAL.LUA", "for dlgname,dlgdata in npcdata.dialog do", "for dlgname,dlgdata in pairs(npcdata.dialog) do"}, // Line 67
 	{"GLOBAL.LUA", "s = format( \"npcs.%s.dialog.%s.counter", "s = string.format( \"npcs.%s.dialog.%s.counter"}, // Line 68
 	{"GLOBAL.LUA", "s = format( \"npcs.%s.dialog.%s.finished = ", "s = string.format( \"npcs.%s.dialog.%s.finished = "}, // line 70
-	{"MAP00.LUA", "tempfunc = function() emptybed_use( %x, %y, %v1, %v2 ) end", "tempfunc = function() emptybed_use(x, y, v1, v2) end"},
-	{"MAP00.LUA", "if( getn( beds ) == 0 ) then", "if( #beds == 0 ) then"},
-	{"MAP01.LUA", "if( covert_index < getn(covert_dialog) ) then", "if( covert_index < #covert_dialog ) then"},
-	{"MAP01.LUA", "if( chiste_index < getn( chiste_dialog ) )then", "if( covert_index < #covert_dialog ) then"},
+	{"MAP00.LUA", "tempfunc = function() emptybed_use( %x, %y, %v1, %v2 ) end", "tempfunc = function() emptybed_use(x, y, v1, v2) end"}, // line 926
+	{"MAP00.LUA", "if( getn( beds ) == 0 ) then", "if( #beds == 0 ) then"}, // line 924
+	{"MAP01.LUA", "if( covert_index < getn(covert_dialog) ) then", "if( covert_index < #covert_dialog ) then"}, // line 766
+	{"MAP01.LUA", "if( chiste_index < getn( chiste_dialog ) )then", "if( covert_index < #covert_dialog ) then"}, // 845
 	{"MAP01.LUA", "strsub(", "string.sub("}, // line 23
-	{"MAP10.LUA", "emptybed_use( %x, %y, %v1, %v2 )", "emptybed_use( x, y, v1, v2 )"},
-	{"MAP10.LUA", "if( getn( beds ) == 0 ) then", "if( #beds == 0 ) then"},
-	{"MAP11.LUA", "mapstring = strsub( LASTMAP, 1, 5 )", "mapstring = string.sub( LASTMAP, 1, 5 )"},
+	{"MAP10.LUA", "emptybed_use( %x, %y, %v1, %v2 )", "emptybed_use( x, y, v1, v2 )"}, // line 121
+	{"MAP10.LUA", "if( getn( beds ) == 0 ) then", "if( #beds == 0 ) then"}, // line 119
+	{"MAP11.LUA", "mapstring = strsub( LASTMAP, 1, 5 )", "mapstring = string.sub( LASTMAP, 1, 5 )"}, // line 51
 	{"MAP21.LUA", "mapstring = strsub( LASTMAP, 1, 5 )", "mapstring = string.sub( LASTMAP, 1, 5 )"}, // line 105
 	{NULL, NULL, NULL}
 };


Commit: c10fee7393dd0abf08a4c381a7df15aa78fb3562
    https://github.com/scummvm/scummvm/commit/c10fee7393dd0abf08a4c381a7df15aa78fb3562
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:24+02:00

Commit Message:
HDB: More Lua script patches to MAP30.LUA

Changed paths:
    engines/hdb/lua-script.cpp


diff --git a/engines/hdb/lua-script.cpp b/engines/hdb/lua-script.cpp
index cd2bf0b..048fd01 100644
--- a/engines/hdb/lua-script.cpp
+++ b/engines/hdb/lua-script.cpp
@@ -58,6 +58,9 @@ struct ScriptPatch {
 	{"MAP10.LUA", "if( getn( beds ) == 0 ) then", "if( #beds == 0 ) then"}, // line 119
 	{"MAP11.LUA", "mapstring = strsub( LASTMAP, 1, 5 )", "mapstring = string.sub( LASTMAP, 1, 5 )"}, // line 51
 	{"MAP21.LUA", "mapstring = strsub( LASTMAP, 1, 5 )", "mapstring = string.sub( LASTMAP, 1, 5 )"}, // line 105
+	{"MAP30.LUA", "if i1 > getn(tiles)", "if i1 > #tiles"}, // line 211
+	{"MAP30.LUA", "if i2 > getn(tiles)", "if i2 > #tiles"}, // line 212
+	{"MAP30.LUA", "if i3 > getn(tiles)", "if i3 > #tiles"}, // line 213
 	{NULL, NULL, NULL}
 };
 


Commit: cecf6e5fc8587974836bf328c1669eeba2ae9920
    https://github.com/scummvm/scummvm/commit/cecf6e5fc8587974836bf328c1669eeba2ae9920
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:24+02:00

Commit Message:
HDB: Fix progress bar rendering

Changed paths:
    engines/hdb/hdb.cpp


diff --git a/engines/hdb/hdb.cpp b/engines/hdb/hdb.cpp
index 8eb06c1..b404ee4 100644
--- a/engines/hdb/hdb.cpp
+++ b/engines/hdb/hdb.cpp
@@ -750,6 +750,7 @@ void HDBGame::drawProgressBar() {
 	GameState temp = _gameState;
 	_gameState = GAME_LOADING;
 	paint();
+	g_system->updateScreen();
 	_gameState = temp;
 }
 


Commit: 7b07d2f88cb5916105060255bcdc56c8f422c932
    https://github.com/scummvm/scummvm/commit/7b07d2f88cb5916105060255bcdc56c8f422c932
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:24+02:00

Commit Message:
HDB: Hid some debug messages to deeper level

Changed paths:
    engines/hdb/file-manager.cpp
    engines/hdb/saveload.cpp


diff --git a/engines/hdb/file-manager.cpp b/engines/hdb/file-manager.cpp
index 7e1e68e..1d74db4 100644
--- a/engines/hdb/file-manager.cpp
+++ b/engines/hdb/file-manager.cpp
@@ -108,7 +108,7 @@ Common::SeekableReadStream *FileMan::findFirstData(const char *string, DataType
 	if (pDest)
 		*pDest = '_';
 
-	debug(4, "Looking for Data: '%s' <- '%s'", fname, string);
+	debug(8, "Looking for Data: '%s' <- '%s'", fname, string);
 
 	// Find MPC Entry
 	for (MPCIterator it = _dir.begin(); it != _dir.end(); it++) {
diff --git a/engines/hdb/saveload.cpp b/engines/hdb/saveload.cpp
index 1c385b7..2735a3a 100644
--- a/engines/hdb/saveload.cpp
+++ b/engines/hdb/saveload.cpp
@@ -104,12 +104,12 @@ Common::Error HDBGame::loadGameState(int slot) {
 	if (!_ai->cinematicsActive())
 		_gfx->turnOffFade();
 
-	debug(1, "Action List Info:");
+	debug(7, "Action List Info:");
 	for (int k = 0; k < 20; k++) {
-		debug(1, "Action %d: entityName: %s", k, _ai->_actions[k].entityName);
-		debug(1, "Action %d: x1: %d, y1: %d", k, _ai->_actions[k].x1, _ai->_actions[k].y1);
-		debug(1, "Action %d: x2: %d, y2: %d", k, _ai->_actions[k].x2, _ai->_actions[k].y2);
-		debug(1, "Action %d: luaFuncInit: %s, luaFuncUse: %s", k, _ai->_actions[k].luaFuncInit, _ai->_actions[k].luaFuncUse);
+		debug(7, "Action %d: entityName: %s", k, _ai->_actions[k].entityName);
+		debug(7, "Action %d: x1: %d, y1: %d", k, _ai->_actions[k].x1, _ai->_actions[k].y1);
+		debug(7, "Action %d: x2: %d, y2: %d", k, _ai->_actions[k].x2, _ai->_actions[k].y2);
+		debug(7, "Action %d: luaFuncInit: %s, luaFuncUse: %s", k, _ai->_actions[k].luaFuncInit, _ai->_actions[k].luaFuncUse);
 	}
 
 	return Common::kNoError;


Commit: b96049a2368f3707f566c7f4daf41fe41f7c3795
    https://github.com/scummvm/scummvm/commit/b96049a2368f3707f566c7f4daf41fe41f7c3795
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:24+02:00

Commit Message:
HDB: Fix game restarting

Changed paths:
    engines/hdb/lua-script.cpp


diff --git a/engines/hdb/lua-script.cpp b/engines/hdb/lua-script.cpp
index 048fd01..775daf4 100644
--- a/engines/hdb/lua-script.cpp
+++ b/engines/hdb/lua-script.cpp
@@ -1804,7 +1804,7 @@ bool LuaScript::initScript(Common::SeekableReadStream *stream, const char *scrip
 	}
 
 	// Load GLOBAL.LUA and execute it
-
+	_globalLuaStream->seek(0); // Make sure we start from the beginning
 	if (!executeMPC(_globalLuaStream, "global code", "GLOBAL.LUA", _globalLuaLength)) {
 		error("LuaScript::initScript: 'global code' failed to execute");
 		return false;


Commit: f9422e43478aecb9430466a7da4651d0e3fc7a58
    https://github.com/scummvm/scummvm/commit/f9422e43478aecb9430466a7da4651d0e3fc7a58
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:24+02:00

Commit Message:
HDB: Fix another incorrect allocation/deallocation.

This leads to double free, because gfxList contains list to pointers to gfxCache,
which is managed by the Gfx code

Changed paths:
    engines/hdb/ai.h


diff --git a/engines/hdb/ai.h b/engines/hdb/ai.h
index bb86222..ab8cb9a 100644
--- a/engines/hdb/ai.h
+++ b/engines/hdb/ai.h
@@ -596,13 +596,6 @@ struct AnimTarget {
 
 	AnimTarget() : x(0), y(0), start(0), end(0), vel(0), animCycle(0), animFrame(0), killAuto(false), inMap(false) {
 		for (int i = 0; i < kMaxAnimTFrames; i++) {
-			gfxList[i] = new Tile;
-		}
-	}
-
-	~AnimTarget() {
-		for (int i = 0; i < kMaxAnimTFrames; i++) {
-			delete gfxList[i];
 			gfxList[i] = NULL;
 		}
 	}


Commit: edc68ef7b1f6ba89092b2f4c41f3594ae15bd4eb
    https://github.com/scummvm/scummvm/commit/edc68ef7b1f6ba89092b2f4c41f3594ae15bd4eb
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:25+02:00

Commit Message:
HDB: Added more constants instead of magic numbers

Changed paths:
    engines/hdb/gfx.h
    engines/hdb/map.cpp
    engines/hdb/map.h


diff --git a/engines/hdb/gfx.h b/engines/hdb/gfx.h
index 73fb92a..26b0810 100644
--- a/engines/hdb/gfx.h
+++ b/engines/hdb/gfx.h
@@ -32,6 +32,8 @@ namespace HDB {
 enum {
 	kScreenWidth = 640,
 	kScreenHeight = 480,
+	kScreenDrawWidth = (kScreenWidth - 160), // visible pixels wide
+	kScreenDrawHeight = 480,
 	kTileWidth = 32,
 	kTileHeight = 32,
 	kMaxSkies = 10,
diff --git a/engines/hdb/map.cpp b/engines/hdb/map.cpp
index ca8e2a2..daec9a8 100644
--- a/engines/hdb/map.cpp
+++ b/engines/hdb/map.cpp
@@ -1114,39 +1114,39 @@ void Map::centerMapXY(int x, int y) {
 	int minx, miny, maxx, maxy;
 
 	// Scan from centerX to right edge
-	maxx = (_width - (16/2)) * kTileWidth;
-	for (int i = checkx + 1; i <= checkx + (16 / 2); i++) {
+	maxx = (_width - (kScreenTileWidth / 2)) * kTileWidth;
+	for (int i = checkx + 1; i <= checkx + (kScreenTileWidth / 2); i++) {
 		if (!getMapBGTileIndex(i, checky)) {
-			maxx = (i - (16 / 2)) * kTileWidth;
+			maxx = (i - (kScreenTileWidth / 2)) * kTileWidth;
 			break;
 		}
 	}
 
 	// Scan from centerX to left edge
 	minx = 0;
-	for (int i = checkx - 1; i >= checkx - (16 / 2); i--) {
+	for (int i = checkx - 1; i >= checkx - (kScreenTileWidth / 2); i--) {
 		if (!getMapBGTileIndex(i, checky)) {
 			// +1 because we don't want to see one whole tile
-			minx = (1 + i + (16 / 2)) * kTileWidth;
+			minx = (1 + i + (kScreenTileWidth / 2)) * kTileWidth;
 			break;
 		}
 	}
 
 	// Scan from centerY to bottom edge
-	maxy = (_height - (16/2)) * kTileHeight;
-	for (int i = checky + 1; i <= checky + (16 / 2); i++) {
+	maxy = (_height - (kScreenTileHeight / 2)) * kTileHeight;
+	for (int i = checky + 1; i <= checky + (kScreenTileHeight / 2); i++) {
 		if (!getMapBGTileIndex(checkx, i)) {
-			maxy = (i - (16 / 2)) * kTileHeight;
+			maxy = (i - (kScreenTileHeight / 2)) * kTileHeight;
 			break;
 		}
 	}
 
 	// Scan from centerY to top edge
 	miny = 0;
-	for (int i = checky - 1; i >= checkx - (16 / 2); i--) {
+	for (int i = checky - 1; i >= checkx - (kScreenTileHeight / 2); i--) {
 		if (!getMapBGTileIndex(checkx, i)) {
-			// +! because we don't want to see one whole tile
-			miny = (1 + i + (16 / 2)) * kTileHeight;
+			// +1 because we don't want to see one whole tile
+			miny = (1 + i + (kScreenTileHeight / 2)) * kTileHeight;
 			break;
 		}
 	}
@@ -1163,8 +1163,8 @@ void Map::centerMapXY(int x, int y) {
 		y = maxy;
 	}
 
-	x -= (480 / 2);
-	y -= (480 / 2);
+	x -= (kScreenDrawWidth / 2);
+	y -= (kScreenDrawHeight / 2);
 
 	setMapXY(x, y);
 }
diff --git a/engines/hdb/map.h b/engines/hdb/map.h
index 1822c86..91cecf1 100644
--- a/engines/hdb/map.h
+++ b/engines/hdb/map.h
@@ -30,6 +30,8 @@ namespace HDB {
 enum {
 	kScreenXTiles = 17,
 	kScreenYTiles = 16,
+	kScreenTileWidth = 16,
+	kScreenTileHeight = 16,
 	kMaxGratings = 250,
 	kMaxForegrounds = 250
 };


Commit: f778e08a1ae5ee99d4eb3a244b113f3e3ffb2d02
    https://github.com/scummvm/scummvm/commit/f778e08a1ae5ee99d4eb3a244b113f3e3ffb2d02
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:25+02:00

Commit Message:
HDB: Fix copy/paste error in map centering code.

This prevents us from seeing NO TILES in MAP10

Changed paths:
    engines/hdb/map.cpp


diff --git a/engines/hdb/map.cpp b/engines/hdb/map.cpp
index daec9a8..8229801 100644
--- a/engines/hdb/map.cpp
+++ b/engines/hdb/map.cpp
@@ -1143,7 +1143,7 @@ void Map::centerMapXY(int x, int y) {
 
 	// Scan from centerY to top edge
 	miny = 0;
-	for (int i = checky - 1; i >= checkx - (kScreenTileHeight / 2); i--) {
+	for (int i = checky - 1; i >= checky - (kScreenTileHeight / 2); i--) {
 		if (!getMapBGTileIndex(checkx, i)) {
 			// +1 because we don't want to see one whole tile
 			miny = (1 + i + (kScreenTileHeight / 2)) * kTileHeight;


Commit: c34824de58782026091324aca843a236e531d655
    https://github.com/scummvm/scummvm/commit/c34824de58782026091324aca843a236e531d655
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:25+02:00

Commit Message:
HDB: Added support for CINE_OUTRO from the command line (level 31)

Changed paths:
    engines/hdb/hdb.cpp


diff --git a/engines/hdb/hdb.cpp b/engines/hdb/hdb.cpp
index b404ee4..bb495a8 100644
--- a/engines/hdb/hdb.cpp
+++ b/engines/hdb/hdb.cpp
@@ -864,13 +864,17 @@ Common::Error HDBGame::run() {
 		char mapname[10];
 		int arg = ConfMan.getInt("boot_param");
 		int actionMode = MIN(arg / 100, 1);
-		int level = MIN(arg % 100, 30);
+		int level = MIN(arg % 100, 31);
 
 		setActionMode(actionMode);
 
-		debug("Starting level %d in %s", level, getActionMode() ? "Action Mode" : "Puzzle Mode");
+		if (level <= 30)
+			snprintf(mapname, 10, "MAP%02d", level);
+		else
+			strcpy(mapname, "CINE_OUTRO");
+
+		debug("Starting level %s in %s", mapname, getActionMode() ? "Action Mode" : "Puzzle Mode");
 
-		snprintf(mapname, 10, "MAP%02d", level);
 		_ai->clearPersistent();
 		startMap(mapname);
 


Commit: b2f52580f4f268715d41ebc71f0678f782a3aa34
    https://github.com/scummvm/scummvm/commit/b2f52580f4f268715d41ebc71f0678f782a3aa34
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:25+02:00

Commit Message:
HDB: Added cheat code for MAP11 for testing the Lab

Changed paths:
    engines/hdb/hdb.cpp


diff --git a/engines/hdb/hdb.cpp b/engines/hdb/hdb.cpp
index bb495a8..c982a8d 100644
--- a/engines/hdb/hdb.cpp
+++ b/engines/hdb/hdb.cpp
@@ -197,6 +197,17 @@ bool HDBGame::restartMap() {
 	_window->restartSystem();
 	_ai->restartSystem();
 	_lua->init();
+
+#if CHEAT_PATCHES
+	if (!strcmp(_currentLuaName, "MAP11.LUA")) {
+		// Let enter the labs
+
+		_lua->saveGlobalNumber("map12_complete", 1);
+
+		strcpy(_lastMapname, "MAP12");
+	}
+#endif
+
 	_lua->loadLua(_currentLuaName);
 
 	_sound->markSoundCacheFreeable();


Commit: 29884079360ef57f97d43ed1e1b9dd460f5b52ac
    https://github.com/scummvm/scummvm/commit/29884079360ef57f97d43ed1e1b9dd460f5b52ac
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:25+02:00

Commit Message:
HDB: Improved error messages during Lua execution

Changed paths:
    engines/hdb/lua-script.cpp


diff --git a/engines/hdb/lua-script.cpp b/engines/hdb/lua-script.cpp
index 775daf4..39ad12f 100644
--- a/engines/hdb/lua-script.cpp
+++ b/engines/hdb/lua-script.cpp
@@ -1824,7 +1824,7 @@ bool LuaScript::initScript(Common::SeekableReadStream *stream, const char *scrip
 	lua_insert(_state, -2);
 
 	if (lua_pcall(_state, 0, 0, -2)) {
-		error("An error occured while executing \"%s\": %s.", "level_init", lua_tostring(_state, -1));
+		error("LuaScript::initScript: An error occured while executing \"%s\": %s.", "level_init", lua_tostring(_state, -1));
 		lua_pop(_state, -1);
 
 		return false;
@@ -1866,7 +1866,7 @@ void LuaScript::call(int args, int returns) {
 		return;
 
 	if (lua_pcall(_state, args, returns, -2)) {
-		error("An error occured while executing: %s.", lua_tostring(_state, -1));
+		error("LuaScript::call: An error occured while executing: %s.", lua_tostring(_state, -1));
 		lua_pop(_state, -1);
 	}
 }
@@ -1879,7 +1879,7 @@ bool LuaScript::callFunction(const char *name, int returns) {
 	lua_getglobal(_state, name);
 
 	if (lua_pcall(_state, 0, returns, -2)) {
-		error("callFunction: An error occured while executing \"%s\": %s.", name, lua_tostring(_state, -1));
+		error("LuaScript::callFunction: An error occured while executing \"%s\": %s.", name, lua_tostring(_state, -1));
 		lua_pop(_state, -1);
 
 		return false;
@@ -1997,7 +1997,7 @@ bool LuaScript::executeChunk(Common::String &chunk, const Common::String &chunkN
 
 	// Execute Chunk
 	if (lua_pcall(_state, 0, 0, -2)) {
-		error("executeChunk: An error occured while executing \"%s\": %s.", chunkName.c_str(), lua_tostring(_state, -1));
+		error("LuaScript::executeChunk: An error occured while executing \"%s\": %s.", chunkName.c_str(), lua_tostring(_state, -1));
 		lua_pop(_state, -1);
 
 		return false;


Commit: 409a62352b4d6b98fa52c765f8e746d65ba15645
    https://github.com/scummvm/scummvm/commit/409a62352b4d6b98fa52c765f8e746d65ba15645
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:25+02:00

Commit Message:
HDB: Add one more patch to GLOBAL.LUA

The call first occurs in MAP11.LUA when entering the lab

Changed paths:
    engines/hdb/lua-script.cpp


diff --git a/engines/hdb/lua-script.cpp b/engines/hdb/lua-script.cpp
index 39ad12f..843cf09 100644
--- a/engines/hdb/lua-script.cpp
+++ b/engines/hdb/lua-script.cpp
@@ -49,6 +49,7 @@ struct ScriptPatch {
 	{"GLOBAL.LUA", "for dlgname,dlgdata in npcdata.dialog do", "for dlgname,dlgdata in pairs(npcdata.dialog) do"}, // Line 67
 	{"GLOBAL.LUA", "s = format( \"npcs.%s.dialog.%s.counter", "s = string.format( \"npcs.%s.dialog.%s.counter"}, // Line 68
 	{"GLOBAL.LUA", "s = format( \"npcs.%s.dialog.%s.finished = ", "s = string.format( \"npcs.%s.dialog.%s.finished = "}, // line 70
+	{"GLOBAL.LUA", "local mapname = format( \"MAP", "local mapname = string.format( \"MAP"}, // line 225
 	{"MAP00.LUA", "tempfunc = function() emptybed_use( %x, %y, %v1, %v2 ) end", "tempfunc = function() emptybed_use(x, y, v1, v2) end"}, // line 926
 	{"MAP00.LUA", "if( getn( beds ) == 0 ) then", "if( #beds == 0 ) then"}, // line 924
 	{"MAP01.LUA", "if( covert_index < getn(covert_dialog) ) then", "if( covert_index < #covert_dialog ) then"}, // line 766


Commit: d7c876d2696869ab732004b42abc1a95cb7f7de4
    https://github.com/scummvm/scummvm/commit/d7c876d2696869ab732004b42abc1a95cb7f7de4
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:25+02:00

Commit Message:
HDB: Sorted script patches

Changed paths:
    engines/hdb/lua-script.cpp


diff --git a/engines/hdb/lua-script.cpp b/engines/hdb/lua-script.cpp
index 843cf09..8134258 100644
--- a/engines/hdb/lua-script.cpp
+++ b/engines/hdb/lua-script.cpp
@@ -34,34 +34,41 @@ struct ScriptPatch {
 	const char *search;
 	const char *replace;
 } scriptPatches[] = {
-	{"GLOBAL.LUA", "for i,npc in npcs do", "for i,npc in pairs(npcs) do"}, // 323
-	{"GLOBAL.LUA", "setglobal( npcdef.codename..\"_init\", function() return NPC_Init( %npcdef ) end )", "_G[npcdef.codename .. \"_init\"] = function() return NPC_Init( npcdef ) end"}, // line 317
-	{"GLOBAL.LUA", "setglobal( npcdef.codename..\"_use\", function(x, y, v1, v2) return NPC_Use( %npcdef, x, y, v1, v2 ) end )", "_G[npcdef.codename .. \"_use\"] = function(x, y, v1, v2) return NPC_Use( npcdef, x, y, v1, v2 ) end"}, // line 318
-	{"GLOBAL.LUA", "if( dtable.counter < getn(dtable) ) then", "if( dtable.counter < #dtable ) then"}, // line 254
-	{"GLOBAL.LUA", "if( getglobal( \"map\"..tostring(v1)..\"_complete\" ) ) then", "if( _G[\"map\"..tostring(v1)..\"_complete\"] ) then"}, // line 219
-	{"GLOBAL.LUA", "closefunc = getglobal( npcdef.codename..\"_use\" )", "closefunc = _G[npcdef.codename..\"_use\"]"}, // line 272
-	{"GLOBAL.LUA", "strsub(", "string.sub("}, // line 15
-	{"GLOBAL.LUA", "for i,v in globals() do", "for i,v in pairs(_G) do"}, // line 52
 	{"GLOBAL.LUA", "return gsub( s, \"\\n\", \"\\\\\\n\" )", "return string.gsub( s, \"\\n\", \"\\\\\\n\" )"}, // line 10
-	{"GLOBAL.LUA", "for i,v in t do", "for i,v in pairs(t) do"},  // line 43
+	{"GLOBAL.LUA", "strsub(", "string.sub("}, // line 15
 	{"GLOBAL.LUA", "if type(v) == 'userdata' or type(v) == 'function' then return end", "if type(v) == 'userdata' or type(v) == 'function' or i == 'package' or i == 'os' or i == 'io' or i == 'string' or i == 'table' or i == 'debug' or i == 'math' or i == 'coroutine' then return end" }, // Line 16
+	{"GLOBAL.LUA", "for i,v in t do", "for i,v in pairs(t) do"},  // line 43
+	{"GLOBAL.LUA", "for i,v in globals() do", "for i,v in pairs(_G) do"}, // line 52
 	{"GLOBAL.LUA", "for npcname,npcdata in npcs do", "for npcname,npcdata in pairs(npcs) do"}, // Line 66
 	{"GLOBAL.LUA", "for dlgname,dlgdata in npcdata.dialog do", "for dlgname,dlgdata in pairs(npcdata.dialog) do"}, // Line 67
 	{"GLOBAL.LUA", "s = format( \"npcs.%s.dialog.%s.counter", "s = string.format( \"npcs.%s.dialog.%s.counter"}, // Line 68
 	{"GLOBAL.LUA", "s = format( \"npcs.%s.dialog.%s.finished = ", "s = string.format( \"npcs.%s.dialog.%s.finished = "}, // line 70
+	{"GLOBAL.LUA", "if( getglobal( \"map\"..tostring(v1)..\"_complete\" ) ) then", "if( _G[\"map\"..tostring(v1)..\"_complete\"] ) then"}, // line 219
 	{"GLOBAL.LUA", "local mapname = format( \"MAP", "local mapname = string.format( \"MAP"}, // line 225
-	{"MAP00.LUA", "tempfunc = function() emptybed_use( %x, %y, %v1, %v2 ) end", "tempfunc = function() emptybed_use(x, y, v1, v2) end"}, // line 926
+	{"GLOBAL.LUA", "if( dtable.counter < getn(dtable) ) then", "if( dtable.counter < #dtable ) then"}, // line 254
+	{"GLOBAL.LUA", "closefunc = getglobal( npcdef.codename..\"_use\" )", "closefunc = _G[npcdef.codename..\"_use\"]"}, // line 272
+	{"GLOBAL.LUA", "setglobal( npcdef.codename..\"_init\", function() return NPC_Init( %npcdef ) end )", "_G[npcdef.codename .. \"_init\"] = function() return NPC_Init( npcdef ) end"}, // line 317
+	{"GLOBAL.LUA", "setglobal( npcdef.codename..\"_use\", function(x, y, v1, v2) return NPC_Use( %npcdef, x, y, v1, v2 ) end )", "_G[npcdef.codename .. \"_use\"] = function(x, y, v1, v2) return NPC_Use( npcdef, x, y, v1, v2 ) end"}, // line 318
+	{"GLOBAL.LUA", "for i,npc in npcs do", "for i,npc in pairs(npcs) do"}, // 323
+
 	{"MAP00.LUA", "if( getn( beds ) == 0 ) then", "if( #beds == 0 ) then"}, // line 924
+	{"MAP00.LUA", "tempfunc = function() emptybed_use( %x, %y, %v1, %v2 ) end", "tempfunc = function() emptybed_use(x, y, v1, v2) end"}, // line 926
+
+	{"MAP01.LUA", "strsub(", "string.sub("}, // line 23
 	{"MAP01.LUA", "if( covert_index < getn(covert_dialog) ) then", "if( covert_index < #covert_dialog ) then"}, // line 766
 	{"MAP01.LUA", "if( chiste_index < getn( chiste_dialog ) )then", "if( covert_index < #covert_dialog ) then"}, // 845
-	{"MAP01.LUA", "strsub(", "string.sub("}, // line 23
-	{"MAP10.LUA", "emptybed_use( %x, %y, %v1, %v2 )", "emptybed_use( x, y, v1, v2 )"}, // line 121
+
 	{"MAP10.LUA", "if( getn( beds ) == 0 ) then", "if( #beds == 0 ) then"}, // line 119
+	{"MAP10.LUA", "emptybed_use( %x, %y, %v1, %v2 )", "emptybed_use( x, y, v1, v2 )"}, // line 121
+
 	{"MAP11.LUA", "mapstring = strsub( LASTMAP, 1, 5 )", "mapstring = string.sub( LASTMAP, 1, 5 )"}, // line 51
+
 	{"MAP21.LUA", "mapstring = strsub( LASTMAP, 1, 5 )", "mapstring = string.sub( LASTMAP, 1, 5 )"}, // line 105
+
 	{"MAP30.LUA", "if i1 > getn(tiles)", "if i1 > #tiles"}, // line 211
 	{"MAP30.LUA", "if i2 > getn(tiles)", "if i2 > #tiles"}, // line 212
 	{"MAP30.LUA", "if i3 > getn(tiles)", "if i3 > #tiles"}, // line 213
+
 	{NULL, NULL, NULL}
 };
 


Commit: 54c94a9b257a0dbbba84098b23a203abcc973ed6
    https://github.com/scummvm/scummvm/commit/54c94a9b257a0dbbba84098b23a203abcc973ed6
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:25+02:00

Commit Message:
HDB: Added more script patches to MAP30.LUA

Changed paths:
    engines/hdb/lua-script.cpp


diff --git a/engines/hdb/lua-script.cpp b/engines/hdb/lua-script.cpp
index 8134258..3f3ec23 100644
--- a/engines/hdb/lua-script.cpp
+++ b/engines/hdb/lua-script.cpp
@@ -68,6 +68,9 @@ struct ScriptPatch {
 	{"MAP30.LUA", "if i1 > getn(tiles)", "if i1 > #tiles"}, // line 211
 	{"MAP30.LUA", "if i2 > getn(tiles)", "if i2 > #tiles"}, // line 212
 	{"MAP30.LUA", "if i3 > getn(tiles)", "if i3 > #tiles"}, // line 213
+	{"MAP30.LUA", "if i2 > getn(tiles)", "if i2 > #tiles"}, // line 237
+	{"MAP30.LUA", "if i3 > getn(tiles)", "if i3 > #tiles"}, // line 238
+	{"MAP30.LUA", "if i3 > getn(tiles)", "if i3 > #tiles"}, // line 261
 
 	{NULL, NULL, NULL}
 };


Commit: 74e6168e0a35e9f71a571987e09998209e2cf6cb
    https://github.com/scummvm/scummvm/commit/74e6168e0a35e9f71a571987e09998209e2cf6cb
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:25+02:00

Commit Message:
HDB: Added script patch for MAP29.LUA

Changed paths:
    engines/hdb/lua-script.cpp


diff --git a/engines/hdb/lua-script.cpp b/engines/hdb/lua-script.cpp
index 3f3ec23..28ae8f5 100644
--- a/engines/hdb/lua-script.cpp
+++ b/engines/hdb/lua-script.cpp
@@ -65,6 +65,8 @@ struct ScriptPatch {
 
 	{"MAP21.LUA", "mapstring = strsub( LASTMAP, 1, 5 )", "mapstring = string.sub( LASTMAP, 1, 5 )"}, // line 105
 
+	{"MAP29.LUA", "Message( format( \"", "Message( string.format( \""}, // line 195
+
 	{"MAP30.LUA", "if i1 > getn(tiles)", "if i1 > #tiles"}, // line 211
 	{"MAP30.LUA", "if i2 > getn(tiles)", "if i2 > #tiles"}, // line 212
 	{"MAP30.LUA", "if i3 > getn(tiles)", "if i3 > #tiles"}, // line 213


Commit: 9370c0a4f37ac3e88d67a0aab4e9d615b96ee414
    https://github.com/scummvm/scummvm/commit/9370c0a4f37ac3e88d67a0aab4e9d615b96ee414
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:25+02:00

Commit Message:
HDB: Added script patches for MAP19.LUA

Changed paths:
    engines/hdb/lua-script.cpp


diff --git a/engines/hdb/lua-script.cpp b/engines/hdb/lua-script.cpp
index 28ae8f5..b227ada 100644
--- a/engines/hdb/lua-script.cpp
+++ b/engines/hdb/lua-script.cpp
@@ -61,6 +61,9 @@ struct ScriptPatch {
 	{"MAP10.LUA", "if( getn( beds ) == 0 ) then", "if( #beds == 0 ) then"}, // line 119
 	{"MAP10.LUA", "emptybed_use( %x, %y, %v1, %v2 )", "emptybed_use( x, y, v1, v2 )"}, // line 121
 
+	{"MAP19.LUA", "func = getglobal( \"frustrato_nice\"..tostring(frustrato_stage) )", "func = _G[ \"frustrato_nice\"..tostring(frustrato_stage) ]"}, // line 296
+	{"MAP19.LUA", "func = getglobal( \"frustrato_choice\"..tostring(frustrato_stage + 1) )", "func = _G[ \"frustrato_choice\"..tostring(frustrato_stage + 1) ]"}, // line 298
+
 	{"MAP11.LUA", "mapstring = strsub( LASTMAP, 1, 5 )", "mapstring = string.sub( LASTMAP, 1, 5 )"}, // line 51
 
 	{"MAP21.LUA", "mapstring = strsub( LASTMAP, 1, 5 )", "mapstring = string.sub( LASTMAP, 1, 5 )"}, // line 105


Commit: 4c0181ac310d79343a4874aa33052de8485d8c7e
    https://github.com/scummvm/scummvm/commit/4c0181ac310d79343a4874aa33052de8485d8c7e
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:25+02:00

Commit Message:
HDB: Remove leftover code

Changed paths:
    engines/hdb/hdb.cpp


diff --git a/engines/hdb/hdb.cpp b/engines/hdb/hdb.cpp
index c982a8d..b395835 100644
--- a/engines/hdb/hdb.cpp
+++ b/engines/hdb/hdb.cpp
@@ -69,9 +69,6 @@ HDBGame::HDBGame(OSystem *syst, const ADGameDescription *gameDesc) : Engine(syst
 	_monkeystone7 = STARS_MONKEYSTONE_7_FAKE;
 	_monkeystone14 = STARS_MONKEYSTONE_14_FAKE;
 	_monkeystone21 = STARS_MONKEYSTONE_21_FAKE;
-
-	DebugMan.addDebugChannel(kDebugExample1, "Example1", "This is just an example to test");
-	DebugMan.addDebugChannel(kDebugExample2, "Example2", "This is also an example");
 }
 
 HDBGame::~HDBGame() {


Commit: 252c6e61c9bddd9db1b9325d9c622b13736a92d7
    https://github.com/scummvm/scummvm/commit/252c6e61c9bddd9db1b9325d9c622b13736a92d7
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:25+02:00

Commit Message:
HDB: Fix player collision detection code

Changed paths:
    engines/hdb/ai-funcs.cpp


diff --git a/engines/hdb/ai-funcs.cpp b/engines/hdb/ai-funcs.cpp
index 02c6941..7b72c97 100644
--- a/engines/hdb/ai-funcs.cpp
+++ b/engines/hdb/ai-funcs.cpp
@@ -2064,7 +2064,8 @@ bool AI::checkPlayerCollision(int x, int y, int border) {
 	if (g_hdb->getDebug() == 2 || !_player)
 		return false;
 
-	return (x > (_player->x - 32 + border) && x < (_player->x - 32 - border) && y >(_player->y - 32 + border) && y < (_player->y - 32 - border));
+	return (x > (_player->x - 32 + border) && x < (_player->x + 32 - border) &&
+			y > (_player->y - 32 + border) && y < (_player->y + 32 - border));
 }
 
 void AI::clearDiverters() {


Commit: bd26cda952e2f36d3138c7d8a6143a9a60597d80
    https://github.com/scummvm/scummvm/commit/bd26cda952e2f36d3138c7d8a6143a9a60597d80
Author: Strangerke (strangerke at scummvm.org)
Date: 2019-09-03T17:17:25+02:00

Commit Message:
HDB: Fix compilation for MSVC9

Changed paths:
    engines/hdb/ai.h
    engines/hdb/gfx.cpp
    engines/hdb/input.cpp


diff --git a/engines/hdb/ai.h b/engines/hdb/ai.h
index ab8cb9a..43f857d 100644
--- a/engines/hdb/ai.h
+++ b/engines/hdb/ai.h
@@ -383,7 +383,7 @@ enum CallbackType {
 
 struct AIStateDef {
 	AIState state;
-	const char name[64];
+	const char *name;
 };
 
 struct AIEntity {
diff --git a/engines/hdb/gfx.cpp b/engines/hdb/gfx.cpp
index 05adecb..aba8742 100644
--- a/engines/hdb/gfx.cpp
+++ b/engines/hdb/gfx.cpp
@@ -1052,7 +1052,8 @@ void Gfx::drawDebugInfo(Tile *_debugLogo, int fps) {
 	}
 }
 
-Picture::Picture() : _width(0), _height(0), _name("") {
+Picture::Picture() : _width(0), _height(0) {
+	_name[0] = 0;
 	_surface.create(_width, _height, g_hdb->_format);
 }
 
@@ -1109,7 +1110,8 @@ int Picture::drawMasked(int x, int y, int alpha) {
 	return 0;
 }
 
-Tile::Tile() : _flags(0), _name("") {
+Tile::Tile() : _flags(0) {
+	_name[0] = 0;
 	_surface.create(32, 32, g_hdb->_format);
 }
 
diff --git a/engines/hdb/input.cpp b/engines/hdb/input.cpp
index b8f9660..91b3a97 100644
--- a/engines/hdb/input.cpp
+++ b/engines/hdb/input.cpp
@@ -145,6 +145,7 @@ void Input::stylusDown(int x, int y) {
 		g_hdb->_menu->processInput(x, y);
 		break;
 	case GAME_PLAY:
+		{
 		// Is Player Dead? Click on TRY AGAIN
 		if (g_hdb->_ai->playerDead()) {
 			if (y >= kTryRestartY && y <= kTryRestartY + 24) {
@@ -220,6 +221,7 @@ void Input::stylusDown(int x, int y) {
 
 		g_hdb->setTargetXY(worldX, worldY);
 		break;
+		}
 	case GAME_LOADING:
 		break;
 	}


Commit: 43438a632c6feeab71f125f8a0c8fe2da18811dd
    https://github.com/scummvm/scummvm/commit/43438a632c6feeab71f125f8a0c8fe2da18811dd
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:25+02:00

Commit Message:
HDB: Support loading from the launcher

Changed paths:
    engines/hdb/detection.cpp
    engines/hdb/saveload.cpp


diff --git a/engines/hdb/detection.cpp b/engines/hdb/detection.cpp
index b8bf22e..e236a6c 100644
--- a/engines/hdb/detection.cpp
+++ b/engines/hdb/detection.cpp
@@ -108,21 +108,72 @@ public:
 
 	virtual bool hasFeature(MetaEngineFeature f) const;
 	virtual int getMaximumSaveSlot() const;
+	virtual SaveStateList listSaves(const char *target) const;
 	virtual bool createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const;
 };
 
 bool HDBMetaEngine::hasFeature(MetaEngineFeature f) const {
 	return
-		(f == kSupportsLoadingDuringStartup);
+		(f == kSupportsLoadingDuringStartup) ||
+		(f == kSupportsLoadingDuringStartup) ||
+		(f == kSupportsListSaves) ||
+		(f == kSavesSupportMetaInfo) ||
+		(f == kSavesSupportThumbnail) ||
+		(f == kSavesSupportPlayTime);
 }
 
 bool HDB::HDBGame::hasFeature(Engine::EngineFeature f) const {
-	warning("FIXME: quitGame() exits the application, instead of RTL");
-	return (f == kSupportsRTL);
+	return (f == kSupportsRTL) ||
+		   (f == kSupportsLoadingDuringRuntime) ||
+		   (f == kSupportsSavingDuringRuntime);
 }
 
 int HDBMetaEngine::getMaximumSaveSlot() const { return 9; }
 
+SaveStateList HDBMetaEngine::listSaves(const char *target) const {
+	Common::SaveFileManager *saveFileMan = g_system->getSavefileManager();
+	Common::StringArray filenames;
+	Common::String pattern = target;
+	pattern += ".###";
+
+	filenames = saveFileMan->listSavefiles(pattern);
+
+	SaveStateList saveList;
+	for (Common::StringArray::const_iterator file = filenames.begin(); file != filenames.end(); ++file) {
+		// Obtain the last 2 digits of the filename, since they correspond to the save slot
+		int slotNum = atoi(file->c_str() + file->size() - 2);
+
+		if (slotNum >= 0 && slotNum <= getMaximumSaveSlot()) {
+			Common::ScopedPtr<Common::InSaveFile> in(saveFileMan->openForLoading(*file));
+			if (in) {
+				SaveStateDescriptor desc;
+				char mapName[32];
+				Graphics::Surface *thumbnail;
+
+				if (!Graphics::loadThumbnail(*in, thumbnail)) {
+					warning("Error loading thumbnail for %s", file->c_str());
+				}
+				desc.setThumbnail(thumbnail);
+
+				uint32 timeSeconds = in->readUint32LE();;
+				in->read(mapName, 32);
+
+				warning("mapName: %s playtime: %d", mapName, timeSeconds);
+
+				desc.setSaveSlot(slotNum);
+				desc.setPlayTime(timeSeconds * 1000);
+				desc.setDescription(mapName);
+
+				saveList.push_back(desc);
+			}
+		}
+	}
+
+	// Sort saves based on slot number.
+	Common::sort(saveList.begin(), saveList.end(), SaveStateDescriptorSlotComparator());
+	return saveList;
+}
+
 bool HDBMetaEngine::createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const {
 	if (desc) {
 		*engine = new HDB::HDBGame(syst, desc);
diff --git a/engines/hdb/saveload.cpp b/engines/hdb/saveload.cpp
index 2735a3a..1163d56 100644
--- a/engines/hdb/saveload.cpp
+++ b/engines/hdb/saveload.cpp
@@ -153,7 +153,7 @@ void HDBGame::loadGame(Common::InSaveFile *in) {
 	debug(1, "HDBGame::loadGame: start at %u", in->pos());
 
 	// Load Map Name and Time
-	_timeSeconds = in->readUint32LE();;
+	_timeSeconds = in->readUint32LE();
 	_timePlayed = 0;
 	in->read(_inMapName, 32);
 


Commit: 0d989250ee8c465823acce59a978410c50a1fa62
    https://github.com/scummvm/scummvm/commit/0d989250ee8c465823acce59a978410c50a1fa62
Author: Strangerke (strangerke at scummvm.org)
Date: 2019-09-03T17:17:25+02:00

Commit Message:
HDB: Fix some CppCheck warnings in ai-bots

Changed paths:
    engines/hdb/ai-bots.cpp


diff --git a/engines/hdb/ai-bots.cpp b/engines/hdb/ai-bots.cpp
index 2234bc5..3918a6d 100644
--- a/engines/hdb/ai-bots.cpp
+++ b/engines/hdb/ai-bots.cpp
@@ -69,7 +69,7 @@ void aiOmniBotAction(AIEntity *e) {
 			if (onEvenTile(e->x, e->y) && g_hdb->getActionMode()) {
 				int xv = 0, yv = 0, result;
 				int shoot = 0;
-				AIEntity *omni;
+
 				// FIXME: Is reloading Player required here?
 				p = g_hdb->_ai->getPlayer();
 
@@ -113,7 +113,7 @@ void aiOmniBotAction(AIEntity *e) {
 				// (2) Check we're not shooting into an Entity unless it's the player
 				AIEntity *hit = g_hdb->_ai->legalMoveOverWater(e->tileX+xv, e->tileY + yv, e->level, &result);
 				if (shoot && !hit && result) {
-					omni = g_hdb->_ai->spawn(AI_OMNIBOT_MISSILE, e->dir, e->tileX + xv, e->tileY + yv, NULL, NULL, NULL, DIR_NONE, e->level, 0, 0, 1);
+					AIEntity *omni = g_hdb->_ai->spawn(AI_OMNIBOT_MISSILE, e->dir, e->tileX + xv, e->tileY + yv, NULL, NULL, NULL, DIR_NONE, e->level, 0, 0, 1);
 					omni->xVel = xv * kPlayerMoveSpeed * 2;
 					omni->yVel = yv * kPlayerMoveSpeed * 2;
 					if (g_hdb->_map->onScreen(e->tileX, e->tileY))
@@ -202,10 +202,9 @@ void aiTurnBotChoose(AIEntity *e) {
 	int xvAhead[5] = { 9, 0, 0, -1, 1 }, yvAhead[5] = { 9, -1, 1, 0, 0 };
 	AIDir turnRight[5] = { DIR_NONE, DIR_RIGHT, DIR_LEFT, DIR_UP, DIR_DOWN };
 	AIState dirState[5] = { STATE_NONE, STATE_MOVEUP, STATE_MOVEDOWN, STATE_MOVELEFT, STATE_MOVERIGHT };
-	int xv, yv;
 
-	xv = xvAhead[e->dir];
-	yv = yvAhead[e->dir];
+	int xv = xvAhead[e->dir];
+	int yv = yvAhead[e->dir];
 	if (g_hdb->_map->getMapBGTileFlags(e->tileX + xv, e->tileY + yv) & (kFlagSolid | kFlagWater)) {
 		e->xVel = e->yVel = 0;
 		e->animFrame = 0;
@@ -359,29 +358,29 @@ void aiRightBotInit2(AIEntity *e) {
 }
 
 void aiRightBotFindGoal(AIEntity *e) {
-	int	xv, yv, xv2, yv2, xv3, yv3;
+	int	xv, yv;
 	int	bg, bg2, bg3;
-	AIEntity *e1, *e2, *e3, *p;
-	int	hit, sx, sy, rotate;
+	AIEntity *e1, *e2, *e3;
+	int	sx, sy;
 
-	int		xvAhead[5]	= { 9, 0, 0,-1, 1 }, yvAhead[5]	= { 9,-1, 1, 0, 0 };
-	int		xvAToR[5]	= { 9, 1,-1,-1, 1 }, yvAToR[5]	= { 9,-1, 1,-1, 1 };
-	int		xvToR[5]	= { 9, 1,-1, 0, 0 }, yvToR[5]	= { 9, 0, 0,-1, 1 };
-	int		xvToL[5]	= { 9,-1, 1, 0, 0 }, yvToL[5]	= { 9, 0, 0, 1,-1 };
+	int	xvAhead[5]	= { 9, 0, 0,-1, 1 }, yvAhead[5]	= { 9,-1, 1, 0, 0 };
+	int	xvAToR[5]	= { 9, 1,-1,-1, 1 }, yvAToR[5]	= { 9,-1, 1,-1, 1 };
+	int	xvToR[5]	= { 9, 1,-1, 0, 0 }, yvToR[5]	= { 9, 0, 0,-1, 1 };
+	int	xvToL[5]	= { 9,-1, 1, 0, 0 }, yvToL[5]	= { 9, 0, 0, 1,-1 };
 
-	p = g_hdb->_ai->getPlayer();
-	rotate = 0;
+	AIEntity *p = g_hdb->_ai->getPlayer();
+	int rotate = 0;
 
 	do {
 		xv = xvAhead[e->dir];	// Search Ahead
 		yv = yvAhead[e->dir];
-		xv2 = xvAToR[e->dir];	// Search Ahead and to the Right
-		yv2 = yvAToR[e->dir];
-		xv3 = xvToR[e->dir];	// Search to the Right
-		yv3 = yvToR[e->dir];
+		int xv2 = xvAToR[e->dir];	// Search Ahead and to the Right
+		int yv2 = yvAToR[e->dir];
+		int xv3 = xvToR[e->dir];	// Search to the Right
+		int yv3 = yvToR[e->dir];
 
 		// Search until we hit a wall...or empty space to our right (and forward)
-		hit = 0;
+		bool hit = false;
 		sx = e->tileX;
 		sy = e->tileY;
 
@@ -405,7 +404,7 @@ void aiRightBotFindGoal(AIEntity *e) {
 				sy += yv;
 				rotate = 0;
 			} else
-				hit = 1;
+				hit = true;
 		}
 
 		// Are we stuck in a corner?
@@ -527,9 +526,7 @@ void aiPushBotAction(AIEntity *e) {
 	int	xvAhead[5] = { 9, 0, 0,-1, 1 }, yvAhead[5] = { 9,-1, 1, 0, 0 };
 	AIDir oneEighty[5] = { DIR_NONE, DIR_DOWN, DIR_UP, DIR_RIGHT, DIR_LEFT };
 
-	uint32 bgFlags, fgFlags;
-	int nx, ny, nx2, ny2, result;
-	AIEntity *e1 = NULL, *e2;
+	AIEntity *e1 = nullptr;
 
 	if (e->goalX) {
 		g_hdb->_ai->animateEntity(e);
@@ -540,9 +537,10 @@ void aiPushBotAction(AIEntity *e) {
 			g_hdb->_ai->killPlayer(DEATH_NORMAL);
 
 		// Where to go next
-		nx = e->tileX + xvAhead[e->dir];
-		ny = e->tileY + yvAhead[e->dir];
+		int nx = e->tileX + xvAhead[e->dir];
+		int ny = e->tileY + yvAhead[e->dir];
 
+		int result;
 		e1 = g_hdb->_ai->legalMove(nx, ny, e->level, &result);
 
 		// Push something
@@ -557,17 +555,17 @@ void aiPushBotAction(AIEntity *e) {
 				return;
 			}
 
-			nx2 = nx + xvAhead[e->dir];
-			ny2 = ny + yvAhead[e->dir];
+			int nx2 = nx + xvAhead[e->dir];
+			int ny2 = ny + yvAhead[e->dir];
 
-			bgFlags = g_hdb->_map->getMapBGTileFlags(nx2, ny2);
-			fgFlags = g_hdb->_map->getMapFGTileFlags(nx2, ny2);
-			e2 = g_hdb->_ai->findEntity(nx2, ny2);
+			uint32 bgFlags = g_hdb->_map->getMapBGTileFlags(nx2, ny2);
+			uint32 fgFlags = g_hdb->_map->getMapFGTileFlags(nx2, ny2);
+			AIEntity *e2 = g_hdb->_ai->findEntity(nx2, ny2);
 			result = (e->level == 1) ? (bgFlags & kFlagSolid) : !(fgFlags & kFlagGrating) && (bgFlags & kFlagSolid);
 
 			// If we're going to push something onto a floating thing, that's ok
 			if (e2 && (e2->state == STATE_FLOATING || e2->state == STATE_MELTED))
-				e2 = NULL;
+				e2 = nullptr;
 
 			// If no walls in front & no entities
 			if (!result && !e2 && e1->state != STATE_EXPLODING) {
@@ -882,8 +880,6 @@ void aiMaintBotAction(AIEntity *e) {
 	AIState useState[5] = {STATE_NONE, STATE_USEUP, STATE_USEDOWN, STATE_USELEFT, STATE_USERIGHT};
 	AIState standState[5] = {STATE_NONE, STATE_STANDUP, STATE_STANDDOWN, STATE_STANDLEFT, STATE_STANDRIGHT};
 	int	xvAhead[5] = {9, 0, 0,-1, 1}, yvAhead[5] = {9,-1, 1, 0, 0};
-	AIEntity *it;
-	int nx, ny;
 	int	whistles[3] = {SND_MBOT_WHISTLE1, SND_MBOT_WHISTLE2, SND_MBOT_WHISTLE3};
 
 	// Waiting at an arrow (or hit by player)?
@@ -903,11 +899,11 @@ void aiMaintBotAction(AIEntity *e) {
 				}
 				break;
 			// Need to USE the object
-			case 30:
+			case 30: {
 				e->state = useState[e->dir];
-				nx = e->tileX + xvAhead[e->dir];
-				ny = e->tileY + yvAhead[e->dir];
-				it = g_hdb->_ai->findEntity(nx, ny);
+				int nx = e->tileX + xvAhead[e->dir];
+				int ny = e->tileY + yvAhead[e->dir];
+				AIEntity *it = g_hdb->_ai->findEntity(nx, ny);
 				if (it) {
 					if (e->onScreen)
 						e->value1 = 1;
@@ -933,6 +929,7 @@ void aiMaintBotAction(AIEntity *e) {
 					break;
 				}
 				break;
+				}
 			// Play a sound if we used something
 			case 25:
 				e->value1 = 0;
@@ -1040,10 +1037,9 @@ void aiFourFirerInit2(AIEntity *e) {
 }
 
 void aiFourFirerAction(AIEntity *e) {
-	AIEntity *p = g_hdb->_ai->getPlayer(), *fire, *hit;
+	AIEntity *p = g_hdb->_ai->getPlayer();
 	AIState state[5] = {STATE_NONE, STATE_STANDUP, STATE_STANDDOWN, STATE_STANDLEFT, STATE_STANDRIGHT};
 	AIDir turn[5] = {DIR_NONE, DIR_RIGHT, DIR_LEFT, DIR_UP, DIR_DOWN};
-	int	shoot, xv, yv, result;
 
 	// Time to turn right?
 	if (!e->value1) {
@@ -1068,24 +1064,28 @@ void aiFourFirerAction(AIEntity *e) {
 		return;
 
 	// Check player direction
-	shoot = xv = yv = 0;
+	bool shoot = false;
+	int xv = 0;
+	int yv = 0;
+
 	switch (e->dir) {
-	case DIR_UP:	if (p->x == e->x && p->y < e->y) { shoot = 1; yv = -1; } break;
-	case DIR_DOWN:	if (p->x == e->x && p->y > e->y) { shoot = 1; yv = 1; } break;
-	case DIR_LEFT:	if (p->y == e->y && p->x < e->x) { shoot = 1; xv = -1; } break;
-	case DIR_RIGHT:	if (p->y == e->y && p->x > e->x) { shoot = 1; xv = 1; } break;
+	case DIR_UP:	if (p->x == e->x && p->y < e->y) { shoot = true; yv = -1; } break;
+	case DIR_DOWN:	if (p->x == e->x && p->y > e->y) { shoot = true; yv = 1; } break;
+	case DIR_LEFT:	if (p->y == e->y && p->x < e->x) { shoot = true; xv = -1; } break;
+	case DIR_RIGHT:	if (p->y == e->y && p->x > e->x) { shoot = true; xv = 1; } break;
 	case DIR_NONE: warning("aiFourFirerAction: DIR_NONE found"); break;
 	}
 
 	// Shoot if needed
 	// Make sure not shooting into solid tile
 	// Make sure if shooting at entity it is the player
-	hit = g_hdb->_ai->legalMoveOverWater(e->tileX + xv, e->tileY + yv, e->level, &result);
+	int result;
+	AIEntity *hit = g_hdb->_ai->legalMoveOverWater(e->tileX + xv, e->tileY + yv, e->level, &result);
 	if (hit && hit->type == AI_GUY)
-		hit = NULL;
+		hit = nullptr;
 
 	if (shoot && !hit && result) {
-		fire = g_hdb->_ai->spawn(AI_OMNIBOT_MISSILE, e->dir, e->tileX + xv, e->tileY + yv, NULL, NULL, NULL, DIR_NONE, e->level, 0, 0, 1);
+		AIEntity *fire = g_hdb->_ai->spawn(AI_OMNIBOT_MISSILE, e->dir, e->tileX + xv, e->tileY + yv, NULL, NULL, NULL, DIR_NONE, e->level, 0, 0, 1);
 		if (g_hdb->_map->onScreen(e->tileX, e->tileY))
 			g_hdb->_sound->playSound(SND_FOUR_FIRE);
 		fire->xVel = xv * kPlayerMoveSpeed * 2;
@@ -1211,7 +1211,7 @@ void aiDeadEyeAction(AIEntity *e) {
 				if (okToMove) {
 					e->moveSpeed = kPlayerMoveSpeed << 1;
 					g_hdb->_ai->setEntityGoal(e, newX, newY);
-					p->tileX & 1 ? g_hdb->_sound->playSound(SND_DEADEYE_ATTACK01) : g_hdb->_sound->playSound(SND_DEADEYE_ATTACK02);
+					(p->tileX & 1) ? g_hdb->_sound->playSound(SND_DEADEYE_ATTACK01) : g_hdb->_sound->playSound(SND_DEADEYE_ATTACK02);
 				}
 				g_hdb->_ai->animateEntity(e);
 				return;
@@ -2407,9 +2407,7 @@ void aiBadFairyInit2(AIEntity *e) {
 void aiBadFairyAction(AIEntity *e) {
 	AIState	state[5] = {STATE_NONE, STATE_MOVEUP, STATE_MOVEDOWN, STATE_MOVELEFT, STATE_MOVERIGHT};
 	int	xvAhead[5] = {9, 0, 0,-1, 1}, yvAhead[5] = {9,-1, 1, 0, 0};
-	int xv, yv;
 	int	result;
-	AIEntity *hit;
 
 	if (e->sequence) {
 		e->sequence--;
@@ -2448,13 +2446,13 @@ void aiBadFairyAction(AIEntity *e) {
 
 					e->dir = d;
 					e->state = state[d];
-					xv = xvAhead[d] * walk;
+					int xv = xvAhead[d] * walk;
 					if (e->tileX + xv < 1)
 						xv = -e->tileX + 1;
 					if (e->tileX + xv > g_hdb->_map->_width)
 						xv = g_hdb->_map->_width - e->tileX - 1;
 
-					yv = yvAhead[d] * walk;
+					int yv = yvAhead[d] * walk;
 					if (e->tileY + yv < 1)
 						yv = -e->tileY + 1;
 					if (e->tileY + yv > g_hdb->_map->_height)
@@ -2466,7 +2464,7 @@ void aiBadFairyAction(AIEntity *e) {
 					if (!g_hdb->getActionMode())
 						e->moveSpeed >>= 1;
 
-					hit = g_hdb->_ai->legalMoveOverWater(e->tileX + e->value1, e->tileY + e->value2, e->level, &result);
+					AIEntity *hit = g_hdb->_ai->legalMoveOverWater(e->tileX + e->value1, e->tileY + e->value2, e->level, &result);
 					uint32 bg_flags = g_hdb->_map->getMapBGTileFlags(e->tileX + e->value1, e->tileY + e->value2);
 					if (hit == p && !g_hdb->_ai->playerDead()) {
 						g_hdb->_ai->killPlayer(DEATH_FRIED);
@@ -2506,7 +2504,7 @@ void aiBadFairyAction(AIEntity *e) {
 		// did we run into a wall, entity, water, slime etc?
 		// if so, pick a new direction!
 		if (onEvenTile(e->x, e->y)) {
-			hit = g_hdb->_ai->legalMoveOverWater(e->tileX + e->value1, e->tileY + e->value2, e->level, &result);
+			AIEntity *hit = g_hdb->_ai->legalMoveOverWater(e->tileX + e->value1, e->tileY + e->value2, e->level, &result);
 			uint32 bg_flags = g_hdb->_map->getMapBGTileFlags(e->tileX + e->value1, e->tileY + e->value2);
 			if (!result || (hit && hit->type != AI_GUY) || (bg_flags & kFlagSpecial)) {
 				g_hdb->_ai->stopEntity(e);


Commit: 01bf7aa811a331dd05810c6d0160f94cc025ae15
    https://github.com/scummvm/scummvm/commit/01bf7aa811a331dd05810c6d0160f94cc025ae15
Author: Strangerke (strangerke at scummvm.org)
Date: 2019-09-03T17:17:25+02:00

Commit Message:
HDB: Fix some more CppCheck warnings, use static const in various functions

Changed paths:
    engines/hdb/ai-bots.cpp
    engines/hdb/ai-cinematic.cpp


diff --git a/engines/hdb/ai-bots.cpp b/engines/hdb/ai-bots.cpp
index 3918a6d..104e035 100644
--- a/engines/hdb/ai-bots.cpp
+++ b/engines/hdb/ai-bots.cpp
@@ -199,9 +199,10 @@ void aiTurnBotInit2(AIEntity *e) {
 }
 
 void aiTurnBotChoose(AIEntity *e) {
-	int xvAhead[5] = { 9, 0, 0, -1, 1 }, yvAhead[5] = { 9, -1, 1, 0, 0 };
-	AIDir turnRight[5] = { DIR_NONE, DIR_RIGHT, DIR_LEFT, DIR_UP, DIR_DOWN };
-	AIState dirState[5] = { STATE_NONE, STATE_MOVEUP, STATE_MOVEDOWN, STATE_MOVELEFT, STATE_MOVERIGHT };
+	static const int xvAhead[5] = { 9, 0, 0, -1, 1 };
+	static const int yvAhead[5] = { 9, -1, 1, 0, 0 };
+	static const AIDir turnRight[5] = { DIR_NONE, DIR_RIGHT, DIR_LEFT, DIR_UP, DIR_DOWN };
+	static const AIState dirState[5] = { STATE_NONE, STATE_MOVEUP, STATE_MOVEDOWN, STATE_MOVELEFT, STATE_MOVERIGHT };
 
 	int xv = xvAhead[e->dir];
 	int yv = yvAhead[e->dir];
@@ -358,19 +359,23 @@ void aiRightBotInit2(AIEntity *e) {
 }
 
 void aiRightBotFindGoal(AIEntity *e) {
+	static const int xvAhead[5] = { 9, 0, 0,-1, 1 };
+	static const int yvAhead[5] = { 9,-1, 1, 0, 0 };
+	static const int xvAToR[5]  = { 9, 1,-1,-1, 1 };
+	static const int yvAToR[5]  = { 9,-1, 1,-1, 1 };
+	static const int xvToR[5]   = { 9, 1,-1, 0, 0 };
+	static const int yvToR[5]   = { 9, 0, 0,-1, 1 };
+	static const int xvToL[5]   = { 9,-1, 1, 0, 0 };
+	static const int yvToL[5]   = { 9, 0, 0, 1,-1 };
+
+	AIEntity *p = g_hdb->_ai->getPlayer();
+	int rotate = 0;
+
 	int	xv, yv;
 	int	bg, bg2, bg3;
 	AIEntity *e1, *e2, *e3;
 	int	sx, sy;
 
-	int	xvAhead[5]	= { 9, 0, 0,-1, 1 }, yvAhead[5]	= { 9,-1, 1, 0, 0 };
-	int	xvAToR[5]	= { 9, 1,-1,-1, 1 }, yvAToR[5]	= { 9,-1, 1,-1, 1 };
-	int	xvToR[5]	= { 9, 1,-1, 0, 0 }, yvToR[5]	= { 9, 0, 0,-1, 1 };
-	int	xvToL[5]	= { 9,-1, 1, 0, 0 }, yvToL[5]	= { 9, 0, 0, 1,-1 };
-
-	AIEntity *p = g_hdb->_ai->getPlayer();
-	int rotate = 0;
-
 	do {
 		xv = xvAhead[e->dir];	// Search Ahead
 		yv = yvAhead[e->dir];
@@ -522,9 +527,10 @@ void aiPushBotInit2(AIEntity *e) {
 }
 
 void aiPushBotAction(AIEntity *e) {
-	AIState moveState[5] = { STATE_NONE, STATE_MOVEUP, STATE_MOVEDOWN, STATE_MOVELEFT, STATE_MOVERIGHT };
-	int	xvAhead[5] = { 9, 0, 0,-1, 1 }, yvAhead[5] = { 9,-1, 1, 0, 0 };
-	AIDir oneEighty[5] = { DIR_NONE, DIR_DOWN, DIR_UP, DIR_RIGHT, DIR_LEFT };
+	static const AIState moveState[5] = { STATE_NONE, STATE_MOVEUP, STATE_MOVEDOWN, STATE_MOVELEFT, STATE_MOVERIGHT };
+	static const int xvAhead[5] = { 9, 0, 0,-1, 1 };
+	static const int yvAhead[5] = { 9,-1, 1, 0, 0 };
+	static const AIDir oneEighty[5] = { DIR_NONE, DIR_DOWN, DIR_UP, DIR_RIGHT, DIR_LEFT };
 
 	AIEntity *e1 = nullptr;
 
@@ -710,9 +716,10 @@ void aiRailRiderOnUse(AIEntity *e) {
 }
 
 void aiRailRiderOnAction(AIEntity *e) {
-	int	xv[5] = { 9, 0, 0, -1, 1 }, yv[5] = { 9, -1, 1, 0, 0 };
+	static const int xv[5] = { 9, 0, 0, -1, 1 };
+	static const int yv[5] = { 9, -1, 1, 0, 0 };
+
 	AIEntity*p = g_hdb->_ai->getPlayer();
-	SingleTele t;
 
 	switch (e->sequence) {
 	// Player is boarding
@@ -743,7 +750,7 @@ void aiRailRiderOnAction(AIEntity *e) {
 
 	// New RailRider gfx
 	// Move the RailRider
-	case 2:
+	case 2: {
 		// Done moving to next spot?
 		if (!e->goalX) {
 			ArrowPath *arrowPath = g_hdb->_ai->findArrowPath(e->tileX, e->tileY);
@@ -816,6 +823,7 @@ void aiRailRiderOnAction(AIEntity *e) {
 		}
 		g_hdb->_map->centerMapXY(e->x + 16, e->y + 16);
 
+		SingleTele t;
 		// Did we hit a tunnel entrance?
 		if (onEvenTile(e->x, e->y) && g_hdb->_ai->findTeleporterDest(e->tileX, e->tileY, &t) && !e->value1 && !e->dir2) {
 			// Set tunnel destination
@@ -835,6 +843,7 @@ void aiRailRiderOnAction(AIEntity *e) {
 		} else if (e->dir2 && e->dir2 != (AIDir)(e->tileX + e->tileY))
 			e->dir2 = DIR_NONE;
 		break;
+		}
 	// Waiting for Player to move to Dest
 	case 4:
 		if (!p->goalX) {
@@ -877,10 +886,11 @@ void aiMaintBotInit2(AIEntity *e) {
 }
 
 void aiMaintBotAction(AIEntity *e) {
-	AIState useState[5] = {STATE_NONE, STATE_USEUP, STATE_USEDOWN, STATE_USELEFT, STATE_USERIGHT};
-	AIState standState[5] = {STATE_NONE, STATE_STANDUP, STATE_STANDDOWN, STATE_STANDLEFT, STATE_STANDRIGHT};
-	int	xvAhead[5] = {9, 0, 0,-1, 1}, yvAhead[5] = {9,-1, 1, 0, 0};
-	int	whistles[3] = {SND_MBOT_WHISTLE1, SND_MBOT_WHISTLE2, SND_MBOT_WHISTLE3};
+	static const AIState useState[5]   = {STATE_NONE, STATE_USEUP, STATE_USEDOWN, STATE_USELEFT, STATE_USERIGHT};
+	static const AIState standState[5] = {STATE_NONE, STATE_STANDUP, STATE_STANDDOWN, STATE_STANDLEFT, STATE_STANDRIGHT};
+	static const int xvAhead[5]  = {9, 0, 0,-1, 1};
+	static const int yvAhead[5]  = {9,-1, 1, 0, 0};
+	static const int whistles[3] = {SND_MBOT_WHISTLE1, SND_MBOT_WHISTLE2, SND_MBOT_WHISTLE3};
 
 	// Waiting at an arrow (or hit by player)?
 	if (e->sequence) {
@@ -2534,7 +2544,9 @@ void aiGatePuddleInit2(AIEntity *e) {
 }
 
 void aiGatePuddleAction(AIEntity *e) {
-	int	xva[5] = {9, 0, 0,-1, 1}, yva[5] = {9,-1, 1, 0, 0};
+	static const int xva[5] = {9, 0, 0,-1, 1};
+	static const int yva[5] = {9,-1, 1, 0, 0};
+	
 	AIEntity *p = g_hdb->_ai->getPlayer();
 
 	if (e->goalX) {
diff --git a/engines/hdb/ai-cinematic.cpp b/engines/hdb/ai-cinematic.cpp
index 414aa93..05986ca 100644
--- a/engines/hdb/ai-cinematic.cpp
+++ b/engines/hdb/ai-cinematic.cpp
@@ -378,7 +378,7 @@ void AI::processCines() {
 			break;
 
 		case C_USEENTITY:
-			for (Common::Array<AIEntity *>::iterator it = _ents->begin(); it != _ents->end(); it++) {
+			for (Common::Array<AIEntity *>::iterator it = _ents->begin(); it != _ents->end(); ++it) {
 				if ((*it)->entityName && Common::matchString((*it)->entityName, _cine[i]->string, true)) {
 					g_hdb->useEntity((*it));
 				}


Commit: 73c90d1a208ec0e2701c4d24a59ffcde35261b3c
    https://github.com/scummvm/scummvm/commit/73c90d1a208ec0e2701c4d24a59ffcde35261b3c
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:25+02:00

Commit Message:
HDB: Clear MAP06 through level-select

Changed paths:
    engines/hdb/hdb.cpp


diff --git a/engines/hdb/hdb.cpp b/engines/hdb/hdb.cpp
index b395835..445c5d8 100644
--- a/engines/hdb/hdb.cpp
+++ b/engines/hdb/hdb.cpp
@@ -203,6 +203,13 @@ bool HDBGame::restartMap() {
 
 		strcpy(_lastMapname, "MAP12");
 	}
+
+	if (!strcmp(_currentLuaName, "MAP06.LUA")) {
+		// Have overtime pay for Hanson
+
+		_ai->setGemAmount(100);
+	}
+
 #endif
 
 	_lua->loadLua(_currentLuaName);


Commit: 1b9e2f36f1727ba8032e6227c57f697b66327295
    https://github.com/scummvm/scummvm/commit/1b9e2f36f1727ba8032e6227c57f697b66327295
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:26+02:00

Commit Message:
HDB: Fix aiFatFrogTongueDraw()

Changed paths:
    engines/hdb/ai-bots.cpp


diff --git a/engines/hdb/ai-bots.cpp b/engines/hdb/ai-bots.cpp
index 104e035..e9cb229 100644
--- a/engines/hdb/ai-bots.cpp
+++ b/engines/hdb/ai-bots.cpp
@@ -1874,7 +1874,7 @@ void aiFatFrogInit2(AIEntity *e) {
 	switch (e->dir) {
 	case DIR_DOWN:
 		if (!g_hdb->_ai->_tileFroglickMiddleUD) {
-			g_hdb->_ai->_tileFroglickMiddleLR = g_hdb->_gfx->loadTile(TILE_FFTONGUE_UD_MIDDLE);
+			g_hdb->_ai->_tileFroglickMiddleUD = g_hdb->_gfx->loadTile(TILE_FFTONGUE_UD_MIDDLE);
 			g_hdb->_ai->_tileFroglickWiggleUD[0] = g_hdb->_gfx->loadTile(TILE_FFTONGUE_UD_WIGGLE_L);
 			g_hdb->_ai->_tileFroglickWiggleUD[1] = g_hdb->_gfx->loadTile(TILE_FFTONGUE_UD_WIGGLE_M);
 			g_hdb->_ai->_tileFroglickWiggleUD[2] = g_hdb->_gfx->loadTile(TILE_FFTONGUE_UD_WIGGLE_R);


Commit: 933089dcba9ae5cc6eb4ac39adc838a87e48e8a8
    https://github.com/scummvm/scummvm/commit/933089dcba9ae5cc6eb4ac39adc838a87e48e8a8
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:26+02:00

Commit Message:
HDB: Patch misplaced function names

Changed paths:
    engines/hdb/lua-script.cpp


diff --git a/engines/hdb/lua-script.cpp b/engines/hdb/lua-script.cpp
index b227ada..b61276d 100644
--- a/engines/hdb/lua-script.cpp
+++ b/engines/hdb/lua-script.cpp
@@ -61,6 +61,12 @@ struct ScriptPatch {
 	{"MAP10.LUA", "if( getn( beds ) == 0 ) then", "if( #beds == 0 ) then"}, // line 119
 	{"MAP10.LUA", "emptybed_use( %x, %y, %v1, %v2 )", "emptybed_use( x, y, v1, v2 )"}, // line 121
 
+	{"MAP15.LUA", "function cop5_5b()", "function cop5_4b()"}, // line 112
+	{"MAP15.LUA", "function cop5_5c()", "function cop5_4c()"}, // line 115
+	{"MAP15.LUA", "function cop5_5d()", "function cop5_4d()"}, // line 118
+	{"MAP15.LUA", "function cop5_5e()", "function cop5_4e()"}, // line 121
+	{"MAP15.LUA", "function cop5_5f()", "function cop5_4f()"}, // line 124
+
 	{"MAP19.LUA", "func = getglobal( \"frustrato_nice\"..tostring(frustrato_stage) )", "func = _G[ \"frustrato_nice\"..tostring(frustrato_stage) ]"}, // line 296
 	{"MAP19.LUA", "func = getglobal( \"frustrato_choice\"..tostring(frustrato_stage + 1) )", "func = _G[ \"frustrato_choice\"..tostring(frustrato_stage + 1) ]"}, // line 298
 


Commit: 1fd53de72a8288b5b44f2c10bc812dbbd6b7d8ef
    https://github.com/scummvm/scummvm/commit/1fd53de72a8288b5b44f2c10bc812dbbd6b7d8ef
Author: Strangerke (strangerke at scummvm.org)
Date: 2019-09-03T17:17:26+02:00

Commit Message:
HDB: Fix CppCheck warnings in ai-funcs

Changed paths:
    engines/hdb/ai-funcs.cpp


diff --git a/engines/hdb/ai-funcs.cpp b/engines/hdb/ai-funcs.cpp
index 7b72c97..b114390 100644
--- a/engines/hdb/ai-funcs.cpp
+++ b/engines/hdb/ai-funcs.cpp
@@ -101,7 +101,7 @@ bool AI::cacheEntGfx(AIEntity *e, bool init) {
 				if (gfxFiles->size() == 0)
 					warning("AI::cacheEntGfx: no files for %s", list[j].name);
 
-				for (Common::Array<const char *>::iterator it = gfxFiles->begin(); it != gfxFiles->end(); it++) {
+				for (Common::Array<const char *>::iterator it = gfxFiles->begin(); it != gfxFiles->end(); ++it) {
 					size = g_hdb->_fileMan->getLength((*it), TYPE_TILE32);
 
 					if (g_hdb->_gfx->selectGfxType((*it))) {
@@ -459,8 +459,11 @@ void AI::stopEntity(AIEntity *e) {
 	// Align with tile boundaries
 	e->x = e->tileX * kTileWidth;
 	e->y = e->tileY * kTileHeight;
-	e->goalX = e->tileX;
-	e->goalY = e->tileY;
+
+	// TODO: Check in the original if also present. Removed as it's useless
+	// e->goalX = e->tileX;
+	// e->goalY = e->tileY;
+
 	e->drawXOff = e->drawYOff = 0;
 	e->goalX = e->goalY = e->xVel = e->yVel = 0;
 
@@ -509,7 +512,7 @@ void AI::stopEntity(AIEntity *e) {
 }
 
 AIEntity *AI::locateEntity(const char *luaName) {
-	for (Common::Array<AIEntity *>::iterator it = _ents->begin(); it != _ents->end(); it++) {
+	for (Common::Array<AIEntity *>::iterator it = _ents->begin(); it != _ents->end(); ++it) {
 		if (Common::matchString((*it)->entityName, luaName)) {
 			return *it;
 		}
@@ -518,13 +521,13 @@ AIEntity *AI::locateEntity(const char *luaName) {
 }
 
 AIEntity *AI::findEntity(int x, int y) {
-	for (Common::Array<AIEntity *>::iterator it = _ents->begin(); it != _ents->end(); it++) {
+	for (Common::Array<AIEntity *>::iterator it = _ents->begin(); it != _ents->end(); ++it) {
 		if ((*it)->tileX == x && (*it)->tileY == y) {
 			return *it;
 		}
 	}
 
-	for (Common::Array<AIEntity *>::iterator it = _floats->begin(); it != _floats->end(); it++) {
+	for (Common::Array<AIEntity *>::iterator it = _floats->begin(); it != _floats->end(); ++it) {
 		if ((*it)->tileX == x && (*it)->tileY == y) {
 			return *it;
 		}
@@ -537,13 +540,13 @@ AIEntity *AI::findEntity(int x, int y) {
 }
 
 AIEntity *AI::findEntityIgnore(int x, int y, AIEntity *ignore) {
-	for (Common::Array<AIEntity *>::iterator it = _ents->begin(); it != _ents->end(); it++) {
+	for (Common::Array<AIEntity *>::iterator it = _ents->begin(); it != _ents->end(); ++it) {
 		if ((*it)->tileX == x && (*it)->tileY == y && (*it) != ignore) {
 			return *it;
 		}
 	}
 
-	for (Common::Array<AIEntity *>::iterator it = _floats->begin(); it != _floats->end(); it++) {
+	for (Common::Array<AIEntity *>::iterator it = _floats->begin(); it != _floats->end(); ++it) {
 		if ((*it)->tileX == x && (*it)->tileY == y && (*it) != ignore) {
 			return *it;
 		}
@@ -556,13 +559,13 @@ AIEntity *AI::findEntityIgnore(int x, int y, AIEntity *ignore) {
 }
 
 AIEntity *AI::findEntityType(AIType type, int x, int y) {
-	for (Common::Array<AIEntity *>::iterator it = _ents->begin(); it != _ents->end(); it++) {
+	for (Common::Array<AIEntity *>::iterator it = _ents->begin(); it != _ents->end(); ++it) {
 		if ((*it)->tileX == x && (*it)->tileY == y && (*it)->type == type) {
 			return *it;
 		}
 	}
 
-	for (Common::Array<AIEntity *>::iterator it = _floats->begin(); it != _floats->end(); it++) {
+	for (Common::Array<AIEntity *>::iterator it = _floats->begin(); it != _floats->end(); ++it) {
 		if ((*it)->tileX == x && (*it)->tileY == y && (*it)->type == type) {
 			return *it;
 		}
@@ -578,7 +581,7 @@ void AI::getEntityXY(const char *entName, int *x, int *y) {
 	AIEntity *e;
 	HereT *h;
 
-	for (Common::Array<AIEntity *>::iterator it = _ents->begin(); it != _ents->end(); it++) {
+	for (Common::Array<AIEntity *>::iterator it = _ents->begin(); it != _ents->end(); ++it) {
 		e = *it;
 		if (e->entityName && !scumm_stricmp(entName, e->entityName)) {
 			*x = e->tileX;
@@ -587,7 +590,7 @@ void AI::getEntityXY(const char *entName, int *x, int *y) {
 		}
 	}
 
-	for (Common::Array<AIEntity *>::iterator jt = _floats->begin(); jt != _floats->end(); jt++) {
+	for (Common::Array<AIEntity *>::iterator jt = _floats->begin(); jt != _floats->end(); ++jt) {
 		e = *jt;
 		if (e->entityName && !scumm_stricmp(entName, e->entityName)) {
 			*x = e->tileX;
@@ -596,7 +599,7 @@ void AI::getEntityXY(const char *entName, int *x, int *y) {
 		}
 	}
 
-	for (Common::Array<HereT *>::iterator kt = _hereList->begin(); kt != _hereList->end(); kt++) {
+	for (Common::Array<HereT *>::iterator kt = _hereList->begin(); kt != _hereList->end(); ++kt) {
 		h = *kt;
 		if (!scumm_stricmp(entName, h->entName)) {
 			*x = h->x;
@@ -607,10 +610,8 @@ void AI::getEntityXY(const char *entName, int *x, int *y) {
 }
 
 bool AI::useLuaEntity(const char *initName) {
-	AIEntity *e;
-
-	for (Common::Array<AIEntity *>::iterator it = _ents->begin(); it != _ents->end(); it++) {
-		e = *it;
+	for (Common::Array<AIEntity *>::iterator it = _ents->begin(); it != _ents->end(); ++it) {
+		AIEntity *e = *it;
 		if (e->entityName && !scumm_stricmp(initName, e->entityName)) {
 			e->aiUse(e);
 			checkActionList(e, e->tileX, e->tileY, true);
@@ -632,10 +633,8 @@ bool AI::useLuaEntity(const char *initName) {
 }
 
 void AI::removeLuaEntity(const char *initName) {
-	AIEntity *e;
-
 	for (uint i = 0; i < _ents->size(); i++) {
-		e = _ents->operator[](i);
+		AIEntity *e = _ents->operator[](i);
 		if (e->entityName && !scumm_stricmp(initName, e->entityName)) {
 			removeEntity(e);
 			i--;
@@ -644,10 +643,8 @@ void AI::removeLuaEntity(const char *initName) {
 }
 
 void AI::animLuaEntity(const char *initName, AIState st) {
-	AIEntity *e;
-
-	for (Common::Array<AIEntity *>::iterator it = _ents->begin(); it != _ents->end(); it++) {
-		e = *it;
+	for (Common::Array<AIEntity *>::iterator it = _ents->begin(); it != _ents->end(); ++it) {
+		AIEntity *e = *it;
 		if (e->entityName && !scumm_stricmp(initName, e->entityName)) {
 			e->state = st;
 			e->animFrame = 0;
@@ -657,10 +654,8 @@ void AI::animLuaEntity(const char *initName, AIState st) {
 }
 
 void AI::setLuaAnimFrame(const char *initName, AIState st, int frame) {
-	AIEntity *e;
-
-	for (Common::Array<AIEntity *>::iterator it = _ents->begin(); it != _ents->end(); it++) {
-		e = *it;
+	for (Common::Array<AIEntity *>::iterator it = _ents->begin(); it != _ents->end(); ++it) {
+		AIEntity *e = *it;
 		if (e->entityName && !scumm_stricmp(initName, e->entityName)) {
 			e->state = st;
 			e->animFrame = frame;
@@ -688,11 +683,9 @@ void AI::removeEntity(AIEntity *e) {
 }
 
 void AI::setEntityGoal(AIEntity *e, int x, int y) {
-	int xv, yv;
-
 	e->xVel = e->yVel = 0;
 
-	xv = x - e->tileX;
+	int xv = x - e->tileX;
 	if (xv < 0) {
 		e->xVel = -e->moveSpeed;
 		e->state = STATE_MOVELEFT;
@@ -703,7 +696,7 @@ void AI::setEntityGoal(AIEntity *e, int x, int y) {
 		e->dir = DIR_RIGHT;
 	}
 
-	yv = y - e->tileY;
+	int yv = y - e->tileY;
 	if (yv < 0) {
 		e->yVel = -e->moveSpeed;
 		e->state = STATE_MOVEUP;
@@ -727,7 +720,7 @@ void AI::setEntityGoal(AIEntity *e, int x, int y) {
 
 // Initializes each entity after map is loaded
 void AI::initAllEnts() {
-	for (Common::Array<AIEntity *>::iterator it = _ents->begin(); it != _ents->end(); it++) {
+	for (Common::Array<AIEntity *>::iterator it = _ents->begin(); it != _ents->end(); ++it) {
 		(*it)->aiInit((*it));
 		if ((*it)->luaFuncInit[0]) {
 			if (g_hdb->_lua->callFunction((*it)->luaFuncInit, 2)) {
@@ -739,8 +732,7 @@ void AI::initAllEnts() {
 		}
 	}
 
-	int i;
-	for (i = 0; i < _numInventory; i++) {
+	for (int i = 0; i < _numInventory; i++) {
 		AIEntity *temp = &_inventory[i].ent;
 
 		// Clear out all ptrs in entity before writing
@@ -774,7 +766,7 @@ void AI::initAllEnts() {
 		cacheEntGfx(temp, false);
 	}
 
-	for (i = 0; i < _numDeliveries; i++) {
+	for (int i = 0; i < _numDeliveries; i++) {
 		_deliveries[i].itemGfx = g_hdb->_gfx->getTileGfx(_deliveries[i].itemGfxName, -1);
 		_deliveries[i].destGfx = g_hdb->_gfx->getTileGfx(_deliveries[i].destGfxName, -1);
 	}
@@ -784,7 +776,6 @@ void AI::initAllEnts() {
 }
 
 void AI::killPlayer(Death method) {
-
 	int x = _player->x, y = _player->y;
 
 	stopEntity(_player);
@@ -893,11 +884,12 @@ void AI::stunEnemy(AIEntity *e, int time) {
 	player in here to move him along his waypoints.
 */
 void AI::animateEntity(AIEntity *e) {
+	static const int xva[5] = {9, 0, 0, -1, 1};
+	static const int yva[5] = {9, -1, 1, 0, 0};
 
 	int bgTileFlags, bgTileIndex;
 	int fgTileFlags;
 	bool result;
-	uint64 flags;
 
 	// Move entity if player is not dead
 	debug(9, "Before animateEntity, e->x: %d, e->y: %d", e->x, e->y);
@@ -952,7 +944,6 @@ void AI::animateEntity(AIEntity *e) {
 		fgTileFlags = g_hdb->_map->getMapFGTileFlags(e->tileX, e->tileY);
 
 		if (e->level == 1 ? ((bgTileFlags & kFlagIce) == kFlagIce) : (((bgTileFlags & kFlagIce) == kFlagIce) && !(fgTileFlags & kFlagGrating))) {
-			int xva[] = {9, 0, 0, -1, 1}, yva[] = {9, -1, 1, 0, 0};
 			int nx, ny, moveOK = 0;
 			AIEntity *hit;
 
@@ -1056,9 +1047,9 @@ void AI::animateEntity(AIEntity *e) {
 
 		// Check if player wants to stop
 		// If yes, sets last waypoint right in front of player
-		int xOff = 0, yOff = 0;
 		if (_numWaypoints > 1) {
-
+			int xOff = 0;
+			int yOff = 0;
 			switch (e->dir) {
 			case DIR_UP:
 				xOff = 0;
@@ -1126,9 +1117,6 @@ void AI::animateEntity(AIEntity *e) {
 			uint16 buttons = g_hdb->_input->getButtons();
 
 			if (e == _player && (buttons & (kButtonUp | kButtonDown | kButtonLeft | kButtonRight))) {
-				int xva[] = {9, 0, 0, -1, 1}, yva[] = {9, -1, 1, 0, 0};
-				int nx, ny, result2;
-
 				if (e->state != STATE_PUSHRIGHT && e->state != STATE_PUSHLEFT && e->state != STATE_PUSHUP && e->state != STATE_PUSHDOWN) {
 					if (buttons & kButtonUp)
 						e->dir = DIR_UP;
@@ -1139,8 +1127,9 @@ void AI::animateEntity(AIEntity *e) {
 					else if (buttons & kButtonRight)
 						e->dir = DIR_RIGHT;
 
-					nx = e->tileX + xva[e->dir];
-					ny = e->tileY + yva[e->dir];
+					int nx = e->tileX + xva[e->dir];
+					int ny = e->tileY + yva[e->dir];
+					int result2;
 					AIEntity *hit = legalMove(nx, ny, e->level, &result2);
 					if (!hit && result2) {
 						switch (e->dir) {
@@ -1180,6 +1169,7 @@ void AI::animateEntity(AIEntity *e) {
 
 			// Checking at the Destination
 
+			uint64 flags;
 			// Can this entity float and it is over-water
 			if (((flags = g_hdb->_map->getMapBGTileFlags(e->tileX, e->tileY)) & kFlagWater) && (e->type == AI_CRATE || e->type == AI_LIGHTBARREL || e->type == AI_BOOMBARREL || e->type == AI_HEAVYBARREL || e->type == AI_FROGSTATUE || e->type == AI_DIVERTER)) {
 				// On a grating and level2?
@@ -1860,7 +1850,7 @@ void AI::moveEnts() {
 	frameDelay = kAnimFrameDelay;
 
 	// Call aiAction for Floating Entities
-	for (Common::Array<AIEntity *>::iterator it = _floats->begin(); it != _floats->end(); it++) {
+	for (Common::Array<AIEntity *>::iterator it = _floats->begin(); it != _floats->end(); ++it) {
 		if ((*it)->aiAction)
 			(*it)->aiAction((*it));
 	}
@@ -1942,15 +1932,13 @@ bool AI::findPath(AIEntity *e) {
 	else
 		max = g_hdb->_map->_height;
 
-	ArrowPath *arrowPath;
-	uint32 flags;
 	while (max--) {
-		arrowPath = findArrowPath(x + xv, y + yv);
+		ArrowPath *arrowPath = findArrowPath(x + xv, y + yv);
 		if (arrowPath) {
 			setEntityGoal(e, arrowPath->tileX, arrowPath->tileY);
 			return true;
 		} else {
-			flags = g_hdb->_map->getMapBGTileFlags(x + xv, y + yv);
+			uint32 flags = g_hdb->_map->getMapBGTileFlags(x + xv, y + yv);
 			if (flags & kFlagSolid)
 				return false;
 		}
@@ -2042,9 +2030,8 @@ AIEntity *AI::legalMoveOverWaterIgnore(int tileX, int tileY, int level, int *res
 }
 
 AIEntity *AI::playerCollision(int topBorder, int bottomBorder, int leftBorder, int rightBorder) {
-	AIEntity *e;
-	for (Common::Array<AIEntity *>::iterator it = _ents->begin(); it != _ents->end(); it++) {
-		e = *it;
+	for (Common::Array<AIEntity *>::iterator it = _ents->begin(); it != _ents->end(); ++it) {
+		AIEntity *e = *it;
 		if (e == _player || !e->onScreen)
 			continue;
 		if (e->x > (_player->x - 32 - leftBorder) && e->x < (_player->x + 32 + rightBorder) && e->y >(_player->y - 32 - topBorder) && e->y < (_player->y + 32 + bottomBorder))
@@ -2069,30 +2056,26 @@ bool AI::checkPlayerCollision(int x, int y, int border) {
 }
 
 void AI::clearDiverters() {
-	AIEntity *e;
-
 	for (uint i = 0; i < _ents->size(); i++) {
-		e = _ents->operator[](i);
+		AIEntity *e = _ents->operator[](i);
 		if (e->type == AI_DIVERTER)
 			e->value1 = e->value2 = 0;
 	}
 }
 
 void AI::laserScan() {
-	AIEntity *e;
-
 	clearDiverters();
 	g_hdb->_map->clearLaserBeams();
 
 	for (uint i = 0; i < _ents->size(); i++) {
-		e = _ents->operator[](i);
+		AIEntity *e = _ents->operator[](i);
 		if (e->type == AI_LASER)
 			aiLaserAction(e);
 	}
 }
 
 void AI::floatEntity(AIEntity *e, AIState state) {
-	for (Common::Array<AIEntity *>::iterator it = _ents->begin(); it != _ents->end(); it++) {
+	for (Common::Array<AIEntity *>::iterator it = _ents->begin(); it != _ents->end(); ++it) {
 		if (e == *it) {
 			_floats->push_back(*it);
 			_ents->erase(it);
@@ -2104,7 +2087,7 @@ void AI::floatEntity(AIEntity *e, AIState state) {
 }
 
 bool AI::checkFloating(int x, int y) {
-	for (Common::Array<AIEntity *>::iterator it = _floats->begin(); it != _floats->end(); it++) {
+	for (Common::Array<AIEntity *>::iterator it = _floats->begin(); it != _floats->end(); ++it) {
 		if ((*it)->tileX == x && (*it)->tileY == y)
 			return true;
 	}
@@ -2246,7 +2229,6 @@ void AI::movePlayer(uint16 buttons) {
 	int	yva[5] = {9,-1, 1, 0, 0};
 	AIEntity *hit;
 	int	xv = 0, yv = 0, nx, ny;
-	int	attackable;
 
 	if (!_player)
 		return;
@@ -2306,7 +2288,7 @@ void AI::movePlayer(uint16 buttons) {
 
 		// Attackable Entity? (we're right up on it)
 		int amt = getGemAmount();
-		attackable = 0;
+		int	attackable = 0;
 		if (hit)
 			switch (hit->type) {
 			case AI_OMNIBOT:


Commit: 8a44ed4a9743c4c0fd14a761a402631f71f21ea3
    https://github.com/scummvm/scummvm/commit/8a44ed4a9743c4c0fd14a761a402631f71f21ea3
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:26+02:00

Commit Message:
HDB: Fix findTeleporterDest()

Changed paths:
    engines/hdb/ai-lists.cpp


diff --git a/engines/hdb/ai-lists.cpp b/engines/hdb/ai-lists.cpp
index f3b087e..0b4b7d3 100644
--- a/engines/hdb/ai-lists.cpp
+++ b/engines/hdb/ai-lists.cpp
@@ -650,7 +650,7 @@ void AI::addToTeleportList(int teleIndex, int x, int y, int dir, int level, int
 
 bool AI::findTeleporterDest(int tileX, int tileY, SingleTele *info) {
 	for (int i = 0; i < _numTeleporters; i++) {
-		if ((_teleporters[i].x1 == tileX) && (_teleporters[i].x1 == tileY)) {
+		if ((_teleporters[i].x1 == tileX) && (_teleporters[i].y1 == tileY)) {
 			info->anim = _teleporters[i].anim2;
 			info->x = _teleporters[i].x2;
 			info->y = _teleporters[i].y2;
@@ -659,7 +659,7 @@ bool AI::findTeleporterDest(int tileX, int tileY, SingleTele *info) {
 			info->usable = _teleporters[i].usable2;
 			return true;
 		}
-		if ((_teleporters[i].x1 == tileX) && (_teleporters[i].x1 == tileY)) {
+		if ((_teleporters[i].x2 == tileX) && (_teleporters[i].y2 == tileY)) {
 			info->anim = _teleporters[i].anim1;
 			info->x = _teleporters[i].x1;
 			info->y = _teleporters[i].y1;


Commit: cfe228d7bbb04159da660ceebb7ef8583dcfe405
    https://github.com/scummvm/scummvm/commit/cfe228d7bbb04159da660ceebb7ef8583dcfe405
Author: Strangerke (strangerke at scummvm.org)
Date: 2019-09-03T17:17:26+02:00

Commit Message:
HDB: Fix some CppCheck warnings in ai-inventory and ai-lists

Changed paths:
    engines/hdb/ai-inventory.cpp
    engines/hdb/ai-lists.cpp


diff --git a/engines/hdb/ai-inventory.cpp b/engines/hdb/ai-inventory.cpp
index ff14f15..7449697 100644
--- a/engines/hdb/ai-inventory.cpp
+++ b/engines/hdb/ai-inventory.cpp
@@ -110,8 +110,6 @@ AIEntity *AI::getInvItem(int which) {
 }
 
 int AI::queryInventory(const char *string) {
-	int		i, count;
-
 	if (!scumm_stricmp(string, "monkeystone"))
 		return getMonkeystoneAmount();
 	if (!scumm_stricmp(string, "goo"))
@@ -122,8 +120,8 @@ int AI::queryInventory(const char *string) {
 	if (!_numInventory)
 		return 0;
 
-	count = 0;
-	for (i = _numInventory - 1; i >= 0; i--)
+	int count = 0;
+	for (int i = _numInventory - 1; i >= 0; i--)
 		if (_inventory[i].ent.entityName && strstr(_inventory[i].ent.entityName, string))
 			count++;
 
@@ -131,9 +129,6 @@ int AI::queryInventory(const char *string) {
 }
 
 bool AI::removeInvItem(const char *string, int amount) {
-	int		i, j;
-	int		found;
-
 	// Check specially for Gems, Monkeystones and Goo Cups
 	if (!scumm_stricmp(string, "gem")) {
 		_numGems -= amount;
@@ -149,12 +144,13 @@ bool AI::removeInvItem(const char *string, int amount) {
 	if (!_numInventory)
 		return false;
 
+	bool found;
 	do {
-		found = 0;
+		found = false;
 
-		for (i = _numInventory - 1; i >= 0; i--)
+		for (int i = _numInventory - 1; i >= 0; i--)
 			if (_inventory[i].ent.entityName && strstr(_inventory[i].ent.entityName, string)) {
-				j = i;
+				int j = i;
 				memset(&_inventory[j], 0, sizeof(InvEnt));
 				while (j < _numInventory - 1) {
 					memcpy(&_inventory[j], &_inventory[j + 1], sizeof(InvEnt));
@@ -163,7 +159,7 @@ bool AI::removeInvItem(const char *string, int amount) {
 				}
 				_numInventory--;
 				amount--;
-				found = 1;
+				found = true;
 				if (!amount)
 					break;
 			}
@@ -177,8 +173,6 @@ bool AI::removeInvItem(const char *string, int amount) {
 }
 
 int AI::queryInventoryType(AIType which) {
-	int		i, count;
-
 	if (which == ITEM_MONKEYSTONE)
 		return getMonkeystoneAmount();
 	if (which == ITEM_GOO_CUP)
@@ -189,8 +183,8 @@ int AI::queryInventoryType(AIType which) {
 	if (!_numInventory)
 		return 0;
 
-	count = 0;
-	for (i = 0; i < _numInventory; i++)
+	int count = 0;
+	for (int i = 0; i < _numInventory; i++)
 		if (_inventory[i].ent.type == which)
 			count++;
 
@@ -198,20 +192,16 @@ int AI::queryInventoryType(AIType which) {
 }
 
 int AI::queryInventoryTypeSlot(AIType which) {
-	int i;
-
 	if (!_numInventory)
 		return 0;
 
-	for (i = 0; i < _numInventory; i++)
+	for (int i = 0; i < _numInventory; i++)
 		if (_inventory[i].ent.type == which)
 			return i;
 	return -1;
 }
 
 bool AI::removeInvItemType(AIType which, int amount) {
-	int		i, j, found;
-
 	// Check specially for Gems, Monkeystones and Goo Cups
 	if (which == ITEM_GEM_WHITE) {
 		_numGems -= amount;
@@ -227,12 +217,13 @@ bool AI::removeInvItemType(AIType which, int amount) {
 	if (!_numInventory)
 		return false;
 
+	bool found;
 	do {
-		found = 0;
+		found = false;
 
-		for (i = 0; i < _numInventory; i++)
+		for (int i = 0; i < _numInventory; i++)
 			if (_inventory[i].ent.type == which) {
-				j = i;
+				int j = i;
 				memset(&_inventory[j], 0, sizeof(InvEnt));
 				while (j < _numInventory - 1) {
 					memcpy(&_inventory[j], &_inventory[j + 1], sizeof(InvEnt));
@@ -241,7 +232,7 @@ bool AI::removeInvItemType(AIType which, int amount) {
 				}
 				_numInventory--;
 				amount--;
-				found = 1;
+				found = true;
 				if (!amount)
 					break;
 			}
@@ -255,11 +246,9 @@ bool AI::removeInvItemType(AIType which, int amount) {
 }
 
 bool AI::addItemToInventory(AIType type, int amount, const char *funcInit, const char *funcAction, const char *funcUse) {
-	int		i;
-	AIEntity *e;
-	for (i = 0; i < amount; i++) {
+	for (int i = 0; i < amount; i++) {
 		spawn(type, DIR_UP, 0, 0, funcInit, funcAction, funcUse, DIR_UP, 1, 0, 0, 1);
-		e = findEntity(0, 0);
+		AIEntity *e = findEntity(0, 0);
 		if (!e)
 			return false;
 		if (!addToInventory(e))
@@ -269,9 +258,10 @@ bool AI::addItemToInventory(AIType type, int amount, const char *funcInit, const
 }
 
 void AI::keepInvItem(AIType type) {
-	for (int i = 0; i < _numInventory; i++)
+	for (int i = 0; i < _numInventory; i++) {
 		if (_inventory[i].ent.type == type)
 			_inventory[i].keep = 1;
+	}
 }
 
 void AI::printYouGotMsg(const char *name) {
diff --git a/engines/hdb/ai-lists.cpp b/engines/hdb/ai-lists.cpp
index 0b4b7d3..0c6c17d 100644
--- a/engines/hdb/ai-lists.cpp
+++ b/engines/hdb/ai-lists.cpp
@@ -162,7 +162,7 @@ void AI::addBridgeExtend(int x, int y, int bridgeType) {
 }
 
 void AI::animateBridges() {
-	int	i, j, tileIndex, xv, yv;
+	int	tileIndex, xv, yv;
 	uint32 flags;
 	bool done;
 
@@ -170,7 +170,7 @@ void AI::animateBridges() {
 	if (!_numBridges)
 		return;
 
-	for (i = 0; i < _numBridges; i++) {
+	for (int i = 0; i < _numBridges; i++) {
 		if (_bridges[i].delay-- > 0)
 			continue;
 
@@ -231,7 +231,7 @@ void AI::animateBridges() {
 			if (!flags || (flags & kFlagMetal) || tileIndex >= 0 || (flags & kFlagSolid)) {
 				if (g_hdb->_map->onScreen(_bridges[i].x, _bridges[i].y))
 					g_hdb->_sound->playSound(SND_BRIDGE_END);
-				for (j = 0; j < _numBridges - 1; j++)
+				for (int j = 0; j < _numBridges - 1; j++)
 					memcpy(&_bridges[i], &_bridges[i + 1], sizeof(Bridge));
 				_numBridges--;
 			}
@@ -250,17 +250,16 @@ void AI::addToFairystones(int index, int tileX, int tileY, int sourceOrDest) {
 }
 
 int AI::checkFairystones(int tileX, int tileY) {
-	int i;
-	for (i = 0; i < kMaxFairystones; i++)
+	for (int i = 0; i < kMaxFairystones; i++) {
 		if (_fairystones[i].destX == tileX && _fairystones[i].destY == tileY)
 			return i;
+	}
 	return -1;
 }
 
 // Add an action location to the list of possible actions
 // Each action must be paired with another of the same number
 void AI::addToActionList(int actionIndex, int x, int y, char *luaFuncInit, char *luaFuncUse) {
-
 	if (!_actions[actionIndex].x1) {
 		_actions[actionIndex].x1 = x;
 		_actions[actionIndex].y1 = y;
@@ -356,7 +355,7 @@ void AI::addToHereList(const char *entName, int x, int y) {
 }
 
 HereT *AI::findHere(int x, int y) {
-	for (Common::Array<HereT *>::iterator it = _hereList->begin(); it != _hereList->end(); it++) {
+	for (Common::Array<HereT *>::iterator it = _hereList->begin(); it != _hereList->end(); ++it) {
 		if ((*it)->x == x && (*it)->y == y)
 			return *it;
 	}
@@ -770,7 +769,7 @@ bool AI::checkTeleportList(AIEntity *e, int x, int y) {
 				g_hdb->_window->stopPanicZone();
 
 			// Is there an attack gem still floating around?
-			for (Common::Array<AIEntity *>::iterator it = _ents->begin(); it != _ents->end(); it++) {
+			for (Common::Array<AIEntity *>::iterator it = _ents->begin(); it != _ents->end(); ++it) {
 				if ((*it)->type == AI_GEM_ATTACK) {
 					int amt = getGemAmount();
 					setGemAmount(amt + 1);
@@ -799,7 +798,7 @@ void AI::addToPathList(int x, int y, int type, AIDir dir) {
 }
 
 ArrowPath *AI::findArrowPath(int x, int y) {
-	for (Common::Array<ArrowPath *>::iterator it = _arrowPaths->begin(); it != _arrowPaths->end(); it++) {
+	for (Common::Array<ArrowPath *>::iterator it = _arrowPaths->begin(); it != _arrowPaths->end(); ++it) {
 		if ((*it)->tileX == x && (*it)->tileY == y)
 			return *it;
 	}
@@ -835,10 +834,8 @@ void AI::addToTriggerList(char *luaFuncInit, char *luaFuncUse, int x, int y, int
 }
 
 bool AI::checkTriggerList(char *entName, int x, int y) {
-	Trigger *t;
-
-	for (Common::Array<Trigger *>::iterator it = _triggerList->begin(); it != _triggerList->end(); it++) {
-		t = *it;
+	for (Common::Array<Trigger *>::iterator it = _triggerList->begin(); it != _triggerList->end(); ++it) {
+		Trigger *t = *it;
 		if (t->x == x && t->y == y) {
 			if (!t->luaFuncUse[0])
 				return false;


Commit: d4f927f338d4d221de59a04c85f9286a0a505528
    https://github.com/scummvm/scummvm/commit/d4f927f338d4d221de59a04c85f9286a0a505528
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:26+02:00

Commit Message:
HDB: Put both data and Lua saves into single file

Changed paths:
    engines/hdb/hdb.cpp
    engines/hdb/hdb.h
    engines/hdb/lua-script.cpp
    engines/hdb/lua-script.h
    engines/hdb/saveload.cpp


diff --git a/engines/hdb/hdb.cpp b/engines/hdb/hdb.cpp
index 445c5d8..e8e75d1 100644
--- a/engines/hdb/hdb.cpp
+++ b/engines/hdb/hdb.cpp
@@ -64,6 +64,9 @@ HDBGame::HDBGame(OSystem *syst, const ADGameDescription *gameDesc) : Engine(syst
 
 	_timePlayed = _timeSlice = _prevTimeSlice = _timeSeconds = _tiempo = 0;
 
+	_currentOutSaveFile = NULL;
+	_currentInSaveFile = NULL;
+
 	_progressActive = false;
 
 	_monkeystone7 = STARS_MONKEYSTONE_7_FAKE;
diff --git a/engines/hdb/hdb.h b/engines/hdb/hdb.h
index 3b42c26..cea8ab3 100644
--- a/engines/hdb/hdb.h
+++ b/engines/hdb/hdb.h
@@ -305,6 +305,9 @@ public:
 	// FPS Variables
 	Common::Array<uint32> _frames;
 
+	Common::OutSaveFile *_currentOutSaveFile;
+	Common::InSaveFile *_currentInSaveFile;
+
 private:
 
 	uint32 _timePlayed;
diff --git a/engines/hdb/lua-script.cpp b/engines/hdb/lua-script.cpp
index b61276d..cf0ef69 100644
--- a/engines/hdb/lua-script.cpp
+++ b/engines/hdb/lua-script.cpp
@@ -187,7 +187,7 @@ void LuaScript::purgeGlobals() {
 	_globals.clear();
 }
 
-void LuaScript::save(Common::OutSaveFile *out, int slot) {
+void LuaScript::save(Common::OutSaveFile *out) {
 	out->writeUint32LE(_globals.size());
 
 	// Save Globals
@@ -198,15 +198,18 @@ void LuaScript::save(Common::OutSaveFile *out, int slot) {
 		out->write(_globals[i]->string, 32);
 	}
 
-	Common::String saveLuaName = g_hdb->genSaveFileName(slot, true);
+	g_hdb->_currentOutSaveFile = out;
+
 	lua_printstack(_state);
 	lua_getglobal(_state, "SaveState");
 
-	lua_pushstring(_state, saveLuaName.c_str());
+	lua_pushstring(_state, "tempSave"); // the save file will be ignored
 	lua_call(_state, 1, 0);
+
+	g_hdb->_currentOutSaveFile = NULL;
 }
 
-void LuaScript::loadSaveFile(Common::InSaveFile *in, const char *fName) {
+void LuaScript::loadSaveFile(Common::InSaveFile *in) {
 	// Clear out all globals
 	_globals.clear();
 
@@ -223,10 +226,14 @@ void LuaScript::loadSaveFile(Common::InSaveFile *in, const char *fName) {
 		_globals.push_back(g);
 	}
 
+	g_hdb->_currentInSaveFile = in;
+
 	lua_getglobal(_state, "LoadState");
-	lua_pushstring(_state, fName);
+	lua_pushstring(_state, "tempSave");		// it will be ignored
 
 	lua_call(_state, 1, 0);
+
+	g_hdb->_currentInSaveFile = NULL;
 }
 
 void LuaScript::setLuaGlobalValue(const char *name, int value) {
@@ -1342,28 +1349,17 @@ static int playVoice(lua_State *L) {
 }
 
 static int openFile(lua_State *L) {
-
-	const char *fName = lua_tostring(L, 1);
-	const char *mode = lua_tostring(L, 2);
-
 	g_hdb->_lua->checkParameters("openFile", 2);
 
-	lua_pop(L, 2);
+	lua_pop(L, 2); // drop 2 parameters
 
-	if (!scumm_stricmp(mode, "wt")) {
-		Common::OutSaveFile *outLua = g_system->getSavefileManager()->openForSaving(fName);
-		if (!outLua)
-			error("Cannot open %s", fName);
-		lua_pushlightuserdata(L, outLua);
-	} else {
-		error("LUA openFile: Unsupported mode '%s'", mode);
-	}
+	lua_pushlightuserdata(L, 0);
 
 	return 1;
 }
 
 static int write(lua_State *L) {
-	Common::OutSaveFile *out = (Common::OutSaveFile *)lua_topointer(L, 1);
+	Common::OutSaveFile *out = g_hdb->_currentOutSaveFile;
 	const char *data = lua_tostring(L, 2);
 
 	g_hdb->_lua->checkParameters("write", 2);
@@ -1376,30 +1372,21 @@ static int write(lua_State *L) {
 }
 
 static int closeFile(lua_State *L) {
-	Common::OutSaveFile *out = (Common::OutSaveFile *)lua_topointer(L, 1);
-
 	g_hdb->_lua->checkParameters("closeFile", 1);
 
 	lua_pop(L, 1);
 
-	out->finalize();
-
-	delete out;
+	// No op
 
 	return 0;
 }
 
 static int dofile(lua_State *L) {
-	const char *fName = lua_tostring(L, 1);
-
 	g_hdb->_lua->checkParameters("dofile", 1);
 
 	lua_pop(L, 1);
 
-	Common::InSaveFile *in = g_system->getSavefileManager()->openForLoading(fName);
-
-	if (!in)
-		error("Lua dofile: cannot open file '%s'", fName);
+	Common::InSaveFile *in = g_hdb->_currentInSaveFile;
 
 	int length = in->size();
 	char *chunk = new char[length + 1];
@@ -1410,9 +1397,7 @@ static int dofile(lua_State *L) {
 	Common::String chunkString(chunk);
 	delete[] chunk;
 
-	delete in;
-
-	if (!g_hdb->_lua->executeChunk(chunkString, fName)) {
+	if (!g_hdb->_lua->executeChunk(chunkString, "saveState")) {
 		return 0;
 	}
 
diff --git a/engines/hdb/lua-script.h b/engines/hdb/lua-script.h
index 4dab94e..10d68c8 100644
--- a/engines/hdb/lua-script.h
+++ b/engines/hdb/lua-script.h
@@ -59,8 +59,8 @@ public:
 	void saveGlobalString(const char *global, const char *string);
 	void loadGlobal(const char *global);
 	void purgeGlobals();
-	void save(Common::OutSaveFile *out, int slot);
-	void loadSaveFile(Common::InSaveFile *in, const char *fName);
+	void save(Common::OutSaveFile *out);
+	void loadSaveFile(Common::InSaveFile *in);
 
 	bool init();
 	bool initScript(Common::SeekableReadStream *stream, const char *scriptName, int32 length);
diff --git a/engines/hdb/saveload.cpp b/engines/hdb/saveload.cpp
index 1163d56..ef086f4 100644
--- a/engines/hdb/saveload.cpp
+++ b/engines/hdb/saveload.cpp
@@ -60,7 +60,7 @@ Common::Error HDBGame::saveGameState(int slot, const Common::String &desc) {
 
 	// Actual Save Data
 	saveGame(out);
-	_lua->save(out, slot);
+	_lua->save(out);
 
 	out->finalize();
 	if (out->err())
@@ -91,8 +91,7 @@ Common::Error HDBGame::loadGameState(int slot) {
 
 	_lua->loadLua(_currentLuaName); // load the Lua code FIRST! (if no file, it's ok)
 
-	saveFileName = genSaveFileName(slot, true);
-	_lua->loadSaveFile(in, saveFileName.c_str());
+	_lua->loadSaveFile(in);
 
 	delete in;
 


Commit: 7d4c665176d08e3cd7badede8877c3f661f36aba
    https://github.com/scummvm/scummvm/commit/7d4c665176d08e3cd7badede8877c3f661f36aba
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:26+02:00

Commit Message:
HDB: Fix LIGHTBARREL in Slime & moving floats

Changed paths:
    engines/hdb/ai-funcs.cpp


diff --git a/engines/hdb/ai-funcs.cpp b/engines/hdb/ai-funcs.cpp
index b114390..77485f7 100644
--- a/engines/hdb/ai-funcs.cpp
+++ b/engines/hdb/ai-funcs.cpp
@@ -1197,6 +1197,7 @@ void AI::animateEntity(AIEntity *e) {
 							addAnimateTarget(e->x, e->y, 0, 3, ANIM_NORMAL, false, false, GROUP_STEAM_PUFF_SIT);
 							removeEntity(e);
 							g_hdb->_sound->playSound(SND_BARREL_MELTING);
+							return;
 						}
 					}
 				} else if ((flags & kFlagLightMelt) && e->type == AI_LIGHTBARREL) {
@@ -1237,11 +1238,12 @@ void AI::animateEntity(AIEntity *e) {
 						return;
 					} else {
 						// Make it float and splash in water
+						e->state = STATE_FLOATING;
 						addAnimateTarget(e->x, e->y, 0, 3, ANIM_NORMAL, false, false, GROUP_WATER_SPLASH_SIT);
 						floatEntity(e, STATE_FLOATING);
 						g_hdb->_sound->playSound(SND_SPLASH);
-						return;
 					}
+				}
 
 				// If it is floating downstream, keep moving it
 				if (flags & (kFlagPushRight | kFlagPushLeft | kFlagPushUp | kFlagPushDown)) {
@@ -1306,7 +1308,6 @@ void AI::animateEntity(AIEntity *e) {
 						e->moveSpeed = kPushMoveSpeed >> 1;
 						setEntityGoal(e, e->tileX + xv, e->tileY + yv);
 						e->state = state;
-						}
 					}
 				}
 			} else if (((flags = g_hdb->_map->getMapBGTileFlags(e->tileX, e->tileY)) & kFlagWater) && (e->type == AI_MAGIC_EGG || e->type == AI_ICE_BLOCK)) {


Commit: 599e144453af1aafc35e06973983345f05da8ae5
    https://github.com/scummvm/scummvm/commit/599e144453af1aafc35e06973983345f05da8ae5
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:26+02:00

Commit Message:
HDB: Fix initialization warning

Changed paths:
    engines/hdb/ai-funcs.cpp


diff --git a/engines/hdb/ai-funcs.cpp b/engines/hdb/ai-funcs.cpp
index 77485f7..e383670 100644
--- a/engines/hdb/ai-funcs.cpp
+++ b/engines/hdb/ai-funcs.cpp
@@ -1248,7 +1248,7 @@ void AI::animateEntity(AIEntity *e) {
 				// If it is floating downstream, keep moving it
 				if (flags & (kFlagPushRight | kFlagPushLeft | kFlagPushUp | kFlagPushDown)) {
 					int xv = 0, yv = 0;
-					AIState state;
+					AIState state = STATE_NONE;
 
 					if (flags & kFlagPushRight) {
 						e->dir = DIR_RIGHT;


Commit: d61d93ebe183c29cdc8153df7dc9109ee71dc347
    https://github.com/scummvm/scummvm/commit/d61d93ebe183c29cdc8153df7dc9109ee71dc347
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:26+02:00

Commit Message:
HDB: Fix loading of Lua script from the save

Changed paths:
    engines/hdb/lua-script.cpp


diff --git a/engines/hdb/lua-script.cpp b/engines/hdb/lua-script.cpp
index cf0ef69..1776ab7 100644
--- a/engines/hdb/lua-script.cpp
+++ b/engines/hdb/lua-script.cpp
@@ -1388,7 +1388,7 @@ static int dofile(lua_State *L) {
 
 	Common::InSaveFile *in = g_hdb->_currentInSaveFile;
 
-	int length = in->size();
+	int length = in->size() - in->pos();
 	char *chunk = new char[length + 1];
 	in->read((void *)chunk, length);
 


Commit: 312ebf6aaff590cf3a5c66d8064bb7fc88ec95cf
    https://github.com/scummvm/scummvm/commit/312ebf6aaff590cf3a5c66d8064bb7fc88ec95cf
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:26+02:00

Commit Message:
HDB: Load thumbnail from the launcher

Changed paths:
    engines/hdb/detection.cpp


diff --git a/engines/hdb/detection.cpp b/engines/hdb/detection.cpp
index e236a6c..245787f 100644
--- a/engines/hdb/detection.cpp
+++ b/engines/hdb/detection.cpp
@@ -109,6 +109,7 @@ public:
 	virtual bool hasFeature(MetaEngineFeature f) const;
 	virtual int getMaximumSaveSlot() const;
 	virtual SaveStateList listSaves(const char *target) const;
+	SaveStateDescriptor querySaveMetaInfos(const char *target, int slot) const;
 	virtual bool createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const;
 };
 
@@ -174,6 +175,32 @@ SaveStateList HDBMetaEngine::listSaves(const char *target) const {
 	return saveList;
 }
 
+SaveStateDescriptor HDBMetaEngine::querySaveMetaInfos(const char *target, int slot) const {
+	Common::ScopedPtr<Common::InSaveFile> in(g_system->getSavefileManager()->openForLoading(Common::String::format("%s.%03d", target, slot)));
+
+	if (in) {
+		SaveStateDescriptor desc;
+		char mapName[32];
+		Graphics::Surface *thumbnail;
+
+		if (!Graphics::loadThumbnail(*in, thumbnail)) {
+			warning("Error loading thumbnail");
+		}
+		desc.setThumbnail(thumbnail);
+
+		uint32 timeSeconds = in->readUint32LE();;
+		in->read(mapName, 32);
+
+		desc.setSaveSlot(slot);
+		desc.setPlayTime(timeSeconds * 1000);
+		desc.setDescription(mapName);
+
+		return desc;
+	}
+
+	return SaveStateDescriptor();
+}
+
 bool HDBMetaEngine::createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const {
 	if (desc) {
 		*engine = new HDB::HDBGame(syst, desc);


Commit: f94d1532758ab8fe2bb8e48f82792055c8b699b3
    https://github.com/scummvm/scummvm/commit/f94d1532758ab8fe2bb8e48f82792055c8b699b3
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:26+02:00

Commit Message:
HDB: Fix secret stars level launching

Changed paths:
    engines/hdb/menu.cpp


diff --git a/engines/hdb/menu.cpp b/engines/hdb/menu.cpp
index 83bfdbd..8c354fa 100644
--- a/engines/hdb/menu.cpp
+++ b/engines/hdb/menu.cpp
@@ -1101,7 +1101,7 @@ void Menu::processInput(int x, int y) {
 					g_hdb->saveGameState(kAutoSaveSlot, "FIXME"); // Add here date/level name // TODO
 				_starWarp = 0;
 				g_hdb->_sound->playSound(SND_MONKEYSTONE_SECRET_STAR);
-				g_hdb->startMap("map30");
+				g_hdb->startMap("MAP30");
 			} else if (x >= kStarGreenX && x <= kStarGreenX + _starGreenGfx[0]->_width &&
 				y >= kStarGreenY && y <= kStarGreenY + _starGreenGfx[0]->_height &&
 				g_hdb->getStarsMonkeystone14() == STARS_MONKEYSTONE_14) {
@@ -1111,7 +1111,7 @@ void Menu::processInput(int x, int y) {
 					g_hdb->saveGameState(kAutoSaveSlot, "FIXME"); // Add here date/level name // TODO
 				_starWarp = 1;
 				g_hdb->_sound->playSound(SND_MONKEYSTONE_SECRET_STAR);
-				g_hdb->startMap("map30");
+				g_hdb->startMap("MAP30");
 
 			} else if (x >= kStarBlueX && x <= kStarBlueX + _starBlueGfx[0]->_width &&
 				y >= kStarBlueY && y <= kStarBlueY + _starBlueGfx[0]->_height &&
@@ -1122,7 +1122,7 @@ void Menu::processInput(int x, int y) {
 					g_hdb->saveGameState(kAutoSaveSlot, "FIXME"); // Add here date/level name // TODO
 				_starWarp = 2;
 				g_hdb->_sound->playSound(SND_MONKEYSTONE_SECRET_STAR);
-				g_hdb->startMap("map30");
+				g_hdb->startMap("MAP30");
 			}
 		}
 		// secret warp menu? (click on nebula!)


Commit: b776651e454c438a1d14942efcaf37d4a9f58b97
    https://github.com/scummvm/scummvm/commit/b776651e454c438a1d14942efcaf37d4a9f58b97
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:26+02:00

Commit Message:
HDB: More script patches to MAP30.LUA

Changed paths:
    engines/hdb/lua-script.cpp


diff --git a/engines/hdb/lua-script.cpp b/engines/hdb/lua-script.cpp
index 1776ab7..abe3c3f 100644
--- a/engines/hdb/lua-script.cpp
+++ b/engines/hdb/lua-script.cpp
@@ -76,11 +76,14 @@ struct ScriptPatch {
 
 	{"MAP29.LUA", "Message( format( \"", "Message( string.format( \""}, // line 195
 
+	{"MAP30.LUA", "rots = 19 + random( 6 )", "rots = 19 + math.random( 6 )"}, // line 208
 	{"MAP30.LUA", "if i1 > getn(tiles)", "if i1 > #tiles"}, // line 211
 	{"MAP30.LUA", "if i2 > getn(tiles)", "if i2 > #tiles"}, // line 212
 	{"MAP30.LUA", "if i3 > getn(tiles)", "if i3 > #tiles"}, // line 213
+	{"MAP30.LUA", "rots = 13 + random( 4 )", "rots = 13 + math.random( 4 )"}, // line 234
 	{"MAP30.LUA", "if i2 > getn(tiles)", "if i2 > #tiles"}, // line 237
 	{"MAP30.LUA", "if i3 > getn(tiles)", "if i3 > #tiles"}, // line 238
+	{"MAP30.LUA", "rots = 13 + random( 4 )", "rots = 13 + math.random( 4 )"}, // line 258
 	{"MAP30.LUA", "if i3 > getn(tiles)", "if i3 > #tiles"}, // line 261
 
 	{NULL, NULL, NULL}


Commit: 04901e7ac9d38ef17191832b370ef25ea5557bef
    https://github.com/scummvm/scummvm/commit/04901e7ac9d38ef17191832b370ef25ea5557bef
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:26+02:00

Commit Message:
HDB: Fix load menu items

Changed paths:
    engines/hdb/detection.cpp
    engines/hdb/menu.cpp


diff --git a/engines/hdb/detection.cpp b/engines/hdb/detection.cpp
index 245787f..a69a83c 100644
--- a/engines/hdb/detection.cpp
+++ b/engines/hdb/detection.cpp
@@ -188,7 +188,7 @@ SaveStateDescriptor HDBMetaEngine::querySaveMetaInfos(const char *target, int sl
 		}
 		desc.setThumbnail(thumbnail);
 
-		uint32 timeSeconds = in->readUint32LE();;
+		uint32 timeSeconds = in->readUint32LE();
 		in->read(mapName, 32);
 
 		desc.setSaveSlot(slot);
diff --git a/engines/hdb/menu.cpp b/engines/hdb/menu.cpp
index 8c354fa..fbaa389 100644
--- a/engines/hdb/menu.cpp
+++ b/engines/hdb/menu.cpp
@@ -1020,6 +1020,8 @@ void Menu::fillSavegameSlots() {
 		if (!in) {
 			memset(&_saveGames[i], 0, sizeof(Save));
 		} else {
+			Graphics::skipThumbnail(*in);
+
 			strcpy(_saveGames[i].saveID, saveGameFile.c_str());
 			_saveGames[i].seconds = in->readUint32LE();
 			in->read(_saveGames[i].mapName, 32);


Commit: bcf910470c0dfef858045cc224ec686e539937b8
    https://github.com/scummvm/scummvm/commit/bcf910470c0dfef858045cc224ec686e539937b8
Author: Strangerke (strangerke at scummvm.org)
Date: 2019-09-03T17:17:26+02:00

Commit Message:
HDB: Fix some CppCheck warnings in ai-player, ai-use, ai-waypoint and gfx

Changed paths:
    engines/hdb/ai-player.cpp
    engines/hdb/ai-use.cpp
    engines/hdb/ai-waypoint.cpp
    engines/hdb/gfx.cpp


diff --git a/engines/hdb/ai-player.cpp b/engines/hdb/ai-player.cpp
index 25f3712..86d22b2 100644
--- a/engines/hdb/ai-player.cpp
+++ b/engines/hdb/ai-player.cpp
@@ -107,8 +107,10 @@ void aiPlayerInit2(AIEntity *e) {
 }
 
 void aiPlayerAction(AIEntity *e) {
-	AIState stand[5] = {STATE_NONE, STATE_STANDUP, STATE_STANDDOWN, STATE_STANDLEFT, STATE_STANDRIGHT};
-	int xvAhead[5] = {9, 0, 0, -1, 1}, yvAhead[5] = {9, -1, 1, 0, 0};
+	static const AIState stand[5] = {STATE_NONE, STATE_STANDUP, STATE_STANDDOWN, STATE_STANDLEFT, STATE_STANDRIGHT};
+	static const int xvAhead[5] = {9, 0, 0, -1, 1};
+	static const int yvAhead[5] = {9, -1, 1, 0, 0};
+
 	AIEntity *hit = NULL;
 
 	// Draw the STUN lightning if it exists
@@ -473,9 +475,8 @@ void aiGemAttackInit(AIEntity *e) {
 }
 
 void aiGemAttackAction(AIEntity *e) {
-	int xv[5] = {9, 0, 0, -1, 1}, yv[5] = {9, -1, 1, 0, 0};
-	AIEntity *hit;
-	int		result;
+	static const int xv[5] = {9, 0, 0, -1, 1};
+	static const int yv[5] = {9, -1, 1, 0, 0};
 
 	switch (e->sequence) {
 		// flying out at something
@@ -486,10 +487,10 @@ void aiGemAttackAction(AIEntity *e) {
 			g_hdb->_ai->checkActionList(e, e->tileX, e->tileY, false);
 			g_hdb->_ai->checkAutoList(e, e->tileX, e->tileY);
 
-			hit = g_hdb->_ai->findEntityIgnore(e->tileX, e->tileY, e);
+			AIEntity *hit = g_hdb->_ai->findEntityIgnore(e->tileX, e->tileY, e);
 			uint32 bgFlags = g_hdb->_map->getMapBGTileFlags(e->tileX, e->tileY);
 			uint32 fgFlags = g_hdb->_map->getMapFGTileFlags(e->tileX, e->tileY);
-			result = (e->level == 1 ? (bgFlags & (kFlagSolid)) : !(fgFlags & kFlagGrating) && (bgFlags & (kFlagSolid)));
+			int result = (e->level == 1 ? (bgFlags & (kFlagSolid)) : !(fgFlags & kFlagGrating) && (bgFlags & (kFlagSolid)));
 			if (hit) {
 				switch (hit->type) {
 				case AI_CHICKEN:
@@ -791,30 +792,29 @@ void aiBarrelExplodeAction(AIEntity *e) {
 }
 
 void aiBarrelExplodeSpread(AIEntity *e) {
-	AIEntity *e2;
+	static const int xv1[4] = {-1,  1, -1,  0};
+	static const int yv1[4] = {-1, -1,  0, -1};
+	static const int xv2[4] = {1,  0,  1, -1};
+	static const int yv2[4] = {0,  1,  1,  1};
+
 	int	x = e->tileX;
 	int	y = e->tileY;
-	int	xv, yv;
 	int	index = e->animFrame;
-	int	xv1[4] = {-1,  1, -1,  0};
-	int yv1[4] = {-1, -1,  0, -1};
-	int xv2[4] = {1,  0,  1, -1};
-	int yv2[4] = {0,  1,  1,  1};
 
 	// are we just starting an explosion ring?
 	if (e->animDelay != e->animCycle)
 		return;
 
 	// the animation frame is the index into which set of 2 explosions to spawn
-	xv = xv1[index];
-	yv = yv1[index];
+	int xv = xv1[index];
+	int yv = yv1[index];
 
 	// explosion 1: check to see if we can explode (non-solid tile)
 	// if so, spawn it and mark it in the explosion matrix
 	if (!(g_hdb->_map->getMapBGTileFlags(x + xv, y + yv) & kFlagSolid) && !g_hdb->_map->explosionExist(x + xv, y + yv)) {
 		aiBarrelBlowup(e, x + xv, y + yv);
 		// are we blowing up on another BOOMBARREL?  if so, start it exploding.
-		e2 = g_hdb->_ai->findEntity(x + xv, y + yv);
+		AIEntity *e2 = g_hdb->_ai->findEntity(x + xv, y + yv);
 		if (e2 && e2->state != STATE_EXPLODING) {
 			switch (e2->type) {
 			case AI_GUY:
@@ -858,7 +858,7 @@ void aiBarrelExplodeSpread(AIEntity *e) {
 	if (!(g_hdb->_map->getMapBGTileFlags(x + xv, y + yv) & kFlagSolid) && !g_hdb->_map->explosionExist(x + xv, y + yv)) {
 		aiBarrelBlowup(e, x + xv, y + yv);
 		// are we blowing up on another BOOMBARREL?  if so, start it exploding.
-		e2 = g_hdb->_ai->findEntity(x + xv, y + yv);
+		AIEntity *e2 = g_hdb->_ai->findEntity(x + xv, y + yv);
 		if (e2 && e2->state != STATE_EXPLODING) {
 			switch (e2->type) {
 			case AI_GUY:
@@ -1590,17 +1590,14 @@ void aiMonkeystoneUse(AIEntity *e) {
 }
 
 void aiGemAction(AIEntity *e) {
-	AIEntity *p;
-	int tolerance;
-
 	e->animFrame++;
 	if (e->animFrame >= e->standdownFrames) {
 		e->animFrame = 0;
 
 		// every 4th frame, check for player collision &
 		// add to inventory if it happens
-		p = g_hdb->_ai->getPlayer();
-		tolerance = 16;
+		AIEntity *p = g_hdb->_ai->getPlayer();
+		int tolerance = 16;
 		if (g_hdb->_ai->playerRunning())
 			tolerance = 24;
 
diff --git a/engines/hdb/ai-use.cpp b/engines/hdb/ai-use.cpp
index 806491f..21c331b 100644
--- a/engines/hdb/ai-use.cpp
+++ b/engines/hdb/ai-use.cpp
@@ -89,11 +89,9 @@ bool AI::isOpenDoor(int x, int y) {
 }
 
 bool AI::useTarget(int x, int y, int targetX, int targetY, int newTile, int *worked) {
-	int tileIndex;
-
 	// open a locked door?
 	if (isClosedDoor(targetX, targetY)) {
-		tileIndex = g_hdb->_map->getMapBGTileIndex(targetX, targetY);
+		int tileIndex = g_hdb->_map->getMapBGTileIndex(targetX, targetY);
 
 		addAnimateTarget(targetX, targetY, tileIndex, tileIndex - 3, ANIM_SLOW, false, true, NULL);
 		g_hdb->_map->setMapBGTileIndex(x, y, newTile);
@@ -105,7 +103,7 @@ bool AI::useTarget(int x, int y, int targetX, int targetY, int newTile, int *wor
 
 	// close an open door?
 	if (isOpenDoor(targetX, targetY)) {
-		tileIndex = g_hdb->_map->getMapBGTileIndex(targetX, targetY);
+		int tileIndex = g_hdb->_map->getMapBGTileIndex(targetX, targetY);
 
 		addAnimateTarget(targetX, targetY, tileIndex, tileIndex + 3, ANIM_SLOW, false, true, NULL);
 		g_hdb->_map->setMapBGTileIndex(x, y, newTile);
@@ -116,7 +114,7 @@ bool AI::useTarget(int x, int y, int targetX, int targetY, int newTile, int *wor
 	}
 
 	// open up a bridge?
-	tileIndex = g_hdb->_map->getMapFGTileIndex(targetX, targetY);
+	int tileIndex = g_hdb->_map->getMapFGTileIndex(targetX, targetY);
 	if (tileIndex == _targetBridgeU ||
 		tileIndex == _targetBridgeD ||
 		tileIndex == _targetBridgeL ||
@@ -158,11 +156,9 @@ bool AI::useLockedSwitch(AIEntity *e, int x, int y, int targetX, int targetY, in
 		return false;
 
 	int	amount = queryInventoryType(item);
-	int	worked;
-	bool rtn;
-
 	if (amount) {
-		rtn = useTarget(x, y, targetX, targetY, onTile, &worked);
+		int	worked;
+		bool rtn = useTarget(x, y, targetX, targetY, onTile, &worked);
 		if (worked) {
 			removeInvItemType(item, 1);
 			if (g_hdb->_map->onScreen(x, y))
@@ -182,12 +178,11 @@ bool AI::useLockedSwitchOn(AIEntity *e, int x, int y, int targetX, int targetY,
 	if (abs(x - _player->tileX) > 1 || abs(y - _player->tileY) > 1)
 		return false;
 
-	int	worked;
-	bool rtn;
 	if (getInvAmount() == 10)
 		return false;
 
-	rtn = useTarget(x, y, targetX, targetY, offTile, &worked);
+	int	worked;
+	bool rtn = useTarget(x, y, targetX, targetY, offTile, &worked);
 	if (worked) {
 		addItemToInventory(item, 1, NULL, NULL, NULL);
 		if (g_hdb->_map->onScreen(x, y))
@@ -203,11 +198,10 @@ bool AI::useCellHolder(AIEntity *e, int x, int y, int targetX, int targetY) {
 		return false;
 
 	int	amount = queryInventoryType(ITEM_CELL);
-	int	worked;
-	bool rtn;
 
 	if (amount) {
-		rtn = useTarget(x, y, targetX, targetY, _useHolderFull, &worked);
+		int	worked;
+		bool rtn = useTarget(x, y, targetX, targetY, _useHolderFull, &worked);
 		if (worked) {
 			removeInvItemType(ITEM_CELL, 1);
 			if (g_hdb->_map->onScreen(x, y))
diff --git a/engines/hdb/ai-waypoint.cpp b/engines/hdb/ai-waypoint.cpp
index cbc9e9e..34704d2 100644
--- a/engines/hdb/ai-waypoint.cpp
+++ b/engines/hdb/ai-waypoint.cpp
@@ -363,29 +363,29 @@ void AI::clearWaypoints() {
 }
 
 bool AI::traceStraightPath(int x1, int y1, int *x2, int *y2, int *level) {
-	int	xVel, yVel, ok, entOK;
-	AIEntity *e;
-
 	// this checks to make sure we're only going vert or horz
 	if (x1 != *x2 && y1 != *y2)
 		return false;
 
 	// this sets a -1, 0, or 1 step value
-	xVel = *x2 - x1;
+	int xVel = *x2 - x1;
 	if (xVel < 0)
 		xVel = -1;
 	if (xVel > 0)
 		xVel = 1;
 
-	yVel = *y2 - y1;
+	int yVel = *y2 - y1;
 	if (yVel < 0)
 		yVel = -1;
 	if (yVel > 0)
 		yVel = 1;
 
+	AIEntity *e;
 	while (1) {
 		// clear tile ahead?
-		entOK = ok = 0;
+		bool entOK = false;
+		bool ok = false;
+
 		uint32 flags = g_hdb->_map->getMapBGTileFlags(x1, y1);
 		if (flags & kFlagStairTop)
 			*level = 2;
@@ -401,23 +401,23 @@ bool AI::traceStraightPath(int x1, int y1, int *x2, int *y2, int *level) {
 					((flags & kFlagRadFloor) == kFlagRadFloor);
 				e = findEntity(x1, y1);
 				if (e && g_hdb->_ai->walkThroughEnt(e->type))
-					entOK = 1;
+					entOK = true;
 				else if (ok && e && (e->state == STATE_FLOATING || e->state == STATE_MELTED || e == _player))
-					entOK = ok = 1;
+					entOK = ok = true;
 				else
-					ok = 0;
+					ok = false;
 			} else if (ok &&
 				((flags & kFlagWater) == kFlagWater ||
 				(flags & kFlagSlime) == kFlagSlime)) {
 				// if it's non-blocking, is there water or slime?
 				e = findEntity(x1, y1);
 				if (e && g_hdb->_ai->walkThroughEnt(e->type))
-					entOK = 1;
+					entOK = true;
 				else
 					if (e && (e->state == STATE_FLOATING || e->state == STATE_MELTED || e == _player))
-						entOK = ok = 1;
+						entOK = ok = true;
 					else
-						ok = 0;
+						ok = false;
 				}
 		} else {
 			// Floor level 2
@@ -432,23 +432,23 @@ bool AI::traceStraightPath(int x1, int y1, int *x2, int *y2, int *level) {
 						((flags & kFlagRadFloor) == kFlagRadFloor);
 					e = findEntity(x1, y1);
 					if (e && g_hdb->_ai->walkThroughEnt(e->type))
-						entOK = 1;
+						entOK = true;
 					else if (ok && e && (e->state == STATE_FLOATING || e->state == STATE_MELTED || e == _player))
-							entOK = ok = 1;
+							entOK = ok = true;
 					else
-						ok = 0;
+						ok = false;
 				} else if (ok &&
 					((flags & kFlagWater) == kFlagWater ||
 					(flags & kFlagSlime) == kFlagSlime)) {
 					// if it's non-blocking, is there water or slime?
 					e = findEntity(x1, y1);
 					if (e && g_hdb->_ai->walkThroughEnt(e->type))
-						entOK = 1;
+						entOK = true;
 					else
 						if (e && (e->state == STATE_FLOATING || e->state == STATE_MELTED || e == _player))
-							entOK = ok = 1;
+							entOK = ok = true;
 						else
-							ok = 0;
+							ok = false;
 				}
 			}
 		}
@@ -529,16 +529,15 @@ Tile *AI::getStandFrameDir(AIEntity *e) {
 }
 
 void AI::drawWayPoints() {
-	int	i;
-	int	mapX, mapY;
 	static int anim = 0;
 	static uint32 delay = g_hdb->getTimeSlice();
 	static int alpha = 255;
 	static int aVel = -4;
 
+	int	mapX, mapY;
 	g_hdb->_map->getMapXY(&mapX, &mapY);
 
-	for (i = 0; i < _numWaypoints; i++) {
+	for (int i = 0; i < _numWaypoints; i++) {
 		int	x = _waypoints[i].x * kTileWidth;
 		int	y = _waypoints[i].y * kTileHeight;
 
@@ -562,6 +561,7 @@ void AI::drawWayPoints() {
 	// don't animate every single game frame...
 	if (delay > g_hdb->getTimeSlice())
 		return;
+
 	delay = g_hdb->getTimeSlice() + 100;
 
 	// cycle the waypoint gfx animation
diff --git a/engines/hdb/gfx.cpp b/engines/hdb/gfx.cpp
index aba8742..9dc3d3b 100644
--- a/engines/hdb/gfx.cpp
+++ b/engines/hdb/gfx.cpp
@@ -171,8 +171,6 @@ bool Gfx::init() {
 }
 
 void Gfx::save(Common::OutSaveFile *out) {
-	int i;
-
 	out->writeSint32LE(_currentSky);
 
 	out->writeByte(_fadeInfo.active);
@@ -183,19 +181,17 @@ void Gfx::save(Common::OutSaveFile *out) {
 	out->writeSint32LE(_fadeInfo.curStep);
 
 	out->writeByte(_snowInfo.active);
-	for (i = 0; i < MAX_SNOW; i++)
+	for (int i = 0; i < MAX_SNOW; i++)
 		out->writeDoubleLE(_snowInfo.x[i]);
-	for (i = 0; i < MAX_SNOW; i++)
+	for (int i = 0; i < MAX_SNOW; i++)
 		out->writeDoubleLE(_snowInfo.y[i]);
-	for (i = 0; i < MAX_SNOW; i++)
+	for (int i = 0; i < MAX_SNOW; i++)
 		out->writeDoubleLE(_snowInfo.yv[i]);
-	for (i = 0; i < MAX_SNOW; i++)
+	for (int i = 0; i < MAX_SNOW; i++)
 		out->writeSint32LE(_snowInfo.xvindex[i]);
 }
 
 void Gfx::loadSaveFile(Common::InSaveFile *in) {
-	int i;
-
 	_currentSky = in->readSint32LE();
 
 	_fadeInfo.active = in->readByte();
@@ -207,13 +203,13 @@ void Gfx::loadSaveFile(Common::InSaveFile *in) {
 
 	_snowInfo.active = in->readByte();
 
-	for (i = 0; i < MAX_SNOW; i++)
+	for (int i = 0; i < MAX_SNOW; i++)
 		_snowInfo.x[i] = in->readDoubleLE();
-	for (i = 0; i < MAX_SNOW; i++)
+	for (int i = 0; i < MAX_SNOW; i++)
 		_snowInfo.y[i] = in->readDoubleLE();
-	for (i = 0; i < MAX_SNOW; i++)
+	for (int i = 0; i < MAX_SNOW; i++)
 		_snowInfo.yv[i] = in->readDoubleLE();
-	for (i = 0; i < MAX_SNOW; i++)
+	for (int i = 0; i < MAX_SNOW; i++)
 		_snowInfo.xvindex[i] = in->readSint32LE();
 
 	setSky(_currentSky);
@@ -387,9 +383,8 @@ void Gfx::updateFade() {
 }
 
 void Gfx::turnOnSnow() {
-	int		i;
 	_snowInfo.active = true;
-	for (i = 0; i < MAX_SNOW; i++) {
+	for (int i = 0; i < MAX_SNOW; i++) {
 		_snowInfo.x[i] = g_hdb->_rnd->getRandomNumber(kScreenWidth - 1);
 		_snowInfo.y[i] = g_hdb->_rnd->getRandomNumber(kScreenHeight - 1);
 		_snowInfo.yv[i] = g_hdb->_rnd->getRandomNumber(2) + 1;
@@ -434,7 +429,6 @@ Tile *Gfx::loadIcon(const char *tileName) {
 }
 
 Tile *Gfx::getTile(int index) {
-
 	if (index < 0 || index > _numTiles) {
 		if (index != 0xFFFF)
 			debug(6, "getTile(%d): wrong index > %d", index, _numTiles);
@@ -535,7 +529,7 @@ bool Gfx::selectGfxType(const char *name) {
 
 Tile *Gfx::getTileGfx(const char *name, int32 size) {
 	// Try to find graphic
-	for (Common::Array<GfxCache *>::iterator it = _gfxCache->begin(); it != _gfxCache->end(); it++) {
+	for (Common::Array<GfxCache *>::iterator it = _gfxCache->begin(); it != _gfxCache->end(); ++it) {
 		if (Common::matchString((*it)->name, name)) {
 			if ((*it)->loaded == -1) {	// Marked for Deletetion?
 				(*it)->loaded = 1;		// Reactivate it
@@ -559,7 +553,7 @@ Tile *Gfx::getTileGfx(const char *name, int32 size) {
 }
 
 void Gfx::markGfxCacheFreeable() {
-	for (Common::Array<GfxCache *>::iterator it = _gfxCache->begin(); it != _gfxCache->end(); it++)
+	for (Common::Array<GfxCache *>::iterator it = _gfxCache->begin(); it != _gfxCache->end(); ++it)
 		(*it)->loaded = -1;
 }
 
@@ -569,7 +563,7 @@ void Gfx::markTileCacheFreeable() {
 
 Picture *Gfx::getPicGfx(const char *name, int32 size) {
 	// Try to find graphic
-	for (Common::Array<GfxCache *>::iterator it = _gfxCache->begin(); it != _gfxCache->end(); it++) {
+	for (Common::Array<GfxCache *>::iterator it = _gfxCache->begin(); it != _gfxCache->end(); ++it) {
 		if (Common::matchString((*it)->name, name)) {
 			if ((*it)->loaded == -1) {	// Marked for Deletetion?
 				(*it)->loaded = 1;		// Reactivate it
@@ -740,12 +734,11 @@ bool Gfx::loadFont(const char *string) {
 	debug(3, "leading: %d", _fontHeader.leading);
 
 	// Loading _charInfoBlocks & creating character surfaces
-	CharInfo *cInfo;
 	int startPos = stream->pos();	// Position after _fontHeader
 	int curPos;						// Position after reading cInfo
 	uint16 *ptr;
 	for (int i = 0; i < _fontHeader.numChars; i++) {
-		cInfo = new CharInfo;
+		CharInfo *cInfo = new CharInfo;
 		cInfo->width = (int16)stream->readUint32LE();
 		cInfo->offset = (int32)stream->readUint32LE();
 
@@ -856,13 +849,12 @@ void Gfx::getDimensions(const char *string, int *pixelsWide, int *lines) {
 	}
 
 	int width, maxWidth, height;
-	unsigned char c;
 	maxWidth = 0;
 	width = _eLeft;
 	height = 1;
 
 	for (int i = 0; i < (int)strlen(string); i++) {
-		c = string[i];
+		unsigned char c = string[i];
 		width += _charInfoBlocks[c]->width + _fontHeader.kerning + kFontIncrement;
 		if (c == ' ')
 			width += kFontSpace;
@@ -909,9 +901,9 @@ int Gfx::stringLength(const char *string) {
 }
 
 void Gfx::centerPrint(const char *string) {
-	int totalWidth = 0, i;
+	int totalWidth = 0;
 
-	for (i = 0; i < (int)strlen(string); i++) {
+	for (int i = 0; i < (int)strlen(string); i++) {
 		if (string[i] == ' ')
 			totalWidth += kFontSpace;
 		else if (string[i] != '\n')
@@ -957,9 +949,8 @@ void Gfx::getCursor(int *x, int *y) {
 }
 
 void Gfx::turnOnBonusStars(int which) {
-	int	i;
 	_starsInfo.active = true;
-	for (i = 0; i < 10; i++)
+	for (int i = 0; i < 10; i++)
 		_starsInfo.starAngle[i] = (36 * (i + 1)) - 10;
 	if (!_starsInfo.gfx[0]) {
 		switch (which) {
@@ -987,8 +978,6 @@ void Gfx::turnOnBonusStars(int which) {
 }
 
 void Gfx::drawBonusStars() {
-	int		i, w, h;
-
 	if (!_starsInfo.active)
 		return;
 
@@ -997,10 +986,10 @@ void Gfx::drawBonusStars() {
 		_starsInfo.anim = 1 - _starsInfo.anim;
 	}
 
-	w = _starsInfo.gfx[0]->_width / 2;
-	h = _starsInfo.gfx[0]->_height / 2;
+	int w = _starsInfo.gfx[0]->_width / 2;
+	int h = _starsInfo.gfx[0]->_height / 2;
 
-	for (i = 0; i < 10; i++) {
+	for (int i = 0; i < 10; i++) {
 		_starsInfo.gfx[_starsInfo.anim]->drawMasked(
 			(int)(480 / 2 + ((float)_starsInfo.radius / 2)) + (int)((double)_starsInfo.radius * _cosines->at(_starsInfo.starAngle[i]) - w),
 			(480 / 2) + (int)((double)_starsInfo.radius * _sines->at(_starsInfo.starAngle[i]) - h)
@@ -1027,8 +1016,6 @@ void Gfx::drawBonusStars() {
 }
 
 void Gfx::drawDebugInfo(Tile *_debugLogo, int fps) {
-	int x, y;
-	AIEntity *p;
 	char buff[64];
 
 	_debugLogo->drawMasked(kScreenWidth - 32, 0);
@@ -1040,12 +1027,14 @@ void Gfx::drawDebugInfo(Tile *_debugLogo, int fps) {
 
 	// Draw Player Info
 	setCursor(0, 16);
+
+	int x, y;
 	g_hdb->_ai->getPlayerXY(&x, &y);
 	sprintf(buff, "Player X: %d, Y: %d", x / kTileWidth, y / kTileHeight);
 	drawText(buff);
 
 	setCursor(0, 32);
-	p = g_hdb->_ai->getPlayer();
+	AIEntity *p = g_hdb->_ai->getPlayer();
 	if (p) {
 		sprintf(buff, "Player height level: %d", p->level);
 		drawText(buff);
@@ -1071,10 +1060,8 @@ Graphics::Surface Picture::load(Common::SeekableReadStream *stream) {
 	_surface.create(_width, _height, g_hdb->_format);
 	stream->readUint32LE(); // Skip Win32 Surface
 
-	uint16 *ptr;
-
 	for (int y = 0; y < _height; y++) {
-		ptr = (uint16 *)_surface.getBasePtr(0, y);
+		uint16 *ptr = (uint16 *)_surface.getBasePtr(0, y);
 		for (int x = 0; x < _width; x++) {
 			*ptr = TO_LE_16(stream->readUint16LE());
 			ptr++;
@@ -1125,10 +1112,8 @@ Graphics::Surface Tile::load(Common::SeekableReadStream *stream) {
 	_surface.create(32, 32, g_hdb->_format);
 	stream->readUint32LE(); // Skip Win32 Surface
 
-	uint16 *ptr;
-
 	for (uint y = 0; y < 32; y++) {
-		ptr = (uint16 *)_surface.getBasePtr(0, y);
+		uint16 *ptr = (uint16 *)_surface.getBasePtr(0, y);
 		for (uint x = 0; x < 32; x++) {
 			*ptr = TO_LE_16(stream->readUint16LE());
 			ptr++;


Commit: 616045496c7fd25b09c6c1554f8fcb02d8e6a706
    https://github.com/scummvm/scummvm/commit/616045496c7fd25b09c6c1554f8fcb02d8e6a706
Author: Strangerke (strangerke at scummvm.org)
Date: 2019-09-03T17:17:26+02:00

Commit Message:
HDB: (Hopefully) fix a c&p error in hasFeature()

Changed paths:
    engines/hdb/detection.cpp


diff --git a/engines/hdb/detection.cpp b/engines/hdb/detection.cpp
index a69a83c..3c3c153 100644
--- a/engines/hdb/detection.cpp
+++ b/engines/hdb/detection.cpp
@@ -116,8 +116,8 @@ public:
 bool HDBMetaEngine::hasFeature(MetaEngineFeature f) const {
 	return
 		(f == kSupportsLoadingDuringStartup) ||
-		(f == kSupportsLoadingDuringStartup) ||
 		(f == kSupportsListSaves) ||
+		(f == kSupportsDeleteSave) ||
 		(f == kSavesSupportMetaInfo) ||
 		(f == kSavesSupportThumbnail) ||
 		(f == kSavesSupportPlayTime);


Commit: bf57f7befb5af0c7f3d95b96d6fd1f8a46c056ef
    https://github.com/scummvm/scummvm/commit/bf57f7befb5af0c7f3d95b96d6fd1f8a46c056ef
Author: Strangerke (strangerke at scummvm.org)
Date: 2019-09-03T17:17:26+02:00

Commit Message:
HDB: Fix an out of bound issue in mapname

Changed paths:
    engines/hdb/hdb.cpp


diff --git a/engines/hdb/hdb.cpp b/engines/hdb/hdb.cpp
index e8e75d1..837bb96 100644
--- a/engines/hdb/hdb.cpp
+++ b/engines/hdb/hdb.cpp
@@ -879,7 +879,7 @@ Common::Error HDBGame::run() {
 #endif
 
 	if (ConfMan.hasKey("boot_param")) {
-		char mapname[10];
+		char mapname[11];
 		int arg = ConfMan.getInt("boot_param");
 		int actionMode = MIN(arg / 100, 1);
 		int level = MIN(arg % 100, 31);


Commit: 4b65e396c801e1a08c89de79ebfeaf2f20ada0a0
    https://github.com/scummvm/scummvm/commit/4b65e396c801e1a08c89de79ebfeaf2f20ada0a0
Author: Strangerke (strangerke at scummvm.org)
Date: 2019-09-03T17:17:26+02:00

Commit Message:
HDB: Reduce some variable scopes, some janitorial work

Changed paths:
    engines/hdb/gfx.cpp
    engines/hdb/hdb.cpp
    engines/hdb/input.cpp
    engines/hdb/lua-script.cpp


diff --git a/engines/hdb/gfx.cpp b/engines/hdb/gfx.cpp
index 9dc3d3b..641f179 100644
--- a/engines/hdb/gfx.cpp
+++ b/engines/hdb/gfx.cpp
@@ -734,9 +734,9 @@ bool Gfx::loadFont(const char *string) {
 	debug(3, "leading: %d", _fontHeader.leading);
 
 	// Loading _charInfoBlocks & creating character surfaces
-	int startPos = stream->pos();	// Position after _fontHeader
-	int curPos;						// Position after reading cInfo
-	uint16 *ptr;
+
+	// Position after _fontHeader
+	int startPos = stream->pos();
 	for (int i = 0; i < _fontHeader.numChars; i++) {
 		CharInfo *cInfo = new CharInfo;
 		cInfo->width = (int16)stream->readUint32LE();
@@ -744,7 +744,8 @@ bool Gfx::loadFont(const char *string) {
 
 		debug(3, "Loaded _charInfoBlocks[%d]: width: %d, offset: %d", i, cInfo->width, cInfo->offset);
 
-		curPos = stream->pos();
+		// Position after reading cInfo
+		int curPos = stream->pos();
 
 		_fontSurfaces[i].create(cInfo->width, _fontHeader.height, g_hdb->_format);
 
@@ -752,7 +753,7 @@ bool Gfx::loadFont(const char *string) {
 		stream->seek(startPos+cInfo->offset);
 
 		for (int y = 0; y < _fontHeader.height; y++) {
-			ptr = (uint16 *)_fontSurfaces[i].getBasePtr(0, y);
+			uint16 *ptr = (uint16 *)_fontSurfaces[i].getBasePtr(0, y);
 			for (int x = 0; x < cInfo->width; x++) {
 				*ptr = TO_LE_16(stream->readUint16LE());
 				ptr++;
@@ -782,11 +783,10 @@ void Gfx::drawText(const char *string) {
 
 	// Word Wrapping
 	int width = _eLeft;
-	unsigned char c;
 	char cr[256];	// Carriage Return Array
 
 	for (int i = 0; i < (int)strlen(string); i++) {
-		c = string[i];
+		unsigned char c = string[i];
 		width += _charInfoBlocks[c]->width + _fontHeader.kerning + kFontIncrement;
 		if (c == ' ')
 			width += kFontSpace;
@@ -806,7 +806,7 @@ void Gfx::drawText(const char *string) {
 
 	// Draw the characters
 	for (int j = 0; j < (int)strlen(string); j++) {
-		c = string[j];
+		unsigned char c = string[j];
 		if (c == '\n' || cr[j]) {
 			_cursorX = _eLeft;
 			_cursorY += _fontHeader.height + _fontHeader.leading;
@@ -848,10 +848,9 @@ void Gfx::getDimensions(const char *string, int *pixelsWide, int *lines) {
 		return;
 	}
 
-	int width, maxWidth, height;
-	maxWidth = 0;
-	width = _eLeft;
-	height = 1;
+	int maxWidth = 0;
+	int width = _eLeft;
+	int height = 1;
 
 	for (int i = 0; i < (int)strlen(string); i++) {
 		unsigned char c = string[i];
diff --git a/engines/hdb/hdb.cpp b/engines/hdb/hdb.cpp
index 837bb96..3fb963a 100644
--- a/engines/hdb/hdb.cpp
+++ b/engines/hdb/hdb.cpp
@@ -908,10 +908,7 @@ Common::Error HDBGame::run() {
 	lua->executeFile("test.lua");
 #endif
 
-	AIEntity *e;
-
 	while (!shouldQuit()) {
-
 		Common::Event event;
 		while (g_system->getEventManager()->pollEvent(event)) {
 			switch (event.type) {
@@ -960,7 +957,7 @@ Common::Error HDBGame::run() {
 			_ai->processCines();
 			//_window->drawDialog();
 
-			e = _ai->getPlayer();
+			AIEntity *e = _ai->getPlayer();
 
 			if (e && e->level < 2)
 				_ai->drawWayPoints();
diff --git a/engines/hdb/input.cpp b/engines/hdb/input.cpp
index 91b3a97..e345032 100644
--- a/engines/hdb/input.cpp
+++ b/engines/hdb/input.cpp
@@ -121,8 +121,6 @@ uint16 Input::getButtons() {
 }
 
 void Input::stylusDown(int x, int y) {
-	int worldX, worldY;
-	GameState gs;
 	static uint32 delay = 0, time;
 
 	// Don't let the screen get clicked too fast
@@ -134,7 +132,7 @@ void Input::stylusDown(int x, int y) {
 	_stylusDown = true;
 	_stylusDownX = x;
 	_stylusDownY = y;
-	gs = g_hdb->getGameState();
+	GameState gs = g_hdb->getGameState();
 
 	switch (gs) {
 	case GAME_TITLE:
@@ -183,9 +181,9 @@ void Input::stylusDown(int x, int y) {
 
 		// Check for map dragging in debug Mode and place player there
 		if ((GAME_PLAY == g_hdb->getGameState()) && g_hdb->getDebug() == 2) {
-			int		mx, my;
-
+			int mx, my;
 			g_hdb->_map->getMapXY(&mx, &my);
+
 			mx = ((mx + _stylusDownY) / kTileWidth) * kTileWidth;
 			my = ((my + _stylusDownY) / kTileHeight) * kTileHeight;
 			g_hdb->_ai->setPlayerXY(mx, my);
@@ -195,6 +193,7 @@ void Input::stylusDown(int x, int y) {
 		}
 
 		// Clicked in the world
+		int worldX, worldY;
 		g_hdb->_map->getMapXY(&worldX, &worldY);
 		worldX = ((worldX + x) / kTileWidth) * kTileWidth;
 		worldY = ((worldY + y) / kTileHeight) * kTileHeight;
@@ -317,6 +316,7 @@ void Input::updateMouseButtons(int l, int m, int r) {
 }
 
 void Input::updateKeys(Common::Event event, bool keyDown) {
+	static int current = 0, last = 0;
 
 	if (keyDown && event.kbd.keycode == _keyQuit) {
 		g_hdb->quitGame();
@@ -326,18 +326,15 @@ void Input::updateKeys(Common::Event event, bool keyDown) {
 	uint16 buttons = getButtons();
 
 	// PAUSE key pressed?
-	{
-		static int	current = 0, last = 0;
-		last = current;
-		if (keyDown && event.kbd.keycode == Common::KEYCODE_p && g_hdb->getGameState() == GAME_PLAY) {
-			current = 1;
-			if (!last) {
-				g_hdb->togglePause();
-				g_hdb->_sound->playSound(SND_POP);
-			}
-		} else
-			current = 0;
-	}
+	last = current;
+	if (keyDown && event.kbd.keycode == Common::KEYCODE_p && g_hdb->getGameState() == GAME_PLAY) {
+		current = 1;
+		if (!last) {
+			g_hdb->togglePause();
+			g_hdb->_sound->playSound(SND_POP);
+		}
+	} else
+		current = 0;
 
 	if (!g_hdb->getPause()) {
 		if (event.kbd.keycode == _keyUp) {
diff --git a/engines/hdb/lua-script.cpp b/engines/hdb/lua-script.cpp
index abe3c3f..c0e3a57 100644
--- a/engines/hdb/lua-script.cpp
+++ b/engines/hdb/lua-script.cpp
@@ -95,9 +95,9 @@ LuaScript::LuaScript() {
 }
 
 LuaScript::~LuaScript() {
-	if (_state) {
+	if (_state)
 		lua_close(_state);
-	}
+
 	if (_globalLuaStream)
 		delete _globalLuaStream;
 }
@@ -206,7 +206,8 @@ void LuaScript::save(Common::OutSaveFile *out) {
 	lua_printstack(_state);
 	lua_getglobal(_state, "SaveState");
 
-	lua_pushstring(_state, "tempSave"); // the save file will be ignored
+	// the save file will be ignored
+	lua_pushstring(_state, "tempSave");
 	lua_call(_state, 1, 0);
 
 	g_hdb->_currentOutSaveFile = NULL;
@@ -232,7 +233,8 @@ void LuaScript::loadSaveFile(Common::InSaveFile *in) {
 	g_hdb->_currentInSaveFile = in;
 
 	lua_getglobal(_state, "LoadState");
-	lua_pushstring(_state, "tempSave");		// it will be ignored
+	// it will be ignored
+	lua_pushstring(_state, "tempSave");
 
 	lua_call(_state, 1, 0);
 
@@ -405,8 +407,8 @@ static int cinePlaySound(lua_State *L) {
 }
 
 static int cinePlayVoice(lua_State *L) {
-	double	index = lua_tonumber(L, 1);
-	double	actor = lua_tonumber(L, 2);
+	double index = lua_tonumber(L, 1);
+	double actor = lua_tonumber(L, 2);
 
 	g_hdb->_lua->checkParameters("cinePlayVoice", 2);
 
@@ -700,14 +702,11 @@ static int cineCenterTextOut(lua_State *L) {
 }
 
 static int newDelivery(lua_State *L) {
-	const char *itemTextName, *itemGfxName;
-	const char *destTextName, *destGfxName, *id;
-
-	itemTextName = lua_tostring(L, 1);
-	itemGfxName = lua_tostring(L, 2);
-	destTextName = lua_tostring(L, 3);
-	destGfxName = lua_tostring(L, 4);
-	id = lua_tostring(L, 5);
+	const char *itemTextName = lua_tostring(L, 1);
+	const char *itemGfxName = lua_tostring(L, 2);
+	const char *destTextName = lua_tostring(L, 3);
+	const char *destGfxName = lua_tostring(L, 4);
+	const char *id = lua_tostring(L, 5);
 
 	g_hdb->_lua->checkParameters("newDelivery", 5);
 
@@ -736,13 +735,13 @@ static int deliveriesLeft(lua_State *L) {
 }
 
 static int getEntityXY(lua_State *L) {
-	int x, y;
 	const char *initName = lua_tostring(L, 1);
 
 	g_hdb->_lua->checkParameters("getEntityXY", 1);
 
 	lua_pop(L, 1);
 
+	int x, y;
 	g_hdb->_ai->getEntityXY(initName, &x, &y);
 
 	lua_pushnumber(L, x);
@@ -751,8 +750,6 @@ static int getEntityXY(lua_State *L) {
 }
 
 static int setEntity(lua_State *L) {
-	AIEntity *e = NULL;
-
 	const char *entName = lua_tostring(L, 1);
 	double x = lua_tonumber(L, 2);
 	double y = lua_tonumber(L, 3);
@@ -761,7 +758,7 @@ static int setEntity(lua_State *L) {
 	g_hdb->_lua->checkParameters("setEntity", 4);
 
 	lua_pop(L, 4);
-	e = g_hdb->_ai->locateEntity(entName);
+	AIEntity *e = g_hdb->_ai->locateEntity(entName);
 	if (e) {
 		e->x = (int)x * kTileWidth;
 		e->tileX = (int)x;
@@ -777,21 +774,19 @@ static int setEntity(lua_State *L) {
 }
 
 static int setEntDir(lua_State *L) {
-	AIEntity *e;
-	char buff[64];
-
 	const char *entName = lua_tostring(L, 1);
 	double d = lua_tonumber(L, 2);
 
 	g_hdb->_lua->checkParameters("setEntDir", 2);
 
 	lua_pop(L, 2);
-	e = g_hdb->_ai->locateEntity(entName);
+	AIEntity *e = g_hdb->_ai->locateEntity(entName);
 
 	if (e) {
 		int	dd = (int)d;
 		e->dir = (AIDir)dd;
 	} else {
+		char buff[64];
 		sprintf(buff, "Could not SetEntDir on '%s'", entName);
 		g_hdb->_window->openMessageBar(buff, 10);
 	}
@@ -908,13 +903,10 @@ static int setBackground(lua_State *L) {
 }
 
 static int dialog(lua_State *L) {
-	const char *title, *string, *more;
-	double tileIndex;
-
-	title = lua_tostring(L, 1);
-	tileIndex = lua_tonumber(L, 2);
-	string = lua_tostring(L, 3);
-	more = lua_tostring(L, 4);
+	const char *title = lua_tostring(L, 1);
+	double tileIndex = lua_tonumber(L, 2);
+	const char *string = lua_tostring(L, 3);
+	const char *more = lua_tostring(L, 4);
 
 	if (!more || more[0] == '0')
 		more = NULL;
@@ -933,11 +925,11 @@ static int dialogChoice(lua_State *L) {
 	const char *func = lua_tostring(L, 3);
 	const char *choice[10] = {0,0,0,0,0,0,0,0,0,0};
 
-	int	i, amount = lua_gettop(L) - 3;
+	int	amount = lua_gettop(L) - 3;
 	if (amount > 9)
 		amount = 9;
 
-	for (i = 0; i < amount; i++)
+	for (int i = 0; i < amount; i++)
 		choice[i] = lua_tostring(L, 4 + i);
 
 	lua_pop(L, amount + 3);
@@ -947,12 +939,8 @@ static int dialogChoice(lua_State *L) {
 }
 
 static int message(lua_State *L) {
-	const char *title;
-	double	delay;
-
-	title = lua_tostring(L, 1);
-	delay = lua_tonumber(L, 2);
-
+	const char *title = lua_tostring(L, 1);
+	double delay = lua_tonumber(L, 2);
 
 	g_hdb->_lua->checkParameters("message", 2);
 
@@ -963,10 +951,10 @@ static int message(lua_State *L) {
 }
 
 static int animation(lua_State *L) {
-	double	x = lua_tonumber(L, 1);
-	double	y = lua_tonumber(L, 2);
-	double	which = lua_tonumber(L, 3);
-	double	playsnd = lua_tonumber(L, 4);
+	double x = lua_tonumber(L, 1);
+	double y = lua_tonumber(L, 2);
+	double which = lua_tonumber(L, 3);
+	double playsnd = lua_tonumber(L, 4);
 
 	g_hdb->_lua->checkParameters("animation", 4);
 
@@ -1012,16 +1000,16 @@ static int animation(lua_State *L) {
 
 static int spawnEntity(lua_State *L) {
 	double type = lua_tonumber(L, 1);
-	double	dir = lua_tonumber(L, 2);
-	double	x = lua_tonumber(L, 3);
-	double	y = lua_tonumber(L, 4);
+	double dir = lua_tonumber(L, 2);
+	double x = lua_tonumber(L, 3);
+	double y = lua_tonumber(L, 4);
 	const char *funcInit = lua_tostring(L, 5);
 	const char *funcAction = lua_tostring(L, 6);
 	const char *funcUse = lua_tostring(L, 7);
-	double	dir2 = lua_tonumber(L, 8);
-	double	level = lua_tonumber(L, 9);
-	double	value1 = lua_tonumber(L, 10);
-	double	value2 = lua_tonumber(L, 11);
+	double dir2 = lua_tonumber(L, 8);
+	double level = lua_tonumber(L, 9);
+	double value1 = lua_tonumber(L, 10);
+	double value2 = lua_tonumber(L, 11);
 
 	int t = (int)type;
 	int d = (int)dir;
@@ -1036,8 +1024,8 @@ static int spawnEntity(lua_State *L) {
 }
 
 static int addInvItem(lua_State *L) {
-	double	type = lua_tonumber(L, 1);
-	double	amount = lua_tonumber(L, 2);
+	double type = lua_tonumber(L, 1);
+	double amount = lua_tonumber(L, 2);
 	const char *funcInit = lua_tostring(L, 3);
 	const char *funcAction = lua_tostring(L, 4);
 	const char *funcUse = lua_tostring(L, 5);
@@ -1067,17 +1055,17 @@ static int keepInvItem(lua_State *L) {
 }
 
 static int queryInv(lua_State *L) {
-	const char *search;
-	int	result;
-
-	search = lua_tostring(L, 1);		// get the passed-in search string
+	// get the passed-in search string
+	const char *search = lua_tostring(L, 1);
 
 	g_hdb->_lua->checkParameters("queryInv", 1);
 
 	lua_pop(L, 1);
 
-	result = g_hdb->_ai->queryInventory(search);			// call the function & get return value
-	lua_pushnumber(L, result);					// send the return value back to Lua
+	// call the function & get return value
+	int result = g_hdb->_ai->queryInventory(search);
+	// send the return value back to Lua
+	lua_pushnumber(L, result);
 	return 1;
 }
 
@@ -1087,41 +1075,40 @@ static int purgeInv(lua_State *L) {
 }
 
 static int queryInvItem(lua_State *L) {
-	double	search;
-	int	result, s1;
-
-	search = lua_tonumber(L, 1);					// get the passed-in search string
-	s1 = (int)search;
+	// get the passed-in search string
+	double search = lua_tonumber(L, 1);
+	int s1 = (int)search;
 
 	g_hdb->_lua->checkParameters("queryInvItem", 1);
 
 	lua_pop(L, 1);
 
-	result = g_hdb->_ai->queryInventoryType((AIType)s1);	// call the function & get return value
-	lua_pushnumber(L, result);					// send the return value back to Lua
+	// call the function & get return value
+	int result = g_hdb->_ai->queryInventoryType((AIType)s1);
+	// send the return value back to Lua
+	lua_pushnumber(L, result);
 	return 1;
 }
 
 static int removeInv(lua_State *L) {
-	const char *search;
-	int	result;
-
-	search = lua_tostring(L, 1);		// get the passed-in search string
+	// get the passed-in search string
+	const char *search = lua_tostring(L, 1);
 	double number = lua_tonumber(L, 2);
 
 	g_hdb->_lua->checkParameters("removeInv", 2);
 
 	lua_pop(L, 2);
 
-	result = (int)g_hdb->_ai->removeInvItem(search, (int)number);	// call the function & get return value
-	lua_pushnumber(L, result);					// send the return value back to Lua
+	// call the function & get return value
+	int result = (int)g_hdb->_ai->removeInvItem(search, (int)number);
+	// send the return value back to Lua
+	lua_pushnumber(L, result);
 	return 1;
 }
 
 static int removeInvItem(lua_State *L) {
-	int	result;
-
-	double	search = lua_tonumber(L, 1);		// get the passed-in type value
+	// get the passed-in type value
+	double	search = lua_tonumber(L, 1);
 	double	number = lua_tonumber(L, 2);
 
 	g_hdb->_lua->checkParameters("removeInvItem", 2);
@@ -1129,8 +1116,10 @@ static int removeInvItem(lua_State *L) {
 	lua_pop(L, 2);
 
 	int	s = (int)search;
-	result = (int)g_hdb->_ai->removeInvItemType((AIType)s, (int)number);	// call the function & get return value
-	lua_pushnumber(L, result);					// send the return value back to Lua
+	// call the function & get return value
+	int result = (int)g_hdb->_ai->removeInvItemType((AIType)s, (int)number);
+	// send the return value back to Lua
+	lua_pushnumber(L, result);
 	return 1;
 }
 
@@ -1145,22 +1134,18 @@ static int killTrigger(lua_State *L) {
 }
 
 static int startMusic(lua_State *L) {
-	bool error;
-
 	double song = lua_tonumber(L, 1);
 	int s1 = (int)song;
 
 	g_hdb->_lua->checkParameters("startMusic", 1);
 
 	lua_pop(L, 1);
-	error = g_hdb->_sound->startMusic((SoundType)s1);
+	bool error = g_hdb->_sound->startMusic((SoundType)s1);
 
 	return 0;
 }
 
 static int fadeInMusic(lua_State *L) {
-	bool error;
-
 	double song = lua_tonumber(L, 1);
 	int s1 = (int)song;
 	int ramp = (int)lua_tonumber(L, 2);
@@ -1170,7 +1155,7 @@ static int fadeInMusic(lua_State *L) {
 	g_hdb->_lua->checkParameters("fadeInMusic", 2);
 
 	lua_pop(L, 2);
-	error = g_hdb->_sound->fadeInMusic((SoundType)s1, ramp);
+	bool error = g_hdb->_sound->fadeInMusic((SoundType)s1, ramp);
 
 	return 0;
 }
@@ -1240,14 +1225,13 @@ static int startMap(lua_State *L) {
 
 static int saveGlobal(lua_State *L) {
 	const char *global = lua_tostring(L, 1);
-	int type;
 
 	g_hdb->_lua->checkParameters("saveGlobal", 1);
 
 	lua_pop(L, 1);
 
 	lua_getglobal(L, global);
-	type = lua_type(L, 1);
+	int type = lua_type(L, 1);
 	if (type == LUA_TNUMBER) {
 		double value = lua_tonumber(L, 1);
 		g_hdb->_lua->saveGlobalNumber(global, value);
@@ -1798,7 +1782,7 @@ bool LuaScript::initScript(Common::SeekableReadStream *stream, const char *scrip
 
 	// Running the code, the error handler function sets the top of the stack
 	if (lua_pcall(_state, 0, 1, 0) != 0) {
-		// An error occurred, so dislay the reason and exit
+		// An error occurred, so display the reason and exit
 		error("Couldn't prepare luaL_pcall errorhandler:\n%s", lua_tostring(_state, -1));
 		lua_pop(_state, 1);
 
@@ -1814,7 +1798,9 @@ bool LuaScript::initScript(Common::SeekableReadStream *stream, const char *scrip
 	}
 
 	// Load GLOBAL.LUA and execute it
-	_globalLuaStream->seek(0); // Make sure we start from the beginning
+
+	// Make sure we start from the beginning
+	_globalLuaStream->seek(0);
 	if (!executeMPC(_globalLuaStream, "global code", "GLOBAL.LUA", _globalLuaLength)) {
 		error("LuaScript::initScript: 'global code' failed to execute");
 		return false;
@@ -1859,13 +1845,11 @@ void LuaScript::pushString(char *string) {
 }
 
 void LuaScript::pushFunction(char *func) {
-	int type;
-
 	if (!_systemInit)
 		return;
 
 	lua_getglobal(_state, func);
-	type = lua_type(_state, 1);
+	int type = lua_type(_state, 1);
 	if (type != LUA_TFUNCTION && type != LUA_TNUMBER) {
 		warning("pushFunction: Function '%s' doesn't exists", func);
 	}
@@ -1899,13 +1883,11 @@ bool LuaScript::callFunction(const char *name, int returns) {
 }
 
 void LuaScript::invokeLuaFunction(char *luaFunc, int x, int y, int value1, int value2) {
-	int type;
-
 	if (!_systemInit)
 		return;
 
 	lua_getglobal(_state, luaFunc);
-	type = lua_type(_state, 1);
+	int type = lua_type(_state, 1);
 
 #if 0
 	if (!strcmp(luaFunc, "ferretbed_use")) {


Commit: 20a270a5aebc10e5945020b8db6b76e91deb3240
    https://github.com/scummvm/scummvm/commit/20a270a5aebc10e5945020b8db6b76e91deb3240
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:26+02:00

Commit Message:
HDB: Fix waypoints calculation code

Now player does not go back and forth

Changed paths:
    engines/hdb/ai-waypoint.cpp


diff --git a/engines/hdb/ai-waypoint.cpp b/engines/hdb/ai-waypoint.cpp
index 34704d2..312c2cf 100644
--- a/engines/hdb/ai-waypoint.cpp
+++ b/engines/hdb/ai-waypoint.cpp
@@ -25,16 +25,20 @@
 namespace HDB {
 
 void AI::addWaypoint(int px, int py, int x, int y, int level) {
+	// at the max yet?
 	if (_numWaypoints >= kMaxWaypoints || (playerOnIce() && _player->goalX))
 		return;
 
-	// Check for duplicates
+	// first, let's see if this is a duplicate waypoint
 	int i;
 	for (i = 0; i < _numWaypoints; i++)
 		if (_waypoints[i].x == x && _waypoints[i].y == y)
 			return;
 
-	// Check if path is clear
+	// check to make sure the path is clear...
+	// if it's not, don't add to waypoint list!
+	// The destination x,y might be modified, so
+	// we'll pass in the address to them...
 	int nx = x;
 	int ny = y;
 	if (!_numWaypoints) {
@@ -60,71 +64,13 @@ void AI::addWaypoint(int px, int py, int x, int y, int level) {
 			lvl1 = lvl2 = level;
 
 			if (traceStraightPath(px, py, &tx, &ty, &lvl1)) {
-				if (tx != nx || ty != py) {
-					tx = px;
-					ty = ny;
-					tx2 = nx;
-					ty2 = ny;
-
-					lvl1 = lvl2 = level;
-
-					if (traceStraightPath(px, py, &tx, &ty, &lvl1)) {
-						if (tx != px || ty != ny)
-							return;
-
-						traceStraightPath(tx, ty, &nx, &ny, &lvl2);
-
-						if (tx2 != nx || ty2 != ny)
-							return;
-
-						_waypoints[_numWaypoints].x = tx;
-						_waypoints[_numWaypoints].y = ty;
-						_waypoints[_numWaypoints].level = lvl1;
-						_numWaypoints++;
-						_waypoints[_numWaypoints].x = nx;
-						_waypoints[_numWaypoints].y = ny;
-						_waypoints[_numWaypoints].level = lvl2;
-						_numWaypoints++;
-						g_hdb->_sound->playSound(SND_MENU_SLIDER);
-
-						if (onEvenTile(_player->x, _player->y))
-							setEntityGoal(_player, tx, ty);
-					}
-				}
+				if (tx != nx || ty != py)
+					goto newpath;
 
 				traceStraightPath(tx, ty, &tx2, &ty2, &lvl2);
 
-				if (tx2 != nx || ty2 != ny) {
-					tx = px;
-					ty = ny;
-					tx2 = nx;
-					ty2 = ny;
-
-					lvl1 = lvl2 = level;
-
-					if (traceStraightPath(px, py, &tx, &ty, &lvl1)) {
-						if (tx != px || ty != ny)
-							return;
-
-						traceStraightPath(tx, ty, &nx, &ny, &lvl2);
-
-						if (tx2 != nx || ty2 != ny)
-							return;
-
-						_waypoints[_numWaypoints].x = tx;
-						_waypoints[_numWaypoints].y = ty;
-						_waypoints[_numWaypoints].level = lvl1;
-						_numWaypoints++;
-						_waypoints[_numWaypoints].x = nx;
-						_waypoints[_numWaypoints].y = ny;
-						_waypoints[_numWaypoints].level = lvl2;
-						_numWaypoints++;
-						g_hdb->_sound->playSound(SND_MENU_SLIDER);
-
-						if (onEvenTile(_player->x, _player->y))
-							setEntityGoal(_player, tx, ty);
-					}
-				}
+				if (tx2 != nx || ty2 != ny)
+					goto newpath;
 
 				_waypoints[_numWaypoints].x = tx;
 				_waypoints[_numWaypoints].y = ty;
@@ -139,6 +85,7 @@ void AI::addWaypoint(int px, int py, int x, int y, int level) {
 				if (onEvenTile(_player->x, _player->y))
 					setEntityGoal(_player, tx, ty);
 			} else {
+newpath:
 				tx = px;
 				ty = ny;
 				tx2 = nx;
@@ -199,77 +146,13 @@ void AI::addWaypoint(int px, int py, int x, int y, int level) {
 			lvl1 = lvl2 = level;
 
 			if (traceStraightPath(px, py, &tx, &ty, &lvl1)) {
-				if (tx != nx || ty != py) {
-					tx = px;
-					ty = ny;
-					tx2 = nx;
-					ty2 = ny;
-
-					lvl1 = lvl2 = level;
-
-					if (traceStraightPath(px, py, &tx, &ty, &lvl1)) {
-						if (tx != px || ty != ny)
-							return;
-
-						traceStraightPath(tx, ty, &nx, &ny, &lvl2);
-
-						if (tx2 != nx || ty2 != ny)
-							return;
-
-						if (_numWaypoints < kMaxWaypoints) {
-							_waypoints[_numWaypoints].x = tx;
-							_waypoints[_numWaypoints].y = ty;
-							_waypoints[_numWaypoints].level = lvl1;
-							_numWaypoints++;
-							g_hdb->_sound->playSound(SND_MENU_SLIDER);
-						}
-
-						if (_numWaypoints < kMaxWaypoints) {
-							_waypoints[_numWaypoints].x = nx;
-							_waypoints[_numWaypoints].y = ny;
-							_waypoints[_numWaypoints].level = lvl2;
-							_numWaypoints++;
-							g_hdb->_sound->playSound(SND_MENU_SLIDER);
-						}
-					}
-				}
+				if (tx != nx || ty != py)
+					goto newpath2;
 
 				traceStraightPath(tx, ty, &tx2, &ty2, &lvl2);
 
-				if (tx2 != nx || ty2 != ny) {
-					tx = px;
-					ty = ny;
-					tx2 = nx;
-					ty2 = ny;
-
-					lvl1 = lvl2 = level;
-
-					if (traceStraightPath(px, py, &tx, &ty, &lvl1)) {
-						if (tx != px || ty != ny)
-							return;
-
-						traceStraightPath(tx, ty, &nx, &ny, &lvl2);
-
-						if (tx2 != nx || ty2 != ny)
-							return;
-
-						if (_numWaypoints < kMaxWaypoints) {
-							_waypoints[_numWaypoints].x = tx;
-							_waypoints[_numWaypoints].y = ty;
-							_waypoints[_numWaypoints].level = lvl1;
-							_numWaypoints++;
-							g_hdb->_sound->playSound(SND_MENU_SLIDER);
-						}
-
-						if (_numWaypoints < kMaxWaypoints) {
-							_waypoints[_numWaypoints].x = nx;
-							_waypoints[_numWaypoints].y = ny;
-							_waypoints[_numWaypoints].level = lvl2;
-							_numWaypoints++;
-							g_hdb->_sound->playSound(SND_MENU_SLIDER);
-						}
-					}
-				}
+				if (tx2 != nx || ty2 != ny)
+					goto newpath2;
 
 				if (_numWaypoints < kMaxWaypoints) {
 					_waypoints[_numWaypoints].x = tx;
@@ -287,6 +170,7 @@ void AI::addWaypoint(int px, int py, int x, int y, int level) {
 					g_hdb->_sound->playSound(SND_MENU_SLIDER);
 				}
 			} else {
+newpath2:
 				tx = px;
 				ty = ny;
 				tx2 = nx;


Commit: 0ce52ccc5362de5d63223329af244825b764c5d0
    https://github.com/scummvm/scummvm/commit/0ce52ccc5362de5d63223329af244825b764c5d0
Author: Strangerke (strangerke at scummvm.org)
Date: 2019-09-03T17:17:26+02:00

Commit Message:
HDB: Implement removeSaveState()

Changed paths:
    engines/hdb/detection.cpp


diff --git a/engines/hdb/detection.cpp b/engines/hdb/detection.cpp
index 3c3c153..b0895aa 100644
--- a/engines/hdb/detection.cpp
+++ b/engines/hdb/detection.cpp
@@ -108,6 +108,7 @@ public:
 
 	virtual bool hasFeature(MetaEngineFeature f) const;
 	virtual int getMaximumSaveSlot() const;
+	virtual void removeSaveState(const char *target, int slot) const;
 	virtual SaveStateList listSaves(const char *target) const;
 	SaveStateDescriptor querySaveMetaInfos(const char *target, int slot) const;
 	virtual bool createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const;
@@ -129,6 +130,11 @@ bool HDB::HDBGame::hasFeature(Engine::EngineFeature f) const {
 		   (f == kSupportsSavingDuringRuntime);
 }
 
+void HDBMetaEngine::removeSaveState(const char *target, int slot) const {
+	Common::String fileName = Common::String::format("%s.%03d", target, slot);
+	g_system->getSavefileManager()->removeSavefile(fileName);
+}
+
 int HDBMetaEngine::getMaximumSaveSlot() const { return 9; }
 
 SaveStateList HDBMetaEngine::listSaves(const char *target) const {


Commit: f1bf353cd34bd38558814538324f7dd7a6b754e1
    https://github.com/scummvm/scummvm/commit/f1bf353cd34bd38558814538324f7dd7a6b754e1
Author: Strangerke (strangerke at scummvm.org)
Date: 2019-09-03T17:17:26+02:00

Commit Message:
HDB: Reduce some more variable scopes

Changed paths:
    engines/hdb/ai-lists.cpp
    engines/hdb/map.cpp
    engines/hdb/menu.cpp
    engines/hdb/window.cpp


diff --git a/engines/hdb/ai-lists.cpp b/engines/hdb/ai-lists.cpp
index 0c6c17d..b2f3a69 100644
--- a/engines/hdb/ai-lists.cpp
+++ b/engines/hdb/ai-lists.cpp
@@ -61,16 +61,13 @@ void AI::addAnimateTarget(int x, int y, int start, int end, AnimSpeed speed, boo
 	// Set Info if this is not an inMap animation
 	at->inMap = inMap;
 	if (!inMap) {
-
 		char name[32];
-		uint32 size;
-
 		for (int i = start; i <= end; i++) {
 			if (i < 10)
 				snprintf(name, 32, "%s0%d", tileName, i + 1);
 			else
 				snprintf(name, 32, "%s%d", tileName, i + 1);
-			size = g_hdb->_fileMan->getLength(name, TYPE_TILE32);
+			uint32 size = g_hdb->_fileMan->getLength(name, TYPE_TILE32);
 			at->gfxList[i] = g_hdb->_gfx->getTileGfx(name, size);
 		}
 	}
@@ -84,14 +81,11 @@ void AI::addAnimateTarget(int x, int y, int start, int end, AnimSpeed speed, boo
 	Called every frame
 */
 void AI::animateTargets() {
-	AnimTarget *at;
 	int mx, my;
-	int layer;
-
 	g_hdb->_map->getMapXY(&mx, &my);
 
 	for (uint i = 0; i < _animTargets.size(); i++) {
-		at = _animTargets[i];
+		AnimTarget *at = _animTargets[i];
 		debug(9, "AnimTarget #%i: at: at->x: %d, at->y: %d, at->start: %d, at->end: %d, at->vel: %d", i, at->x, at->y, at->start, at->end, at->vel);
 
 		// Draw Non-map stuff every frame
@@ -105,7 +99,7 @@ void AI::animateTargets() {
 
 			if (at->inMap) {
 				// Animate Map Tiles
-				layer = 0; // BG layer
+				int layer = 0; // BG layer
 				if (!(at->start == g_hdb->_map->getMapBGTileIndex(at->x, at->y)))
 					layer = 1;
 
@@ -162,10 +156,6 @@ void AI::addBridgeExtend(int x, int y, int bridgeType) {
 }
 
 void AI::animateBridges() {
-	int	tileIndex, xv, yv;
-	uint32 flags;
-	bool done;
-
 	// out quick!
 	if (!_numBridges)
 		return;
@@ -175,8 +165,9 @@ void AI::animateBridges() {
 			continue;
 
 		_bridges[i].delay = 5;
-		done = false;
-		xv = yv = 0;
+		bool done = false;
+		int xv = 0;
+		int yv = 0;
 
 		switch (_bridges[i].dir) {
 		case DIR_UP:
@@ -220,17 +211,19 @@ void AI::animateBridges() {
 		}
 
 		// is this bridge done extending one chunk?
-		if (done == true) {
+		if (done) {
 			if (g_hdb->_map->onScreen(_bridges[i].x, _bridges[i].y))
 				g_hdb->_sound->playSound(SND_BRIDGE_EXTEND);
 			_bridges[i].anim = 0;
 			_bridges[i].x += xv;
 			_bridges[i].y += yv;
-			tileIndex = g_hdb->_map->getMapFGTileIndex(_bridges[i].x, _bridges[i].y);
-			flags = g_hdb->_map->getMapBGTileFlags(_bridges[i].x, _bridges[i].y);
+			int tileIndex = g_hdb->_map->getMapFGTileIndex(_bridges[i].x, _bridges[i].y);
+			uint32 flags = g_hdb->_map->getMapBGTileFlags(_bridges[i].x, _bridges[i].y);
 			if (!flags || (flags & kFlagMetal) || tileIndex >= 0 || (flags & kFlagSolid)) {
 				if (g_hdb->_map->onScreen(_bridges[i].x, _bridges[i].y))
 					g_hdb->_sound->playSound(SND_BRIDGE_END);
+				// TODO: CHECKME - Using i as an index looks very wrong as the for statement uses j.
+				// This results in copying multiple times the same data
 				for (int j = 0; j < _numBridges - 1; j++)
 					memcpy(&_bridges[i], &_bridges[i + 1], sizeof(Bridge));
 				_numBridges--;
@@ -363,9 +356,6 @@ HereT *AI::findHere(int x, int y) {
 }
 
 void AI::addToAutoList(int x, int y, const char *luaFuncInit, const char *luaFuncUse) {
-
-	const char *get;
-
 	for (int i = 0; i < kMaxAutoActions; i++) {
 		if (!_autoActions[i].x) {
 			_autoActions[i].x = x;
@@ -378,7 +368,7 @@ void AI::addToAutoList(int x, int y, const char *luaFuncInit, const char *luaFun
 
 			if (_autoActions[i].luaFuncInit[0]) {
 				g_hdb->_lua->callFunction(_autoActions[i].luaFuncInit, 2);
-				get = g_hdb->_lua->getStringOffStack();
+				const char *get = g_hdb->_lua->getStringOffStack();
 				if (!get)
 					return;
 				strcpy(&_autoActions[i].entityName[0], get);
diff --git a/engines/hdb/map.cpp b/engines/hdb/map.cpp
index 8229801..4467a9f 100644
--- a/engines/hdb/map.cpp
+++ b/engines/hdb/map.cpp
@@ -209,13 +209,13 @@ void Map::loadSaveFile(Common::InSaveFile *in) {
 
 int Map::loadTiles() {
 
-	int tile, temp;
+	int temp;
 	int skyIndex = 0;
 
 	// Load all tiles
 	for (uint j = 0; j < _height; j++) {
 		for (uint i = 0; i < _width; i++) {
-			tile = _background[j * _width + i];
+			int tile = _background[j * _width + i];
 			if ((temp = g_hdb->_gfx->isSky(tile)) && !skyIndex) {
 				skyIndex = temp;
 			}
@@ -607,7 +607,6 @@ bool Map::load(Common::SeekableReadStream *stream) {
 	// Scan all icons and init all Entities
 	g_hdb->setupProgressBar(_iconNum);
 	for (int i = 0; i < _iconNum; i++) {
-
 		g_hdb->makeProgress();
 
 		// Don't spawn Action Mode Entities in Puzzle Mode
@@ -811,13 +810,8 @@ bool Map::load(Common::SeekableReadStream *stream) {
 }
 
 void Map::draw() {
-	if (!_mapLoaded) {
+	if (!_mapLoaded)
 		return;
-	}
-
-	int matrixY;
-	int screenX, screenY;
-	int maxTileX, maxTileY;
 
 	// Calculate Tile Offsets and Panning Offsets
 	_mapTileX = _mapX / kTileWidth;
@@ -825,8 +819,8 @@ void Map::draw() {
 	_mapTileXOff = -(_mapX % kTileWidth);
 	_mapTileYOff = -(_mapY % kTileHeight);
 
-	matrixY = _mapTileY * _width;
-	screenY = _mapTileYOff;
+	int matrixY = _mapTileY * _width;
+	int screenY = _mapTileYOff;
 
 	/*
 		Note from Original Source:
@@ -838,8 +832,8 @@ void Map::draw() {
 		when we're at the very bottom of the map.
 	*/
 
-	maxTileX = (_mapTileXOff >= -8) ? kScreenXTiles - 1 : kScreenXTiles;
-	maxTileY = (!_mapTileYOff) ? kScreenYTiles - 1 : kScreenYTiles;
+	int maxTileX = (_mapTileXOff >= -8) ? kScreenXTiles - 1 : kScreenXTiles;
+	int maxTileY = (!_mapTileYOff) ? kScreenYTiles - 1 : kScreenYTiles;
 
 	if (matrixY + (maxTileY - 1)*_width > _height * _width) {
 		return;
@@ -848,7 +842,7 @@ void Map::draw() {
 	_numForegrounds = _numGratings = 0;
 
 	for (int j = 0; j < maxTileY; j++) {
-		screenX = _mapTileXOff;
+		int screenX = _mapTileXOff;
 		for (int i = 0; i < maxTileX; i++) {
 
 			// Draw Background Tile
@@ -900,33 +894,33 @@ void Map::draw() {
 
 	// Animate FAST Map Tiles
 	if (!(_animCycle % kAnimFastFrames)) {
-		for (Common::Array<uint32>::iterator it = _listBGAnimFast.begin(); it != _listBGAnimFast.end(); it++) {
+		for (Common::Array<uint32>::iterator it = _listBGAnimFast.begin(); it != _listBGAnimFast.end(); ++it) {
 			_background[(*it)] = g_hdb->_gfx->animateTile(_background[(*it)]);
 		}
 
-		for (Common::Array<uint32>::iterator it = _listFGAnimFast.begin(); it != _listFGAnimFast.end(); it++) {
+		for (Common::Array<uint32>::iterator it = _listFGAnimFast.begin(); it != _listFGAnimFast.end(); ++it) {
 			_foreground[(*it)] = g_hdb->_gfx->animateTile(_foreground[(*it)]);
 		}
 	}
 
 	// Animate MEDIUM Map Tiles
 	if (!(_animCycle % kAnimMediumFrames)) {
-		for (Common::Array<uint32>::iterator it = _listBGAnimMedium.begin(); it != _listBGAnimMedium.end(); it++) {
+		for (Common::Array<uint32>::iterator it = _listBGAnimMedium.begin(); it != _listBGAnimMedium.end(); ++it) {
 			_background[(*it)] = g_hdb->_gfx->animateTile(_background[(*it)]);
 		}
 
-		for (Common::Array<uint32>::iterator it = _listFGAnimMedium.begin(); it != _listFGAnimMedium.end(); it++) {
+		for (Common::Array<uint32>::iterator it = _listFGAnimMedium.begin(); it != _listFGAnimMedium.end(); ++it) {
 			_foreground[(*it)] = g_hdb->_gfx->animateTile(_foreground[(*it)]);
 		}
 	}
 
 	// Animate SLOW Map Tiles
 	if (!(_animCycle % kAnimSlowFrames)) {
-		for (Common::Array<uint32>::iterator it = _listBGAnimSlow.begin(); it != _listBGAnimSlow.end(); it++) {
+		for (Common::Array<uint32>::iterator it = _listBGAnimSlow.begin(); it != _listBGAnimSlow.end(); ++it) {
 			_background[(*it)] = g_hdb->_gfx->animateTile(_background[(*it)]);
 		}
 
-		for (Common::Array<uint32>::iterator it = _listFGAnimSlow.begin(); it != _listFGAnimSlow.end(); it++) {
+		for (Common::Array<uint32>::iterator it = _listFGAnimSlow.begin(); it != _listFGAnimSlow.end(); ++it) {
 			_foreground[(*it)] = g_hdb->_gfx->animateTile(_foreground[(*it)]);
 		}
 	}
@@ -1009,6 +1003,7 @@ void Map::addBGTileAnimation(int x, int y) {
 	Tile *tile = g_hdb->_gfx->getTile(_background[i]);
 	if (!tile)
 		return;
+
 	uint32 flags = tile->_flags;
 
 	// BACKGROUND
diff --git a/engines/hdb/menu.cpp b/engines/hdb/menu.cpp
index fbaa389..f97cacf 100644
--- a/engines/hdb/menu.cpp
+++ b/engines/hdb/menu.cpp
@@ -248,12 +248,10 @@ static const char nebulaNames[kNebulaCount][32] = {
 
 
 void Menu::startMenu() {
-	int	i;
-
 	// stuff that gets loaded-in at Title Screen
 	if (!_titleLogo) {
 		_titleLogo = g_hdb->_gfx->loadPic(TITLELOGO);
-		for (i = 0; i < kNebulaCount; i++)
+		for (int i = 0; i < kNebulaCount; i++)
 			_nebulaGfx[i] = g_hdb->_gfx->loadPic(nebulaNames[i]);
 
 		_rocketMain = g_hdb->_gfx->loadPic(MENU_ROCKETSHIP1);
@@ -308,7 +306,7 @@ void Menu::startMenu() {
 
 	// if we're popping back into menu, don't init this
 	if (!_fStars[0].y) {
-		for (i = 0; i < kMaxStars; i++) {
+		for (int i = 0; i < kMaxStars; i++) {
 			_fStars[i].y = -30;
 			_fStars[i].x = g_hdb->_rnd->getRandomNumber(kScreenWidth - 1);
 			_fStars[i].speed = g_hdb->_rnd->getRandomNumber(4) + 1;
@@ -565,7 +563,6 @@ void Menu::drawMenu() {
 		//-------------------------------------------------------------------
 		//	DRAW GAMEFILES MENU
 		//-------------------------------------------------------------------
-		int		i;
 
 		g_hdb->_gfx->draw3DStars();
 		//
@@ -587,8 +584,8 @@ void Menu::drawMenu() {
 
 			drawRocketAndSelections();
 		} else {
-			static int	anim = 0;
-			static	uint32 anim_time = 0;
+			static int anim = 0;
+			static uint32 anim_time = 0;
 
 			drawNebula();
 			_titleLogo->drawMasked(centerPic(_titleLogo), _rocketY + kMTitleY);
@@ -607,9 +604,8 @@ void Menu::drawMenu() {
 					anim = 0;
 			}
 
-			for (i = 0; i < kNumSaveSlots; i++) {
-				char	buff[16];
-				int		seconds = _saveGames[i].seconds;
+			for (int i = 0; i < kNumSaveSlots; i++) {
+				int seconds = _saveGames[i].seconds;
 
 				_slotGfx->drawMasked(kSaveSlotX - 8, i * 32 + (kSaveSlotY - 4));
 				if (seconds || _saveGames[i].mapName[0]) {
@@ -619,6 +615,7 @@ void Menu::drawMenu() {
 					g_hdb->_gfx->drawText(_saveGames[i].mapName);
 
 					g_hdb->_gfx->setCursor(kSaveSlotX + 180, i * 32 + kSaveSlotY);
+					char buff[16];
 					sprintf(buff, "%02d:%02d", seconds / 3600, (seconds / 60) % 60);
 					g_hdb->_gfx->drawText(buff);
 				}
@@ -628,9 +625,6 @@ void Menu::drawMenu() {
 		//-------------------------------------------------------------------
 		//	DRAW WARP MENU
 		//-------------------------------------------------------------------
-		int		i;
-		char	string[32];
-
 		g_hdb->_gfx->draw3DStars();
 		drawNebula();
 		drawWarpScreen();
@@ -638,17 +632,18 @@ void Menu::drawMenu() {
 		_titleLogo->drawMasked(centerPic(_titleLogo), _rocketY + kMTitleY);
 		_menuBackoutGfx->drawMasked(kWarpBackoutX, kWarpBackoutY);
 
-		for (i = 0; i < 10; i++) {
+		char string[32];
+		for (int i = 0; i < 10; i++) {
 			sprintf(string, "Map %2d", i);
 			g_hdb->_gfx->setCursor(kWarpX + 4, i * 16 + kWarpY);
 			g_hdb->_gfx->drawText(string);
 		}
-		for (i = 0; i < 10; i++) {
+		for (int i = 0; i < 10; i++) {
 			sprintf(string, "Map %d", i + 10);
 			g_hdb->_gfx->setCursor(kWarpX + 80, i * 16 + kWarpY);
 			g_hdb->_gfx->drawText(string);
 		}
-		for (i = 0; i < 10; i++) {
+		for (int i = 0; i < 10; i++) {
 			sprintf(string, "Map %d", i + 20);
 			g_hdb->_gfx->setCursor(kWarpX + 160, i * 16 + kWarpY);
 			g_hdb->_gfx->drawText(string);
@@ -674,8 +669,6 @@ void Menu::drawMenu() {
 }
 
 void Menu::freeMenu() {
-	int		i;
-
 	// title sequence stuff
 	if (_titleScreen)
 		delete _titleScreen;
@@ -722,11 +715,12 @@ void Menu::freeMenu() {
 		delete _hdbLogoScreen;
 	_hdbLogoScreen = NULL;
 
-	if (_nebulaGfx[0])
-		for (i = 0; i < kNebulaCount; i++) {
+	if (_nebulaGfx[0]) {
+		for (int i = 0; i < kNebulaCount; i++) {
 			delete _nebulaGfx[i];
 			_nebulaGfx[i] = NULL;
 		}
+	}
 
 	if (_sliderLeft)
 		delete _sliderLeft;
@@ -804,8 +798,6 @@ void Menu::freeMenu() {
 }
 
 bool Menu::startTitle() {
-	int i;
-
 	readConfig();
 
 	_titleScreen = g_hdb->_gfx->loadPic(MONKEYLOGOSCREEN);
@@ -819,7 +811,7 @@ bool Menu::startTitle() {
 	_rocketEx2 = g_hdb->_gfx->loadPic(MENU_EXHAUST2);
 	_titleLogo = g_hdb->_gfx->loadPic(TITLELOGO);
 
-	for (i = 0; i < kNebulaCount; i++)
+	for (int i = 0; i < kNebulaCount; i++)
 		_nebulaGfx[i] = g_hdb->_gfx->loadPic(nebulaNames[i]);
 
 	_titleCycle = 1;	// 1 = Waiting for OOH OOH
@@ -1172,8 +1164,6 @@ void Menu::processInput(int x, int y) {
 		//-------------------------------------------------------------------
 		//	OPTIONS INPUT
 		//-------------------------------------------------------------------
-		int	offset, oldVol;
-
 		int	xit = getMenuKey();
 
 		//
@@ -1184,10 +1174,11 @@ void Menu::processInput(int x, int y) {
 			return;
 		}
 
+		int	offset;
 		// Slider 1
 		if (x >= 0 && x <= kOptionsX + 200 &&
 			y >= kOptionsY + 20 && y <= kOptionsY + 36) {
-			oldVol = g_hdb->_sound->getMusicVolume();
+			int oldVol = g_hdb->_sound->getMusicVolume();
 			if (x < kOptionsX) {
 				if (oldVol) {
 					g_hdb->_sound->stopMusic();
@@ -1243,8 +1234,8 @@ void Menu::processInput(int x, int y) {
 			g_hdb->_sound->playSound(SND_MENU_BACKOUT);
 		}
 
-		int		i;
-		for (i = 0; i < kNumSaveSlots; i++)
+		int i = 0;
+		for (; i < kNumSaveSlots; i++)
 			if (y >= (i * 32 + kSaveSlotY - 4) && y <= (i * 32 + kSaveSlotY + 24))
 				break;
 		if (i >= kNumSaveSlots)
@@ -1253,33 +1244,29 @@ void Menu::processInput(int x, int y) {
 		_saveSlot = i;
 
 		// LOAD GAME!
-		{
-			// clicked on empty slot?
-			if (!_saveGames[i].seconds && !_saveGames[i].mapName[0]) {
-				g_hdb->_sound->playSound(SND_MENU_BACKOUT);
-				return;
-			}
+		// clicked on empty slot?
+		if (!_saveGames[i].seconds && !_saveGames[i].mapName[0]) {
+			g_hdb->_sound->playSound(SND_MENU_BACKOUT);
+			return;
+		}
 
-			g_hdb->_sound->playSound(SND_MENU_ACCEPT);
-			if (g_hdb->loadGameState(_saveSlot).getCode() == Common::kNoError) {
-				_gamefilesActive = false;
+		g_hdb->_sound->playSound(SND_MENU_ACCEPT);
+		if (g_hdb->loadGameState(_saveSlot).getCode() == Common::kNoError) {
+			_gamefilesActive = false;
 
-				freeMenu();
-				g_hdb->setGameState(GAME_PLAY);
-				// if we're at the very start of the level, re-init the level
-				if (!_saveGames[i].seconds) {
-					g_hdb->_lua->callFunction("level_loaded", 0); // call "level_loaded" Lua function, if it exists
-					if (!g_hdb->_ai->cinematicsActive())
-						g_hdb->_gfx->turnOffFade();
-				}
+			freeMenu();
+			g_hdb->setGameState(GAME_PLAY);
+			// if we're at the very start of the level, re-init the level
+			if (!_saveGames[i].seconds) {
+				g_hdb->_lua->callFunction("level_loaded", 0); // call "level_loaded" Lua function, if it exists
+				if (!g_hdb->_ai->cinematicsActive())
+					g_hdb->_gfx->turnOffFade();
 			}
 		}
 	} else if (_warpActive) {
 		//-------------------------------------------------------------------
 		//	WARP INPUT
 		//-------------------------------------------------------------------
-		int		map;
-
 		int	xit = getMenuKey();
 
 		if ((y >= kMenuExitY && x < kMenuExitXLeft) || xit) {
@@ -1288,7 +1275,7 @@ void Menu::processInput(int x, int y) {
 			g_hdb->_sound->playSound(SND_MENU_BACKOUT);
 			_clickDelay = 10;
 		} else if (y >= kWarpY && y < kWarpY + 160) {
-			char	string[16];
+			int map;
 
 			if (x > kWarpX + 160)
 				map = 20;
@@ -1306,6 +1293,7 @@ void Menu::processInput(int x, int y) {
 				g_hdb->_gfx->updateVideo();
 			_warpActive = 0;
 
+			char string[16];
 			if (map < 10)
 				sprintf(string, "MAP0%d", map);
 			else
@@ -1363,9 +1351,7 @@ void Menu::drawNebula() {
 	//
 	// draw the falling stars
 	//
-	int		i;
-
-	for (i = 0; i < kMaxStars; i++) {
+	for (int i = 0; i < kMaxStars; i++) {
 		_fStars[i].y += _fStars[i].speed;
 		if (_fStars[i].y > kScreenHeight) {
 			_fStars[i].y = (g_hdb->_rnd->getRandomNumber(29) + 30) * -1;
@@ -1421,14 +1407,12 @@ void Menu::drawRocketAndSelections() {
 }
 
 void Menu::drawSlider(int x, int y, int offset) {
-	int	i, x1;
-
-	x1 = x;
+	int x1 = x;
 
 	_sliderLeft->drawMasked(x, y);
 	x += _sliderLeft->_width;
 
-	for (i = 0; i < 12; i++) {
+	for (int i = 0; i < 12; i++) {
 		_sliderMid->draw(x, y);
 		x += _sliderMid->_width;
 	}
@@ -1438,14 +1422,12 @@ void Menu::drawSlider(int x, int y, int offset) {
 }
 
 void Menu::drawToggle(int x, int y, bool flag) {
-	int	i, x1;
-
-	x1 = x;
+	int	x1 = x;
 
 	_gCheckLeft->drawMasked(x, y);
 	x += _gCheckLeft->_width;
 
-	for (i = 0; i < 12; i++) {
+	for (int i = 0; i < 12; i++) {
 		_gCheckEmpty->draw(x, y);
 		x += _gCheckEmpty->_width;
 	}
diff --git a/engines/hdb/window.cpp b/engines/hdb/window.cpp
index 343f3eb..ae28df7 100644
--- a/engines/hdb/window.cpp
+++ b/engines/hdb/window.cpp
@@ -1065,11 +1065,9 @@ void Window::checkInvSelect(int x, int y) {
 }
 
 void Window::openDeliveries(bool animate) {
-	DlvEnt *d;
-
 	// Load Gfx
 	for (int i = 0; i < g_hdb->_ai->getDeliveriesAmount(); i++) {
-		d = g_hdb->_ai->getDeliveryItem(i);
+		DlvEnt *d = g_hdb->_ai->getDeliveryItem(i);
 		if (d->itemGfxName[0])
 			d->itemGfx = g_hdb->_gfx->loadTile(d->itemGfxName);
 		if (d->destGfxName[0])
@@ -1092,8 +1090,6 @@ void Window::openDeliveries(bool animate) {
 }
 
 void Window::drawDeliveries() {
-	int baseX, drawX, drawY;
-	DlvEnt *d;
 	//static uint32 timer = g_hdb->getTimeSlice() + 300; //unused
 
 	int crazySounds[kNumCrazy] = {
@@ -1139,17 +1135,18 @@ void Window::drawDeliveries() {
 	if (_infobarDimmed > 1)
 		return;
 
-	baseX = drawX = _dlvsInfo.x;
-	drawY = _dlvsInfo.y;
+	int baseX = _dlvsInfo.x;
+	int drawX = _dlvsInfo.x;
+	int drawY = _dlvsInfo.y;
 
 	if (_dlvsInfo.selected >= g_hdb->_ai->getDeliveriesAmount())
 		_dlvsInfo.selected = g_hdb->_ai->getDeliveriesAmount() - 1;
 
 	// Draw Delivery Items
-	int inv;
-	for (inv = 0; inv < g_hdb->_ai->getDeliveriesAmount(); inv++) {
+	int inv = 0;
+	for (; inv < g_hdb->_ai->getDeliveriesAmount(); inv++) {
 		int centerX = baseX + (kScreenWidth - baseX) / 2;
-		d = g_hdb->_ai->getDeliveryItem(inv);
+		DlvEnt *d = g_hdb->_ai->getDeliveryItem(inv);
 		if (_dlvsInfo.animate && inv == g_hdb->_ai->getDeliveriesAmount() - 1) {
 			if (_dlvsInfo.go1) {
 				if (_dlvsInfo.delay1 < g_hdb->getTimeSlice()) {


Commit: 452612d02a2296a7ba4c9daa1d727855090e671d
    https://github.com/scummvm/scummvm/commit/452612d02a2296a7ba4c9daa1d727855090e671d
Author: Strangerke (strangerke at scummvm.org)
Date: 2019-09-03T17:17:26+02:00

Commit Message:
HDB: Fix CppCheck warnings in window

Changed paths:
    engines/hdb/window.cpp


diff --git a/engines/hdb/window.cpp b/engines/hdb/window.cpp
index ae28df7..b717a0e 100644
--- a/engines/hdb/window.cpp
+++ b/engines/hdb/window.cpp
@@ -1244,8 +1244,6 @@ void Window::setSelectedDelivery(int which) {
 }
 
 void Window::checkDlvSelect(int x, int y) {
-	int xc, yc;
-
 	if (_dlvsInfo.animate)
 		return;
 
@@ -1253,8 +1251,8 @@ void Window::checkDlvSelect(int x, int y) {
 
 	// Click on a Delivery to select it for inspection?
 	if (x >= _dlvsInfo.x && x < _dlvsInfo.x + _dlvsInfo.width && y >= _dlvsInfo.y && y < _dlvsInfo.y + _dlvsInfo.height) {
-		xc = (x - _dlvsInfo.x) / kDlvItemSpaceX;
-		yc = (y - _dlvsInfo.y) / kDlvItemSpaceY;
+		int xc = (x - _dlvsInfo.x) / kDlvItemSpaceX;
+		int yc = (y - _dlvsInfo.y) / kDlvItemSpaceY;
 		int value = yc * kDlvItemPerLine + xc;
 		if (value < amt)
 			setSelectedDelivery(value);
@@ -1309,8 +1307,6 @@ void Window::loadPanicZoneGfx() {
 }
 
 void Window::drawPanicZone() {
-	int xx, yy;
-
 	if (!_pzInfo.active)
 		return;
 
@@ -1326,46 +1322,48 @@ void Window::drawPanicZone() {
 
 		// Move PANIC ZONE to screen center
 	case PANICZONE_START:
-		xx = g_hdb->_rnd->getRandomNumber(9) - 5;
-		yy = g_hdb->_rnd->getRandomNumber(9) - 5;
-		_pzInfo.x1 += _pzInfo.xv;
-		_pzInfo.y1++;
-		_pzInfo.x2 += _pzInfo.yv;
-		_pzInfo.y2--;
-		if (_pzInfo.x1 > kPanicXStop) {
-			_pzInfo.timer = 30;
-			_pzInfo.sequence++;
+		{
+			int xx = g_hdb->_rnd->getRandomNumber(9) - 5;
+			int yy = g_hdb->_rnd->getRandomNumber(9) - 5;
+			_pzInfo.x1 += _pzInfo.xv;
+			_pzInfo.y1++;
+			_pzInfo.x2 += _pzInfo.yv;
+			_pzInfo.y2--;
+			if (_pzInfo.x1 > kPanicXStop) {
+				_pzInfo.timer = 30;
+				_pzInfo.sequence++;
+			}
+			_pzInfo.gfxPanic->drawMasked(_pzInfo.x1 + xx, _pzInfo.y1 + yy);
+			_pzInfo.gfxZone->drawMasked(_pzInfo.x2 + yy, _pzInfo.y2 + xx);
 		}
-		_pzInfo.gfxPanic->drawMasked(_pzInfo.x1 + xx, _pzInfo.y1 + yy);
-		_pzInfo.gfxZone->drawMasked(_pzInfo.x2 + yy, _pzInfo.y2 + xx);
 		break;
-
 	case PANICZONE_TITLESTOP:
-		xx = g_hdb->_rnd->getRandomNumber(9) - 5;
-		yy = g_hdb->_rnd->getRandomNumber(9) - 5;
-		_pzInfo.gfxPanic->drawMasked(_pzInfo.x1 + xx, _pzInfo.y1 + yy);
-		_pzInfo.gfxZone->drawMasked(_pzInfo.x2 + yy, _pzInfo.y2 + xx);
-		_pzInfo.timer--;
-		if (!_pzInfo.timer) {
-			_pzInfo.sequence++;
+		{
+			int xx = g_hdb->_rnd->getRandomNumber(9) - 5;
+			int yy = g_hdb->_rnd->getRandomNumber(9) - 5;
+			_pzInfo.gfxPanic->drawMasked(_pzInfo.x1 + xx, _pzInfo.y1 + yy);
+			_pzInfo.gfxZone->drawMasked(_pzInfo.x2 + yy, _pzInfo.y2 + xx);
+			_pzInfo.timer--;
+			if (!_pzInfo.timer)
+				_pzInfo.sequence++;
 		}
 		break;
-
 	case PANICZONE_BLASTOFF:
-		xx = g_hdb->_rnd->getRandomNumber(9) - 5;
-		yy = g_hdb->_rnd->getRandomNumber(9) - 5;
-		_pzInfo.y1 -= 10;
-		_pzInfo.y2 += 10;
-		_pzInfo.gfxPanic->drawMasked(_pzInfo.x1 + xx, _pzInfo.y1 + yy);
-		_pzInfo.gfxZone->drawMasked(_pzInfo.x2 + yy, _pzInfo.y2 + xx);
-		if (_pzInfo.y1 < -_pzInfo.gfxPanic->_height &&
-			_pzInfo.y2 > kScreenHeight) {
-			g_hdb->_sound->playSound(SND_PANIC_COUNT);
-			_pzInfo.sequence++;
-			_pzInfo.timer = 30 + g_hdb->getTime();
+		{
+			int xx = g_hdb->_rnd->getRandomNumber(9) - 5;
+			int yy = g_hdb->_rnd->getRandomNumber(9) - 5;
+			_pzInfo.y1 -= 10;
+			_pzInfo.y2 += 10;
+			_pzInfo.gfxPanic->drawMasked(_pzInfo.x1 + xx, _pzInfo.y1 + yy);
+			_pzInfo.gfxZone->drawMasked(_pzInfo.x2 + yy, _pzInfo.y2 + xx);
+			if (_pzInfo.y1 < -_pzInfo.gfxPanic->_height &&
+				_pzInfo.y2 > kScreenHeight) {
+				g_hdb->_sound->playSound(SND_PANIC_COUNT);
+				_pzInfo.sequence++;
+				_pzInfo.timer = 30 + g_hdb->getTime();
+			}
 		}
 		break;
-
 	case PANICZONE_COUNTDOWN:
 		{
 			static int last_seconds = 0, seconds = 0;
@@ -1440,20 +1438,17 @@ void Window::centerTextOut(const char *text, int y, int timer) {
 }
 
 void Window::drawTextOut() {
-	int e1, e2, e3, e4;
-	uint32 time;
-	TOut *t;
-
 	if (_textOutList.empty())
 		return;
 
+	int e1, e2, e3, e4;
 	g_hdb->_gfx->getTextEdges(&e1, &e2, &e3, &e4);
 	g_hdb->_gfx->setTextEdges(0, 480, 0, kScreenHeight);
 
-	time = g_system->getMillis();
+	uint32 time = g_system->getMillis();
 
 	for (uint i = 0; i < _textOutList.size(); i++) {
-		t = _textOutList[i];
+		TOut *t = _textOutList[i];
 		g_hdb->_gfx->setCursor(t->x, t->y);
 		g_hdb->_gfx->drawText(t->text);
 


Commit: 8e102a7dc76b6bbf73aef479e7832ef2c2af5cc9
    https://github.com/scummvm/scummvm/commit/8e102a7dc76b6bbf73aef479e7832ef2c2af5cc9
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:26+02:00

Commit Message:
HDB: Add cheat to test MAP29

Changed paths:
    engines/hdb/hdb.cpp


diff --git a/engines/hdb/hdb.cpp b/engines/hdb/hdb.cpp
index 3fb963a..ec99b7e 100644
--- a/engines/hdb/hdb.cpp
+++ b/engines/hdb/hdb.cpp
@@ -213,6 +213,12 @@ bool HDBGame::restartMap() {
 		_ai->setGemAmount(100);
 	}
 
+	if (!strcmp(_currentLuaName, "MAP29.LUA")) {
+		// Finish MAP29
+
+		_ai->_numGooCups = 8;
+	}
+
 #endif
 
 	_lua->loadLua(_currentLuaName);


Commit: 4a7c028e707fe08afb2bc950097af39c06944e53
    https://github.com/scummvm/scummvm/commit/4a7c028e707fe08afb2bc950097af39c06944e53
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:26+02:00

Commit Message:
HDB: Add sound data to mpc.h

Changed paths:
    engines/hdb/mpc.h


diff --git a/engines/hdb/mpc.h b/engines/hdb/mpc.h
index 6b8f19d..94d7800 100644
--- a/engines/hdb/mpc.h
+++ b/engines/hdb/mpc.h
@@ -696,7 +696,1304 @@ namespace HDB {
 #define		PIC_SNOWFLAKE		"pic_snowflake"
 #define		PIC_INFOBAR		"pic_infobar"
 #define		PIC_LOADSCREEN		"pic_loadscreen"
+#define		BUZZFLY_AMBIENT_WAV		"buzzfly_ambient.wav"
+#define		CHICKEN_AMBIENT_WAV		"chicken_ambient.wav"
+#define		CHICKEN_BAGAWK_WAV		"chicken_bagawk.wav"
+#define		CHICKEN_DEATH_WAV		"chicken_death.wav"
+#define		FERRET_SQUEAK_WAV		"ferret_squeak.wav"
+#define		MBOT_HMMM_WAV		"mbot_hmmm.wav"
+#define		MBOT_HMMM2_WAV		"mbot_hmmm2.wav"
+#define		MBOT_HYEAH_WAV		"mbot_hyeah.wav"
+#define		MBOT_YEAH_WAV		"mbot_yeah.wav"
+#define		MBOT_DEATH_WAV		"mbot_death.wav"
+#define		MBOT_WHISTLE1_WAV		"mbot_whistle1.wav"
+#define		MBOT_WHISTLE2_WAV		"mbot_whistle2.wav"
+#define		MBOT_WHISTLE3_WAV		"mbot_whistle3.wav"
+#define		DEADEYE_AMBIENT01_WAV		"deadeye_ambient01.wav"
+#define		DEADEYE_AMBIENT02_WAV		"deadeye_ambient02.wav"
+#define		DEADEYE_GROWL01_WAV		"deadeye_growl01.wav"
+#define		DEADEYE_GROWL02_WAV		"deadeye_growl02.wav"
+#define		FROG_LICK_WAV		"frog_lick.wav"
+#define		FROG_RIBBIT1_WAV		"frog_ribbit1.wav"
+#define		FROG_RIBBIT2_WAV		"frog_ribbit2.wav"
+#define		FATFROG_STUNNED_WAV		"fatfrog_stunned.wav"
+#define		RIGHTBOT_TURN_WAV		"rightbot_turn.wav"
+#define		RIGHTBOT_STUNNED_WAV		"rightbot_stunned.wav"
+#define		OMNIBOT_AMBIENT_WAV		"omnibot_ambient.wav"
+#define		OMNIBOT_FIRE_WAV		"omnibot_fire.wav"
+#define		OMNIBOT_STUNNED_WAV		"omnibot_stunned.wav"
+#define		FOURFIRE_TURN_WAV		"fourfire_turn.wav"
+#define		FOUR_FIRE_WAV		"four_fire.wav"
+#define		SHOCKBOT_AMBIENT_WAV		"shockbot_ambient.wav"
+#define		SHOCKBOT_SHOCK_WAV		"shockbot_shock.wav"
+#define		RAILRIDER_ONTRACK_WAV		"railrider_ontrack.wav"
+#define		RAILRIDER_EXIT_WAV		"railrider_exit.wav"
+#define		RAILRIDER_TASTE_WAV		"railrider_taste.wav"
+#define		BUZZFLY_STUNNED_WAV		"buzzfly_stunned.wav"
+#define		BUZZFLY_STING_WAV		"buzzfly_sting.wav"
+#define		ROBOT_STUNNED_WAV		"robot_stunned.wav"
+#define		FART_WAV		"fart.wav"
+#define		FART2_WAV		"fart2.wav"
+#define		PUSHBOT_STRAIN_WAV		"pushbot_strain.wav"
+#define		PUSHBOT_STUNNED_WAV		"pushbot_stunned.wav"
+#define		MEERKAT_BITE_WAV		"meerkat_bite.wav"
+#define		MEERKAT_WARNING_WAV		"meerkat_warning.wav"
+#define		MEERKAT_APPEAR_WAV		"meerkat_appear.wav"
+#define		MEERKAT_STUNNED_WAV		"meerkat_stunned.wav"
+#define		TURNBOT_TURN_WAV		"turnbot_turn.wav"
+#define		TURNBOT_STUNNED_WAV		"turnbot_stunned.wav"
+#define		DRAGON_WAKE_WAV		"dragon_wake.wav"
+#define		DRAGON_FALL_ASLEEP_WAV		"dragon_fall_asleep.wav"
+#define		DRAGON_BREATHE_FIRE_WAV		"dragon_breathe_fire.wav"
+#define		GOOD_FAERIE_AMBIENT_WAV		"good_faerie_ambient.wav"
+#define		GOOD_FAERIE_SPELL_WAV		"good_faerie_spell.wav"
+#define		GOOD_FAERIE_STUNNED_WAV		"good_faerie_stunned.wav"
+#define		BAD_FAERIE_AMBIENT_WAV		"bad_faerie_ambient.wav"
+#define		BAD_FAERIE_SPELL_WAV		"bad_faerie_spell.wav"
+#define		BAD_FAERIE_STUNNED_WAV		"bad_faerie_stunned.wav"
+#define		ICEPUFF_APPEAR_WAV		"icepuff_appear.wav"
+#define		ICEPUFF_WARNING_WAV		"icepuff_warning.wav"
+#define		ICEPUFF_THROW_WAV		"icepuff_throw.wav"
+#define		ICEPUFF_STUNNED_WAV		"icepuff_stunned.wav"
+#define		DEMIGOD_AMBIENT_WAV		"demigod_ambient.wav"
+#define		DEMIGOD_HOLYSPEECH_WAV		"demigod_holyspeech.wav"
+#define		DEMIGOD_UNHAPPY_WAV		"demigod_unhappy.wav"
+#define		GATEPUDDLE_AMBIENT_WAV		"gatepuddle_ambient.wav"
+#define		GATEPUDDLE_DISSIPATE_WAV		"gatepuddle_dissipate.wav"
+#define		GATEPUDDLE_SPAWN_WAV		"gatepuddle_spawn.wav"
+#define		MANNY_CRASH_WAV		"manny_crash.wav"
+#define		FOOTSTEPS_WAV		"footsteps.wav"
+#define		STEPS_ICE_WAV		"steps_ice.wav"
+#define		GUY_DROWN_WAV		"guy_drown.wav"
+#define		GUY_FRIED_WAV		"guy_fried.wav"
+#define		GUY_GRABBED_WAV		"guy_grabbed.wav"
+#define		GUY_DYING_WAV		"guy_dying.wav"
+#define		GUY_UHUH_WAV		"guy_uhuh.wav"
+#define		GUY_PLUMMET_WAV		"guy_plummet.wav"
+#define		GET_STUNNER_WAV		"get_stunner.wav"
+#define		GET_THING_WAV		"get_thing.wav"
+#define		GET_CLUB_WAV		"get_club.wav"
+#define		GET_SLUG_WAV		"get_slug.wav"
+#define		GET_MONKEYSTONE_WAV		"get_monkeystone.wav"
+#define		GET_GEM_WAV		"get_gem.wav"
+#define		GET_GOO_WAV		"get_goo.wav"
+#define		CLUB_MISS_WAV		"club_miss.wav"
+#define		CLUB_HIT_METAL_WAV		"club_hit_metal.wav"
+#define		CLUB_HIT_FLESH_WAV		"club_hit_flesh.wav"
+#define		STUNNER_BUZZ_WAV		"stunner_buzz.wav"
+#define		STUNNER_ZAP_WAV		"stunner_zap.wav"
+#define		SLUG_FIRE_WAV		"slug_fire.wav"
+#define		SLUG_HIT_WAV		"slug_hit.wav"
+#define		GEM_THROW_WAV		"gem_throw.wav"
+#define		MONKEYSTONE_SECRET_STAR_WAV		"monkeystone_secret_star.wav"
+#define		CRATE_SLIDE_WAV		"crate_slide.wav"
+#define		HEAVY_SLIDE_WAV		"heavy_slide.wav"
+#define		LIGHT_SLIDE_WAV		"light_slide.wav"
+#define		BARREL_EXPLODE_WAV		"barrel_explode.wav"
+#define		BARREL_MELTING_WAV		"barrel_melting.wav"
+#define		GUY_NOPUSH_SIZZLE_WAV		"guy_nopush_sizzle.wav"
+#define		SPLASH_WAV		"splash.wav"
+#define		TELEPORT3_WAV		"teleport3.wav"
+#define		FALL_DOWN_HOLE_WAV		"fall_down_hole.wav"
+#define		SLIME_BURN_WAV		"slime_burn.wav"
+#define		PLASMAFLOOR_SLIDE_WAV		"plasmafloor_slide.wav"
+#define		LASERD_PUSH_WAV		"laserd_push.wav"
 #define		MENU_ACCEPT_WAV		"menu_accept.wav"
+#define		MENU_BACKOUT_WAV		"menu_backout.wav"
+#define		MENU_SLIDER_WAV		"menu_slider.wav"
+#define		POP_WAV		"pop.wav"
+#define		BURP_WAV		"burp.wav"
+#define		TELEPORT3_WAV		"teleport3.wav"
+#define		DIALOG_OPEN_WAV		"dialog_open.wav"
+#define		DIALOG_CLOSE_WAV		"dialog_close.wav"
+#define		FUTUREBEEP2_WAV		"futurebeep2.wav"
+#define		INV_SELECT_WAV		"inv_select.wav"
+#define		MOVE_SELECTION_WAV		"move_selection.wav"
+#define		CELLHOLDER_USE_REJECT_WAV		"cellholder_use_reject.wav"
+#define		DOOR_OPEN_CLOSE_WAV		"door_open_close.wav"
+#define		SWITCH_USE_WAV		"switch_use.wav"
+#define		AIRLOCK_CLOSE_WAV		"airlock_close.wav"
+#define		TOUCHPLATE_CLICK_WAV		"touchplate_click.wav"
+#define		INSERT_CELL_WAV		"insert_cell.wav"
+#define		CABINET_OPEN_WAV		"cabinet_open.wav"
+#define		CABINET_CLOSE_WAV		"cabinet_close.wav"
+#define		BRIDGE_EXTEND_WAV		"bridge_extend.wav"
+#define		BRIDGE_START_WAV		"bridge_start.wav"
+#define		BRIDGE_END_WAV		"bridge_end.wav"
+#define		COMPUTERPROCESS_WAV		"computerprocess.wav"
+#define		MAILSORTER_HAPPY_WAV		"mailsorter_happy.wav"
+#define		MAILSORTER_UNHAPPY_WAV		"mailsorter_unhappy.wav"
+#define		NOTICE_WAV		"notice.wav"
+#define		MAINTBOT_WHOOSH1_WAV		"maintbot_whoosh1.wav"
+#define		MAINTBOT_WHOOSH2_WAV		"maintbot_whoosh2.wav"
+#define		SHIP_MOVING_INTRO_WAV		"ship_moving_intro.wav"
+#define		LASER_LOOP_WAV		"laser_loop.wav"
+#define		INFOCOMP_WAV		"infocomp.wav"
+#define		SLOT_SPIN_WAV		"slot_spin.wav"
+#define		SLOT_STOP_WAV		"slot_stop.wav"
+#define		SLOT_WIN_WAV		"slot_win.wav"
+#define		CLOCK_BONK_WAV		"clock_bonk.wav"
+#define		PASSCODE_CORRECT_WAV		"passcode_correct.wav"
+#define		SLOTMACHINE_SPINS_WAV		"slotmachine_spins.wav"
+#define		SLOTMACHINE_STOP_WAV		"slotmachine_stop.wav"
+#define		SLOTMACHINE_WIN_WAV		"slotmachine_win.wav"
+#define		PANIC_WAV		"panic.wav"
+#define		PANIC_TIMER_WAV		"panic_timer.wav"
+#define		PANIC_DEATH_WAV		"panic_death.wav"
+#define		QUEST_COMPLETE_WAV		"quest_complete.wav"
+#define		QUEST_FAILED_WAV		"quest_failed.wav"
+#define		TRY_AGAIN_WAV		"try_again.wav"
+#define		MONKEY_OOHOOH_WAV		"monkey_oohooh.wav"
+#define		MONKEY_WIN_WAV		"monkey_win.wav"
+#define		BYE_WAV		"bye.wav"
+#define		HDB_WAV		"hdb.wav"
+#define		VORTEXIAN_SAVE_WAV		"vortexian_save.wav"
+#define		UNLOCKED_ITEM_WAV		"unlocked_item.wav"
+#define		BEEPBEEPBEEP_WAV		"beepbeepbeep.wav"
+#define		MACHINE_AMBIENT1_WAV		"machine_ambient1.wav"
+#define		M00_AIRLOCK_01_MP3		"m00_airlock_01.mp3"
+#define		M00_ARNIE_01_MP3		"m00_arnie_01.mp3"
+#define		M00_BRAD_01_MP3		"m00_brad_01.mp3"
+#define		M00_BRAD_02_MP3		"m00_brad_02.mp3"
+#define		M00_BRAD_03_MP3		"m00_brad_03.mp3"
+#define		M00_BUSTER_01_MP3		"m00_buster_01.mp3"
+#define		M00_BUSTER_02_MP3		"m00_buster_02.mp3"
+#define		M00_BUSTER_03_MP3		"m00_buster_03.mp3"
+#define		M00_BUSTER_04_MP3		"m00_buster_04.mp3"
+#define		M00_BUSTER_05_MP3		"m00_buster_05.mp3"
+#define		M00_BUSTER_06_MP3		"m00_buster_06.mp3"
+#define		M00_BUSTER_07_MP3		"m00_buster_07.mp3"
+#define		M00_BUSTER_08_MP3		"m00_buster_08.mp3"
+#define		M00_BUSTER_09_MP3		"m00_buster_09.mp3"
+#define		M00_BUSTER_10_MP3		"m00_buster_10.mp3"
+#define		M00_BUSTER_11_MP3		"m00_buster_11.mp3"
+#define		M00_BUSTER_12_MP3		"m00_buster_12.mp3"
+#define		M00_BUSTER_13A_MP3		"m00_buster_13a.mp3"
+#define		M00_BUSTER_13B_MP3		"m00_buster_13b.mp3"
+#define		M00_BUSTER_14_MP3		"m00_buster_14.mp3"
+#define		M00_BUSTER_15_MP3		"m00_buster_15.mp3"
+#define		M00_BUSTER_16_MP3		"m00_buster_16.mp3"
+#define		M00_BUSTER_17_MP3		"m00_buster_17.mp3"
+#define		M00_BUSTER_18_MP3		"m00_buster_18.mp3"
+#define		M00_BUSTER_19_MP3		"m00_buster_19.mp3"
+#define		M00_CHICKEN_01_MP3		"m00_chicken_01.mp3"
+#define		M00_CHUTEGUARD_01_MP3		"m00_chuteguard_01.mp3"
+#define		M00_CHUTEGUARD_02_MP3		"m00_chuteguard_02.mp3"
+#define		M00_CHUTEGUARD_03_MP3		"m00_chuteguard_03.mp3"
+#define		M00_CHUTEGUARD_04_MP3		"m00_chuteguard_04.mp3"
+#define		M00_CHUTEGUARD_05_MP3		"m00_chuteguard_05.mp3"
+#define		M00_COOPER_01_MP3		"m00_cooper_01.mp3"
+#define		M00_COOPER_02_MP3		"m00_cooper_02.mp3"
+#define		M00_COOPER_03_MP3		"m00_cooper_03.mp3"
+#define		M00_COOPER_04_MP3		"m00_cooper_04.mp3"
+#define		M00_COOPER_05_MP3		"m00_cooper_05.mp3"
+#define		M00_DINERS_01_MP3		"m00_diners_01.mp3"
+#define		M00_DINERS_02_MP3		"m00_diners_02.mp3"
+#define		M00_DINERS_03_MP3		"m00_diners_03.mp3"
+#define		M00_DINERS_04_MP3		"m00_diners_04.mp3"
+#define		M00_DINERS_05_MP3		"m00_diners_05.mp3"
+#define		M00_DINERS_06_MP3		"m00_diners_06.mp3"
+#define		M00_DOLLY_01_MP3		"m00_dolly_01.mp3"
+#define		M00_DOLLY_02_MP3		"m00_dolly_02.mp3"
+#define		M00_DOLLY_03_MP3		"m00_dolly_03.mp3"
+#define		M00_DOLLY_04_MP3		"m00_dolly_04.mp3"
+#define		M00_DOLLY_05_MP3		"m00_dolly_05.mp3"
+#define		M00_DOLLY_06_MP3		"m00_dolly_06.mp3"
+#define		M00_DOLLY_07_MP3		"m00_dolly_07.mp3"
+#define		M00_DOLLY_08_MP3		"m00_dolly_08.mp3"
+#define		M00_DOLLY_09_MP3		"m00_dolly_09.mp3"
+#define		M00_DOREK_01_MP3		"m00_dorek_01.mp3"
+#define		M00_DOREK_02_MP3		"m00_dorek_02.mp3"
+#define		M00_DOREK_03_MP3		"m00_dorek_03.mp3"
+#define		M00_DOREK_04_MP3		"m00_dorek_04.mp3"
+#define		M00_ENGCOMPUTER_01_MP3		"m00_engcomputer_01.mp3"
+#define		M00_ENGCOMPUTER_02_MP3		"m00_engcomputer_02.mp3"
+#define		M00_FARBLE_01_MP3		"m00_farble_01.mp3"
+#define		M00_FARBLE_02_MP3		"m00_farble_02.mp3"
+#define		M00_FARBLE_03_MP3		"m00_farble_03.mp3"
+#define		M00_FARBLE_04_MP3		"m00_farble_04.mp3"
+#define		M00_FARBLE_05_MP3		"m00_farble_05.mp3"
+#define		M00_FARBLE_06_MP3		"m00_farble_06.mp3"
+#define		M00_FARBLE_07_MP3		"m00_farble_07.mp3"
+#define		M00_FARBLE_08_MP3		"m00_farble_08.mp3"
+#define		M00_GRUNETT_01_MP3		"m00_grunett_01.mp3"
+#define		M00_GRUNETT_02_MP3		"m00_grunett_02.mp3"
+#define		M00_GRUNETT_03_MP3		"m00_grunett_03.mp3"
+#define		M00_GRUNETT_04_MP3		"m00_grunett_04.mp3"
+#define		M00_GUY_01_MP3		"m00_guy_01.mp3"
+#define		M00_GUY_02_MP3		"m00_guy_02.mp3"
+#define		M00_GUY_03_MP3		"m00_guy_03.mp3"
+#define		M00_GUY_04_MP3		"m00_guy_04.mp3"
+#define		M00_GUY_05_MP3		"m00_guy_05.mp3"
+#define		M00_GUY_06_MP3		"m00_guy_06.mp3"
+#define		M00_GUY_07_MP3		"m00_guy_07.mp3"
+#define		M00_GUY_08_MP3		"m00_guy_08.mp3"
+#define		M00_GUY_09_MP3		"m00_guy_09.mp3"
+#define		M00_GUY_10A_MP3		"m00_guy_10a.mp3"
+#define		M00_GUY_10B_MP3		"m00_guy_10b.mp3"
+#define		M00_GUY_11_MP3		"m00_guy_11.mp3"
+#define		M00_GUY_12_MP3		"m00_guy_12.mp3"
+#define		M00_GUY_13_MP3		"m00_guy_13.mp3"
+#define		M00_GUY_14_MP3		"m00_guy_14.mp3"
+#define		M00_GUY_15_MP3		"m00_guy_15.mp3"
+#define		M00_GUY_16_MP3		"m00_guy_16.mp3"
+#define		M00_GUY_17_MP3		"m00_guy_17.mp3"
+#define		M00_GUY_18_MP3		"m00_guy_18.mp3"
+#define		M00_HUMBERT_01_MP3		"m00_humbert_01.mp3"
+#define		M00_HUMBERT_02_MP3		"m00_humbert_02.mp3"
+#define		M00_ILLIAC_01_MP3		"m00_illiac_01.mp3"
+#define		M00_INFOCOMP_01_MP3		"m00_infocomp_01.mp3"
+#define		M00_JAQUES_01_MP3		"m00_jaques_01.mp3"
+#define		M00_JAQUES_03_MP3		"m00_jaques_03.mp3"
+#define		M00_JAQUES_04_MP3		"m00_jaques_04.mp3"
+#define		M00_JAQUES_05_MP3		"m00_jaques_05.mp3"
+#define		M00_LUMBAR_01_MP3		"m00_lumbar_01.mp3"
+#define		M00_MAILSORTER_01_MP3		"m00_mailsorter_01.mp3"
+#define		M00_MAILSORTER_02_MP3		"m00_mailsorter_02.mp3"
+#define		M00_MAILSORTER_03_MP3		"m00_mailsorter_03.mp3"
+#define		M00_MAILSORTER_04_MP3		"m00_mailsorter_04.mp3"
+#define		M00_MAILSORTER_05_MP3		"m00_mailsorter_05.mp3"
+#define		M00_MAILSORTER_06_MP3		"m00_mailsorter_06.mp3"
+#define		M00_MAILSORTER_07_MP3		"m00_mailsorter_07.mp3"
+#define		M00_MAILSORTER_08_MP3		"m00_mailsorter_08.mp3"
+#define		M00_MAILSORTER_09_MP3		"m00_mailsorter_09.mp3"
+#define		M00_MAILSORTER_10_MP3		"m00_mailsorter_10.mp3"
+#define		M00_MAILSORTER_11_MP3		"m00_mailsorter_11.mp3"
+#define		M00_MAILSORTER_12_MP3		"m00_mailsorter_12.mp3"
+#define		M00_MAILSORTER_13_MP3		"m00_mailsorter_13.mp3"
+#define		M00_MAILSORTER_14_MP3		"m00_mailsorter_14.mp3"
+#define		M00_MAILSORTER_15_MP3		"m00_mailsorter_15.mp3"
+#define		M00_MANNY_01_MP3		"m00_manny_01.mp3"
+#define		M00_MANNY_02_MP3		"m00_manny_02.mp3"
+#define		M00_MANNY_03_MP3		"m00_manny_03.mp3"
+#define		M00_MANNY_04_MP3		"m00_manny_04.mp3"
+#define		M00_MANNY_05_MP3		"m00_manny_05.mp3"
+#define		M00_MANNY_06_MP3		"m00_manny_06.mp3"
+#define		M00_MANNY_07_MP3		"m00_manny_07.mp3"
+#define		M00_MANNY_08_MP3		"m00_manny_08.mp3"
+#define		M00_MANNY_09_MP3		"m00_manny_09.mp3"
+#define		M00_MANNY_10_MP3		"m00_manny_10.mp3"
+#define		M00_MANNY_11_MP3		"m00_manny_11.mp3"
+#define		M00_MANNY_12_MP3		"m00_manny_12.mp3"
+#define		M00_MANNY_13_MP3		"m00_manny_13.mp3"
+#define		M00_MANNY_14_MP3		"m00_manny_14.mp3"
+#define		M00_MANNY_15_MP3		"m00_manny_15.mp3"
+#define		M00_MANNY_16_MP3		"m00_manny_16.mp3"
+#define		M00_MANNY_17_MP3		"m00_manny_17.mp3"
+#define		M00_MANNY_18_MP3		"m00_manny_18.mp3"
+#define		M00_NOTEBRICK_01_MP3		"m00_notebrick_01.mp3"
+#define		M00_PILOTS_01_MP3		"m00_pilots_01.mp3"
+#define		M00_PILOTS_02_MP3		"m00_pilots_02.mp3"
+#define		M00_POLONEY_01_MP3		"m00_poloney_01.mp3"
+#define		M00_POLONEY_02_MP3		"m00_poloney_02.mp3"
+#define		M00_POLONEY_03_MP3		"m00_poloney_03.mp3"
+#define		M00_POLONEY_04_MP3		"m00_poloney_04.mp3"
+#define		M00_POLONEY_05_MP3		"m00_poloney_05.mp3"
+#define		M00_POLONEY_06_MP3		"m00_poloney_06.mp3"
+#define		M00_SARGE_01_MP3		"m00_sarge_01.mp3"
+#define		M00_SARGE_02_MP3		"m00_sarge_02.mp3"
+#define		M00_SARGE_03_MP3		"m00_sarge_03.mp3"
+#define		M00_SARGE_04_MP3		"m00_sarge_04.mp3"
+#define		M00_SARGE_05_MP3		"m00_sarge_05.mp3"
+#define		M00_SARGE_06_MP3		"m00_sarge_06.mp3"
+#define		M00_SARGE_07_MP3		"m00_sarge_07.mp3"
+#define		M00_SARGE_08_MP3		"m00_sarge_08.mp3"
+#define		M00_SARGE_09_MP3		"m00_sarge_09.mp3"
+#define		M00_SARGE_10_MP3		"m00_sarge_10.mp3"
+#define		M00_SARGE_11_MP3		"m00_sarge_11.mp3"
+#define		M00_SARGE_12_MP3		"m00_sarge_12.mp3"
+#define		M00_SARGE_13_MP3		"m00_sarge_13.mp3"
+#define		M00_SARGE_14_MP3		"m00_sarge_14.mp3"
+#define		M00_SARGE_15_MP3		"m00_sarge_15.mp3"
+#define		M00_SARGE_16_MP3		"m00_sarge_16.mp3"
+#define		M01_ALABASTER_01_MP3		"m01_alabaster_01.mp3"
+#define		M01_ALABASTER_02_MP3		"m01_alabaster_02.mp3"
+#define		M01_ALABASTER_03_MP3		"m01_alabaster_03.mp3"
+#define		M01_ALABASTER_04_MP3		"m01_alabaster_04.mp3"
+#define		M01_ALABASTER_05_MP3		"m01_alabaster_05.mp3"
+#define		M01_ALABASTER_06_MP3		"m01_alabaster_06.mp3"
+#define		M01_BRAKER_01_MP3		"m01_braker_01.mp3"
+#define		M01_BRAKER_02_MP3		"m01_braker_02.mp3"
+#define		M01_BRAKER_03_MP3		"m01_braker_03.mp3"
+#define		M01_BRAKER_04_MP3		"m01_braker_04.mp3"
+#define		M01_CHISTE_01_MP3		"m01_chiste_01.mp3"
+#define		M01_CHISTE_02_MP3		"m01_chiste_02.mp3"
+#define		M01_CHISTE_03_MP3		"m01_chiste_03.mp3"
+#define		M01_CHISTE_04_MP3		"m01_chiste_04.mp3"
+#define		M01_CHISTE_05_MP3		"m01_chiste_05.mp3"
+#define		M01_CHISTE_06_MP3		"m01_chiste_06.mp3"
+#define		M01_CHISTE_07_MP3		"m01_chiste_07.mp3"
+#define		M01_CHISTE_08_MP3		"m01_chiste_08.mp3"
+#define		M01_CHISTE_09_MP3		"m01_chiste_09.mp3"
+#define		M01_CHISTE_10_MP3		"m01_chiste_10.mp3"
+#define		M01_CHISTE_11_MP3		"m01_chiste_11.mp3"
+#define		M01_CHISTE_12_MP3		"m01_chiste_12.mp3"
+#define		M01_CHISTE_13_MP3		"m01_chiste_13.mp3"
+#define		M01_CHISTE_14_MP3		"m01_chiste_14.mp3"
+#define		M01_COVERT_01_MP3		"m01_covert_01.mp3"
+#define		M01_COVERT_02_MP3		"m01_covert_02.mp3"
+#define		M01_COVERT_03_MP3		"m01_covert_03.mp3"
+#define		M01_COVERT_04_MP3		"m01_covert_04.mp3"
+#define		M01_COVERT_05_MP3		"m01_covert_05.mp3"
+#define		M01_COVERT_06_MP3		"m01_covert_06.mp3"
+#define		M01_COVERT_07_MP3		"m01_covert_07.mp3"
+#define		M01_COVERT_08_MP3		"m01_covert_08.mp3"
+#define		M01_COVERT_09_MP3		"m01_covert_09.mp3"
+#define		M01_COVERT_10_MP3		"m01_covert_10.mp3"
+#define		M01_COVERT_11_MP3		"m01_covert_11.mp3"
+#define		M01_COVERT_12_MP3		"m01_covert_12.mp3"
+#define		M01_COVERT_13_MP3		"m01_covert_13.mp3"
+#define		M01_DAGEAUBE_01_MP3		"m01_dageaube_01.mp3"
+#define		M01_DAGEAUBE_02_MP3		"m01_dageaube_02.mp3"
+#define		M01_DAGEAUBE_03_MP3		"m01_dageaube_03.mp3"
+#define		M01_DAGEAUBE_04_MP3		"m01_dageaube_04.mp3"
+#define		M01_DAGEAUBE_05_MP3		"m01_dageaube_05.mp3"
+#define		M01_EMC2_01_MP3		"m01_emc2_01.mp3"
+#define		M01_EMC2_02_MP3		"m01_emc2_02.mp3"
+#define		M01_GIZZARD_01_MP3		"m01_gizzard_01.mp3"
+#define		M01_GIZZARD_02_MP3		"m01_gizzard_02.mp3"
+#define		M01_GUY_01_MP3		"m01_guy_01.mp3"
+#define		M01_GUY_02_MP3		"m01_guy_02.mp3"
+#define		M01_GUY_03_MP3		"m01_guy_03.mp3"
+#define		M01_GUY_04_MP3		"m01_guy_04.mp3"
+#define		M01_GUY_05_MP3		"m01_guy_05.mp3"
+#define		M01_HIDROW_01_MP3		"m01_hidrow_01.mp3"
+#define		M01_HIDROW_02_MP3		"m01_hidrow_02.mp3"
+#define		M01_HIDROW_03_MP3		"m01_hidrow_03.mp3"
+#define		M01_KEBOTTLE_01_MP3		"m01_kebottle_01.mp3"
+#define		M01_KEBOTTLE_02_MP3		"m01_kebottle_02.mp3"
+#define		M01_KEBOTTLE_03_MP3		"m01_kebottle_03.mp3"
+#define		M01_KEBOTTLE_04_MP3		"m01_kebottle_04.mp3"
+#define		M01_KEBOTTLE_05_MP3		"m01_kebottle_05.mp3"
+#define		M01_KEBOTTLE_06_MP3		"m01_kebottle_06.mp3"
+#define		M01_KEBOTTLE_07_MP3		"m01_kebottle_07.mp3"
+#define		M01_PONTE_01_MP3		"m01_ponte_01.mp3"
+#define		M01_PONTE_02_MP3		"m01_ponte_02.mp3"
+#define		M01_PONTE_03_MP3		"m01_ponte_03.mp3"
+#define		M01_PONTE_04_MP3		"m01_ponte_04.mp3"
+#define		M01_PONTE_05_MP3		"m01_ponte_05.mp3"
+#define		M01_PONTE_06_MP3		"m01_ponte_06.mp3"
+#define		M01_PONTE_07_MP3		"m01_ponte_07.mp3"
+#define		M01_PONTE_08_MP3		"m01_ponte_08.mp3"
+#define		M01_PONTE_09_MP3		"m01_ponte_09.mp3"
+#define		M01_PONTE_10_MP3		"m01_ponte_10.mp3"
+#define		M01_POPOPOLIS_01_MP3		"m01_popopolis_01.mp3"
+#define		M01_POPOPOLIS_02_MP3		"m01_popopolis_02.mp3"
+#define		M01_POPOPOLIS_03_MP3		"m01_popopolis_03.mp3"
+#define		M01_POPOPOLIS_04_MP3		"m01_popopolis_04.mp3"
+#define		M01_POPOPOLIS_05_MP3		"m01_popopolis_05.mp3"
+#define		M01_POPOPOLIS_06_MP3		"m01_popopolis_06.mp3"
+#define		M01_POPOPOLIS_07_MP3		"m01_popopolis_07.mp3"
+#define		M01_POPOPOLIS_08_MP3		"m01_popopolis_08.mp3"
+#define		M01_POPOPOLIS_09_MP3		"m01_popopolis_09.mp3"
+#define		M01_POPOPOLIS_10_MP3		"m01_popopolis_10.mp3"
+#define		M01_POPOPOLIS_11_MP3		"m01_popopolis_11.mp3"
+#define		M01_POPOPOLIS_12_MP3		"m01_popopolis_12.mp3"
+#define		M01_POPOPOLIS_13_MP3		"m01_popopolis_13.mp3"
+#define		M01_POPOPOLIS_14_MP3		"m01_popopolis_14.mp3"
+#define		M01_POPOPOLIS_15_MP3		"m01_popopolis_15.mp3"
+#define		M01_POPOPOLIS_16_MP3		"m01_popopolis_16.mp3"
+#define		M01_POPOPOLIS_17_MP3		"m01_popopolis_17.mp3"
+#define		M01_POPOPOLIS_18_MP3		"m01_popopolis_18.mp3"
+#define		M01_POPOPOLIS_19_MP3		"m01_popopolis_19.mp3"
+#define		M01_POPOPOLIS_20_MP3		"m01_popopolis_20.mp3"
+#define		M01_POPOPOLIS_21_MP3		"m01_popopolis_21.mp3"
+#define		M01_POPOPOLIS_22_MP3		"m01_popopolis_22.mp3"
+#define		M01_POPOPOLIS_23_MP3		"m01_popopolis_23.mp3"
+#define		M01_POPOPOLIS_24_MP3		"m01_popopolis_24.mp3"
+#define		M01_POPOPOLIS_25_MP3		"m01_popopolis_25.mp3"
+#define		M01_POPOPOLIS_26_MP3		"m01_popopolis_26.mp3"
+#define		M01_POPOPOLIS_27_MP3		"m01_popopolis_27.mp3"
+#define		M01_POPOPOLIS_28_MP3		"m01_popopolis_28.mp3"
+#define		M01_POPOPOLIS_29_MP3		"m01_popopolis_29.mp3"
+#define		M01_POPOPOLIS_30_MP3		"m01_popopolis_30.mp3"
+#define		M01_POPOPOLIS_31_MP3		"m01_popopolis_31.mp3"
+#define		M01_POPOPOLIS_32_MP3		"m01_popopolis_32.mp3"
+#define		M01_POPOPOLIS_33_MP3		"m01_popopolis_33.mp3"
+#define		M01_POPOPOLIS_34_MP3		"m01_popopolis_34.mp3"
+#define		M01_POPOPOLIS_35_MP3		"m01_popopolis_35.mp3"
+#define		M01_POPOPOLIS_36_MP3		"m01_popopolis_36.mp3"
+#define		M01_POPOPOLIS_37_MP3		"m01_popopolis_37.mp3"
+#define		M01_SARGE_01_MP3		"m01_sarge_01.mp3"
+#define		M01_SARGE_02_MP3		"m01_sarge_02.mp3"
+#define		M01_SARGE_03_MP3		"m01_sarge_03.mp3"
+#define		M01_SARGE_04_MP3		"m01_sarge_04.mp3"
+#define		M01_SOBREDELLE_01_MP3		"m01_sobredelle_01.mp3"
+#define		M01_SOBREDELLE_02_MP3		"m01_sobredelle_02.mp3"
+#define		M01_SOBREDELLE_03_MP3		"m01_sobredelle_03.mp3"
+#define		M01_WAYNE_01_MP3		"m01_wayne_01.mp3"
+#define		M01_WAYNE_02_MP3		"m01_wayne_02.mp3"
+#define		M01_ZIQUOZ_01_MP3		"m01_ziquoz_01.mp3"
+#define		M01_ZIQUOZ_02_MP3		"m01_ziquoz_02.mp3"
+#define		M01_ZIQUOZ_03_MP3		"m01_ziquoz_03.mp3"
+#define		M02_AGUSTO_01_MP3		"m02_agusto_01.mp3"
+#define		M02_AGUSTO_02_MP3		"m02_agusto_02.mp3"
+#define		M02_ALBONDIGAS_01_MP3		"m02_albondigas_01.mp3"
+#define		M02_ALBONDIGAS_02_MP3		"m02_albondigas_02.mp3"
+#define		M02_BUMPER_01_MP3		"m02_bumper_01.mp3"
+#define		M02_BUMPER_02_MP3		"m02_bumper_02.mp3"
+#define		M02_BUMPER_03_MP3		"m02_bumper_03.mp3"
+#define		M02_BUMPER_04_MP3		"m02_bumper_04.mp3"
+#define		M02_BUMPER_05_MP3		"m02_bumper_05.mp3"
+#define		M02_BUMPER_06_MP3		"m02_bumper_06.mp3"
+#define		M02_BUMPER_07_MP3		"m02_bumper_07.mp3"
+#define		M02_DELGADO_01_MP3		"m02_delgado_01.mp3"
+#define		M02_FEBRARO_01_MP3		"m02_febraro_01.mp3"
+#define		M02_GUY_01_MP3		"m02_guy_01.mp3"
+#define		M02_GUY_02_MP3		"m02_guy_02.mp3"
+#define		M03_ACROPHO_01_MP3		"m03_acropho_01.mp3"
+#define		M03_ACROPHO_02_MP3		"m03_acropho_02.mp3"
+#define		M03_ACROPHO_03_MP3		"m03_acropho_03.mp3"
+#define		M03_ACROPHO_04_MP3		"m03_acropho_04.mp3"
+#define		M03_ENERO_01_MP3		"m03_enero_01.mp3"
+#define		M03_ENERO_02_MP3		"m03_enero_02.mp3"
+#define		M03_ENERO_03_MP3		"m03_enero_03.mp3"
+#define		M03_ENERO_04_MP3		"m03_enero_04.mp3"
+#define		M03_ENERO_05_MP3		"m03_enero_05.mp3"
+#define		M03_GAIA_01_MP3		"m03_gaia_01.mp3"
+#define		M03_GAIA_02_MP3		"m03_gaia_02.mp3"
+#define		M03_GAIA_03_MP3		"m03_gaia_03.mp3"
+#define		M03_GAIA_04_MP3		"m03_gaia_04.mp3"
+#define		M03_GAIA_05_MP3		"m03_gaia_05.mp3"
+#define		M03_GAIA_06_MP3		"m03_gaia_06.mp3"
+#define		M03_LAGO_01_MP3		"m03_lago_01.mp3"
+#define		M03_LAGO_02_MP3		"m03_lago_02.mp3"
+#define		M03_LAGO_04_MP3		"m03_lago_04.mp3"
+#define		M03_LAGO_05_MP3		"m03_lago_05.mp3"
+#define		M03_LAGO_06_MP3		"m03_lago_06.mp3"
+#define		M03_LAGO_07_MP3		"m03_lago_07.mp3"
+#define		M04_BONIFACE_01_MP3		"m04_boniface_01.mp3"
+#define		M04_BONIFACE_02_MP3		"m04_boniface_02.mp3"
+#define		M04_BONIFACE_03_MP3		"m04_boniface_03.mp3"
+#define		M04_BONIFACE_04_MP3		"m04_boniface_04.mp3"
+#define		M04_BONIFACE_05_MP3		"m04_boniface_05.mp3"
+#define		M04_BONIFACE_06_MP3		"m04_boniface_06.mp3"
+#define		M04_BONIFACE_07_MP3		"m04_boniface_07.mp3"
+#define		M04_JULIO_01_MP3		"m04_julio_01.mp3"
+#define		M04_JULIO_02_MP3		"m04_julio_02.mp3"
+#define		M04_JULIO_04_MP3		"m04_julio_04.mp3"
+#define		M04_MARZO_01_MP3		"m04_marzo_01.mp3"
+#define		M04_OCTUBRE_01_MP3		"m04_octubre_01.mp3"
+#define		M04_OCTUBRE_02_MP3		"m04_octubre_02.mp3"
+#define		M04_OCTUBRE_03_MP3		"m04_octubre_03.mp3"
+#define		M05_ABRIL_01_MP3		"m05_abril_01.mp3"
+#define		M05_ABRIL_02_MP3		"m05_abril_02.mp3"
+#define		M05_ABRIL_03_MP3		"m05_abril_03.mp3"
+#define		M05_ABRIL_04_MP3		"m05_abril_04.mp3"
+#define		M05_ABRIL_05_MP3		"m05_abril_05.mp3"
+#define		M05_EVERLOO_01_MP3		"m05_everloo_01.mp3"
+#define		M05_EVERLOO_02_MP3		"m05_everloo_02.mp3"
+#define		M05_EVERLOO_03_MP3		"m05_everloo_03.mp3"
+#define		M05_EVERLOO_04_MP3		"m05_everloo_04.mp3"
+#define		M05_GELIGELLA_01_MP3		"m05_geligella_01.mp3"
+#define		M05_GELIGELLA_02_MP3		"m05_geligella_02.mp3"
+#define		M05_RAILRIDER_01_MP3		"m05_railrider_01.mp3"
+#define		M05_RAILRIDER_02_MP3		"m05_railrider_02.mp3"
+#define		M05_RAILRIDER_03_MP3		"m05_railrider_03.mp3"
+#define		M05_RAILRIDER_04_MP3		"m05_railrider_04.mp3"
+#define		M06_AZUL_01_MP3		"m06_azul_01.mp3"
+#define		M06_AZUL_02_MP3		"m06_azul_02.mp3"
+#define		M06_AZUL_03_MP3		"m06_azul_03.mp3"
+#define		M06_AZUL_04_MP3		"m06_azul_04.mp3"
+#define		M06_AZUL_05_MP3		"m06_azul_05.mp3"
+#define		M06_AZUL_06_MP3		"m06_azul_06.mp3"
+#define		M06_AZUL_07_MP3		"m06_azul_07.mp3"
+#define		M06_AZUL_08_MP3		"m06_azul_08.mp3"
+#define		M06_GUY_01_MP3		"m06_guy_01.mp3"
+#define		M06_GUY_02_MP3		"m06_guy_02.mp3"
+#define		M06_GUY_03_MP3		"m06_guy_03.mp3"
+#define		M06_GUY_04_MP3		"m06_guy_04.mp3"
+#define		M06_HANSON_01_MP3		"m06_hanson_01.mp3"
+#define		M06_HANSON_03_MP3		"m06_hanson_03.mp3"
+#define		M06_HANSON_04_MP3		"m06_hanson_04.mp3"
+#define		M06_HANSON_05_MP3		"m06_hanson_05.mp3"
+#define		M06_HANSON_06_MP3		"m06_hanson_06.mp3"
+#define		M06_HANSON_07_MP3		"m06_hanson_07.mp3"
+#define		M06_HANSON_08_MP3		"m06_hanson_08.mp3"
+#define		M06_HANSON_09_MP3		"m06_hanson_09.mp3"
+#define		M06_HANSON_10_MP3		"m06_hanson_10.mp3"
+#define		M06_HANSON_11_MP3		"m06_hanson_11.mp3"
+#define		M06_HANSON_12_MP3		"m06_hanson_12.mp3"
+#define		M06_JUNIO_01_MP3		"m06_junio_01.mp3"
+#define		M06_JUNIO_02_MP3		"m06_junio_02.mp3"
+#define		M06_JUNIO_03_MP3		"m06_junio_03.mp3"
+#define		M06_JUNIO_04_MP3		"m06_junio_04.mp3"
+#define		M06_JUNIO_05_MP3		"m06_junio_05.mp3"
+#define		M06_JUNIO_06_MP3		"m06_junio_06.mp3"
+#define		M06_JUNIO_07_MP3		"m06_junio_07.mp3"
+#define		M06_JUNIO_08_MP3		"m06_junio_08.mp3"
+#define		M06_JUNIO_09_MP3		"m06_junio_09.mp3"
+#define		M06_NARANJA_01_MP3		"m06_naranja_01.mp3"
+#define		M06_NARANJA_02_MP3		"m06_naranja_02.mp3"
+#define		M06_NARANJA_03_MP3		"m06_naranja_03.mp3"
+#define		M06_NARANJA_04_MP3		"m06_naranja_04.mp3"
+#define		M06_NARANJA_05_MP3		"m06_naranja_05.mp3"
+#define		M06_SEPTEMBRE_01_MP3		"m06_septembre_01.mp3"
+#define		M06_SEPTEMBRE_02_MP3		"m06_septembre_02.mp3"
+#define		M06_SEPTEMBRE_03_MP3		"m06_septembre_03.mp3"
+#define		M06_SEPTEMBRE_04_MP3		"m06_septembre_04.mp3"
+#define		M06_SEPTEMBRE_05_MP3		"m06_septembre_05.mp3"
+#define		M06_SEPTEMBRE_06_MP3		"m06_septembre_06.mp3"
+#define		M06_SEPTEMBRE_07_MP3		"m06_septembre_07.mp3"
+#define		M06_SEPTEMBRE_08_MP3		"m06_septembre_08.mp3"
+#define		M06_SEPTEMBRE_09_MP3		"m06_septembre_09.mp3"
+#define		M06_WORKER_01_MP3		"m06_worker_01.mp3"
+#define		M06_WORKER_02_MP3		"m06_worker_02.mp3"
+#define		M06_WORKER_03_MP3		"m06_worker_03.mp3"
+#define		M06_WORKER_04_MP3		"m06_worker_04.mp3"
+#define		M07_CERCO_01_MP3		"m07_cerco_01.mp3"
+#define		M07_CERCO_02_MP3		"m07_cerco_02.mp3"
+#define		M07_COMPUTER_01_MP3		"m07_computer_01.mp3"
+#define		M07_MAYO_01_MP3		"m07_mayo_01.mp3"
+#define		M07_MAYO_02_MP3		"m07_mayo_02.mp3"
+#define		M07_NOVIEMBRE_01_MP3		"m07_noviembre_01.mp3"
+#define		M07_NOVIEMBRE_02_MP3		"m07_noviembre_02.mp3"
+#define		M07_NOVIEMBRE_03_MP3		"m07_noviembre_03.mp3"
+#define		M07_PANITO_01_MP3		"m07_panito_01.mp3"
+#define		M07_PANITO_02_MP3		"m07_panito_02.mp3"
+#define		M07_PANITO_03_MP3		"m07_panito_03.mp3"
+#define		M07_PANITO_04_MP3		"m07_panito_04.mp3"
+#define		M07_PANITO_05_MP3		"m07_panito_05.mp3"
+#define		M08_COOKIE_01_MP3		"m08_cookie_01.mp3"
+#define		M08_COOKIE_02_MP3		"m08_cookie_02.mp3"
+#define		M08_DICIEMBRE_01_MP3		"m08_diciembre_01.mp3"
+#define		M08_GUY_01_MP3		"m08_guy_01.mp3"
+#define		M08_GUY_02_MP3		"m08_guy_02.mp3"
+#define		M08_GUY_03_MP3		"m08_guy_03.mp3"
+#define		M08_MACHINA_01_MP3		"m08_machina_01.mp3"
+#define		M08_MACHINA_02_MP3		"m08_machina_02.mp3"
+#define		M08_MACHINA_03_MP3		"m08_machina_03.mp3"
+#define		M08_MACHINA_04_MP3		"m08_machina_04.mp3"
+#define		M08_MACHINA_05_MP3		"m08_machina_05.mp3"
+#define		M08_MACHINA_06_MP3		"m08_machina_06.mp3"
+#define		M08_MACHINA_07_MP3		"m08_machina_07.mp3"
+#define		M08_MACHINA_08_MP3		"m08_machina_08.mp3"
+#define		M08_MACHINA_09_MP3		"m08_machina_09.mp3"
+#define		M08_MESA_01_MP3		"m08_mesa_01.mp3"
+#define		M08_MESA_02_MP3		"m08_mesa_02.mp3"
+#define		M08_MESA_03_MP3		"m08_mesa_03.mp3"
+#define		M08_MESA_04_MP3		"m08_mesa_04.mp3"
+#define		M08_SHAKIR_01_MP3		"m08_shakir_01.mp3"
+#define		M08_SHAKIR_02_MP3		"m08_shakir_02.mp3"
+#define		M08_SHAKIR_03_MP3		"m08_shakir_03.mp3"
+#define		M09_VIOLETA_01_MP3		"m09_violeta_01.mp3"
+#define		M09_VIOLETA_02_MP3		"m09_violeta_02.mp3"
+#define		M09_VIOLETA_03_MP3		"m09_violeta_03.mp3"
+#define		M09_VIOLETA_04_MP3		"m09_violeta_04.mp3"
+#define		M10_CHICKEN_01_MP3		"m10_chicken_01.mp3"
+#define		M10_COOPER_01_MP3		"m10_cooper_01.mp3"
+#define		M10_COOPER_02_MP3		"m10_cooper_02.mp3"
+#define		M10_COOPER_03_MP3		"m10_cooper_03.mp3"
+#define		M10_COOPER_04_MP3		"m10_cooper_04.mp3"
+#define		M10_COOPER_05_MP3		"m10_cooper_05.mp3"
+#define		M10_COOPER_06_MP3		"m10_cooper_06.mp3"
+#define		M10_COOPER_07_MP3		"m10_cooper_07.mp3"
+#define		M10_COOPER_08_MP3		"m10_cooper_08.mp3"
+#define		M10_COOPER_09_MP3		"m10_cooper_09.mp3"
+#define		M10_DOLLY_01_MP3		"m10_dolly_01.mp3"
+#define		M10_DOLLY_02_MP3		"m10_dolly_02.mp3"
+#define		M10_DOLLY_03_MP3		"m10_dolly_03.mp3"
+#define		M10_DOLLY_04_MP3		"m10_dolly_04.mp3"
+#define		M10_DOLLY_05_MP3		"m10_dolly_05.mp3"
+#define		M10_DOLLY_06_MP3		"m10_dolly_06.mp3"
+#define		M10_DOLLY_07_MP3		"m10_dolly_07.mp3"
+#define		M10_DOLLY_08_MP3		"m10_dolly_08.mp3"
+#define		M10_DOLLY_09_MP3		"m10_dolly_09.mp3"
+#define		M10_DOLLY_10_MP3		"m10_dolly_10.mp3"
+#define		M10_ENGCOMPUTER_01_MP3		"m10_engcomputer_01.mp3"
+#define		M10_FARBLE_01_MP3		"m10_farble_01.mp3"
+#define		M10_FARBLE_02_MP3		"m10_farble_02.mp3"
+#define		M10_FARBLE_03_MP3		"m10_farble_03.mp3"
+#define		M10_FARBLE_04_MP3		"m10_farble_04.mp3"
+#define		M10_FARBLE_05_MP3		"m10_farble_05.mp3"
+#define		M10_FARBLE_06_MP3		"m10_farble_06.mp3"
+#define		M10_GRUNETT_01_MP3		"m10_grunett_01.mp3"
+#define		M10_GRUNETT_02_MP3		"m10_grunett_02.mp3"
+#define		M10_GRUNETT_03_MP3		"m10_grunett_03.mp3"
+#define		M10_GRUNETT_04_MP3		"m10_grunett_04.mp3"
+#define		M10_GRUNETT_05_MP3		"m10_grunett_05.mp3"
+#define		M10_GRUNETT_06_MP3		"m10_grunett_06.mp3"
+#define		M10_GUY_01_MP3		"m10_guy_01.mp3"
+#define		M10_GUY_02_MP3		"m10_guy_02.mp3"
+#define		M10_GUY_03_MP3		"m10_guy_03.mp3"
+#define		M10_GUY_04_MP3		"m10_guy_04.mp3"
+#define		M10_GUY_05_MP3		"m10_guy_05.mp3"
+#define		M10_GUY_06_MP3		"m10_guy_06.mp3"
+#define		M10_GUY_07_MP3		"m10_guy_07.mp3"
+#define		M10_GUY_08_MP3		"m10_guy_08.mp3"
+#define		M10_INFOCOMP_01_MP3		"m10_infocomp_01.mp3"
+#define		M10_NOTEBRICK_01_MP3		"m10_notebrick_01.mp3"
+#define		M10_PILOTS_01_MP3		"m10_pilots_01.mp3"
+#define		M10_PILOTS_02_MP3		"m10_pilots_02.mp3"
+#define		M10_PILOTS_03_MP3		"m10_pilots_03.mp3"
+#define		M10_PILOTS_04_MP3		"m10_pilots_04.mp3"
+#define		M10_PILOTS_05_MP3		"m10_pilots_05.mp3"
+#define		M10_SARGE_01_MP3		"m10_sarge_01.mp3"
+#define		M10_SARGE_02_MP3		"m10_sarge_02.mp3"
+#define		M10_SARGE_03_MP3		"m10_sarge_03.mp3"
+#define		M10_SARGE_04_MP3		"m10_sarge_04.mp3"
+#define		M10_SARGE_05_MP3		"m10_sarge_05.mp3"
+#define		M11_ANCHOVY_01_MP3		"m11_anchovy_01.mp3"
+#define		M11_ANCHOVY_02_MP3		"m11_anchovy_02.mp3"
+#define		M11_ANCHOVY_03_MP3		"m11_anchovy_03.mp3"
+#define		M11_ANCHOVY_04_MP3		"m11_anchovy_04.mp3"
+#define		M11_ANCHOVY_05_MP3		"m11_anchovy_05.mp3"
+#define		M11_ARBIVALL_01_MP3		"m11_arbivall_01.mp3"
+#define		M11_ARBIVALL_02_MP3		"m11_arbivall_02.mp3"
+#define		M11_ARBIVALL_03_MP3		"m11_arbivall_03.mp3"
+#define		M11_ARBIVALL_04_MP3		"m11_arbivall_04.mp3"
+#define		M11_ARBIVALL_05_MP3		"m11_arbivall_05.mp3"
+#define		M11_ARBIVALL_06_MP3		"m11_arbivall_06.mp3"
+#define		M11_ARBIVALL_07_MP3		"m11_arbivall_07.mp3"
+#define		M11_ARNIE_01_MP3		"m11_arnie_01.mp3"
+#define		M11_BELINDA_01_MP3		"m11_belinda_01.mp3"
+#define		M11_BLOCK_01_MP3		"m11_block_01.mp3"
+#define		M11_BLOCK_02_MP3		"m11_block_02.mp3"
+#define		M11_BLOCK_03_MP3		"m11_block_03.mp3"
+#define		M11_BRAD_01_MP3		"m11_brad_01.mp3"
+#define		M11_BRAD_02_MP3		"m11_brad_02.mp3"
+#define		M11_BRAD_03_MP3		"m11_brad_03.mp3"
+#define		M11_BUSTER_01_MP3		"m11_buster_01.mp3"
+#define		M11_BUSTER_02_MP3		"m11_buster_02.mp3"
+#define		M11_BUSTER_03_MP3		"m11_buster_03.mp3"
+#define		M11_DINERS_01_MP3		"m11_diners_01.mp3"
+#define		M11_DINERS_02_MP3		"m11_diners_02.mp3"
+#define		M11_DOPPLER_01_MP3		"m11_doppler_01.mp3"
+#define		M11_DOPPLER_02_MP3		"m11_doppler_02.mp3"
+#define		M11_DOPPLER_03_MP3		"m11_doppler_03.mp3"
+#define		M11_DOPPLER_04_MP3		"m11_doppler_04.mp3"
+#define		M11_DOPPLER_05_MP3		"m11_doppler_05.mp3"
+#define		M11_DOREK_01_MP3		"m11_dorek_01.mp3"
+#define		M11_DOREK_02_MP3		"m11_dorek_02.mp3"
+#define		M11_DOREK_03_MP3		"m11_dorek_03.mp3"
+#define		M11_DOZER_01_MP3		"m11_dozer_01.mp3"
+#define		M11_DOZER_02_MP3		"m11_dozer_02.mp3"
+#define		M11_DOZER_03_MP3		"m11_dozer_03.mp3"
+#define		M11_DOZER_04_MP3		"m11_dozer_04.mp3"
+#define		M11_GNAPPE_01_MP3		"m11_gnappe_01.mp3"
+#define		M11_GNAPPE_02_MP3		"m11_gnappe_02.mp3"
+#define		M11_GNAPPE_03_MP3		"m11_gnappe_03.mp3"
+#define		M11_GNAPPE_04_MP3		"m11_gnappe_04.mp3"
+#define		M11_GNAPPE_05_MP3		"m11_gnappe_05.mp3"
+#define		M11_GNODIMY_01_MP3		"m11_gnodimy_01.mp3"
+#define		M11_GNODIMY_02_MP3		"m11_gnodimy_02.mp3"
+#define		M11_GNODIMY_03_MP3		"m11_gnodimy_03.mp3"
+#define		M11_GNODIMY_04_MP3		"m11_gnodimy_04.mp3"
+#define		M11_GUY_01_MP3		"m11_guy_01.mp3"
+#define		M11_GUY_02_MP3		"m11_guy_02.mp3"
+#define		M11_GUY_03_MP3		"m11_guy_03.mp3"
+#define		M11_GUY_04_MP3		"m11_guy_04.mp3"
+#define		M11_GUY_05_MP3		"m11_guy_05.mp3"
+#define		M11_GUY_06_MP3		"m11_guy_06.mp3"
+#define		M11_GUY_07_MP3		"m11_guy_07.mp3"
+#define		M11_GUY_08_MP3		"m11_guy_08.mp3"
+#define		M11_GUY_09_MP3		"m11_guy_09.mp3"
+#define		M11_GUY_10_MP3		"m11_guy_10.mp3"
+#define		M11_GUY_11_MP3		"m11_guy_11.mp3"
+#define		M11_GUY_12_MP3		"m11_guy_12.mp3"
+#define		M11_GUY_13_MP3		"m11_guy_13.mp3"
+#define		M11_GUY_15_MP3		"m11_guy_15.mp3"
+#define		M11_GUY_16_MP3		"m11_guy_16.mp3"
+#define		M11_GUY_17_MP3		"m11_guy_17.mp3"
+#define		M11_HAMBRE_01_MP3		"m11_hambre_01.mp3"
+#define		M11_HAMBRE_02_MP3		"m11_hambre_02.mp3"
+#define		M11_HAMBRE_03_MP3		"m11_hambre_03.mp3"
+#define		M11_HAMBRE_04_MP3		"m11_hambre_04.mp3"
+#define		M11_HAMBRE_05_MP3		"m11_hambre_05.mp3"
+#define		M11_HUMBERT_01_MP3		"m11_humbert_01.mp3"
+#define		M11_ILLIAC_01_MP3		"m11_illiac_01.mp3"
+#define		M11_JAQUES_01_MP3		"m11_jaques_01.mp3"
+#define		M11_JAQUES_02_MP3		"m11_jaques_02.mp3"
+#define		M11_JAQUES_03_MP3		"m11_jaques_03.mp3"
+#define		M11_JAQUES_04_MP3		"m11_jaques_04.mp3"
+#define		M11_LUMBAR_01_MP3		"m11_lumbar_01.mp3"
+#define		M11_MAN_IN_STALL_01_MP3		"m11_man_in_stall_01.mp3"
+#define		M11_MAN_IN_STALL_02_MP3		"m11_man_in_stall_02.mp3"
+#define		M11_MAN_IN_STALL_03_MP3		"m11_man_in_stall_03.mp3"
+#define		M11_MAN_IN_STALL_04_MP3		"m11_man_in_stall_04.mp3"
+#define		M11_MAN_IN_STALL_05_MP3		"m11_man_in_stall_05.mp3"
+#define		M11_MANNY_01_MP3		"m11_manny_01.mp3"
+#define		M11_MUMPS_01_MP3		"m11_mumps_01.mp3"
+#define		M11_MUMPS_02_MP3		"m11_mumps_02.mp3"
+#define		M11_MUMPS_03_MP3		"m11_mumps_03.mp3"
+#define		M11_MUMPS_04_MP3		"m11_mumps_04.mp3"
+#define		M11_MUMPS_05_MP3		"m11_mumps_05.mp3"
+#define		M11_MUMPS_06_MP3		"m11_mumps_06.mp3"
+#define		M11_MUMPS_07_MP3		"m11_mumps_07.mp3"
+#define		M11_MUMPS_08_MP3		"m11_mumps_08.mp3"
+#define		M11_MUMPS_09_MP3		"m11_mumps_09.mp3"
+#define		M11_MUMPS_10_MP3		"m11_mumps_10.mp3"
+#define		M11_MUMPS_11_MP3		"m11_mumps_11.mp3"
+#define		M11_MUMPS_12_MP3		"m11_mumps_12.mp3"
+#define		M11_MUMPS_13_MP3		"m11_mumps_13.mp3"
+#define		M11_MUMPS_14_MP3		"m11_mumps_14.mp3"
+#define		M11_MUMPS_15_MP3		"m11_mumps_15.mp3"
+#define		M11_MUMPS_16_MP3		"m11_mumps_16.mp3"
+#define		M11_MUMPS_17_MP3		"m11_mumps_17.mp3"
+#define		M11_MUMPS_18_MP3		"m11_mumps_18.mp3"
+#define		M11_MUMPS_19_MP3		"m11_mumps_19.mp3"
+#define		M11_MUMPS_20_MP3		"m11_mumps_20.mp3"
+#define		M11_MUMPS_22_MP3		"m11_mumps_22.mp3"
+#define		M11_MUMPS_23_MP3		"m11_mumps_23.mp3"
+#define		M11_MUMPS_24_MP3		"m11_mumps_24.mp3"
+#define		M11_MUMPS_25_MP3		"m11_mumps_25.mp3"
+#define		M11_MUMPS_26_MP3		"m11_mumps_26.mp3"
+#define		M11_PEDIMENT_01_MP3		"m11_pediment_01.mp3"
+#define		M11_PEDIMENT_02_MP3		"m11_pediment_02.mp3"
+#define		M11_PEDIMENT_03_MP3		"m11_pediment_03.mp3"
+#define		M11_PEDIMENT_04_MP3		"m11_pediment_04.mp3"
+#define		M11_PEDIMENT_05_MP3		"m11_pediment_05.mp3"
+#define		M11_PEDIMENT_06_MP3		"m11_pediment_06.mp3"
+#define		M11_PEDIMENT_07_MP3		"m11_pediment_07.mp3"
+#define		M11_PEDIMENT_08_MP3		"m11_pediment_08.mp3"
+#define		M11_POLONEY_01_MP3		"m11_poloney_01.mp3"
+#define		M11_POLONEY_02_MP3		"m11_poloney_02.mp3"
+#define		M11_POLONEY_03_MP3		"m11_poloney_03.mp3"
+#define		M11_SAUSAGE_01_MP3		"m11_sausage_01.mp3"
+#define		M11_SAUSAGE_02_MP3		"m11_sausage_02.mp3"
+#define		M11_SAUSAGE_03_MP3		"m11_sausage_03.mp3"
+#define		M11_SAUSAGE_04_MP3		"m11_sausage_04.mp3"
+#define		M11_SAUSAGE_05_MP3		"m11_sausage_05.mp3"
+#define		M11_SAUSAGE_06_MP3		"m11_sausage_06.mp3"
+#define		M11_SAUSAGE_07_MP3		"m11_sausage_07.mp3"
+#define		M11_SAUSAGE_08_MP3		"m11_sausage_08.mp3"
+#define		M11_SAUSAGE_09_MP3		"m11_sausage_09.mp3"
+#define		M11_SAUSAGE_10_MP3		"m11_sausage_10.mp3"
+#define		M12_ABLE_01_MP3		"m12_able_01.mp3"
+#define		M12_ABLE_02_MP3		"m12_able_02.mp3"
+#define		M12_ABLE_03_MP3		"m12_able_03.mp3"
+#define		M12_BUSY_01_MP3		"m12_busy_01.mp3"
+#define		M12_BUSY_02_MP3		"m12_busy_02.mp3"
+#define		M12_BUSY_03_MP3		"m12_busy_03.mp3"
+#define		M12_BUSY_04_MP3		"m12_busy_04.mp3"
+#define		M12_BUSY_05_MP3		"m12_busy_05.mp3"
+#define		M12_BUSY_06_MP3		"m12_busy_06.mp3"
+#define		M12_BUSY_07_MP3		"m12_busy_07.mp3"
+#define		M12_BUSY_08_MP3		"m12_busy_08.mp3"
+#define		M12_CHARLIE_01_MP3		"m12_charlie_01.mp3"
+#define		M12_CHARLIE_02_MP3		"m12_charlie_02.mp3"
+#define		M12_CONUNDRUM_01_MP3		"m12_conundrum_01.mp3"
+#define		M12_CONUNDRUM_02_MP3		"m12_conundrum_02.mp3"
+#define		M12_CONUNDRUM_03_MP3		"m12_conundrum_03.mp3"
+#define		M12_CONUNDRUM_04_MP3		"m12_conundrum_04.mp3"
+#define		M12_CONUNDRUM_05_MP3		"m12_conundrum_05.mp3"
+#define		M12_FOXTROT_01_MP3		"m12_foxtrot_01.mp3"
+#define		M12_FOXTROT_02_MP3		"m12_foxtrot_02.mp3"
+#define		M12_GUY_01_MP3		"m12_guy_01.mp3"
+#define		M12_GUY_02_MP3		"m12_guy_02.mp3"
+#define		M12_GUY_03_MP3		"m12_guy_03.mp3"
+#define		M12_HAUTE_01_MP3		"m12_haute_01.mp3"
+#define		M12_HAUTE_02_MP3		"m12_haute_02.mp3"
+#define		M12_HAUTE_03_MP3		"m12_haute_03.mp3"
+#define		M12_HAUTE_04_MP3		"m12_haute_04.mp3"
+#define		M12_HAUTE_05_MP3		"m12_haute_05.mp3"
+#define		M12_HAUTE_06_MP3		"m12_haute_06.mp3"
+#define		M12_HOVER_01_MP3		"m12_hover_01.mp3"
+#define		M12_HOVER_02_MP3		"m12_hover_02.mp3"
+#define		M12_RUBE_01_MP3		"m12_rube_01.mp3"
+#define		M12_RUBE_02_MP3		"m12_rube_02.mp3"
+#define		M12_RUBE_03_MP3		"m12_rube_03.mp3"
+#define		M12_RUBE_04_MP3		"m12_rube_04.mp3"
+#define		M12_RUBE_05_MP3		"m12_rube_05.mp3"
+#define		M12_RUBE_06_MP3		"m12_rube_06.mp3"
+#define		M12_RUBE_07_MP3		"m12_rube_07.mp3"
+#define		M12_RUBE_08_MP3		"m12_rube_08.mp3"
+#define		M12_RUBE_09_MP3		"m12_rube_09.mp3"
+#define		M12_RUBE_10_MP3		"m12_rube_10.mp3"
+#define		M12_TEKT_01_MP3		"m12_tekt_01.mp3"
+#define		M12_TEKT_02_MP3		"m12_tekt_02.mp3"
+#define		M12_TEKT_03_MP3		"m12_tekt_03.mp3"
+#define		M12_TEKT_04_MP3		"m12_tekt_04.mp3"
+#define		M12_TEKT_05_MP3		"m12_tekt_05.mp3"
+#define		M12_TEKT_06_MP3		"m12_tekt_06.mp3"
+#define		M12_TEKT_07_MP3		"m12_tekt_07.mp3"
+#define		M13_ANIBLE_01_MP3		"m13_anible_01.mp3"
+#define		M13_ANIBLE_02_MP3		"m13_anible_02.mp3"
+#define		M13_FLOWER_01_MP3		"m13_flower_01.mp3"
+#define		M13_FLOWER_02_MP3		"m13_flower_02.mp3"
+#define		M13_FOOCHANE_01_MP3		"m13_foochane_01.mp3"
+#define		M13_FOOCHANE_02_MP3		"m13_foochane_02.mp3"
+#define		M13_FOOCHANE_03_MP3		"m13_foochane_03.mp3"
+#define		M13_FOOCHANE_04_MP3		"m13_foochane_04.mp3"
+#define		M13_GHULABUL_01_MP3		"m13_ghulabul_01.mp3"
+#define		M13_GHULABUL_02_MP3		"m13_ghulabul_02.mp3"
+#define		M13_GHULABUL_03_MP3		"m13_ghulabul_03.mp3"
+#define		M13_GHULABUL_04_MP3		"m13_ghulabul_04.mp3"
+#define		M13_GHULABUL_05_MP3		"m13_ghulabul_05.mp3"
+#define		M13_GHULABUL_06_MP3		"m13_ghulabul_06.mp3"
+#define		M13_GHULABUL_07_MP3		"m13_ghulabul_07.mp3"
+#define		M13_GUY_01_MP3		"m13_guy_01.mp3"
+#define		M13_GUY_02_MP3		"m13_guy_02.mp3"
+#define		M13_HAVENGIN_01_MP3		"m13_havengin_01.mp3"
+#define		M13_MELO_01_MP3		"m13_melo_01.mp3"
+#define		M13_MELO_02_MP3		"m13_melo_02.mp3"
+#define		M13_MELO_03_MP3		"m13_melo_03.mp3"
+#define		M13_MITAKO_01_MP3		"m13_mitako_01.mp3"
+#define		M13_MITAKO_02_MP3		"m13_mitako_02.mp3"
+#define		M13_MITAKO_03_MP3		"m13_mitako_03.mp3"
+#define		M13_SPOONIE_01_MP3		"m13_spoonie_01.mp3"
+#define		M13_SPOONIE_02_MP3		"m13_spoonie_02.mp3"
+#define		M13_SPOONIE_03_MP3		"m13_spoonie_03.mp3"
+#define		M13_SPOONIE_04_MP3		"m13_spoonie_04.mp3"
+#define		M13_SPOONIE_05_MP3		"m13_spoonie_05.mp3"
+#define		M13_ZYGOTE_01_MP3		"m13_zygote_01.mp3"
+#define		M13_ZYGOTE_02_MP3		"m13_zygote_02.mp3"
+#define		M13_ZYGOTE_03_MP3		"m13_zygote_03.mp3"
+#define		M13_ZYGOTE_04_MP3		"m13_zygote_04.mp3"
+#define		M13_ZYGOTE_05_MP3		"m13_zygote_05.mp3"
+#define		M14_LAMORTE_01_MP3		"m14_lamorte_01.mp3"
+#define		M14_LAMORTE_02_MP3		"m14_lamorte_02.mp3"
+#define		M15_COPROITE_01_MP3		"m15_coproite_01.mp3"
+#define		M15_COPROITE_02_MP3		"m15_coproite_02.mp3"
+#define		M15_COPROITE_03_MP3		"m15_coproite_03.mp3"
+#define		M15_COPROITE_04_MP3		"m15_coproite_04.mp3"
+#define		M15_COPROITE_05_MP3		"m15_coproite_05.mp3"
+#define		M15_COPROITE_06_MP3		"m15_coproite_06.mp3"
+#define		M15_COPROITE_07_MP3		"m15_coproite_07.mp3"
+#define		M15_COPROITE_08_MP3		"m15_coproite_08.mp3"
+#define		M15_COPROITE_09_MP3		"m15_coproite_09.mp3"
+#define		M15_COPROITE_10_MP3		"m15_coproite_10.mp3"
+#define		M15_COPROITE_11_MP3		"m15_coproite_11.mp3"
+#define		M15_COPROITE_12_MP3		"m15_coproite_12.mp3"
+#define		M15_COPROITE_13_MP3		"m15_coproite_13.mp3"
+#define		M15_COPROITE_14_MP3		"m15_coproite_14.mp3"
+#define		M15_COPROITE_15_MP3		"m15_coproite_15.mp3"
+#define		M15_COPROITE_16_MP3		"m15_coproite_16.mp3"
+#define		M15_COPROITE_17_MP3		"m15_coproite_17.mp3"
+#define		M15_COPROITE_18_MP3		"m15_coproite_18.mp3"
+#define		M15_GUY_01_MP3		"m15_guy_01.mp3"
+#define		M15_GUY_02_MP3		"m15_guy_02.mp3"
+#define		M15_REED_01_MP3		"m15_reed_01.mp3"
+#define		M15_REED_02_MP3		"m15_reed_02.mp3"
+#define		M15_REED_03_MP3		"m15_reed_03.mp3"
+#define		M16_DYING_01_MP3		"m16_dying_01.mp3"
+#define		M16_DYING_02_MP3		"m16_dying_02.mp3"
+#define		M16_GUY_01_MP3		"m16_guy_01.mp3"
+#define		M16_GUY_02_MP3		"m16_guy_02.mp3"
+#define		M16_GUY_03_MP3		"m16_guy_03.mp3"
+#define		M17_ANDERSON_01_MP3		"m17_anderson_01.mp3"
+#define		M17_BARBER_01_MP3		"m17_barber_01.mp3"
+#define		M17_CAMPBELL_01_MP3		"m17_campbell_01.mp3"
+#define		M17_DEVONSHIRE_01_MP3		"m17_devonshire_01.mp3"
+#define		M17_EGGER_01_MP3		"m17_egger_01.mp3"
+#define		M17_EMERALD_01_MP3		"m17_emerald_01.mp3"
+#define		M17_FLINGBESTER_01_MP3		"m17_flingbester_01.mp3"
+#define		M17_GERSHWIN_01_MP3		"m17_gershwin_01.mp3"
+#define		M17_GUY_01_MP3		"m17_guy_01.mp3"
+#define		M17_GUY_02_MP3		"m17_guy_02.mp3"
+#define		M17_GUY_03_MP3		"m17_guy_03.mp3"
+#define		M17_GUY_04_MP3		"m17_guy_04.mp3"
+#define		M17_HEPHASTUS_01_MP3		"m17_hephastus_01.mp3"
+#define		M17_INIWA_01_MP3		"m17_iniwa_01.mp3"
+#define		M17_INIWA_02_MP3		"m17_iniwa_02.mp3"
+#define		M17_INIWA_03_MP3		"m17_iniwa_03.mp3"
+#define		M17_KEYCODE_01_MP3		"m17_keycode_01.mp3"
+#define		M17_KEYCODE_02_MP3		"m17_keycode_02.mp3"
+#define		M17_KEYCODE_03_MP3		"m17_keycode_03.mp3"
+#define		M17_KEYCODE_04_MP3		"m17_keycode_04.mp3"
+#define		M17_TOERIG_01_MP3		"m17_toerig_01.mp3"
+#define		M17_TOERIG_02_MP3		"m17_toerig_02.mp3"
+#define		M17_WARNER_01_MP3		"m17_warner_01.mp3"
+#define		M17_WARNER_02_MP3		"m17_warner_02.mp3"
+#define		M17_WARNER_03_MP3		"m17_warner_03.mp3"
+#define		M17_WARNER_04_MP3		"m17_warner_04.mp3"
+#define		M17_YORP_01_MP3		"m17_yorp_01.mp3"
+#define		M17_YORP_02_MP3		"m17_yorp_02.mp3"
+#define		M18_DERECHA_01_MP3		"m18_derecha_01.mp3"
+#define		M18_GUY_01_MP3		"m18_guy_01.mp3"
+#define		M18_IZQUIERDA_01_MP3		"m18_izquierda_01.mp3"
+#define		M18_IZQUIERDA_02_MP3		"m18_izquierda_02.mp3"
+#define		M18_IZQUIERDA_03_MP3		"m18_izquierda_03.mp3"
+#define		M18_IZQUIERDA_04_MP3		"m18_izquierda_04.mp3"
+#define		M18_IZQUIERDA_05_MP3		"m18_izquierda_05.mp3"
+#define		M18_IZQUIERDA_06_MP3		"m18_izquierda_06.mp3"
+#define		M19_CAVEAT_01_MP3		"m19_caveat_01.mp3"
+#define		M19_CAVEAT_02_MP3		"m19_caveat_02.mp3"
+#define		M19_ENDER_01_MP3		"m19_ender_01.mp3"
+#define		M19_ENDER_02_MP3		"m19_ender_02.mp3"
+#define		M19_FRUSTRATO_01_MP3		"m19_frustrato_01.mp3"
+#define		M19_FRUSTRATO_02_MP3		"m19_frustrato_02.mp3"
+#define		M19_FRUSTRATO_03_MP3		"m19_frustrato_03.mp3"
+#define		M19_FRUSTRATO_04_MP3		"m19_frustrato_04.mp3"
+#define		M19_FRUSTRATO_05_MP3		"m19_frustrato_05.mp3"
+#define		M19_FRUSTRATO_06_MP3		"m19_frustrato_06.mp3"
+#define		M19_FRUSTRATO_07_MP3		"m19_frustrato_07.mp3"
+#define		M19_FRUSTRATO_08_MP3		"m19_frustrato_08.mp3"
+#define		M19_FRUSTRATO_09_MP3		"m19_frustrato_09.mp3"
+#define		M19_FRUSTRATO_10_MP3		"m19_frustrato_10.mp3"
+#define		M19_GUY_01_MP3		"m19_guy_01.mp3"
+#define		M19_GUY_02_MP3		"m19_guy_02.mp3"
+#define		M19_GUY_03_MP3		"m19_guy_03.mp3"
+#define		M19_INTER_01_MP3		"m19_inter_01.mp3"
+#define		M19_INTER_02_MP3		"m19_inter_02.mp3"
+#define		M19_LONE_01_MP3		"m19_lone_01.mp3"
+#define		M19_LONE_02_MP3		"m19_lone_02.mp3"
+#define		M19_LONE_03_MP3		"m19_lone_03.mp3"
+#define		M19_PHILLIPS_01_MP3		"m19_phillips_01.mp3"
+#define		M19_PHILLIPS_02_MP3		"m19_phillips_02.mp3"
+#define		M19_PHILLIPS_03_MP3		"m19_phillips_03.mp3"
+#define		M19_PHILLIPS_04_MP3		"m19_phillips_04.mp3"
+#define		M19_PHILLIPS_05_MP3		"m19_phillips_05.mp3"
+#define		M19_RAILRIDER_01_MP3		"m19_railrider_01.mp3"
+#define		M19_RAILRIDER_02_MP3		"m19_railrider_02.mp3"
+#define		M19_RAILRIDER_03_MP3		"m19_railrider_03.mp3"
+#define		M19_RAILRIDER_04_MP3		"m19_railrider_04.mp3"
+#define		M19_REDRUM_01_MP3		"m19_redrum_01.mp3"
+#define		M19_REDRUM_02_MP3		"m19_redrum_02.mp3"
+#define		M19_REDRUM_03_MP3		"m19_redrum_03.mp3"
+#define		M19_REDRUM_04_MP3		"m19_redrum_04.mp3"
+#define		M19_REDRUM_05_MP3		"m19_redrum_05.mp3"
+#define		M19_REDRUM_06_MP3		"m19_redrum_06.mp3"
+#define		M19_STANDARD_01_MP3		"m19_standard_01.mp3"
+#define		M19_STANDARD_02_MP3		"m19_standard_02.mp3"
+#define		M20_ARNIE_01_MP3		"m20_arnie_01.mp3"
+#define		M20_ARNIE_02_MP3		"m20_arnie_02.mp3"
+#define		M20_BRAD_01_MP3		"m20_brad_01.mp3"
+#define		M20_BRAD_02_MP3		"m20_brad_02.mp3"
+#define		M20_BUSTER_01_MP3		"m20_buster_01.mp3"
+#define		M20_BUSTER_02_MP3		"m20_buster_02.mp3"
+#define		M20_BUSTER_03_MP3		"m20_buster_03.mp3"
+#define		M20_COOPER_01_MP3		"m20_cooper_01.mp3"
+#define		M20_COOPER_02_MP3		"m20_cooper_02.mp3"
+#define		M20_DINERS_01_MP3		"m20_diners_01.mp3"
+#define		M20_DINERS_02_MP3		"m20_diners_02.mp3"
+#define		M20_DOLLY_01_MP3		"m20_dolly_01.mp3"
+#define		M20_DOREK_01_MP3		"m20_dorek_01.mp3"
+#define		M20_DOREK_02_MP3		"m20_dorek_02.mp3"
+#define		M20_DOREK_03_MP3		"m20_dorek_03.mp3"
+#define		M20_FARBLE_01_MP3		"m20_farble_01.mp3"
+#define		M20_FARBLE_02_MP3		"m20_farble_02.mp3"
+#define		M20_GRUNETT_01_MP3		"m20_grunett_01.mp3"
+#define		M20_GRUNETT_02_MP3		"m20_grunett_02.mp3"
+#define		M20_GUY_01_MP3		"m20_guy_01.mp3"
+#define		M20_GUY_02_MP3		"m20_guy_02.mp3"
+#define		M20_GUY_03_MP3		"m20_guy_03.mp3"
+#define		M20_GUY_04_MP3		"m20_guy_04.mp3"
+#define		M20_GUY_05_MP3		"m20_guy_05.mp3"
+#define		M20_GUY_06_MP3		"m20_guy_06.mp3"
+#define		M20_HUMBERT_01_MP3		"m20_humbert_01.mp3"
+#define		M20_ILLIAC_01_MP3		"m20_illiac_01.mp3"
+#define		M20_JAQUES_01_MP3		"m20_jaques_01.mp3"
+#define		M20_JAQUES_02_MP3		"m20_jaques_02.mp3"
+#define		M20_LUMBAR_01_MP3		"m20_lumbar_01.mp3"
+#define		M20_MANNY_01_MP3		"m20_manny_01.mp3"
+#define		M20_POLONEY_01_MP3		"m20_poloney_01.mp3"
+#define		M20_POLONEY_02_MP3		"m20_poloney_02.mp3"
+#define		M20_SARGE_01_MP3		"m20_sarge_01.mp3"
+#define		M20_SARGE_02_MP3		"m20_sarge_02.mp3"
+#define		M20_SARGE_03_MP3		"m20_sarge_03.mp3"
+#define		M20_SARGE_04_MP3		"m20_sarge_04.mp3"
+#define		M20_SARGE_05_MP3		"m20_sarge_05.mp3"
+#define		M21_ANTIMA_01_MP3		"m21_antima_01.mp3"
+#define		M21_ANTIMA_02_MP3		"m21_antima_02.mp3"
+#define		M21_ANTIMA_03_MP3		"m21_antima_03.mp3"
+#define		M21_ANTIMA_04_MP3		"m21_antima_04.mp3"
+#define		M21_ANTIMA_05_MP3		"m21_antima_05.mp3"
+#define		M21_ANTIMA_06_MP3		"m21_antima_06.mp3"
+#define		M21_ANTIMA_07_MP3		"m21_antima_07.mp3"
+#define		M21_BRAN_ONOMI_01_MP3		"m21_bran_onomi_01.mp3"
+#define		M21_BRAN_ONOMI_02_MP3		"m21_bran_onomi_02.mp3"
+#define		M21_BRAN_ONOMI_03_MP3		"m21_bran_onomi_03.mp3"
+#define		M21_CONTENNE_01_MP3		"m21_contenne_01.mp3"
+#define		M21_CONTENNE_02_MP3		"m21_contenne_02.mp3"
+#define		M21_CONTENNE_03_MP3		"m21_contenne_03.mp3"
+#define		M21_CONTENNE_04_MP3		"m21_contenne_04.mp3"
+#define		M21_CONTENNE_05_MP3		"m21_contenne_05.mp3"
+#define		M21_CONTENNE_06_MP3		"m21_contenne_06.mp3"
+#define		M21_CONTENNE_07_MP3		"m21_contenne_07.mp3"
+#define		M21_COUHOUSE_01_MP3		"m21_couhouse_01.mp3"
+#define		M21_COUHOUSE_02_MP3		"m21_couhouse_02.mp3"
+#define		M21_COUHOUSE_03_MP3		"m21_couhouse_03.mp3"
+#define		M21_DEBENSHIRE_01_MP3		"m21_debenshire_01.mp3"
+#define		M21_DEBENSHIRE_02_MP3		"m21_debenshire_02.mp3"
+#define		M21_DEBENSHIRE_03_MP3		"m21_debenshire_03.mp3"
+#define		M21_DEBENSHIRE_04_MP3		"m21_debenshire_04.mp3"
+#define		M21_FEMURIA_01_MP3		"m21_femuria_01.mp3"
+#define		M21_FEMURIA_02_MP3		"m21_femuria_02.mp3"
+#define		M21_FEMURIA_03_MP3		"m21_femuria_03.mp3"
+#define		M21_FEMURIA_04_MP3		"m21_femuria_04.mp3"
+#define		M21_FEMURIA_05_MP3		"m21_femuria_05.mp3"
+#define		M21_GLARATTE_01_MP3		"m21_glaratte_01.mp3"
+#define		M21_GLARATTE_02_MP3		"m21_glaratte_02.mp3"
+#define		M21_GLARATTE_03_MP3		"m21_glaratte_03.mp3"
+#define		M21_GLARATTE_04_MP3		"m21_glaratte_04.mp3"
+#define		M21_GUY_01_MP3		"m21_guy_01.mp3"
+#define		M21_GUY_02_MP3		"m21_guy_02.mp3"
+#define		M21_GUY_03_MP3		"m21_guy_03.mp3"
+#define		M21_GUY_04_MP3		"m21_guy_04.mp3"
+#define		M21_GUY_05_MP3		"m21_guy_05.mp3"
+#define		M21_GUY_06_MP3		"m21_guy_06.mp3"
+#define		M21_GUY_07_MP3		"m21_guy_07.mp3"
+#define		M21_GUY_08_MP3		"m21_guy_08.mp3"
+#define		M21_GUY_09_MP3		"m21_guy_09.mp3"
+#define		M21_HYPERBOLE_01_MP3		"m21_hyperbole_01.mp3"
+#define		M21_KREN_KREN_01_MP3		"m21_kren_kren_01.mp3"
+#define		M21_KREN_KREN_02_MP3		"m21_kren_kren_02.mp3"
+#define		M21_KREN_KREN_03_MP3		"m21_kren_kren_03.mp3"
+#define		M21_KREN_KREN_04_MP3		"m21_kren_kren_04.mp3"
+#define		M21_KREN_KREN_05_MP3		"m21_kren_kren_05.mp3"
+#define		M21_LITOTE_01_MP3		"m21_litote_01.mp3"
+#define		M21_PERIOUS_01_MP3		"m21_perious_01.mp3"
+#define		M21_PERIOUS_02_MP3		"m21_perious_02.mp3"
+#define		M21_PERIOUS_03_MP3		"m21_perious_03.mp3"
+#define		M21_PHAEDRUS_01_MP3		"m21_phaedrus_01.mp3"
+#define		M21_PHAEDRUS_02_MP3		"m21_phaedrus_02.mp3"
+#define		M21_PHAEDRUS_04_MP3		"m21_phaedrus_04.mp3"
+#define		M21_PHAEDRUS_05_MP3		"m21_phaedrus_05.mp3"
+#define		M21_PHAEDRUS_06_MP3		"m21_phaedrus_06.mp3"
+#define		M21_PHAEDRUS_07_MP3		"m21_phaedrus_07.mp3"
+#define		M21_PHAEDRUS_08_MP3		"m21_phaedrus_08.mp3"
+#define		M21_PHAEDRUS_09_MP3		"m21_phaedrus_09.mp3"
+#define		M21_PHAEDRUS_10_MP3		"m21_phaedrus_10.mp3"
+#define		M21_PHAEDRUS_11_MP3		"m21_phaedrus_11.mp3"
+#define		M21_PHAEDRUS_12_MP3		"m21_phaedrus_12.mp3"
+#define		M21_PHAEDRUS_13_MP3		"m21_phaedrus_13.mp3"
+#define		M21_PHAEDRUS_14_MP3		"m21_phaedrus_14.mp3"
+#define		M21_PHAEDRUS_15_MP3		"m21_phaedrus_15.mp3"
+#define		M21_PHAEDRUS_16_MP3		"m21_phaedrus_16.mp3"
+#define		M21_PHAEDRUS_17_MP3		"m21_phaedrus_17.mp3"
+#define		M21_PHAEDRUS_18_MP3		"m21_phaedrus_18.mp3"
+#define		M21_PHAEDRUS_19_MP3		"m21_phaedrus_19.mp3"
+#define		M21_PHAEDRUS_20_MP3		"m21_phaedrus_20.mp3"
+#define		M21_PHAEDRUS_21_MP3		"m21_phaedrus_21.mp3"
+#define		M21_PHAEDRUS_22_MP3		"m21_phaedrus_22.mp3"
+#define		M21_PHAEDRUS_23_MP3		"m21_phaedrus_23.mp3"
+#define		M21_PHAEDRUS_24_MP3		"m21_phaedrus_24.mp3"
+#define		M21_PHAEDRUS_25_MP3		"m21_phaedrus_25.mp3"
+#define		M21_PHAEDRUS_26_MP3		"m21_phaedrus_26.mp3"
+#define		M21_PHIPOLOSSI_01_MP3		"m21_phipolossi_01.mp3"
+#define		M21_PHIPOLOSSI_02_MP3		"m21_phipolossi_02.mp3"
+#define		M21_PHIPOLOSSI_03_MP3		"m21_phipolossi_03.mp3"
+#define		M21_PHIPOLOSSI_04_MP3		"m21_phipolossi_04.mp3"
+#define		M21_PHIPOLOSSI_05_MP3		"m21_phipolossi_05.mp3"
+#define		M21_PHIPOLOSSI_06_MP3		"m21_phipolossi_06.mp3"
+#define		M21_PLODDER_01_MP3		"m21_plodder_01.mp3"
+#define		M21_PLODDER_02_MP3		"m21_plodder_02.mp3"
+#define		M21_PLODDER_03_MP3		"m21_plodder_03.mp3"
+#define		M21_PLODDER_04_MP3		"m21_plodder_04.mp3"
+#define		M21_SARGE_01_MP3		"m21_sarge_01.mp3"
+#define		M21_SARGE_02_MP3		"m21_sarge_02.mp3"
+#define		M21_SARGE_03_MP3		"m21_sarge_03.mp3"
+#define		M21_SARGE_04_MP3		"m21_sarge_04.mp3"
+#define		M21_SARGE_05_MP3		"m21_sarge_05.mp3"
+#define		M21_SARGE_06_MP3		"m21_sarge_06.mp3"
+#define		M21_SARGE_07_MP3		"m21_sarge_07.mp3"
+#define		M21_SARGE_08_MP3		"m21_sarge_08.mp3"
+#define		M21_SATIRE_01_MP3		"m21_satire_01.mp3"
+#define		M21_SATIRE_02_MP3		"m21_satire_02.mp3"
+#define		M21_SHELLEY_01_MP3		"m21_shelley_01.mp3"
+#define		M21_SHELLEY_02_MP3		"m21_shelley_02.mp3"
+#define		M21_SHELLEY_03_MP3		"m21_shelley_03.mp3"
+#define		M21_SHELLEY_04_MP3		"m21_shelley_04.mp3"
+#define		M21_SHELLEY_05_MP3		"m21_shelley_05.mp3"
+#define		M21_VERILITH_01_MP3		"m21_verilith_01.mp3"
+#define		M21_VERILITH_02_MP3		"m21_verilith_02.mp3"
+#define		M21_VERILITH_03_MP3		"m21_verilith_03.mp3"
+#define		M21_VERILITH_04_MP3		"m21_verilith_04.mp3"
+#define		M21_VERILITH_05_MP3		"m21_verilith_05.mp3"
+#define		M22_GUY_01_MP3		"m22_guy_01.mp3"
+#define		M22_OSCURO_01_MP3		"m22_oscuro_01.mp3"
+#define		M22_OSCURO_02_MP3		"m22_oscuro_02.mp3"
+#define		M22_VERILITH_01_MP3		"m22_verilith_01.mp3"
+#define		M22_VERILITH_02_MP3		"m22_verilith_02.mp3"
+#define		M22_VERILITH_03_MP3		"m22_verilith_03.mp3"
+#define		M22_VERILITH_04_MP3		"m22_verilith_04.mp3"
+#define		M23_GUY_01_MP3		"m23_guy_01.mp3"
+#define		M23_GUY_02_MP3		"m23_guy_02.mp3"
+#define		M23_GUY_03_MP3		"m23_guy_03.mp3"
+#define		M23_INSANITO_01_MP3		"m23_insanito_01.mp3"
+#define		M23_INSANITO_02_MP3		"m23_insanito_02.mp3"
+#define		M23_INSANITO_03_MP3		"m23_insanito_03.mp3"
+#define		M23_INSANITO_04_MP3		"m23_insanito_04.mp3"
+#define		M23_INSANITO_05_MP3		"m23_insanito_05.mp3"
+#define		M23_VERILITH_01_MP3		"m23_verilith_01.mp3"
+#define		M24_GUY_01_MP3		"m24_guy_01.mp3"
+#define		M24_GUY_02_MP3		"m24_guy_02.mp3"
+#define		M24_GUY_03_MP3		"m24_guy_03.mp3"
+#define		M24_MANAGOTA_01_MP3		"m24_managota_01.mp3"
+#define		M24_MANAGOTA_02_MP3		"m24_managota_02.mp3"
+#define		M24_MANAGOTA_03_MP3		"m24_managota_03.mp3"
+#define		M24_MANAGOTA_04_MP3		"m24_managota_04.mp3"
+#define		M25_BBOW_01_MP3		"m25_bbow_01.mp3"
+#define		M25_BBOW_02_MP3		"m25_bbow_02.mp3"
+#define		M25_BBOW_03_MP3		"m25_bbow_03.mp3"
+#define		M25_BBOW_04_MP3		"m25_bbow_04.mp3"
+#define		M25_GUY_01_MP3		"m25_guy_01.mp3"
+#define		M25_GUY_02_MP3		"m25_guy_02.mp3"
+#define		M25_VERILITH_01_MP3		"m25_verilith_01.mp3"
+#define		M26_GUY_01_MP3		"m26_guy_01.mp3"
+#define		M26_GUY_02_MP3		"m26_guy_02.mp3"
+#define		M26_GUY_03_MP3		"m26_guy_03.mp3"
+#define		M26_GUY_04_MP3		"m26_guy_04.mp3"
+#define		M26_GUY_05_MP3		"m26_guy_05.mp3"
+#define		M26_FDOE_01_MP3		"m26_fdoe_01.mp3"
+#define		M26_FDOE_02_MP3		"m26_fdoe_02.mp3"
+#define		M26_FDOE_03_MP3		"m26_fdoe_03.mp3"
+#define		M26_FDOE_04_MP3		"m26_fdoe_04.mp3"
+#define		M27_AYONN_01_MP3		"m27_ayonn_01.mp3"
+#define		M27_AYONN_02_MP3		"m27_ayonn_02.mp3"
+#define		M27_AYONN_03_MP3		"m27_ayonn_03.mp3"
+#define		M27_AYONN_04_MP3		"m27_ayonn_04.mp3"
+#define		M27_BALE_01_MP3		"m27_bale_01.mp3"
+#define		M27_BALE_02_MP3		"m27_bale_02.mp3"
+#define		M27_BALE_03_MP3		"m27_bale_03.mp3"
+#define		M27_GUY_01_MP3		"m27_guy_01.mp3"
+#define		M27_GUY_02_MP3		"m27_guy_02.mp3"
+#define		M27_GUY_03_MP3		"m27_guy_03.mp3"
+#define		M27_ONABILDEN_01_MP3		"m27_onabilden_01.mp3"
+#define		M27_ONABILDEN_02_MP3		"m27_onabilden_02.mp3"
+#define		M27_ONABILDEN_03_MP3		"m27_onabilden_03.mp3"
+#define		M27_ONABILDEN_04_MP3		"m27_onabilden_04.mp3"
+#define		M28_FINN_01_MP3		"m28_finn_01.mp3"
+#define		M28_FINN_02_MP3		"m28_finn_02.mp3"
+#define		M28_FINN_03_MP3		"m28_finn_03.mp3"
+#define		M28_GUY_01_MP3		"m28_guy_01.mp3"
+#define		M28_GUY_02_MP3		"m28_guy_02.mp3"
+#define		M28_GUY_03_MP3		"m28_guy_03.mp3"
+#define		M29_ALERE_01_MP3		"m29_alere_01.mp3"
+#define		M29_ALERE_02_MP3		"m29_alere_02.mp3"
+#define		M29_ALERE_03_MP3		"m29_alere_03.mp3"
+#define		M29_AOLOS_01_MP3		"m29_aolos_01.mp3"
+#define		M29_AOLOS_02_MP3		"m29_aolos_02.mp3"
+#define		M29_AOLOS_03_MP3		"m29_aolos_03.mp3"
+#define		M29_AOLOS_04_MP3		"m29_aolos_04.mp3"
+#define		M29_AOLOS_05_MP3		"m29_aolos_05.mp3"
+#define		M29_GUY_01_MP3		"m29_guy_01.mp3"
+#define		M29_GUY_02_MP3		"m29_guy_02.mp3"
+#define		M29_GUY_03_MP3		"m29_guy_03.mp3"
+#define		M29_GUY_04_MP3		"m29_guy_04.mp3"
+#define		M29_GUY_05_MP3		"m29_guy_05.mp3"
+#define		M29_GUY_06_MP3		"m29_guy_06.mp3"
+#define		M29_GUY_07_MP3		"m29_guy_07.mp3"
+#define		M29_GUY_08_MP3		"m29_guy_08.mp3"
+#define		M29_GUY_09_MP3		"m29_guy_09.mp3"
+#define		M29_GUY_10_MP3		"m29_guy_10.mp3"
+#define		M29_GUY_11_MP3		"m29_guy_11.mp3"
+#define		M29_GUY_12_MP3		"m29_guy_12.mp3"
+#define		M29_GUY_13_MP3		"m29_guy_13.mp3"
+#define		M29_GUY_14_MP3		"m29_guy_14.mp3"
+#define		M29_GUY_15_MP3		"m29_guy_15.mp3"
+#define		M29_KORENAAR_01_MP3		"m29_korenaar_01.mp3"
+#define		M29_KORENAAR_02_MP3		"m29_korenaar_02.mp3"
+#define		M29_KORENAAR_03_MP3		"m29_korenaar_03.mp3"
+#define		M29_KORENAAR_04_MP3		"m29_korenaar_04.mp3"
+#define		M29_KORENAAR_05_MP3		"m29_korenaar_05.mp3"
+#define		M29_PHARIBOS_01_MP3		"m29_pharibos_01.mp3"
+#define		M29_PHARIBOS_02_MP3		"m29_pharibos_02.mp3"
+#define		M29_VELEGAL_01_MP3		"m29_velegal_01.mp3"
+#define		M29_VELEGAL_02_MP3		"m29_velegal_02.mp3"
+#define		M30_AOLOS_01_MP3		"m30_aolos_01.mp3"
+#define		M30_AOLOS_02_MP3		"m30_aolos_02.mp3"
+#define		M30_AOLOS_03_MP3		"m30_aolos_03.mp3"
+#define		M30_AOLOS_04_MP3		"m30_aolos_04.mp3"
+#define		M30_AOLOS_05_MP3		"m30_aolos_05.mp3"
+#define		M30_AOLOS_06_MP3		"m30_aolos_06.mp3"
+#define		M30_AOLOS_07_MP3		"m30_aolos_07.mp3"
+#define		M30_AOLOS_08_MP3		"m30_aolos_08.mp3"
+#define		M30_AOLOS_09_MP3		"m30_aolos_09.mp3"
+#define		M30_AOLOS_11_MP3		"m30_aolos_11.mp3"
+#define		M30_AOLOS_12_MP3		"m30_aolos_12.mp3"
+#define		M30_AOLOS_13_MP3		"m30_aolos_13.mp3"
+#define		M30_AOLOS_14_MP3		"m30_aolos_14.mp3"
+#define		M30_AOLOS_15_MP3		"m30_aolos_15.mp3"
+#define		M30_AOLOS_16_MP3		"m30_aolos_16.mp3"
+#define		M30_AOLOS_17_MP3		"m30_aolos_17.mp3"
+#define		M30_AOLOS_18_MP3		"m30_aolos_18.mp3"
+#define		M30_AOLOS_19_MP3		"m30_aolos_19.mp3"
+#define		M30_AOLOS_20_MP3		"m30_aolos_20.mp3"
+#define		M30_CASINOX_01_MP3		"m30_casinox_01.mp3"
+#define		M30_CASINOX_02_MP3		"m30_casinox_02.mp3"
+#define		M30_CASINOX_03_MP3		"m30_casinox_03.mp3"
+#define		M30_CASINOX_04_MP3		"m30_casinox_04.mp3"
+#define		M30_CASINOX_05_MP3		"m30_casinox_05.mp3"
+#define		M30_CASINOX_06_MP3		"m30_casinox_06.mp3"
+#define		M30_CHICKEN_EXPLOSION_01_MP3		"m30_chicken_explosion_01.mp3"
+#define		M30_CHICKEN_EXPLOSION_02_MP3		"m30_chicken_explosion_02.mp3"
+#define		M30_DOPEFISH_01_MP3		"m30_dopefish_01.mp3"
+#define		M30_DOPEFISH_02_MP3		"m30_dopefish_02.mp3"
+#define		M30_DOPEFISH_03_MP3		"m30_dopefish_03.mp3"
+#define		M30_DOPEFISH_04_MP3		"m30_dopefish_04.mp3"
+#define		M30_GUY_01_MP3		"m30_guy_01.mp3"
+#define		M30_GUY_02_MP3		"m30_guy_02.mp3"
+#define		M30_JOHN_01_MP3		"m30_john_01.mp3"
+#define		M30_JOHN_02_MP3		"m30_john_02.mp3"
+#define		M30_JOHN_03_MP3		"m30_john_03.mp3"
+#define		M30_JOHN_04_MP3		"m30_john_04.mp3"
+#define		M30_JOHN_05_MP3		"m30_john_05.mp3"
+#define		M30_LUCAS_01_MP3		"m30_lucas_01.mp3"
+#define		M30_LUCAS_02_MP3		"m30_lucas_02.mp3"
+#define		M30_LUCAS_03_MP3		"m30_lucas_03.mp3"
+#define		M30_LUCAS_04_MP3		"m30_lucas_04.mp3"
+#define		M30_STEVIE_01_MP3		"m30_stevie_01.mp3"
+#define		M30_STEVIE_02_MP3		"m30_stevie_02.mp3"
+#define		M30_STEVIE_03_MP3		"m30_stevie_03.mp3"
+#define		M30_STEVIE_04_MP3		"m30_stevie_04.mp3"
+#define		M30_STEVIE_05_MP3		"m30_stevie_05.mp3"
+#define		M30_STEVIE_06_MP3		"m30_stevie_06.mp3"
+#define		M30_STEVIE_07_MP3		"m30_stevie_07.mp3"
+#define		M30_STEVIE_08_MP3		"m30_stevie_08.mp3"
+#define		M30_STEVIE_09_MP3		"m30_stevie_09.mp3"
+#define		M30_STEVIE_10_MP3		"m30_stevie_10.mp3"
+#define		M30_TOM_01_MP3		"m30_tom_01.mp3"
+#define		M30_TOM_02_MP3		"m30_tom_02.mp3"
+#define		M30_TOM_03_MP3		"m30_tom_03.mp3"
+#define		M30_TOM_04_MP3		"m30_tom_04.mp3"
+#define		M30_TOM_05_MP3		"m30_tom_05.mp3"
+#define		M30_TOM_06_MP3		"m30_tom_06.mp3"
+#define		M30_VERILITH_01_MP3		"m30_verilith_01.mp3"
+#define		M30_VERILITH_02_MP3		"m30_verilith_02.mp3"
+#define		M30_VERILITH_03_MP3		"m30_verilith_03.mp3"
+#define		M30_VERILITH_04_MP3		"m30_verilith_04.mp3"
+#define		M30_VERILITH_05_MP3		"m30_verilith_05.mp3"
+#define		M30_VERILITH_06_MP3		"m30_verilith_06.mp3"
+#define		M30_VERILITH_07_MP3		"m30_verilith_07.mp3"
+#define		OUTRO_DOLLY_01_MP3		"outro_dolly_01.mp3"
+#define		OUTRO_DOLLY_02_MP3		"outro_dolly_02.mp3"
+#define		OUTRO_DOLLY_03_MP3		"outro_dolly_03.mp3"
+#define		OUTRO_DOLLY_04_MP3		"outro_dolly_04.mp3"
+#define		OUTRO_DOLLY_05_MP3		"outro_dolly_05.mp3"
+#define		OUTRO_DOLLY_06_MP3		"outro_dolly_06.mp3"
+#define		OUTRO_DOLLY_07_MP3		"outro_dolly_07.mp3"
+#define		OUTRO_DOLLY_08_MP3		"outro_dolly_08.mp3"
+#define		OUTRO_DOLLY_09_MP3		"outro_dolly_09.mp3"
+#define		OUTRO_DOLLY_10_MP3		"outro_dolly_10.mp3"
+#define		OUTRO_DOLLY_11_MP3		"outro_dolly_11.mp3"
+#define		OUTRO_DOLLY_12_MP3		"outro_dolly_12.mp3"
+#define		OUTRO_DOLLY_13_MP3		"outro_dolly_13.mp3"
+#define		OUTRO_DOLLY_14_MP3		"outro_dolly_14.mp3"
+#define		OUTRO_DOLLY_15_MP3		"outro_dolly_15.mp3"
+#define		OUTRO_DOLLY_16_MP3		"outro_dolly_16.mp3"
+#define		OUTRO_DOLLY_17_MP3		"outro_dolly_17.mp3"
+#define		OUTRO_DOLLY_18_MP3		"outro_dolly_18.mp3"
+#define		OUTRO_DOREK_01_MP3		"outro_dorek_01.mp3"
+#define		OUTRO_DOREK_02_MP3		"outro_dorek_02.mp3"
+#define		OUTRO_DOREK_03_MP3		"outro_dorek_03.mp3"
+#define		OUTRO_DOREK_04_MP3		"outro_dorek_04.mp3"
+#define		OUTRO_DOREK_05_MP3		"outro_dorek_05.mp3"
+#define		OUTRO_DOREK_06_MP3		"outro_dorek_06.mp3"
+#define		OUTRO_GUY_01_MP3		"outro_guy_01.mp3"
+#define		OUTRO_GUY_02_MP3		"outro_guy_02.mp3"
+#define		OUTRO_GUY_03_MP3		"outro_guy_03.mp3"
+#define		OUTRO_GUY_04_MP3		"outro_guy_04.mp3"
+#define		OUTRO_GUY_05_MP3		"outro_guy_05.mp3"
+#define		OUTRO_GUY_06_MP3		"outro_guy_06.mp3"
+#define		OUTRO_JENKINS_01_MP3		"outro_jenkins_01.mp3"
+#define		OUTRO_JENKINS_02_MP3		"outro_jenkins_02.mp3"
+#define		OUTRO_JENKINS_03_MP3		"outro_jenkins_03.mp3"
+#define		OUTRO_JENKINS_04_MP3		"outro_jenkins_04.mp3"
+#define		OUTRO_JENKINS_05_MP3		"outro_jenkins_05.mp3"
+#define		OUTRO_SARGE_01_MP3		"outro_sarge_01.mp3"
+#define		OUTRO_SARGE_02_MP3		"outro_sarge_02.mp3"
+#define		OUTRO_SARGE_03_MP3		"outro_sarge_03.mp3"
+#define		OUTRO_SARGE_04_MP3		"outro_sarge_04.mp3"
+#define		OUTRO_SARGE_05_MP3		"outro_sarge_05.mp3"
+#define		OUTRO_SARGE_06_MP3		"outro_sarge_06.mp3"
+#define		GUY_ENERGY_CELL_MP3		"guy_energy_cell.mp3"
+#define		GUY_GOT_A_JOB_MP3		"guy_got_a_job.mp3"
+#define		GUY_COMPLETED_MP3		"guy_completed.mp3"
+#define		GUY_GOT_SOMETHING_MP3		"guy_got_something.mp3"
+#define		GUY_WINS_MP3		"guy_wins.mp3"
+#define		HDB_INTRO_MP3		"hdb_intro.mp3"
 
 enum IconList {
 	ICON_GUY_DOWN,


Commit: a9fbd1ae1e5af3e9b15efd82e476419c26f23855
    https://github.com/scummvm/scummvm/commit/a9fbd1ae1e5af3e9b15efd82e476419c26f23855
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:27+02:00

Commit Message:
HDB: Add Sound names

Changed paths:
    engines/hdb/sound.cpp
    engines/hdb/sound.h


diff --git a/engines/hdb/sound.cpp b/engines/hdb/sound.cpp
index bd31009..7dab388 100644
--- a/engines/hdb/sound.cpp
+++ b/engines/hdb/sound.cpp
@@ -24,6 +24,1365 @@
 
 namespace HDB {
 
+SoundLookUp soundList[] =  {
+	//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
+	//
+	// List of all the sounds we need
+	// Define new ones here!
+	//
+	//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
+	//
+	//	enum value			hyperspace_msd.h			lua global name
+	//---------------------------------------------------------------
+	{SONG_NONE,			POP_WAV,					"SND_POP" },
+	{SND_GUI_INPUT,		FUTUREBEEP2_WAV,			"SND_GUI_INPUT"},
+	{SND_MAIL_PROCESS,	COMPUTERPROCESS_WAV,		"SND_MAIL_PROCESS"},
+	{SND_MONKEY_OOHOOH,	MONKEY_OOHOOH_WAV,			"SND_MONKEY_OOHOOH"},
+	{SND_GET_GEM,		GET_GEM_WAV,				"SND_GET_GEM"},
+	{SND_MENU_ACCEPT,	MENU_ACCEPT_WAV,			"SND_MENU_ACCEPT"},
+	{SND_MENU_BACKOUT,	MENU_BACKOUT_WAV,			"SND_MENU_BACKOUT"},
+	{SND_MENU_SLIDER,	MENU_SLIDER_WAV,			"SND_MENU_SLIDER"},
+	{SND_DIALOG_CLOSE,	DIALOG_CLOSE_WAV,			"SND_DIALOG_CLOSE"},
+	{SND_CRATE_SLIDE,	CRATE_SLIDE_WAV,			"SND_CRATE_SLIDE"},
+	{SND_LIGHT_SLIDE,	LIGHT_SLIDE_WAV,			"SND_LIGHT_SLIDE"},
+	{SND_HEAVY_SLIDE,	HEAVY_SLIDE_WAV,			"SND_HEAVY_SLIDE"},
+	{SND_POP,			POP_WAV,					"SND_POP"},
+	{SND_TELEPORT,		TELEPORT3_WAV,				"SND_TELEPORT"},
+	{SND_FOOTSTEPS,		FOOTSTEPS_WAV,				"SND_FOOTSTEPS"},
+	{SND_SPLASH,			SPLASH_WAV,					"SND_SPLASH"},
+	{SND_CELLHOLDER_USE_REJECT, CELLHOLDER_USE_REJECT_WAV, "SND_CELLHOLDER_USE_REJECT"},
+	{SND_CHICKEN_AMBIENT, CHICKEN_AMBIENT_WAV,		"SND_CHICKEN_AMBIENT"},
+	{SND_FERRET_SQUEAK,	FERRET_SQUEAK_WAV,			"SND_FERRET_SQUEAK"},
+	{SND_SWITCH_USE,		SWITCH_USE_WAV,				"SND_SWITCH_USE"},
+	{SND_MOVE_SELECTION,	MOVE_SELECTION_WAV,			"SND_MOVE_SELECTION"},
+	{SND_NOTICE,			NOTICE_WAV,					"SND_NOTICE"},
+	{SND_MAINTBOT_WHOOSH1,	MAINTBOT_WHOOSH1_WAV,	"SND_MAINTBOT_WHOOSH1"},
+	{SND_MAINTBOT_WHOOSH2,	MAINTBOT_WHOOSH2_WAV,	"SND_MAINTBOT_WHOOSH2"},
+	{SND_SHIPMOVING_INTRO,	SHIP_MOVING_INTRO_WAV,	"SND_SHIPMOVING_INTRO"},
+	{SND_DIALOG_OPEN,	DIALOG_OPEN_WAV,			"SND_DIALOG_OPEN"},
+	{SND_TOUCHPLATE_CLICK,	TOUCHPLATE_CLICK_WAV,	"SND_TOUCHPLATE_CLICK"},
+	{SND_DOOR_OPEN_CLOSE, DOOR_OPEN_CLOSE_WAV,		"SND_DOOR_OPEN_CLOSE"},
+	{SND_MBOT_HYEAH,		MBOT_HYEAH_WAV,				"SND_MBOT_HYEAH"},
+	{SND_MBOT_YEAH,		MBOT_YEAH_WAV,				"SND_MBOT_YEAH"},
+	{SND_MBOT_WHISTLE1,	MBOT_WHISTLE1_WAV,			"SND_MBOT_WHISTLE1"},
+	{SND_CLUB_MISS,		CLUB_MISS_WAV,				"SND_CLUB_MISS"},
+	{SND_CLUB_HIT_METAL,	CLUB_HIT_METAL_WAV,			"SND_CLUB_HIT_METAL"},
+	{SND_CLUB_HIT_FLESH,	CLUB_HIT_FLESH_WAV,			"SND_CLUB_HIT_FLESH"},
+	{SND_FROG_LICK,		FROG_LICK_WAV,				"SND_FROG_LICK"},
+	{SND_ROBOT_STUNNED,	ROBOT_STUNNED_WAV,			"SND_ROBOT_STUNNED"},
+	{SND_QUEST_FAILED,	QUEST_FAILED_WAV,			"SND_QUEST_FAILED"},
+	{SND_GET_MONKEYSTONE,GET_MONKEYSTONE_WAV,		"SND_GET_MONKEYSTONE"},
+	{SND_INSERT_CELL,	INSERT_CELL_WAV,			"SND_INSERT_CELL"},
+	{SND_CABINET_OPEN,	CABINET_OPEN_WAV,			"SND_CABINET_OPEN"},
+	{SND_CABINET_CLOSE,	CABINET_CLOSE_WAV,			"SND_CABINET_CLOSE"},
+	{SND_MAILSORTER_HAPPY,MAILSORTER_HAPPY_WAV,		"SND_MAILSORTER_HAPPY"},
+	{SND_QUEST_COMPLETE,	QUEST_COMPLETE_WAV,			"SND_QUEST_COMPLETE"},
+	{SND_TRY_AGAIN,		TRY_AGAIN_WAV,				"SND_TRY_AGAIN"},
+	{SND_AIRLOCK_CLOSE,	AIRLOCK_CLOSE_WAV,			"SND_AIRLOCK_CLOSE"},
+	{SND_BYE,			BYE_WAV,					"SND_BYE"},
+	{SND_FART,			FART_WAV,					"SND_FART"},
+	{SND_FART2,			FART2_WAV,					"SND_FART2"},
+	{SND_GUY_UHUH,		GUY_UHUH_WAV,				"SND_GUY_UHUH"},
+	{SND_GUY_DYING,		GUY_DYING_WAV,				"SND_GUY_DYING"},
+	{SND_GEM_THROW,		GEM_THROW_WAV,				"SND_GEM_THROW"},
+	{SND_INV_SELECT,		INV_SELECT_WAV,				"SND_INV_SELECT"},
+	{SND_INFOCOMP,		INFOCOMP_WAV,				"SND_INFOCOMP"},
+	{SND_CLOCK_BONK,		CLOCK_BONK_WAV,				"SND_CLOCK_BONK"},
+	{SND_HDB,			HDB_WAV,					"SND_HDB"},
+	{SND_VORTEX_SAVE,	VORTEXIAN_SAVE_WAV,			"SND_VORTEX_SAVE"},
+	{SND_GET_GOO,		GET_GOO_WAV,				"SND_GET_GOO"},
+	{SND_MANNY_CRASH,	MANNY_CRASH_WAV,			"SND_MANNY_CRASH"},
+	{SND_BARREL_EXPLODE,	BARREL_EXPLODE_WAV,			"SND_BARREL_EXPLODE"},
+	{SND_BARREL_MELTING,	BARREL_MELTING_WAV,			"SND_BARREL_MELTING"},
+	{SND_CHICKEN_BAGAWK,	CHICKEN_BAGAWK_WAV,			"SND_CHICKEN_BAGAWK"},
+	{SND_CHICKEN_DEATH,	CHICKEN_DEATH_WAV,			"SND_CHICKEN_DEATH"},
+	{SND_GET_THING,		GET_THING_WAV,				"SND_GET_THING"},
+	{SND_STEPS_ICE,		STEPS_ICE_WAV,				"SND_STEPS_ICE"},
+	{SND_FOURFIRE_TURN,	FOURFIRE_TURN_WAV,			"SND_FOURFIRE_TURN"},
+	{SND_FOUR_FIRE,		FOUR_FIRE_WAV,				"SND_FOUR_FIRE"},
+	{SND_SHOCKBOT_AMBIENT,SHOCKBOT_AMBIENT_WAV,		"SND_SHOCKBOT_AMBIENT"},
+	{SND_SHOCKBOT_SHOCK,	SHOCKBOT_SHOCK_WAV,			"SND_SHOCKBOT_SHOCK"},
+	{SND_RAILRIDER_ONTRACK,RAILRIDER_ONTRACK_WAV,	"SND_RAILRIDER_ONTRACK"},
+	{SND_RAILRIDER_TASTE, RAILRIDER_TASTE_WAV,		"SND_RAILRIDER_TASTE"},
+	{SND_RAILRIDER_EXIT,	RAILRIDER_EXIT_WAV,			"SND_RAILRIDER_EXIT"},
+	{SND_GUY_FRIED,		GUY_FRIED_WAV,				"SND_GUY_FRIED"},
+	{SND_MAILSORTER_UNHAPPY,	MAILSORTER_UNHAPPY_WAV,	"SND_MAILSORTER_UNHAPPY"},
+	{SND_GET_CLUB,		GET_CLUB_WAV,				"SND_GET_CLUB"},
+	{SND_GUY_GRABBED,	GUY_GRABBED_WAV,			"SND_GUY_GRABBED"},
+	{SND_GUY_DROWN,		GUY_DROWN_WAV,				"SND_GUY_DROWN"},
+	{SND_BUZZFLY_FLY,	BUZZFLY_AMBIENT_WAV,		"SND_BUZZFLY_FLY"},
+	{SND_BUZZFLY_STUNNED, BUZZFLY_STUNNED_WAV,		"SND_BUZZFLY_STUNNED"},
+	{SND_BUZZFLY_STING,	BUZZFLY_STING_WAV,			"SND_BUZZFLY_STING"},
+	{SND_FATFROG_STUNNED, FATFROG_STUNNED_WAV,		"SND_FATFROG_STUNNED"},
+	{SND_NOPUSH_SIZZLE,	GUY_NOPUSH_SIZZLE_WAV,		"SND_NOPUSH_SIZZLE"},
+	{SND_OMNIBOT_FIRE,	OMNIBOT_FIRE_WAV,			"SND_OMNIBOT_FIRE"},
+	{SND_RIGHTBOT_TURN,	RIGHTBOT_TURN_WAV,			"SND_RIGHTBOT_TURN"},
+	{SND_RIGHTBOT_STUNNED, RIGHTBOT_STUNNED_WAV,		"SND_RIGHTBOT_STUNNED"},
+	{SND_MONKEY_WIN,		MONKEY_WIN_WAV,				"SND_MONKEY_WIN"},
+	{SND_FALL_DOWN_HOLE,	FALL_DOWN_HOLE_WAV,			"SND_FALL_DOWN_HOLE"},
+	{SND_MBOT_HMMM,		MBOT_HMMM_WAV,				"SND_MBOT_HMMM"},
+	{SND_MBOT_HMMM2,		MBOT_HMMM2_WAV,				"SND_MBOT_HMMM2"},
+	{SND_MBOT_DEATH,		MBOT_DEATH_WAV,				"SND_MBOT_DEATH"},
+	{SND_MBOT_WHISTLE2,	MBOT_WHISTLE2_WAV,			"SND_MBOT_WHISTLE2"},
+	{SND_MBOT_WHISTLE3,	MBOT_WHISTLE3_WAV,			"SND_MBOT_WHISTLE3"},
+	{SND_DEADEYE_AMB01,	DEADEYE_AMBIENT01_WAV,		"SND_DEADEYE_AMB01"},
+	{SND_DEADEYE_AMB02,	DEADEYE_AMBIENT02_WAV,		"SND_DEADEYE_AMB02"},
+	{SND_DEADEYE_ATTACK01,DEADEYE_GROWL01_WAV,		"SND_DEADEYE_ATTACK01"},
+	{SND_DEADEYE_ATTACK02,DEADEYE_GROWL02_WAV,		"SND_DEADEYE_ATTACK02"},
+	{SND_FROG_RIBBIT1,	FROG_RIBBIT1_WAV,			"SND_FROG_RIBBIT1"},
+	{SND_FROG_RIBBIT2,	FROG_RIBBIT2_WAV,			"SND_FROG_RIBBIT2"},
+	{SND_MEERKAT_BITE,	MEERKAT_BITE_WAV,			"SND_MEERKAT_BITE"},
+	{SND_BRIDGE_EXTEND,	BRIDGE_EXTEND_WAV,			"SND_BRIDGE_EXTEND"},
+	{SND_BRIDGE_START,	BRIDGE_START_WAV,			"SND_BRIDGE_START"},
+	{SND_BRIDGE_END,		BRIDGE_END_WAV,				"SND_BRIDGE_END"},
+	{SND_MACHINE_AMBIENT1,MACHINE_AMBIENT1_WAV,		"SND_MACHINE_AMBIENT1"},
+	{SND_GET_STUNNER,	GET_STUNNER_WAV,			"SND_GET_STUNNER"},
+	{SND_GET_SLUG,		GET_SLUG_WAV,				"SND_GET_SLUG"},
+	{SND_PANIC,			PANIC_WAV,					"SND_PANIC"},
+	{SND_PANIC_COUNT,	PANIC_TIMER_WAV,			"SND_PANIC_COUNT"},
+	{SND_PANIC_DEATH,	PANIC_DEATH_WAV,			"SND_PANIC_DEATH"},
+	{SND_LASER_LOOP,		LASER_LOOP_WAV,				"SND_LASER_LOOP"},
+	{SND_SLOT_WIN,		SLOT_WIN_WAV,				"SND_SLOT_WIN"},
+	{SND_SLOT_SPIN,		SLOT_SPIN_WAV,				"SND_SLOT_SPIN"},
+	{SND_SLOT_STOP,		SLOT_STOP_WAV,				"SND_SLOT_STOP"},
+	{SND_GOOD_FAERIE_AMBIENT,	GOOD_FAERIE_AMBIENT_WAV, "SND_GOOD_FAERIE_AMBIENT"},
+	{SND_GOOD_FAERIE_SPELL,		GOOD_FAERIE_SPELL_WAV,	"SND_GOOD_FAERIE_SPELL"},
+	{SND_GOOD_FAERIE_STUNNED,	GOOD_FAERIE_STUNNED_WAV,	"SND_GOOD_FAERIE_STUNNED"},
+	{SND_ICEPUFF_WARNING,	ICEPUFF_WARNING_WAV,	"SND_ICEPUFF_WARNING"},
+	{SND_ICEPUFF_THROW,		ICEPUFF_THROW_WAV,		"SND_ICEPUFF_THROW"},
+	{SND_ICEPUFF_STUNNED,	ICEPUFF_STUNNED_WAV,	"SND_ICEPUFF_STUNNED"},
+	{SND_ICEPUFF_APPEAR,		ICEPUFF_APPEAR_WAV,		"SND_ICEPUFF_APPEAR"},
+	{SND_GUY_PLUMMET,	GUY_PLUMMET_WAV,			"SND_GUY_PLUMMET"},
+	{SND_PUSH_DIVERTER,	LASERD_PUSH_WAV,			"SND_PUSH_DIVERTER"},
+	{SND_TURNBOT_TURN,		TURNBOT_TURN_WAV,		"SND_TURNBOT_TURN"},
+	{SND_PUSHBOT_STRAIN,	PUSHBOT_STRAIN_WAV,			"SND_PUSHBOT_STRAIN"},
+	{SND_MONKEYSTONE_SECRET_STAR, MONKEYSTONE_SECRET_STAR_WAV, "SND_MONKEYSTONE_SECRET_STAR"},
+	{SND_OMNIBOT_AMBIENT, OMNIBOT_AMBIENT_WAV,		"SND_OMNIBOT_AMBIENT"},
+	{SND_PUSHBOT_STUNNED,	PUSHBOT_STUNNED_WAV,	"SND_PUSHBOT_STUNNED"},
+	{SND_MEERKAT_WARNING,	MEERKAT_WARNING_WAV,	"SND_MEERKAT_WARNING"},
+	{SND_MEERKAT_APPEAR,		MEERKAT_APPEAR_WAV,		"SND_MEERKAT_APPEAR"},
+	{SND_MEERKAT_STUNNED,	MEERKAT_STUNNED_WAV,	"SND_MEERKAT_STUNNED"},
+	{SND_TURNBOT_STUNNED,	TURNBOT_STUNNED_WAV,	"SND_TURNBOT_STUNNED"},
+	{SND_DRAGON_WAKE,		DRAGON_WAKE_WAV,		"SND_DRAGON_WAKE"},
+	{SND_DRAGON_FALLASLEEP,	DRAGON_FALL_ASLEEP_WAV,	"SND_DRAGON_FALLASLEEP"},
+	{SND_DRAGON_BREATHEFIRE,	DRAGON_BREATHE_FIRE_WAV,	"SND_DRAGON_BREATHEFIRE"},
+	{SND_BADFAIRY_AMBIENT,	BAD_FAERIE_AMBIENT_WAV,		"SND_BADFAIRY_AMBIENT"},
+	{SND_BADFAIRY_SPELL,		BAD_FAERIE_SPELL_WAV,		"SND_BADFAIRY_SPELL"},
+	{SND_BADFAIRY_STUNNED,	BAD_FAERIE_STUNNED_WAV,		"SND_BADFAIRY_STUNNED"},
+	{SND_DEMIGOD_AMBIENT,	DEMIGOD_AMBIENT_WAV,	"SND_DEMIGOD_AMBIENT"},
+	{SND_DEMIGOD_HOLYSPEECH,	DEMIGOD_HOLYSPEECH_WAV,	"SND_DEMIGOD_HOLYSPEECH"},
+	{SND_DEMIGOD_UNHAPPY,	DEMIGOD_UNHAPPY_WAV,	"SND_DEMIGOD_UNHAPPY"},
+	{SND_GATEPUDDLE_AMBIENT,	GATEPUDDLE_AMBIENT_WAV,	"SND_GATEPUDDLE_AMBIENT"},
+	{SND_GATEPUDDLE_DISSIPATE, GATEPUDDLE_DISSIPATE_WAV, "SND_GATEPUDDLE_DISSIPATE"},
+	{SND_GATEPUDDLE_SPAWN,	GATEPUDDLE_SPAWN_WAV,	"SND_GATEPUDDLE_SPAWN"},
+	{SND_REALSLOT_SPIN,		SLOTMACHINE_SPINS_WAV,	"SND_REALSLOT_SPIN"},
+	{SND_REALSLOT_STOP,		SLOTMACHINE_STOP_WAV,	"SND_REALSLOT_STOP"},
+	{SND_REALSLOT_WIN,		SLOTMACHINE_WIN_WAV,	"SND_REALSLOT_WIN"},
+	{SND_SLUG_FIRE,			SLUG_FIRE_WAV,			"SND_SLUG_FIRE"},
+	{SND_SLUG_HIT,			SLUG_HIT_WAV,			"SND_SLUG_HIT"},
+	{SND_STUNNER_FIRE,		STUNNER_ZAP_WAV,		"SND_STUNNER_FIRE"},
+	{SND_UNLOCKED_ITEM,		UNLOCKED_ITEM_WAV,		"SND_UNLOCKED_ITEM"},
+
+		//
+		// MP1/2 music - external to .MPC file; they're in a MUSIC subdir
+		//
+	{SONG_TITLE,			SFNAME_TITLE,				"SONG_TITLE"},
+	{SONG_MENU,			SFNAME_MENU,				"SONG_MENU"},
+	{SONG_ROBO,			SFNAME_ROBO,				"SONG_ROBO"},
+	{SONG_MEXI,			SFNAME_MEXI,				"SONG_MEXI"},
+	{SONG_BASSO,			SFNAME_BASSO,				"SONG_BASSO"},
+	{SONG_WIND,			SFNAME_WIND,				"SONG_WIND"},
+	{SONG_INDUSTRO,		SFNAME_INDUSTRO,			"SONG_INDUSTRO"},
+	{SONG_JACKIN,		SFNAME_JACKIN,				"SONG_JACKIN"},
+	{SONG_SNEAKERS,		SFNAME_SNEAKERS,			"SONG_SNEAKERS"},
+	{SONG_QUIET,			SFNAME_QUIET,				"SONG_QUIET"},
+	{SONG_JEEBIES,		SFNAME_JEEBIES,				"SONG_JEEBIES"},
+	{SONG_VIBRACIOUS,	SFNAME_VIBRACIOUS,			"SONG_VIBRACIOUS"},
+	{SONG_ROMANTIC,		SFNAME_ROMANTIC,			"SONG_ROMANTIC"},
+	{SONG_ARETHERE,		SFNAME_ARETHERE,			"SONG_ARETHERE"},
+
+	{SONG_CORRIDOR,		SFNAME_CORRIDOR,			"SONG_CORRIDOR"},
+	{SONG_MOKE,			SFNAME_MOKE,				"SONG_MOKE"},
+	{SONG_TILES,			SFNAME_TILES,				"SONG_TILES"},
+	{SONG_DARKVIB,		SFNAME_DARKVIB,				"SONG_DARKVIB"},
+	{SONG_EXPER,			SFNAME_EXPER,				"SONG_EXPER"},
+
+	{SND_BEEPBEEPBEEP,		BEEPBEEPBEEP_WAV,		"SND_BEEPBEEPBEEP"},
+
+		//
+		// Voice files - in the .MPC file
+		//
+	{V00_AIRLOCK_01,		M00_AIRLOCK_01_MP3,			"V00_AIRLOCK_01"},
+	{V00_ARNIE_01,		M00_ARNIE_01_MP3,			"V00_ARNIE_01"},
+
+	{V00_BRAD_01,		M00_BRAD_01_MP3,			"V00_BRAD_01"},
+	{V00_BRAD_02,		M00_BRAD_02_MP3,			"V00_BRAD_02"},
+	{V00_BRAD_03,		M00_BRAD_03_MP3,			"V00_BRAD_03"},
+
+	{V00_BUSTER_01,		M00_BUSTER_01_MP3,			"V00_BUSTER_01"},
+	{V00_BUSTER_02,		M00_BUSTER_02_MP3,			"V00_BUSTER_02"},
+	{V00_BUSTER_03,		M00_BUSTER_03_MP3,			"V00_BUSTER_03"},
+	{V00_BUSTER_04,		M00_BUSTER_04_MP3,			"V00_BUSTER_04"},
+	{V00_BUSTER_05,		M00_BUSTER_05_MP3,			"V00_BUSTER_05"},
+	{V00_BUSTER_06,		M00_BUSTER_06_MP3,			"V00_BUSTER_06"},
+	{V00_BUSTER_07,		M00_BUSTER_07_MP3,			"V00_BUSTER_07"},
+	{V00_BUSTER_08,		M00_BUSTER_08_MP3,			"V00_BUSTER_08"},
+	{V00_BUSTER_09,		M00_BUSTER_09_MP3,			"V00_BUSTER_09"},
+	{V00_BUSTER_10,		M00_BUSTER_10_MP3,			"V00_BUSTER_10"},
+	{V00_BUSTER_11,		M00_BUSTER_11_MP3,			"V00_BUSTER_11"},
+	{V00_BUSTER_12,		M00_BUSTER_12_MP3,			"V00_BUSTER_12"},
+	{V00_BUSTER_13A,		M00_BUSTER_13A_MP3,			"V00_BUSTER_13A"},
+	{V00_BUSTER_13B,		M00_BUSTER_13B_MP3,			"V00_BUSTER_13B"},
+	{V00_BUSTER_14,		M00_BUSTER_14_MP3,			"V00_BUSTER_14"},
+	{V00_BUSTER_15,		M00_BUSTER_15_MP3,			"V00_BUSTER_15"},
+	{V00_BUSTER_16,		M00_BUSTER_16_MP3,			"V00_BUSTER_16"},
+	{V00_BUSTER_17,		M00_BUSTER_17_MP3,			"V00_BUSTER_17"},
+	{V00_BUSTER_18,		M00_BUSTER_18_MP3,			"V00_BUSTER_18"},
+	{V00_BUSTER_19,		M00_BUSTER_19_MP3,			"V00_BUSTER_19"},
+
+	{V00_CHICKEN_01,		M00_CHICKEN_01_MP3,			"V00_CHICKEN_01"},
+
+	{V00_CHUTEGUARD_01,		M00_CHUTEGUARD_01_MP3,			"V00_CHUTEGUARD_01"},
+	{V00_CHUTEGUARD_02,		M00_CHUTEGUARD_02_MP3,			"V00_CHUTEGUARD_02"},
+	{V00_CHUTEGUARD_03,		M00_CHUTEGUARD_03_MP3,			"V00_CHUTEGUARD_03"},
+	{V00_CHUTEGUARD_04,		M00_CHUTEGUARD_04_MP3,			"V00_CHUTEGUARD_04"},
+	{V00_CHUTEGUARD_05,		M00_CHUTEGUARD_05_MP3,			"V00_CHUTEGUARD_05"},
+
+	{V00_COOPER_01,		M00_COOPER_01_MP3,			"V00_COOPER_01"},
+	{V00_COOPER_02,		M00_COOPER_02_MP3,			"V00_COOPER_02"},
+	{V00_COOPER_03,		M00_COOPER_03_MP3,			"V00_COOPER_03"},
+	{V00_COOPER_04,		M00_COOPER_04_MP3,			"V00_COOPER_04"},
+	{V00_COOPER_05,		M00_COOPER_05_MP3,			"V00_COOPER_05"},
+
+	{V00_DINERS_01,		M00_DINERS_01_MP3,			"V00_DINERS_01"},
+	{V00_DINERS_02,		M00_DINERS_02_MP3,			"V00_DINERS_02"},
+	{V00_DINERS_03,		M00_DINERS_03_MP3,			"V00_DINERS_03"},
+	{V00_DINERS_04,		M00_DINERS_04_MP3,			"V00_DINERS_04"},
+	{V00_DINERS_05,		M00_DINERS_05_MP3,			"V00_DINERS_05"},
+	{V00_DINERS_06,		M00_DINERS_06_MP3,			"V00_DINERS_06"},
+
+	{V00_DOLLY_01,		M00_DOLLY_01_MP3,			"V00_DOLLY_01"},
+	{V00_DOLLY_02,		M00_DOLLY_02_MP3,			"V00_DOLLY_02"},
+	{V00_DOLLY_03,		M00_DOLLY_03_MP3,			"V00_DOLLY_03"},
+	{V00_DOLLY_04,		M00_DOLLY_04_MP3,			"V00_DOLLY_04"},
+	{V00_DOLLY_05,		M00_DOLLY_05_MP3,			"V00_DOLLY_05"},
+	{V00_DOLLY_06,		M00_DOLLY_06_MP3,			"V00_DOLLY_06"},
+	{V00_DOLLY_07,		M00_DOLLY_07_MP3,			"V00_DOLLY_07"},
+	{V00_DOLLY_08,		M00_DOLLY_08_MP3,			"V00_DOLLY_08"},
+	{V00_DOLLY_09,		M00_DOLLY_09_MP3,			"V00_DOLLY_09"},
+
+	{V00_DOREK_01,		M00_DOREK_01_MP3,			"V00_DOREK_01"},
+	{V00_DOREK_02,		M00_DOREK_02_MP3,			"V00_DOREK_02"},
+	{V00_DOREK_03,		M00_DOREK_03_MP3,			"V00_DOREK_03"},
+	{V00_DOREK_04,		M00_DOREK_04_MP3,			"V00_DOREK_04"},
+
+	{V00_ENGCOMPUTER_01,	M00_ENGCOMPUTER_01_MP3,		"V00_ENGCOMPUTER_01"},
+	{V00_ENGCOMPUTER_02,	M00_ENGCOMPUTER_02_MP3,		"V00_ENGCOMPUTER_02"},
+
+	{V00_FARBLE_01,		M00_FARBLE_01_MP3,			"V00_FARBLE_01"},
+	{V00_FARBLE_02,		M00_FARBLE_02_MP3,			"V00_FARBLE_02"},
+	{V00_FARBLE_03,		M00_FARBLE_03_MP3,			"V00_FARBLE_03"},
+	{V00_FARBLE_04,		M00_FARBLE_04_MP3,			"V00_FARBLE_04"},
+	{V00_FARBLE_05,		M00_FARBLE_05_MP3,			"V00_FARBLE_05"},
+	{V00_FARBLE_06,		M00_FARBLE_06_MP3,			"V00_FARBLE_06"},
+	{V00_FARBLE_07,		M00_FARBLE_07_MP3,			"V00_FARBLE_07"},
+	{V00_FARBLE_08,		M00_FARBLE_08_MP3,			"V00_FARBLE_08"},
+
+	{V00_GRUNETT_01,		M00_GRUNETT_01_MP3,			"V00_GRUNETT_01"},
+	{V00_GRUNETT_02,		M00_GRUNETT_02_MP3,			"V00_GRUNETT_02"},
+	{V00_GRUNETT_03,		M00_GRUNETT_03_MP3,			"V00_GRUNETT_03"},
+	{V00_GRUNETT_04,		M00_GRUNETT_04_MP3,			"V00_GRUNETT_04"},
+
+	{V00_GUY_01,		M00_GUY_01_MP3,			"V00_GUY_01"},
+	{V00_GUY_02,		M00_GUY_02_MP3,			"V00_GUY_02"},
+	{V00_GUY_03,		M00_GUY_03_MP3,			"V00_GUY_03"},
+	{V00_GUY_04,		M00_GUY_04_MP3,			"V00_GUY_04"},
+	{V00_GUY_05,		M00_GUY_05_MP3,			"V00_GUY_05"},
+	{V00_GUY_06,		M00_GUY_06_MP3,			"V00_GUY_06"},
+	{V00_GUY_07,		M00_GUY_07_MP3,			"V00_GUY_07"},
+	{V00_GUY_08,		M00_GUY_08_MP3,			"V00_GUY_08"},
+	{V00_GUY_09,		M00_GUY_09_MP3,			"V00_GUY_09"},
+	{V00_GUY_10A,	M00_GUY_10A_MP3,		"V00_GUY_10A"},
+	{V00_GUY_10B,	M00_GUY_10B_MP3,		"V00_GUY_10B"},
+	{V00_GUY_11,		M00_GUY_11_MP3,			"V00_GUY_11"},
+	{V00_GUY_12,		M00_GUY_12_MP3,			"V00_GUY_12"},
+	{V00_GUY_13,		M00_GUY_13_MP3,			"V00_GUY_13"},
+	{V00_GUY_14,		M00_GUY_14_MP3,			"V00_GUY_14"},
+	{V00_GUY_15,		M00_GUY_15_MP3,			"V00_GUY_15"},
+	{V00_GUY_16,		M00_GUY_16_MP3,			"V00_GUY_16"},
+	{V00_GUY_17,		M00_GUY_17_MP3,			"V00_GUY_17"},
+	{V00_GUY_18,		M00_GUY_18_MP3,			"V00_GUY_18"},
+
+	{V00_HUMBERT_01,		M00_HUMBERT_01_MP3,			"V00_HUMBERT_01"},
+	{V00_HUMBERT_02,		M00_HUMBERT_02_MP3,			"V00_HUMBERT_02"},
+
+	{V00_ILLIAC_01,		M00_ILLIAC_01_MP3,			"V00_ILLIAC_01"},
+	{V00_INFOCOMP_01,	M00_INFOCOMP_01_MP3,		"V00_INFOCOMP_01"},
+
+	{V00_JAQUES_01,		M00_JAQUES_01_MP3,			"V00_JAQUES_01"},
+	{V00_JAQUES_03,		M00_JAQUES_03_MP3,			"V00_JAQUES_03"},
+	{V00_JAQUES_04,		M00_JAQUES_04_MP3,			"V00_JAQUES_04"},
+	{V00_JAQUES_05,		M00_JAQUES_05_MP3,			"V00_JAQUES_05"},
+
+	{V00_LUMBAR_01,		M00_LUMBAR_01_MP3,			"V00_LUMBAR_01"},
+
+	{V00_MAILSORTER_01,		M00_MAILSORTER_01_MP3,			"V00_MAILSORTER_01"},
+	{V00_MAILSORTER_02,		M00_MAILSORTER_02_MP3,			"V00_MAILSORTER_02"},
+	{V00_MAILSORTER_03,		M00_MAILSORTER_03_MP3,			"V00_MAILSORTER_03"},
+	{V00_MAILSORTER_04,		M00_MAILSORTER_04_MP3,			"V00_MAILSORTER_04"},
+	{V00_MAILSORTER_05,		M00_MAILSORTER_05_MP3,			"V00_MAILSORTER_05"},
+	{V00_MAILSORTER_06,		M00_MAILSORTER_06_MP3,			"V00_MAILSORTER_06"},
+	{V00_MAILSORTER_07,		M00_MAILSORTER_07_MP3,			"V00_MAILSORTER_07"},
+	{V00_MAILSORTER_08,		M00_MAILSORTER_08_MP3,			"V00_MAILSORTER_08"},
+	{V00_MAILSORTER_09,		M00_MAILSORTER_09_MP3,			"V00_MAILSORTER_09"},
+	{V00_MAILSORTER_10,		M00_MAILSORTER_10_MP3,			"V00_MAILSORTER_10"},
+	{V00_MAILSORTER_11,		M00_MAILSORTER_11_MP3,			"V00_MAILSORTER_11"},
+	{V00_MAILSORTER_12,		M00_MAILSORTER_12_MP3,			"V00_MAILSORTER_12"},
+	{V00_MAILSORTER_13,		M00_MAILSORTER_13_MP3,			"V00_MAILSORTER_13"},
+	{V00_MAILSORTER_14,		M00_MAILSORTER_14_MP3,			"V00_MAILSORTER_14"},
+	{V00_MAILSORTER_15,		M00_MAILSORTER_15_MP3,			"V00_MAILSORTER_15"},
+
+	{V00_MANNY_01,		M00_MANNY_01_MP3,			"V00_MANNY_01"},
+	{V00_MANNY_02,		M00_MANNY_02_MP3,			"V00_MANNY_02"},
+	{V00_MANNY_03,		M00_MANNY_03_MP3,			"V00_MANNY_03"},
+	{V00_MANNY_04,		M00_MANNY_04_MP3,			"V00_MANNY_04"},
+	{V00_MANNY_05,		M00_MANNY_05_MP3,			"V00_MANNY_05"},
+	{V00_MANNY_06,		M00_MANNY_06_MP3,			"V00_MANNY_06"},
+	{V00_MANNY_07,		M00_MANNY_07_MP3,			"V00_MANNY_07"},
+	{V00_MANNY_08,		M00_MANNY_08_MP3,			"V00_MANNY_08"},
+	{V00_MANNY_09,		M00_MANNY_09_MP3,			"V00_MANNY_09"},
+	{V00_MANNY_10,		M00_MANNY_10_MP3,			"V00_MANNY_10"},
+	{V00_MANNY_11,		M00_MANNY_11_MP3,			"V00_MANNY_11"},
+	{V00_MANNY_12,		M00_MANNY_12_MP3,			"V00_MANNY_12"},
+	{V00_MANNY_13,		M00_MANNY_13_MP3,			"V00_MANNY_13"},
+	{V00_MANNY_14,		M00_MANNY_14_MP3,			"V00_MANNY_14"},
+	{V00_MANNY_15,		M00_MANNY_15_MP3,			"V00_MANNY_15"},
+	{V00_MANNY_16,		M00_MANNY_16_MP3,			"V00_MANNY_16"},
+	{V00_MANNY_17,		M00_MANNY_17_MP3,			"V00_MANNY_17"},
+	{V00_MANNY_18,		M00_MANNY_18_MP3,			"V00_MANNY_18"},
+
+	{V00_NOTEBRICK_01,	M00_NOTEBRICK_01_MP3,		"V00_NOTEBRICK_01"},
+
+	{V00_PILOTS_01,		M00_PILOTS_01_MP3,			"V00_PILOTS_01"},
+	{V00_PILOTS_02,		M00_PILOTS_02_MP3,			"V00_PILOTS_02"},
+
+	{V00_POLONEY_01,		M00_POLONEY_01_MP3,			"V00_POLONEY_01"},
+	{V00_POLONEY_02,		M00_POLONEY_02_MP3,			"V00_POLONEY_02"},
+	{V00_POLONEY_03,		M00_POLONEY_03_MP3,			"V00_POLONEY_03"},
+	{V00_POLONEY_04,		M00_POLONEY_04_MP3,			"V00_POLONEY_04"},
+	{V00_POLONEY_05,		M00_POLONEY_05_MP3,			"V00_POLONEY_05"},
+	{V00_POLONEY_06,		M00_POLONEY_06_MP3,			"V00_POLONEY_06"},
+
+	{V00_SARGE_01,		M00_SARGE_01_MP3,			"V00_SARGE_01"},
+	{V00_SARGE_02,		M00_SARGE_02_MP3,			"V00_SARGE_02"},
+	{V00_SARGE_03,		M00_SARGE_03_MP3,			"V00_SARGE_03"},
+	{V00_SARGE_04,		M00_SARGE_04_MP3,			"V00_SARGE_04"},
+	{V00_SARGE_05,		M00_SARGE_05_MP3,			"V00_SARGE_05"},
+	{V00_SARGE_06,		M00_SARGE_06_MP3,			"V00_SARGE_06"},
+	{V00_SARGE_07,		M00_SARGE_07_MP3,			"V00_SARGE_07"},
+	{V00_SARGE_08,		M00_SARGE_08_MP3,			"V00_SARGE_08"},
+	{V00_SARGE_09,		M00_SARGE_09_MP3,			"V00_SARGE_09"},
+	{V00_SARGE_10,		M00_SARGE_10_MP3,			"V00_SARGE_10"},
+	{V00_SARGE_11,		M00_SARGE_11_MP3,			"V00_SARGE_11"},
+	{V00_SARGE_12,		M00_SARGE_12_MP3,			"V00_SARGE_12"},
+	{V00_SARGE_13,		M00_SARGE_13_MP3,			"V00_SARGE_13"},
+	{V00_SARGE_14,		M00_SARGE_14_MP3,			"V00_SARGE_14"},
+	{V00_SARGE_15,		M00_SARGE_15_MP3,			"V00_SARGE_15"},
+	{V00_SARGE_16,		M00_SARGE_16_MP3,			"V00_SARGE_16"},
+
+	{V01_ALABASTER_01,	M01_ALABASTER_01_MP3,	"V01_ALABASTER_01"},
+	{V01_ALABASTER_02,	M01_ALABASTER_02_MP3,	"V01_ALABASTER_02"},
+	{V01_ALABASTER_03,	M01_ALABASTER_03_MP3,	"V01_ALABASTER_03"},
+	{V01_ALABASTER_04,	M01_ALABASTER_04_MP3,	"V01_ALABASTER_04"},
+	{V01_ALABASTER_05,	M01_ALABASTER_05_MP3,	"V01_ALABASTER_05"},
+	{V01_ALABASTER_06,	M01_ALABASTER_06_MP3,	"V01_ALABASTER_06"},
+	{V01_BRAKER_01,		M01_BRAKER_01_MP3,		"V01_BRAKER_01"},
+	{V01_BRAKER_02,		M01_BRAKER_02_MP3,		"V01_BRAKER_02"},
+	{V01_BRAKER_03,		M01_BRAKER_03_MP3,		"V01_BRAKER_03"},
+	{V01_BRAKER_04,		M01_BRAKER_04_MP3,		"V01_BRAKER_04"},
+	{V01_CHISTE_01,		M01_CHISTE_01_MP3,		"V01_CHISTE_01"},
+	{V01_CHISTE_02,		M01_CHISTE_02_MP3,		"V01_CHISTE_02"},
+	{V01_CHISTE_03,		M01_CHISTE_03_MP3,		"V01_CHISTE_03"},
+	{V01_CHISTE_04,		M01_CHISTE_04_MP3,		"V01_CHISTE_04"},
+	{V01_CHISTE_05,		M01_CHISTE_05_MP3,		"V01_CHISTE_05"},
+	{V01_CHISTE_06,		M01_CHISTE_06_MP3,		"V01_CHISTE_06"},
+	{V01_CHISTE_07,		M01_CHISTE_07_MP3,		"V01_CHISTE_07"},
+	{V01_CHISTE_08,		M01_CHISTE_08_MP3,		"V01_CHISTE_08"},
+	{V01_CHISTE_09,		M01_CHISTE_09_MP3,		"V01_CHISTE_09"},
+	{V01_CHISTE_10,		M01_CHISTE_10_MP3,		"V01_CHISTE_10"},
+	{V01_CHISTE_11,		M01_CHISTE_11_MP3,		"V01_CHISTE_11"},
+	{V01_CHISTE_12,		M01_CHISTE_12_MP3,		"V01_CHISTE_12"},
+	{V01_CHISTE_13,		M01_CHISTE_13_MP3,		"V01_CHISTE_13"},
+	{V01_CHISTE_14,		M01_CHISTE_14_MP3,		"V01_CHISTE_14"},
+	{V01_COVERT_01,		M01_COVERT_01_MP3,		"V01_COVERT_01"},
+	{V01_COVERT_02,		M01_COVERT_02_MP3,		"V01_COVERT_02"},
+	{V01_COVERT_03,		M01_COVERT_03_MP3,		"V01_COVERT_03"},
+	{V01_COVERT_04,		M01_COVERT_04_MP3,		"V01_COVERT_04"},
+	{V01_COVERT_05,		M01_COVERT_05_MP3,		"V01_COVERT_05"},
+	{V01_COVERT_06,		M01_COVERT_06_MP3,		"V01_COVERT_06"},
+	{V01_COVERT_07,		M01_COVERT_07_MP3,		"V01_COVERT_07"},
+	{V01_COVERT_08,		M01_COVERT_08_MP3,		"V01_COVERT_08"},
+	{V01_COVERT_09,		M01_COVERT_09_MP3,		"V01_COVERT_09"},
+	{V01_COVERT_10,		M01_COVERT_10_MP3,		"V01_COVERT_10"},
+	{V01_COVERT_11,		M01_COVERT_11_MP3,		"V01_COVERT_11"},
+	{V01_COVERT_12,		M01_COVERT_12_MP3,		"V01_COVERT_12"},
+	{V01_COVERT_13,		M01_COVERT_13_MP3,		"V01_COVERT_13"},
+	{V01_DAGEAUBE_01,	M01_DAGEAUBE_01_MP3,	"V01_DAGEAUBE_01"},
+	{V01_DAGEAUBE_02,	M01_DAGEAUBE_02_MP3,	"V01_DAGEAUBE_02"},
+	{V01_DAGEAUBE_03,	M01_DAGEAUBE_03_MP3,	"V01_DAGEAUBE_03"},
+	{V01_DAGEAUBE_04,	M01_DAGEAUBE_04_MP3,	"V01_DAGEAUBE_04"},
+	{V01_DAGEAUBE_05,	M01_DAGEAUBE_05_MP3,	"V01_DAGEAUBE_05"},
+	{V01_EMC2_01,		M01_EMC2_01_MP3,		"V01_EMC2_01"},
+	{V01_EMC2_02,		M01_EMC2_02_MP3,		"V01_EMC2_02"},
+	{V01_GIZZARD_01,		M01_GIZZARD_01_MP3,		"V01_GIZZARD_01"},
+	{V01_GIZZARD_02,		M01_GIZZARD_02_MP3,		"V01_GIZZARD_02"},
+	{V01_GUY_01,			M01_GUY_01_MP3,			"V01_GUY_01"},
+	{V01_GUY_02,			M01_GUY_02_MP3,			"V01_GUY_02"},
+	{V01_GUY_03,			M01_GUY_03_MP3,			"V01_GUY_03"},
+	{V01_GUY_04,			M01_GUY_04_MP3,			"V01_GUY_04"},
+	{V01_GUY_05,			M01_GUY_05_MP3,			"V01_GUY_05"},
+	{V01_HIDROW_01,		M01_HIDROW_01_MP3,		"V01_HIDROW_01"},
+	{V01_HIDROW_02,		M01_HIDROW_02_MP3,		"V01_HIDROW_02"},
+	{V01_HIDROW_03,		M01_HIDROW_03_MP3,		"V01_HIDROW_03"},
+	{V01_KEBOTTLE_01,	M01_KEBOTTLE_01_MP3,	"V01_KEBOTTLE_01"},
+	{V01_KEBOTTLE_02,	M01_KEBOTTLE_02_MP3,	"V01_KEBOTTLE_02"},
+	{V01_KEBOTTLE_03,	M01_KEBOTTLE_03_MP3,	"V01_KEBOTTLE_03"},
+	{V01_KEBOTTLE_04,	M01_KEBOTTLE_04_MP3,	"V01_KEBOTTLE_04"},
+	{V01_KEBOTTLE_05,	M01_KEBOTTLE_05_MP3,	"V01_KEBOTTLE_05"},
+	{V01_KEBOTTLE_06,	M01_KEBOTTLE_06_MP3,	"V01_KEBOTTLE_06"},
+	{V01_KEBOTTLE_07,	M01_KEBOTTLE_07_MP3,	"V01_KEBOTTLE_07"},
+	{V01_PONTE_01,		M01_PONTE_01_MP3,		"V01_PONTE_01"},
+	{V01_PONTE_02,		M01_PONTE_02_MP3,		"V01_PONTE_02"},
+	{V01_PONTE_03,		M01_PONTE_03_MP3,		"V01_PONTE_03"},
+	{V01_PONTE_04,		M01_PONTE_04_MP3,		"V01_PONTE_04"},
+	{V01_PONTE_05,		M01_PONTE_05_MP3,		"V01_PONTE_05"},
+	{V01_PONTE_06,		M01_PONTE_06_MP3,		"V01_PONTE_06"},
+	{V01_PONTE_07,		M01_PONTE_07_MP3,		"V01_PONTE_07"},
+	{V01_PONTE_08,		M01_PONTE_08_MP3,		"V01_PONTE_08"},
+	{V01_PONTE_09,		M01_PONTE_09_MP3,		"V01_PONTE_09"},
+	{V01_PONTE_10,		M01_PONTE_10_MP3,		"V01_PONTE_10"},
+	{V01_POPOPOLIS_01,	M01_POPOPOLIS_01_MP3,	"V01_POPOPOLIS_01"},
+	{V01_POPOPOLIS_02,	M01_POPOPOLIS_02_MP3,	"V01_POPOPOLIS_02"},
+	{V01_POPOPOLIS_03,	M01_POPOPOLIS_03_MP3,	"V01_POPOPOLIS_03"},
+	{V01_POPOPOLIS_04,	M01_POPOPOLIS_04_MP3,	"V01_POPOPOLIS_04"},
+	{V01_POPOPOLIS_05,	M01_POPOPOLIS_05_MP3,	"V01_POPOPOLIS_05"},
+	{V01_POPOPOLIS_06,	M01_POPOPOLIS_06_MP3,	"V01_POPOPOLIS_06"},
+	{V01_POPOPOLIS_07,	M01_POPOPOLIS_07_MP3,	"V01_POPOPOLIS_07"},
+	{V01_POPOPOLIS_08,	M01_POPOPOLIS_08_MP3,	"V01_POPOPOLIS_08"},
+	{V01_POPOPOLIS_09,	M01_POPOPOLIS_09_MP3,	"V01_POPOPOLIS_09"},
+	{V01_POPOPOLIS_10,	M01_POPOPOLIS_10_MP3,	"V01_POPOPOLIS_10"},
+	{V01_POPOPOLIS_11,	M01_POPOPOLIS_11_MP3,	"V01_POPOPOLIS_11"},
+	{V01_POPOPOLIS_12,	M01_POPOPOLIS_12_MP3,	"V01_POPOPOLIS_12"},
+	{V01_POPOPOLIS_13,	M01_POPOPOLIS_13_MP3,	"V01_POPOPOLIS_13"},
+	{V01_POPOPOLIS_14,	M01_POPOPOLIS_14_MP3,	"V01_POPOPOLIS_14"},
+	{V01_POPOPOLIS_15,	M01_POPOPOLIS_15_MP3,	"V01_POPOPOLIS_15"},
+	{V01_POPOPOLIS_16,	M01_POPOPOLIS_16_MP3,	"V01_POPOPOLIS_16"},
+	{V01_POPOPOLIS_17,	M01_POPOPOLIS_17_MP3,	"V01_POPOPOLIS_17"},
+	{V01_POPOPOLIS_18,	M01_POPOPOLIS_18_MP3,	"V01_POPOPOLIS_18"},
+	{V01_POPOPOLIS_19,	M01_POPOPOLIS_19_MP3,	"V01_POPOPOLIS_19"},
+	{V01_POPOPOLIS_20,	M01_POPOPOLIS_20_MP3,	"V01_POPOPOLIS_20"},
+	{V01_POPOPOLIS_21,	M01_POPOPOLIS_21_MP3,	"V01_POPOPOLIS_21"},
+	{V01_POPOPOLIS_22,	M01_POPOPOLIS_22_MP3,	"V01_POPOPOLIS_22"},
+	{V01_POPOPOLIS_23,	M01_POPOPOLIS_23_MP3,	"V01_POPOPOLIS_23"},
+	{V01_POPOPOLIS_24,	M01_POPOPOLIS_24_MP3,	"V01_POPOPOLIS_24"},
+	{V01_POPOPOLIS_25,	M01_POPOPOLIS_25_MP3,	"V01_POPOPOLIS_25"},
+	{V01_POPOPOLIS_26,	M01_POPOPOLIS_26_MP3,	"V01_POPOPOLIS_26"},
+	{V01_POPOPOLIS_27,	M01_POPOPOLIS_27_MP3,	"V01_POPOPOLIS_27"},
+	{V01_POPOPOLIS_28,	M01_POPOPOLIS_28_MP3,	"V01_POPOPOLIS_28"},
+	{V01_POPOPOLIS_29,	M01_POPOPOLIS_29_MP3,	"V01_POPOPOLIS_29"},
+	{V01_POPOPOLIS_30,	M01_POPOPOLIS_30_MP3,	"V01_POPOPOLIS_30"},
+	{V01_POPOPOLIS_31,	M01_POPOPOLIS_31_MP3,	"V01_POPOPOLIS_31"},
+	{V01_POPOPOLIS_32,	M01_POPOPOLIS_32_MP3,	"V01_POPOPOLIS_32"},
+	{V01_POPOPOLIS_33,	M01_POPOPOLIS_33_MP3,	"V01_POPOPOLIS_33"},
+	{V01_POPOPOLIS_34,	M01_POPOPOLIS_34_MP3,	"V01_POPOPOLIS_34"},
+	{V01_POPOPOLIS_35,	M01_POPOPOLIS_35_MP3,	"V01_POPOPOLIS_35"},
+	{V01_POPOPOLIS_36,	M01_POPOPOLIS_36_MP3,	"V01_POPOPOLIS_36"},
+	{V01_POPOPOLIS_37,	M01_POPOPOLIS_37_MP3,	"V01_POPOPOLIS_37"},
+	{V01_SARGE_01,		M01_SARGE_01_MP3,		"V01_SARGE_01"},
+	{V01_SARGE_02,		M01_SARGE_02_MP3,		"V01_SARGE_02"},
+	{V01_SARGE_03,		M01_SARGE_03_MP3,		"V01_SARGE_03"},
+	{V01_SARGE_04,		M01_SARGE_04_MP3,		"V01_SARGE_04"},
+	{V01_SOBREDELLE_01,	M01_SOBREDELLE_01_MP3,	"V01_SOBREDELLE_01"},
+	{V01_SOBREDELLE_02,	M01_SOBREDELLE_02_MP3,	"V01_SOBREDELLE_02"},
+	{V01_SOBREDELLE_03,	M01_SOBREDELLE_03_MP3,	"V01_SOBREDELLE_03"},
+	{V01_WAYNE_01,		M01_WAYNE_01_MP3,		"V01_WAYNE_01"},
+	{V01_WAYNE_02,		M01_WAYNE_02_MP3,		"V01_WAYNE_02"},
+	{V01_ZIQUOZ_01,		M01_ZIQUOZ_01_MP3,		"V01_ZIQUOZ_01"},
+	{V01_ZIQUOZ_02,		M01_ZIQUOZ_02_MP3,		"V01_ZIQUOZ_02"},
+	{V01_ZIQUOZ_03,		M01_ZIQUOZ_03_MP3,		"V01_ZIQUOZ_03"},
+
+	{V02_AGUSTO_01,		M02_AGUSTO_01_MP3,		"V02_AGUSTO_01"},
+	{V02_AGUSTO_02,		M02_AGUSTO_02_MP3,		"V02_AGUSTO_02"},
+	{V02_ALBONDIGAS_01,		M02_ALBONDIGAS_01_MP3,		"V02_ALBONDIGAS_01"},
+	{V02_ALBONDIGAS_02,		M02_ALBONDIGAS_02_MP3,		"V02_ALBONDIGAS_02"},
+	{V02_BUMPER_01,		M02_BUMPER_01_MP3,		"V02_BUMPER_01"},
+	{V02_BUMPER_02,		M02_BUMPER_02_MP3,		"V02_BUMPER_02"},
+	{V02_BUMPER_03,		M02_BUMPER_03_MP3,		"V02_BUMPER_03"},
+	{V02_BUMPER_04,		M02_BUMPER_04_MP3,		"V02_BUMPER_04"},
+	{V02_BUMPER_05,		M02_BUMPER_05_MP3,		"V02_BUMPER_05"},
+	{V02_BUMPER_06,		M02_BUMPER_06_MP3,		"V02_BUMPER_06"},
+	{V02_BUMPER_07,		M02_BUMPER_07_MP3,		"V02_BUMPER_07"},
+	{V02_DELGADO_01,		M02_DELGADO_01_MP3,		"V02_DELGADO_01"},
+	{V02_FEBRARO_01,		M02_FEBRARO_01_MP3,		"V02_FEBRARO_01"},
+	{V02_GUY_01,		M02_GUY_01_MP3,		"V02_GUY_01"},
+	{V02_GUY_02,		M02_GUY_02_MP3,		"V02_GUY_02"},
+	{V03_ACROPHO_01,		M03_ACROPHO_01_MP3,		"V03_ACROPHO_01"},
+	{V03_ACROPHO_02,		M03_ACROPHO_02_MP3,		"V03_ACROPHO_02"},
+	{V03_ACROPHO_03,		M03_ACROPHO_03_MP3,		"V03_ACROPHO_03"},
+	{V03_ACROPHO_04,		M03_ACROPHO_04_MP3,		"V03_ACROPHO_04"},
+	{V03_ENERO_01,		M03_ENERO_01_MP3,		"V03_ENERO_01"},
+	{V03_ENERO_02,		M03_ENERO_02_MP3,		"V03_ENERO_02"},
+	{V03_ENERO_03,		M03_ENERO_03_MP3,		"V03_ENERO_03"},
+	{V03_ENERO_04,		M03_ENERO_04_MP3,		"V03_ENERO_04"},
+	{V03_ENERO_05,		M03_ENERO_05_MP3,		"V03_ENERO_05"},
+	{V03_GAIA_01,		M03_GAIA_01_MP3,		"V03_GAIA_01"},
+	{V03_GAIA_02,		M03_GAIA_02_MP3,		"V03_GAIA_02"},
+	{V03_GAIA_03,		M03_GAIA_03_MP3,		"V03_GAIA_03"},
+	{V03_GAIA_04,		M03_GAIA_04_MP3,		"V03_GAIA_04"},
+	{V03_GAIA_05,		M03_GAIA_05_MP3,		"V03_GAIA_05"},
+	{V03_GAIA_06,		M03_GAIA_06_MP3,		"V03_GAIA_06"},
+	{V03_LAGO_01,		M03_LAGO_01_MP3,		"V03_LAGO_01"},
+	{V03_LAGO_02,		M03_LAGO_02_MP3,		"V03_LAGO_02"},
+	{V03_LAGO_04,		M03_LAGO_04_MP3,		"V03_LAGO_04"},
+	{V03_LAGO_05,		M03_LAGO_05_MP3,		"V03_LAGO_05"},
+	{V03_LAGO_06,		M03_LAGO_06_MP3,		"V03_LAGO_06"},
+	{V03_LAGO_07,		M03_LAGO_07_MP3,		"V03_LAGO_07"},
+	{V04_BONIFACE_01,		M04_BONIFACE_01_MP3,		"V04_BONIFACE_01"},
+	{V04_BONIFACE_02,		M04_BONIFACE_02_MP3,		"V04_BONIFACE_02"},
+	{V04_BONIFACE_03,		M04_BONIFACE_03_MP3,		"V04_BONIFACE_03"},
+	{V04_BONIFACE_04,		M04_BONIFACE_04_MP3,		"V04_BONIFACE_04"},
+	{V04_BONIFACE_05,		M04_BONIFACE_05_MP3,		"V04_BONIFACE_05"},
+	{V04_BONIFACE_06,		M04_BONIFACE_06_MP3,		"V04_BONIFACE_06"},
+	{V04_BONIFACE_07,		M04_BONIFACE_07_MP3,		"V04_BONIFACE_07"},
+	{V04_JULIO_01,		M04_JULIO_01_MP3,		"V04_JULIO_01"},
+	{V04_JULIO_02,		M04_JULIO_02_MP3,		"V04_JULIO_02"},
+	{V04_JULIO_04,		M04_JULIO_04_MP3,		"V04_JULIO_04"},
+	{V04_MARZO_01,		M04_MARZO_01_MP3,		"V04_MARZO_01"},
+	{V04_OCTUBRE_01,		M04_OCTUBRE_01_MP3,		"V04_OCTUBRE_01"},
+	{V04_OCTUBRE_02,		M04_OCTUBRE_02_MP3,		"V04_OCTUBRE_02"},
+	{V04_OCTUBRE_03,		M04_OCTUBRE_03_MP3,		"V04_OCTUBRE_03"},
+	{V05_ABRIL_01,		M05_ABRIL_01_MP3,		"V05_ABRIL_01"},
+	{V05_ABRIL_02,		M05_ABRIL_02_MP3,		"V05_ABRIL_02"},
+	{V05_ABRIL_03,		M05_ABRIL_03_MP3,		"V05_ABRIL_03"},
+	{V05_ABRIL_04,		M05_ABRIL_04_MP3,		"V05_ABRIL_04"},
+	{V05_ABRIL_05,		M05_ABRIL_05_MP3,		"V05_ABRIL_05"},
+	{V05_GELIGELLA_01,		M05_GELIGELLA_01_MP3,		"V05_GELIGELLA_01"},
+	{V05_GELIGELLA_02,		M05_GELIGELLA_02_MP3,		"V05_GELIGELLA_02"},
+	{V05_RAILRIDER_01,		M05_RAILRIDER_01_MP3,		"V05_RAILRIDER_01"},
+	{V05_RAILRIDER_02,		M05_RAILRIDER_02_MP3,		"V05_RAILRIDER_02"},
+	{V05_RAILRIDER_03,		M05_RAILRIDER_03_MP3,		"V05_RAILRIDER_03"},
+	{V05_RAILRIDER_04,		M05_RAILRIDER_04_MP3,		"V05_RAILRIDER_04"},
+	{V05_EVERLOO_01,		M05_EVERLOO_01_MP3,		"V05_EVERLOO_01"},
+	{V05_EVERLOO_02,		M05_EVERLOO_02_MP3,		"V05_EVERLOO_02"},
+	{V05_EVERLOO_03,		M05_EVERLOO_03_MP3,		"V05_EVERLOO_03"},
+	{V05_EVERLOO_04,		M05_EVERLOO_04_MP3,		"V05_EVERLOO_04"},
+	{V06_AZUL_01,		M06_AZUL_01_MP3,		"V06_AZUL_01"},
+	{V06_AZUL_02,		M06_AZUL_02_MP3,		"V06_AZUL_02"},
+	{V06_AZUL_03,		M06_AZUL_03_MP3,		"V06_AZUL_03"},
+	{V06_AZUL_04,		M06_AZUL_04_MP3,		"V06_AZUL_04"},
+	{V06_AZUL_05,		M06_AZUL_05_MP3,		"V06_AZUL_05"},
+	{V06_AZUL_06,		M06_AZUL_06_MP3,		"V06_AZUL_06"},
+	{V06_AZUL_07,		M06_AZUL_07_MP3,		"V06_AZUL_07"},
+	{V06_AZUL_08,		M06_AZUL_08_MP3,		"V06_AZUL_08"},
+	{V06_GUY_01,		M06_GUY_01_MP3,		"V06_GUY_01"},
+	{V06_GUY_02,		M06_GUY_02_MP3,		"V06_GUY_02"},
+	{V06_GUY_03,		M06_GUY_03_MP3,		"V06_GUY_03"},
+	{V06_GUY_04,		M06_GUY_04_MP3,		"V06_GUY_04"},
+	{V06_HANSON_01,		M06_HANSON_01_MP3,		"V06_HANSON_01"},
+	{V06_HANSON_03,		M06_HANSON_03_MP3,		"V06_HANSON_03"},
+	{V06_HANSON_04,		M06_HANSON_04_MP3,		"V06_HANSON_04"},
+	{V06_HANSON_05,		M06_HANSON_05_MP3,		"V06_HANSON_05"},
+	{V06_HANSON_06,		M06_HANSON_06_MP3,		"V06_HANSON_06"},
+	{V06_HANSON_07,		M06_HANSON_07_MP3,		"V06_HANSON_07"},
+	{V06_HANSON_08,		M06_HANSON_08_MP3,		"V06_HANSON_08"},
+	{V06_HANSON_09,		M06_HANSON_09_MP3,		"V06_HANSON_09"},
+	{V06_HANSON_10,		M06_HANSON_10_MP3,		"V06_HANSON_10"},
+	{V06_HANSON_11,		M06_HANSON_11_MP3,		"V06_HANSON_11"},
+	{V06_HANSON_12,		M06_HANSON_12_MP3,		"V06_HANSON_12"},
+	{V06_JUNIO_01,		M06_JUNIO_01_MP3,		"V06_JUNIO_01"},
+	{V06_JUNIO_02,		M06_JUNIO_02_MP3,		"V06_JUNIO_02"},
+	{V06_JUNIO_03,		M06_JUNIO_03_MP3,		"V06_JUNIO_03"},
+	{V06_JUNIO_04,		M06_JUNIO_04_MP3,		"V06_JUNIO_04"},
+	{V06_JUNIO_05,		M06_JUNIO_05_MP3,		"V06_JUNIO_05"},
+	{V06_JUNIO_06,		M06_JUNIO_06_MP3,		"V06_JUNIO_06"},
+	{V06_JUNIO_07,		M06_JUNIO_07_MP3,		"V06_JUNIO_07"},
+	{V06_JUNIO_08,		M06_JUNIO_08_MP3,		"V06_JUNIO_08"},
+	{V06_JUNIO_09,		M06_JUNIO_09_MP3,		"V06_JUNIO_09"},
+	{V06_NARANJA_01,		M06_NARANJA_01_MP3,		"V06_NARANJA_01"},
+	{V06_NARANJA_02,		M06_NARANJA_02_MP3,		"V06_NARANJA_02"},
+	{V06_NARANJA_03,		M06_NARANJA_03_MP3,		"V06_NARANJA_03"},
+	{V06_NARANJA_04,		M06_NARANJA_04_MP3,		"V06_NARANJA_04"},
+	{V06_NARANJA_05,		M06_NARANJA_05_MP3,		"V06_NARANJA_05"},
+	{V06_SEPTEMBRE_01,		M06_SEPTEMBRE_01_MP3,		"V06_SEPTEMBRE_01"},
+	{V06_SEPTEMBRE_02,		M06_SEPTEMBRE_02_MP3,		"V06_SEPTEMBRE_02"},
+	{V06_SEPTEMBRE_03,		M06_SEPTEMBRE_03_MP3,		"V06_SEPTEMBRE_03"},
+	{V06_SEPTEMBRE_04,		M06_SEPTEMBRE_04_MP3,		"V06_SEPTEMBRE_04"},
+	{V06_SEPTEMBRE_05,		M06_SEPTEMBRE_05_MP3,		"V06_SEPTEMBRE_05"},
+	{V06_SEPTEMBRE_06,		M06_SEPTEMBRE_06_MP3,		"V06_SEPTEMBRE_06"},
+	{V06_SEPTEMBRE_07,		M06_SEPTEMBRE_07_MP3,		"V06_SEPTEMBRE_07"},
+	{V06_SEPTEMBRE_08,		M06_SEPTEMBRE_08_MP3,		"V06_SEPTEMBRE_08"},
+	{V06_SEPTEMBRE_09,		M06_SEPTEMBRE_09_MP3,		"V06_SEPTEMBRE_09"},
+	{V06_WORKER_01,		M06_WORKER_01_MP3,		"V06_WORKER_01"},
+	{V06_WORKER_02,		M06_WORKER_02_MP3,		"V06_WORKER_02"},
+	{V06_WORKER_03,		M06_WORKER_03_MP3,		"V06_WORKER_03"},
+	{V06_WORKER_04,		M06_WORKER_04_MP3,		"V06_WORKER_04"},
+	{V07_CERCO_01,		M07_CERCO_01_MP3,		"V07_CERCO_01"},
+	{V07_CERCO_02,		M07_CERCO_02_MP3,		"V07_CERCO_02"},
+	{V07_COMPUTER_01,		M07_COMPUTER_01_MP3,		"V07_COMPUTER_01"},
+	{V07_MAYO_01,		M07_MAYO_01_MP3,		"V07_MAYO_01"},
+	{V07_MAYO_02,		M07_MAYO_02_MP3,		"V07_MAYO_02"},
+	{V07_NOVIEMBRE_01,		M07_NOVIEMBRE_01_MP3,		"V07_NOVIEMBRE_01"},
+	{V07_NOVIEMBRE_02,		M07_NOVIEMBRE_02_MP3,		"V07_NOVIEMBRE_02"},
+	{V07_NOVIEMBRE_03,		M07_NOVIEMBRE_03_MP3,		"V07_NOVIEMBRE_03"},
+	{V07_PANITO_01,		M07_PANITO_01_MP3,		"V07_PANITO_01"},
+	{V07_PANITO_02,		M07_PANITO_02_MP3,		"V07_PANITO_02"},
+	{V07_PANITO_03,		M07_PANITO_03_MP3,		"V07_PANITO_03"},
+	{V07_PANITO_04,		M07_PANITO_04_MP3,		"V07_PANITO_04"},
+	{V07_PANITO_05,		M07_PANITO_05_MP3,		"V07_PANITO_05"},
+	{V08_COOKIE_01,		M08_COOKIE_01_MP3,		"V08_COOKIE_01"},
+	{V08_COOKIE_02,		M08_COOKIE_02_MP3,		"V08_COOKIE_02"},
+	{V08_DICIEMBRE_01,		M08_DICIEMBRE_01_MP3,		"V08_DICIEMBRE_01"},
+	{V08_GUY_01,		M08_GUY_01_MP3,		"V08_GUY_01"},
+	{V08_GUY_02,		M08_GUY_02_MP3,		"V08_GUY_02"},
+	{V08_GUY_03,		M08_GUY_03_MP3,		"V08_GUY_03"},
+	{V08_MACHINA_01,		M08_MACHINA_01_MP3,		"V08_MACHINA_01"},
+	{V08_MACHINA_02,		M08_MACHINA_02_MP3,		"V08_MACHINA_02"},
+	{V08_MACHINA_03,		M08_MACHINA_03_MP3,		"V08_MACHINA_03"},
+	{V08_MACHINA_04,		M08_MACHINA_04_MP3,		"V08_MACHINA_04"},
+	{V08_MACHINA_05,		M08_MACHINA_05_MP3,		"V08_MACHINA_05"},
+	{V08_MACHINA_06,		M08_MACHINA_06_MP3,		"V08_MACHINA_06"},
+	{V08_MACHINA_07,		M08_MACHINA_07_MP3,		"V08_MACHINA_07"},
+	{V08_MACHINA_08,		M08_MACHINA_08_MP3,		"V08_MACHINA_08"},
+	{V08_MACHINA_09,		M08_MACHINA_09_MP3,		"V08_MACHINA_09"},
+	{V08_MESA_01,		M08_MESA_01_MP3,		"V08_MESA_01"},
+	{V08_MESA_02,		M08_MESA_02_MP3,		"V08_MESA_02"},
+	{V08_MESA_03,		M08_MESA_03_MP3,		"V08_MESA_03"},
+	{V08_MESA_04,		M08_MESA_04_MP3,		"V08_MESA_04"},
+	{V08_SHAKIR_01,		M08_SHAKIR_01_MP3,		"V08_SHAKIR_01"},
+	{V08_SHAKIR_02,		M08_SHAKIR_02_MP3,		"V08_SHAKIR_02"},
+	{V08_SHAKIR_03,		M08_SHAKIR_03_MP3,		"V08_SHAKIR_03"},
+	{V09_VIOLETA_01,		M09_VIOLETA_01_MP3,		"V09_VIOLETA_01"},
+	{V09_VIOLETA_02,		M09_VIOLETA_02_MP3,		"V09_VIOLETA_02"},
+	{V09_VIOLETA_03,		M09_VIOLETA_03_MP3,		"V09_VIOLETA_03"},
+	{V09_VIOLETA_04,		M09_VIOLETA_04_MP3,		"V09_VIOLETA_04"},
+	{V10_CHICKEN_01,		M10_CHICKEN_01_MP3,		"V10_CHICKEN_01"},
+	{V10_COOPER_01,		M10_COOPER_01_MP3,		"V10_COOPER_01"},
+	{V10_COOPER_02,		M10_COOPER_02_MP3,		"V10_COOPER_02"},
+	{V10_COOPER_03,		M10_COOPER_03_MP3,		"V10_COOPER_03"},
+	{V10_COOPER_04,		M10_COOPER_04_MP3,		"V10_COOPER_04"},
+	{V10_COOPER_05,		M10_COOPER_05_MP3,		"V10_COOPER_05"},
+	{V10_COOPER_06,		M10_COOPER_06_MP3,		"V10_COOPER_06"},
+	{V10_COOPER_07,		M10_COOPER_07_MP3,		"V10_COOPER_07"},
+	{V10_COOPER_08,		M10_COOPER_08_MP3,		"V10_COOPER_08"},
+	{V10_COOPER_09,		M10_COOPER_09_MP3,		"V10_COOPER_09"},
+	{V10_DOLLY_01,		M10_DOLLY_01_MP3,		"V10_DOLLY_01"},
+	{V10_DOLLY_02,		M10_DOLLY_02_MP3,		"V10_DOLLY_02"},
+	{V10_DOLLY_03,		M10_DOLLY_03_MP3,		"V10_DOLLY_03"},
+	{V10_DOLLY_04,		M10_DOLLY_04_MP3,		"V10_DOLLY_04"},
+	{V10_DOLLY_05,		M10_DOLLY_05_MP3,		"V10_DOLLY_05"},
+	{V10_DOLLY_06,		M10_DOLLY_06_MP3,		"V10_DOLLY_06"},
+	{V10_DOLLY_07,		M10_DOLLY_07_MP3,		"V10_DOLLY_07"},
+	{V10_DOLLY_08,		M10_DOLLY_08_MP3,		"V10_DOLLY_08"},
+	{V10_DOLLY_09,		M10_DOLLY_09_MP3,		"V10_DOLLY_09"},
+	{V10_DOLLY_10,		M10_DOLLY_10_MP3,		"V10_DOLLY_10"},
+	{V10_ENGCOMPUTER_01,		M10_ENGCOMPUTER_01_MP3,		"V10_ENGCOMPUTER_01"},
+	{V10_FARBLE_01,		M10_FARBLE_01_MP3,		"V10_FARBLE_01"},
+	{V10_FARBLE_02,		M10_FARBLE_02_MP3,		"V10_FARBLE_02"},
+	{V10_FARBLE_03,		M10_FARBLE_03_MP3,		"V10_FARBLE_03"},
+	{V10_FARBLE_04,		M10_FARBLE_04_MP3,		"V10_FARBLE_04"},
+	{V10_FARBLE_05,		M10_FARBLE_05_MP3,		"V10_FARBLE_05"},
+	{V10_FARBLE_06,		M10_FARBLE_06_MP3,		"V10_FARBLE_06"},
+	{V10_GRUNETT_01,		M10_GRUNETT_01_MP3,		"V10_GRUNETT_01"},
+	{V10_GRUNETT_02,		M10_GRUNETT_02_MP3,		"V10_GRUNETT_02"},
+	{V10_GRUNETT_03,		M10_GRUNETT_03_MP3,		"V10_GRUNETT_03"},
+	{V10_GRUNETT_04,		M10_GRUNETT_04_MP3,		"V10_GRUNETT_04"},
+	{V10_GRUNETT_05,		M10_GRUNETT_05_MP3,		"V10_GRUNETT_05"},
+	{V10_GRUNETT_06,		M10_GRUNETT_06_MP3,		"V10_GRUNETT_06"},
+	{V10_GUY_01,		M10_GUY_01_MP3,		"V10_GUY_01"},
+	{V10_GUY_02,		M10_GUY_02_MP3,		"V10_GUY_02"},
+	{V10_GUY_03,		M10_GUY_03_MP3,		"V10_GUY_03"},
+	{V10_GUY_04,		M10_GUY_04_MP3,		"V10_GUY_04"},
+	{V10_GUY_05,		M10_GUY_05_MP3,		"V10_GUY_05"},
+	{V10_GUY_06,		M10_GUY_06_MP3,		"V10_GUY_06"},
+	{V10_GUY_07,		M10_GUY_07_MP3,		"V10_GUY_07"},
+	{V10_GUY_08,		M10_GUY_08_MP3,		"V10_GUY_08"},
+	{V10_INFOCOMP_01,		M10_INFOCOMP_01_MP3,		"V10_INFOCOMP_01"},
+	{V10_NOTEBRICK_01,		M10_NOTEBRICK_01_MP3,		"V10_NOTEBRICK_01"},
+	{V10_PILOTS_01,		M10_PILOTS_01_MP3,		"V10_PILOTS_01"},
+	{V10_PILOTS_02,		M10_PILOTS_02_MP3,		"V10_PILOTS_02"},
+	{V10_PILOTS_03,		M10_PILOTS_03_MP3,		"V10_PILOTS_03"},
+	{V10_PILOTS_04,		M10_PILOTS_04_MP3,		"V10_PILOTS_04"},
+	{V10_PILOTS_05,		M10_PILOTS_05_MP3,		"V10_PILOTS_05"},
+	{V10_SARGE_01,		M10_SARGE_01_MP3,		"V10_SARGE_01"},
+	{V10_SARGE_02,		M10_SARGE_02_MP3,		"V10_SARGE_02"},
+	{V10_SARGE_03,		M10_SARGE_03_MP3,		"V10_SARGE_03"},
+	{V10_SARGE_04,		M10_SARGE_04_MP3,		"V10_SARGE_04"},
+	{V10_SARGE_05,		M10_SARGE_05_MP3,		"V10_SARGE_05"},
+	{V11_ANCHOVY_01,		M11_ANCHOVY_01_MP3,		"V11_ANCHOVY_01"},
+	{V11_ANCHOVY_02,		M11_ANCHOVY_02_MP3,		"V11_ANCHOVY_02"},
+	{V11_ANCHOVY_03,		M11_ANCHOVY_03_MP3,		"V11_ANCHOVY_03"},
+	{V11_ANCHOVY_04,		M11_ANCHOVY_04_MP3,		"V11_ANCHOVY_04"},
+	{V11_ANCHOVY_05,		M11_ANCHOVY_05_MP3,		"V11_ANCHOVY_05"},
+	{V11_ARBIVALL_01,		M11_ARBIVALL_01_MP3,		"V11_ARBIVALL_01"},
+	{V11_ARBIVALL_02,		M11_ARBIVALL_02_MP3,		"V11_ARBIVALL_02"},
+	{V11_ARBIVALL_03,		M11_ARBIVALL_03_MP3,		"V11_ARBIVALL_03"},
+	{V11_ARBIVALL_04,		M11_ARBIVALL_04_MP3,		"V11_ARBIVALL_04"},
+	{V11_ARBIVALL_05,		M11_ARBIVALL_05_MP3,		"V11_ARBIVALL_05"},
+	{V11_ARBIVALL_06,		M11_ARBIVALL_06_MP3,		"V11_ARBIVALL_06"},
+	{V11_ARBIVALL_07,		M11_ARBIVALL_07_MP3,		"V11_ARBIVALL_07"},
+	{V11_ARNIE_01,		M11_ARNIE_01_MP3,		"V11_ARNIE_01"},
+	{V11_BELINDA_01,		M11_BELINDA_01_MP3,		"V11_BELINDA_01"},
+	{V11_BLOCK_01,		M11_BLOCK_01_MP3,		"V11_BLOCK_01"},
+	{V11_BLOCK_02,		M11_BLOCK_02_MP3,		"V11_BLOCK_02"},
+	{V11_BLOCK_03,		M11_BLOCK_03_MP3,		"V11_BLOCK_03"},
+	{V11_BRAD_01,		M11_BRAD_01_MP3,		"V11_BRAD_01"},
+	{V11_BRAD_02,		M11_BRAD_02_MP3,		"V11_BRAD_02"},
+	{V11_BRAD_03,		M11_BRAD_03_MP3,		"V11_BRAD_03"},
+	{V11_BUSTER_01,		M11_BUSTER_01_MP3,		"V11_BUSTER_01"},
+	{V11_BUSTER_02,		M11_BUSTER_02_MP3,		"V11_BUSTER_02"},
+	{V11_BUSTER_03,		M11_BUSTER_03_MP3,		"V11_BUSTER_03"},
+	{V11_DINERS_01,		M11_DINERS_01_MP3,		"V11_DINERS_01"},
+	{V11_DINERS_02,		M11_DINERS_02_MP3,		"V11_DINERS_02"},
+	{V11_DOPPLER_01,		M11_DOPPLER_01_MP3,		"V11_DOPPLER_01"},
+	{V11_DOPPLER_02,		M11_DOPPLER_02_MP3,		"V11_DOPPLER_02"},
+	{V11_DOPPLER_03,		M11_DOPPLER_03_MP3,		"V11_DOPPLER_03"},
+	{V11_DOPPLER_04,		M11_DOPPLER_04_MP3,		"V11_DOPPLER_04"},
+	{V11_DOPPLER_05,		M11_DOPPLER_05_MP3,		"V11_DOPPLER_05"},
+	{V11_DOREK_01,		M11_DOREK_01_MP3,		"V11_DOREK_01"},
+	{V11_DOREK_02,		M11_DOREK_02_MP3,		"V11_DOREK_02"},
+	{V11_DOREK_03,		M11_DOREK_03_MP3,		"V11_DOREK_03"},
+	{V11_DOZER_01,		M11_DOZER_01_MP3,		"V11_DOZER_01"},
+	{V11_DOZER_02,		M11_DOZER_02_MP3,		"V11_DOZER_02"},
+	{V11_DOZER_03,		M11_DOZER_03_MP3,		"V11_DOZER_03"},
+	{V11_DOZER_04,		M11_DOZER_04_MP3,		"V11_DOZER_04"},
+	{V11_GNAPPE_01,		M11_GNAPPE_01_MP3,		"V11_GNAPPE_01"},
+	{V11_GNAPPE_02,		M11_GNAPPE_02_MP3,		"V11_GNAPPE_02"},
+	{V11_GNAPPE_03,		M11_GNAPPE_03_MP3,		"V11_GNAPPE_03"},
+	{V11_GNAPPE_04,		M11_GNAPPE_04_MP3,		"V11_GNAPPE_04"},
+	{V11_GNAPPE_05,		M11_GNAPPE_05_MP3,		"V11_GNAPPE_05"},
+	{V11_GNODIMY_01,		M11_GNODIMY_01_MP3,		"V11_GNODIMY_01"},
+	{V11_GNODIMY_02,		M11_GNODIMY_02_MP3,		"V11_GNODIMY_02"},
+	{V11_GNODIMY_03,		M11_GNODIMY_03_MP3,		"V11_GNODIMY_03"},
+	{V11_GNODIMY_04,		M11_GNODIMY_04_MP3,		"V11_GNODIMY_04"},
+	{V11_GUY_01,		M11_GUY_01_MP3,		"V11_GUY_01"},
+	{V11_GUY_02,		M11_GUY_02_MP3,		"V11_GUY_02"},
+	{V11_GUY_03,		M11_GUY_03_MP3,		"V11_GUY_03"},
+	{V11_GUY_04,		M11_GUY_04_MP3,		"V11_GUY_04"},
+	{V11_GUY_05,		M11_GUY_05_MP3,		"V11_GUY_05"},
+	{V11_GUY_06,		M11_GUY_06_MP3,		"V11_GUY_06"},
+	{V11_GUY_07,		M11_GUY_07_MP3,		"V11_GUY_07"},
+	{V11_GUY_08,		M11_GUY_08_MP3,		"V11_GUY_08"},
+	{V11_GUY_09,		M11_GUY_09_MP3,		"V11_GUY_09"},
+	{V11_GUY_10,		M11_GUY_10_MP3,		"V11_GUY_10"},
+	{V11_GUY_11,		M11_GUY_11_MP3,		"V11_GUY_11"},
+	{V11_GUY_12,		M11_GUY_12_MP3,		"V11_GUY_12"},
+	{V11_GUY_13,		M11_GUY_13_MP3,		"V11_GUY_13"},
+	{V11_GUY_15,		M11_GUY_15_MP3,		"V11_GUY_15"},
+	{V11_GUY_16,		M11_GUY_16_MP3,		"V11_GUY_16"},
+	{V11_GUY_17,		M11_GUY_17_MP3,		"V11_GUY_17"},
+	{V11_HAMBRE_01,		M11_HAMBRE_01_MP3,		"V11_HAMBRE_01"},
+	{V11_HAMBRE_02,		M11_HAMBRE_02_MP3,		"V11_HAMBRE_02"},
+	{V11_HAMBRE_03,		M11_HAMBRE_03_MP3,		"V11_HAMBRE_03"},
+	{V11_HAMBRE_04,		M11_HAMBRE_04_MP3,		"V11_HAMBRE_04"},
+	{V11_HAMBRE_05,		M11_HAMBRE_05_MP3,		"V11_HAMBRE_05"},
+	{V11_HUMBERT_01,		M11_HUMBERT_01_MP3,		"V11_HUMBERT_01"},
+	{V11_ILLIAC_01,		M11_ILLIAC_01_MP3,		"V11_ILLIAC_01"},
+	{V11_JAQUES_01,		M11_JAQUES_01_MP3,		"V11_JAQUES_01"},
+	{V11_JAQUES_02,		M11_JAQUES_02_MP3,		"V11_JAQUES_02"},
+	{V11_JAQUES_03,		M11_JAQUES_03_MP3,		"V11_JAQUES_03"},
+	{V11_JAQUES_04,		M11_JAQUES_04_MP3,		"V11_JAQUES_04"},
+	{V11_LUMBAR_01,		M11_LUMBAR_01_MP3,		"V11_LUMBAR_01"},
+	{V11_MAN_IN_STALL_01,		M11_MAN_IN_STALL_01_MP3,		"V11_MAN_IN_STALL_01"},
+	{V11_MAN_IN_STALL_02,		M11_MAN_IN_STALL_02_MP3,		"V11_MAN_IN_STALL_02"},
+	{V11_MAN_IN_STALL_03,		M11_MAN_IN_STALL_03_MP3,		"V11_MAN_IN_STALL_03"},
+	{V11_MAN_IN_STALL_04,		M11_MAN_IN_STALL_04_MP3,		"V11_MAN_IN_STALL_04"},
+	{V11_MAN_IN_STALL_05,		M11_MAN_IN_STALL_05_MP3,		"V11_MAN_IN_STALL_05"},
+	{V11_MANNY_01,		M11_MANNY_01_MP3,		"V11_MANNY_01"},
+	{V11_MUMPS_01,		M11_MUMPS_01_MP3,		"V11_MUMPS_01"},
+	{V11_MUMPS_02,		M11_MUMPS_02_MP3,		"V11_MUMPS_02"},
+	{V11_MUMPS_03,		M11_MUMPS_03_MP3,		"V11_MUMPS_03"},
+	{V11_MUMPS_04,		M11_MUMPS_04_MP3,		"V11_MUMPS_04"},
+	{V11_MUMPS_05,		M11_MUMPS_05_MP3,		"V11_MUMPS_05"},
+	{V11_MUMPS_06,		M11_MUMPS_06_MP3,		"V11_MUMPS_06"},
+	{V11_MUMPS_07,		M11_MUMPS_07_MP3,		"V11_MUMPS_07"},
+	{V11_MUMPS_08,		M11_MUMPS_08_MP3,		"V11_MUMPS_08"},
+	{V11_MUMPS_09,		M11_MUMPS_09_MP3,		"V11_MUMPS_09"},
+	{V11_MUMPS_10,		M11_MUMPS_10_MP3,		"V11_MUMPS_10"},
+	{V11_MUMPS_11,		M11_MUMPS_11_MP3,		"V11_MUMPS_11"},
+	{V11_MUMPS_12,		M11_MUMPS_12_MP3,		"V11_MUMPS_12"},
+	{V11_MUMPS_13,		M11_MUMPS_13_MP3,		"V11_MUMPS_13"},
+	{V11_MUMPS_14,		M11_MUMPS_14_MP3,		"V11_MUMPS_14"},
+	{V11_MUMPS_15,		M11_MUMPS_15_MP3,		"V11_MUMPS_15"},
+	{V11_MUMPS_16,		M11_MUMPS_16_MP3,		"V11_MUMPS_16"},
+	{V11_MUMPS_17,		M11_MUMPS_17_MP3,		"V11_MUMPS_17"},
+	{V11_MUMPS_18,		M11_MUMPS_18_MP3,		"V11_MUMPS_18"},
+	{V11_MUMPS_19,		M11_MUMPS_19_MP3,		"V11_MUMPS_19"},
+	{V11_MUMPS_20,		M11_MUMPS_20_MP3,		"V11_MUMPS_20"},
+	{V11_MUMPS_22,		M11_MUMPS_22_MP3,		"V11_MUMPS_22"},
+	{V11_MUMPS_23,		M11_MUMPS_23_MP3,		"V11_MUMPS_23"},
+	{V11_MUMPS_24,		M11_MUMPS_24_MP3,		"V11_MUMPS_24"},
+	{V11_MUMPS_25,		M11_MUMPS_25_MP3,		"V11_MUMPS_25"},
+	{V11_MUMPS_26,		M11_MUMPS_26_MP3,		"V11_MUMPS_26"},
+	{V11_PEDIMENT_01,		M11_PEDIMENT_01_MP3,		"V11_PEDIMENT_01"},
+	{V11_PEDIMENT_02,		M11_PEDIMENT_02_MP3,		"V11_PEDIMENT_02"},
+	{V11_PEDIMENT_03,		M11_PEDIMENT_03_MP3,		"V11_PEDIMENT_03"},
+	{V11_PEDIMENT_04,		M11_PEDIMENT_04_MP3,		"V11_PEDIMENT_04"},
+	{V11_PEDIMENT_05,		M11_PEDIMENT_05_MP3,		"V11_PEDIMENT_05"},
+	{V11_PEDIMENT_06,		M11_PEDIMENT_06_MP3,		"V11_PEDIMENT_06"},
+	{V11_PEDIMENT_07,		M11_PEDIMENT_07_MP3,		"V11_PEDIMENT_07"},
+	{V11_PEDIMENT_08,		M11_PEDIMENT_08_MP3,		"V11_PEDIMENT_08"},
+	{V11_POLONEY_01,		M11_POLONEY_01_MP3,		"V11_POLONEY_01"},
+	{V11_POLONEY_02,		M11_POLONEY_02_MP3,		"V11_POLONEY_02"},
+	{V11_POLONEY_03,		M11_POLONEY_03_MP3,		"V11_POLONEY_03"},
+	{V11_SAUSAGE_01,		M11_SAUSAGE_01_MP3,		"V11_SAUSAGE_01"},
+	{V11_SAUSAGE_02,		M11_SAUSAGE_02_MP3,		"V11_SAUSAGE_02"},
+	{V11_SAUSAGE_03,		M11_SAUSAGE_03_MP3,		"V11_SAUSAGE_03"},
+	{V11_SAUSAGE_04,		M11_SAUSAGE_04_MP3,		"V11_SAUSAGE_04"},
+	{V11_SAUSAGE_05,		M11_SAUSAGE_05_MP3,		"V11_SAUSAGE_05"},
+	{V11_SAUSAGE_06,		M11_SAUSAGE_06_MP3,		"V11_SAUSAGE_06"},
+	{V11_SAUSAGE_07,		M11_SAUSAGE_07_MP3,		"V11_SAUSAGE_07"},
+	{V11_SAUSAGE_08,		M11_SAUSAGE_08_MP3,		"V11_SAUSAGE_08"},
+	{V11_SAUSAGE_09,		M11_SAUSAGE_09_MP3,		"V11_SAUSAGE_09"},
+	{V11_SAUSAGE_10,		M11_SAUSAGE_10_MP3,		"V11_SAUSAGE_10"},
+	{V12_ABLE_01,		M12_ABLE_01_MP3,		"V12_ABLE_01"},
+	{V12_ABLE_02,		M12_ABLE_02_MP3,		"V12_ABLE_02"},
+	{V12_ABLE_03,		M12_ABLE_03_MP3,		"V12_ABLE_03"},
+	{V12_BUSY_01,		M12_BUSY_01_MP3,		"V12_BUSY_01"},
+	{V12_BUSY_02,		M12_BUSY_02_MP3,		"V12_BUSY_02"},
+	{V12_BUSY_03,		M12_BUSY_03_MP3,		"V12_BUSY_03"},
+	{V12_BUSY_04,		M12_BUSY_04_MP3,		"V12_BUSY_04"},
+	{V12_BUSY_05,		M12_BUSY_05_MP3,		"V12_BUSY_05"},
+	{V12_BUSY_06,		M12_BUSY_06_MP3,		"V12_BUSY_06"},
+	{V12_BUSY_07,		M12_BUSY_07_MP3,		"V12_BUSY_07"},
+	{V12_BUSY_08,		M12_BUSY_08_MP3,		"V12_BUSY_08"},
+	{V12_CHARLIE_01,		M12_CHARLIE_01_MP3,		"V12_CHARLIE_01"},
+	{V12_CHARLIE_02,		M12_CHARLIE_02_MP3,		"V12_CHARLIE_02"},
+	{V12_CONUNDRUM_01,		M12_CONUNDRUM_01_MP3,		"V12_CONUNDRUM_01"},
+	{V12_CONUNDRUM_02,		M12_CONUNDRUM_02_MP3,		"V12_CONUNDRUM_02"},
+	{V12_CONUNDRUM_03,		M12_CONUNDRUM_03_MP3,		"V12_CONUNDRUM_03"},
+	{V12_CONUNDRUM_04,		M12_CONUNDRUM_04_MP3,		"V12_CONUNDRUM_04"},
+	{V12_CONUNDRUM_05,		M12_CONUNDRUM_05_MP3,		"V12_CONUNDRUM_05"},
+	{V12_FOXTROT_01,		M12_FOXTROT_01_MP3,		"V12_FOXTROT_01"},
+	{V12_FOXTROT_02,		M12_FOXTROT_02_MP3,		"V12_FOXTROT_02"},
+	{V12_GUY_01,			M12_GUY_01_MP3,			"V12_GUY_01"},
+	{V12_GUY_02,			M12_GUY_02_MP3,			"V12_GUY_02"},
+	{V12_GUY_03,			M12_GUY_03_MP3,			"V12_GUY_03"},
+	{V12_HAUTE_01,		M12_HAUTE_01_MP3,		"V12_HAUTE_01"},
+	{V12_HAUTE_02,		M12_HAUTE_02_MP3,		"V12_HAUTE_02"},
+	{V12_HAUTE_03,		M12_HAUTE_03_MP3,		"V12_HAUTE_03"},
+	{V12_HAUTE_04,		M12_HAUTE_04_MP3,		"V12_HAUTE_04"},
+	{V12_HAUTE_05,		M12_HAUTE_05_MP3,		"V12_HAUTE_05"},
+	{V12_HAUTE_06,		M12_HAUTE_06_MP3,		"V12_HAUTE_06"},
+	{V12_HOVER_01,		M12_HOVER_01_MP3,		"V12_HOVER_01"},
+	{V12_HOVER_02,		M12_HOVER_02_MP3,		"V12_HOVER_02"},
+	{V12_RUBE_01,		M12_RUBE_01_MP3,		"V12_RUBE_01"},
+	{V12_RUBE_02,		M12_RUBE_02_MP3,		"V12_RUBE_02"},
+	{V12_RUBE_03,		M12_RUBE_03_MP3,		"V12_RUBE_03"},
+	{V12_RUBE_04,		M12_RUBE_04_MP3,		"V12_RUBE_04"},
+	{V12_RUBE_05,		M12_RUBE_05_MP3,		"V12_RUBE_05"},
+	{V12_RUBE_06,		M12_RUBE_06_MP3,		"V12_RUBE_06"},
+	{V12_RUBE_07,		M12_RUBE_07_MP3,		"V12_RUBE_07"},
+	{V12_RUBE_08,		M12_RUBE_08_MP3,		"V12_RUBE_08"},
+	{V12_RUBE_09,		M12_RUBE_09_MP3,		"V12_RUBE_09"},
+	{V12_RUBE_10,		M12_RUBE_10_MP3,		"V12_RUBE_10"},
+	{V12_TEKT_01,		M12_TEKT_01_MP3,		"V12_TEKT_01"},
+	{V12_TEKT_02,		M12_TEKT_02_MP3,		"V12_TEKT_02"},
+	{V12_TEKT_03,		M12_TEKT_03_MP3,		"V12_TEKT_03"},
+	{V12_TEKT_04,		M12_TEKT_04_MP3,		"V12_TEKT_04"},
+	{V12_TEKT_05,		M12_TEKT_05_MP3,		"V12_TEKT_05"},
+	{V12_TEKT_06,		M12_TEKT_06_MP3,		"V12_TEKT_06"},
+	{V12_TEKT_07,		M12_TEKT_07_MP3,		"V12_TEKT_07"},
+	{V13_ANIBLE_01,		M13_ANIBLE_01_MP3,		"V13_ANIBLE_01"},
+	{V13_ANIBLE_02,		M13_ANIBLE_02_MP3,		"V13_ANIBLE_02"},
+	{V13_FLOWER_01,		M13_FLOWER_01_MP3,		"V13_FLOWER_01"},
+	{V13_FLOWER_02,		M13_FLOWER_02_MP3,		"V13_FLOWER_02"},
+	{V13_FOOCHANE_01,		M13_FOOCHANE_01_MP3,		"V13_FOOCHANE_01"},
+	{V13_FOOCHANE_02,		M13_FOOCHANE_02_MP3,		"V13_FOOCHANE_02"},
+	{V13_FOOCHANE_03,		M13_FOOCHANE_03_MP3,		"V13_FOOCHANE_03"},
+	{V13_FOOCHANE_04,		M13_FOOCHANE_04_MP3,		"V13_FOOCHANE_04"},
+	{V13_GHULABUL_01,		M13_GHULABUL_01_MP3,		"V13_GHULABUL_01"},
+	{V13_GHULABUL_02,		M13_GHULABUL_02_MP3,		"V13_GHULABUL_02"},
+	{V13_GHULABUL_03,		M13_GHULABUL_03_MP3,		"V13_GHULABUL_03"},
+	{V13_GHULABUL_04,		M13_GHULABUL_04_MP3,		"V13_GHULABUL_04"},
+	{V13_GHULABUL_05,		M13_GHULABUL_05_MP3,		"V13_GHULABUL_05"},
+	{V13_GHULABUL_06,		M13_GHULABUL_06_MP3,		"V13_GHULABUL_06"},
+	{V13_GHULABUL_07,		M13_GHULABUL_07_MP3,		"V13_GHULABUL_07"},
+	{V13_GUY_01,		M13_GUY_01_MP3,		"V13_GUY_01"},
+	{V13_GUY_02,		M13_GUY_02_MP3,		"V13_GUY_02"},
+	{V13_HAVENGIN_01,		M13_HAVENGIN_01_MP3,		"V13_HAVENGIN_01"},
+	{V13_MELO_01,		M13_MELO_01_MP3,		"V13_MELO_01"},
+	{V13_MELO_02,		M13_MELO_02_MP3,		"V13_MELO_02"},
+	{V13_MELO_03,		M13_MELO_03_MP3,		"V13_MELO_03"},
+	{V13_MITAKO_01,		M13_MITAKO_01_MP3,		"V13_MITAKO_01"},
+	{V13_MITAKO_02,		M13_MITAKO_02_MP3,		"V13_MITAKO_02"},
+	{V13_MITAKO_03,		M13_MITAKO_03_MP3,		"V13_MITAKO_03"},
+	{V13_SPOONIE_01,		M13_SPOONIE_01_MP3,		"V13_SPOONIE_01"},
+	{V13_SPOONIE_02,		M13_SPOONIE_02_MP3,		"V13_SPOONIE_02"},
+	{V13_SPOONIE_03,		M13_SPOONIE_03_MP3,		"V13_SPOONIE_03"},
+	{V13_SPOONIE_04,		M13_SPOONIE_04_MP3,		"V13_SPOONIE_04"},
+	{V13_SPOONIE_05,		M13_SPOONIE_05_MP3,		"V13_SPOONIE_05"},
+	{V13_ZYGOTE_01,		M13_ZYGOTE_01_MP3,		"V13_ZYGOTE_01"},
+	{V13_ZYGOTE_02,		M13_ZYGOTE_02_MP3,		"V13_ZYGOTE_02"},
+	{V13_ZYGOTE_03,		M13_ZYGOTE_03_MP3,		"V13_ZYGOTE_03"},
+	{V13_ZYGOTE_04,		M13_ZYGOTE_04_MP3,		"V13_ZYGOTE_04"},
+	{V13_ZYGOTE_05,		M13_ZYGOTE_05_MP3,		"V13_ZYGOTE_05"},
+	{V14_LAMORTE_01,		M14_LAMORTE_01_MP3,		"V14_LAMORTE_01"},
+	{V14_LAMORTE_02,		M14_LAMORTE_02_MP3,		"V14_LAMORTE_02"},
+	{V15_COPROLITE_01,		M15_COPROITE_01_MP3,		"V15_COPROLITE_01"},
+	{V15_COPROLITE_02,		M15_COPROITE_02_MP3,		"V15_COPROLITE_02"},
+	{V15_COPROLITE_03,		M15_COPROITE_03_MP3,		"V15_COPROLITE_03"},
+	{V15_COPROLITE_04,		M15_COPROITE_04_MP3,		"V15_COPROLITE_04"},
+	{V15_COPROLITE_05,		M15_COPROITE_05_MP3,		"V15_COPROLITE_05"},
+	{V15_COPROLITE_06,		M15_COPROITE_06_MP3,		"V15_COPROLITE_06"},
+	{V15_COPROLITE_07,		M15_COPROITE_07_MP3,		"V15_COPROLITE_07"},
+	{V15_COPROLITE_08,		M15_COPROITE_08_MP3,		"V15_COPROLITE_08"},
+	{V15_COPROLITE_09,		M15_COPROITE_09_MP3,		"V15_COPROLITE_09"},
+	{V15_COPROLITE_10,		M15_COPROITE_10_MP3,		"V15_COPROLITE_10"},
+	{V15_COPROLITE_11,		M15_COPROITE_11_MP3,		"V15_COPROLITE_11"},
+	{V15_COPROLITE_12,		M15_COPROITE_12_MP3,		"V15_COPROLITE_12"},
+	{V15_COPROLITE_13,		M15_COPROITE_13_MP3,		"V15_COPROLITE_13"},
+	{V15_COPROLITE_14,		M15_COPROITE_14_MP3,		"V15_COPROLITE_14"},
+	{V15_COPROLITE_15,		M15_COPROITE_15_MP3,		"V15_COPROLITE_15"},
+	{V15_COPROLITE_16,		M15_COPROITE_16_MP3,		"V15_COPROLITE_16"},
+	{V15_COPROLITE_17,		M15_COPROITE_17_MP3,		"V15_COPROLITE_17"},
+	{V15_COPROLITE_18,		M15_COPROITE_18_MP3,		"V15_COPROLITE_18"},
+	{V15_GUY_01,		M15_GUY_01_MP3,		"V15_GUY_01"},
+	{V15_GUY_02,		M15_GUY_02_MP3,		"V15_GUY_02"},
+	{V15_REED_01,		M15_REED_01_MP3,		"V15_REED_01"},
+	{V15_REED_02,		M15_REED_02_MP3,		"V15_REED_02"},
+	{V15_REED_03,		M15_REED_03_MP3,		"V15_REED_03"},
+	{V16_DYING_01,		M16_DYING_01_MP3,		"V16_DYING_01"},
+	{V16_DYING_02,		M16_DYING_02_MP3,		"V16_DYING_02"},
+	{V16_GUY_01,		M16_GUY_01_MP3,		"V16_GUY_01"},
+	{V16_GUY_02,		M16_GUY_02_MP3,		"V16_GUY_02"},
+	{V16_GUY_03,		M16_GUY_03_MP3,		"V16_GUY_03"},
+	{V17_ANDERSON_01,		M17_ANDERSON_01_MP3,		"V17_ANDERSON_01"},
+	{V17_BARBER_01,		M17_BARBER_01_MP3,		"V17_BARBER_01"},
+	{V17_CAMPBELL_01,		M17_CAMPBELL_01_MP3,		"V17_CAMPBELL_01"},
+	{V17_DEVONSHIRE_01,		M17_DEVONSHIRE_01_MP3,		"V17_DEVONSHIRE_01"},
+	{V17_EGGER_01,		M17_EGGER_01_MP3,		"V17_EGGER_01"},
+	{V17_EMERALD_01,		M17_EMERALD_01_MP3,		"V17_EMERALD_01"},
+	{V17_FLINGBESTER_01,		M17_FLINGBESTER_01_MP3,		"V17_FLINGBESTER_01"},
+	{V17_GERSHWIN_01,		M17_GERSHWIN_01_MP3,		"V17_GERSHWIN_01"},
+	{V17_GUY_01,		M17_GUY_01_MP3,		"V17_GUY_01"},
+	{V17_GUY_02,		M17_GUY_02_MP3,		"V17_GUY_02"},
+	{V17_GUY_03,		M17_GUY_03_MP3,		"V17_GUY_03"},
+	{V17_GUY_04,		M17_GUY_04_MP3,		"V17_GUY_04"},
+	{V17_HEPHASTUS_01,		M17_HEPHASTUS_01_MP3,		"V17_HEPHASTUS_01"},
+	{V17_INIWA_01,		M17_INIWA_01_MP3,		"V17_INIWA_01"},
+	{V17_INIWA_02,		M17_INIWA_02_MP3,		"V17_INIWA_02"},
+	{V17_INIWA_03,		M17_INIWA_03_MP3,		"V17_INIWA_03"},
+	{V17_KEYCODE_01,		M17_KEYCODE_01_MP3,		"V17_KEYCODE_01"},
+	{V17_KEYCODE_02,		M17_KEYCODE_02_MP3,		"V17_KEYCODE_02"},
+	{V17_KEYCODE_03,		M17_KEYCODE_03_MP3,		"V17_KEYCODE_03"},
+	{V17_KEYCODE_04,		M17_KEYCODE_04_MP3,		"V17_KEYCODE_04"},
+	{V17_TOERIG_01,		M17_TOERIG_01_MP3,		"V17_TOERIG_01"},
+	{V17_TOERIG_02,		M17_TOERIG_02_MP3,		"V17_TOERIG_02"},
+	{V17_WARNER_01,		M17_WARNER_01_MP3,		"V17_WARNER_01"},
+	{V17_WARNER_02,		M17_WARNER_02_MP3,		"V17_WARNER_02"},
+	{V17_WARNER_03,		M17_WARNER_03_MP3,		"V17_WARNER_03"},
+	{V17_WARNER_04,		M17_WARNER_04_MP3,		"V17_WARNER_04"},
+	{V17_YORP_01,		M17_YORP_01_MP3,		"V17_YORP_01"},
+	{V17_YORP_02,		M17_YORP_02_MP3,		"V17_YORP_02"},
+	{V18_DERECHA_01,		M18_DERECHA_01_MP3,		"V18_DERECHA_01"},
+	{V18_GUY_01,		M18_GUY_01_MP3,		"V18_GUY_01"},
+	{V18_IZQUIERDA_01,		M18_IZQUIERDA_01_MP3,		"V18_IZQUIERDA_01"},
+	{V18_IZQUIERDA_02,		M18_IZQUIERDA_02_MP3,		"V18_IZQUIERDA_02"},
+	{V18_IZQUIERDA_03,		M18_IZQUIERDA_03_MP3,		"V18_IZQUIERDA_03"},
+	{V18_IZQUIERDA_04,		M18_IZQUIERDA_04_MP3,		"V18_IZQUIERDA_04"},
+	{V18_IZQUIERDA_05,		M18_IZQUIERDA_05_MP3,		"V18_IZQUIERDA_05"},
+	{V18_IZQUIERDA_06,		M18_IZQUIERDA_06_MP3,		"V18_IZQUIERDA_06"},
+	{V19_CAVEAT_01,		M19_CAVEAT_01_MP3,		"V19_CAVEAT_01"},
+	{V19_CAVEAT_02,		M19_CAVEAT_02_MP3,		"V19_CAVEAT_02"},
+	{V19_ENDER_01,		M19_ENDER_01_MP3,		"V19_ENDER_01"},
+	{V19_ENDER_02,		M19_ENDER_02_MP3,		"V19_ENDER_02"},
+	{V19_FRUSTRATO_01,		M19_FRUSTRATO_01_MP3,		"V19_FRUSTRATO_01"},
+	{V19_FRUSTRATO_02,		M19_FRUSTRATO_02_MP3,		"V19_FRUSTRATO_02"},
+	{V19_FRUSTRATO_03,		M19_FRUSTRATO_03_MP3,		"V19_FRUSTRATO_03"},
+	{V19_FRUSTRATO_04,		M19_FRUSTRATO_04_MP3,		"V19_FRUSTRATO_04"},
+	{V19_FRUSTRATO_05,		M19_FRUSTRATO_05_MP3,		"V19_FRUSTRATO_05"},
+	{V19_FRUSTRATO_06,		M19_FRUSTRATO_06_MP3,		"V19_FRUSTRATO_06"},
+	{V19_FRUSTRATO_07,		M19_FRUSTRATO_07_MP3,		"V19_FRUSTRATO_07"},
+	{V19_FRUSTRATO_08,		M19_FRUSTRATO_08_MP3,		"V19_FRUSTRATO_08"},
+	{V19_FRUSTRATO_09,		M19_FRUSTRATO_09_MP3,		"V19_FRUSTRATO_09"},
+	{V19_FRUSTRATO_10,		M19_FRUSTRATO_10_MP3,		"V19_FRUSTRATO_10"},
+	{V19_GUY_01,		M19_GUY_01_MP3,		"V19_GUY_01"},
+	{V19_GUY_02,		M19_GUY_02_MP3,		"V19_GUY_02"},
+	{V19_GUY_03,		M19_GUY_03_MP3,		"V19_GUY_03"},
+	{V19_INTER_01,		M19_INTER_01_MP3,		"V19_INTER_01"},
+	{V19_INTER_02,		M19_INTER_02_MP3,		"V19_INTER_02"},
+	{V19_LONE_01,		M19_LONE_01_MP3,		"V19_LONE_01"},
+	{V19_LONE_02,		M19_LONE_02_MP3,		"V19_LONE_02"},
+	{V19_LONE_03,		M19_LONE_03_MP3,		"V19_LONE_03"},
+	{V19_PHILLIPS_01,		M19_PHILLIPS_01_MP3,		"V19_PHILLIPS_01"},
+	{V19_PHILLIPS_02,		M19_PHILLIPS_02_MP3,		"V19_PHILLIPS_02"},
+	{V19_PHILLIPS_03,		M19_PHILLIPS_03_MP3,		"V19_PHILLIPS_03"},
+	{V19_PHILLIPS_04,		M19_PHILLIPS_04_MP3,		"V19_PHILLIPS_04"},
+	{V19_PHILLIPS_05,		M19_PHILLIPS_05_MP3,		"V19_PHILLIPS_05"},
+	{V19_RAILRIDER_01,		M19_RAILRIDER_01_MP3,		"V19_RAILRIDER_01"},
+	{V19_RAILRIDER_02,		M19_RAILRIDER_02_MP3,		"V19_RAILRIDER_02"},
+	{V19_RAILRIDER_03,		M19_RAILRIDER_03_MP3,		"V19_RAILRIDER_03"},
+	{V19_RAILRIDER_04,		M19_RAILRIDER_04_MP3,		"V19_RAILRIDER_04"},
+	{V19_REDRUM_01,		M19_REDRUM_01_MP3,		"V19_REDRUM_01"},
+	{V19_REDRUM_02,		M19_REDRUM_02_MP3,		"V19_REDRUM_02"},
+	{V19_REDRUM_03,		M19_REDRUM_03_MP3,		"V19_REDRUM_03"},
+	{V19_REDRUM_04,		M19_REDRUM_04_MP3,		"V19_REDRUM_04"},
+	{V19_REDRUM_05,		M19_REDRUM_05_MP3,		"V19_REDRUM_05"},
+	{V19_REDRUM_06,		M19_REDRUM_06_MP3,		"V19_REDRUM_06"},
+	{V19_STANDARD_01,		M19_STANDARD_01_MP3,		"V19_STANDARD_01"},
+	{V19_STANDARD_02,		M19_STANDARD_02_MP3,		"V19_STANDARD_02"},
+	{V20_ARNIE_01,		M20_ARNIE_01_MP3,		"V20_ARNIE_01"},
+	{V20_ARNIE_02,		M20_ARNIE_02_MP3,		"V20_ARNIE_02"},
+	{V20_BRAD_01,		M20_BRAD_01_MP3,		"V20_BRAD_01"},
+	{V20_BRAD_02,		M20_BRAD_02_MP3,		"V20_BRAD_02"},
+	{V20_BUSTER_01,		M20_BUSTER_01_MP3,		"V20_BUSTER_01"},
+	{V20_BUSTER_02,		M20_BUSTER_02_MP3,		"V20_BUSTER_02"},
+	{V20_BUSTER_03,		M20_BUSTER_03_MP3,		"V20_BUSTER_03"},
+	{V20_COOPER_01,		M20_COOPER_01_MP3,		"V20_COOPER_01"},
+	{V20_COOPER_02,		M20_COOPER_02_MP3,		"V20_COOPER_02"},
+	{V20_DINERS_01,		M20_DINERS_01_MP3,		"V20_DINERS_01"},
+	{V20_DINERS_02,		M20_DINERS_02_MP3,		"V20_DINERS_02"},
+	{V20_DOLLY_01,		M20_DOLLY_01_MP3,		"V20_DOLLY_01"},
+	{V20_DOREK_01,		M20_DOREK_01_MP3,		"V20_DOREK_01"},
+	{V20_DOREK_02,		M20_DOREK_02_MP3,		"V20_DOREK_02"},
+	{V20_DOREK_03,		M20_DOREK_03_MP3,		"V20_DOREK_03"},
+	{V20_FARBLE_01,		M20_FARBLE_01_MP3,		"V20_FARBLE_01"},
+	{V20_FARBLE_02,		M20_FARBLE_02_MP3,		"V20_FARBLE_02"},
+	{V20_GRUNETT_01,		M20_GRUNETT_01_MP3,		"V20_GRUNETT_01"},
+	{V20_GRUNETT_02,		M20_GRUNETT_02_MP3,		"V20_GRUNETT_02"},
+	{V20_GUY_01,		M20_GUY_01_MP3,		"V20_GUY_01"},
+	{V20_GUY_02,		M20_GUY_02_MP3,		"V20_GUY_02"},
+	{V20_GUY_03,		M20_GUY_03_MP3,		"V20_GUY_03"},
+	{V20_GUY_04,		M20_GUY_04_MP3,		"V20_GUY_04"},
+	{V20_GUY_05,		M20_GUY_05_MP3,		"V20_GUY_05"},
+	{V20_GUY_06,		M20_GUY_06_MP3,		"V20_GUY_06"},
+	{V20_HUMBERT_01,		M20_HUMBERT_01_MP3,		"V20_HUMBERT_01"},
+	{V20_ILLIAC_01,		M20_ILLIAC_01_MP3,		"V20_ILLIAC_01"},
+	{V20_JACQUES_01,		M20_JAQUES_01_MP3,		"V20_JACQUES_01"},
+	{V20_JACQUES_02,		M20_JAQUES_02_MP3,		"V20_JACQUES_02"},
+	{V20_LUMBAR_01,		M20_LUMBAR_01_MP3,		"V20_LUMBAR_01"},
+	{V20_MANNY_01,		M20_MANNY_01_MP3,		"V20_MANNY_01"},
+	{V20_POLONEY_01,		M20_POLONEY_01_MP3,		"V20_POLONEY_01"},
+	{V20_POLONEY_02,		M20_POLONEY_02_MP3,		"V20_POLONEY_02"},
+	{V20_SARGE_01,		M20_SARGE_01_MP3,		"V20_SARGE_01"},
+	{V20_SARGE_02,		M20_SARGE_02_MP3,		"V20_SARGE_02"},
+	{V20_SARGE_03,		M20_SARGE_03_MP3,		"V20_SARGE_03"},
+	{V20_SARGE_04,		M20_SARGE_04_MP3,		"V20_SARGE_04"},
+	{V20_SARGE_05,		M20_SARGE_05_MP3,		"V20_SARGE_05"},
+	{V21_ANTIMA_01,		M21_ANTIMA_01_MP3,		"V21_ANTIMA_01"},
+	{V21_ANTIMA_02,		M21_ANTIMA_02_MP3,		"V21_ANTIMA_02"},
+	{V21_ANTIMA_03,		M21_ANTIMA_03_MP3,		"V21_ANTIMA_03"},
+	{V21_ANTIMA_04,		M21_ANTIMA_04_MP3,		"V21_ANTIMA_04"},
+	{V21_ANTIMA_05,		M21_ANTIMA_05_MP3,		"V21_ANTIMA_05"},
+	{V21_ANTIMA_06,		M21_ANTIMA_06_MP3,		"V21_ANTIMA_06"},
+	{V21_ANTIMA_07,		M21_ANTIMA_07_MP3,		"V21_ANTIMA_07"},
+	{V21_BRAN_ONOMI_01,		M21_BRAN_ONOMI_01_MP3,		"V21_BRAN_ONOMI_01"},
+	{V21_BRAN_ONOMI_02,		M21_BRAN_ONOMI_02_MP3,		"V21_BRAN_ONOMI_02"},
+	{V21_BRAN_ONOMI_03,		M21_BRAN_ONOMI_03_MP3,		"V21_BRAN_ONOMI_03"},
+	{V21_CONTENNE_01,		M21_CONTENNE_01_MP3,		"V21_CONTENNE_01"},
+	{V21_CONTENNE_02,		M21_CONTENNE_02_MP3,		"V21_CONTENNE_02"},
+	{V21_CONTENNE_03,		M21_CONTENNE_03_MP3,		"V21_CONTENNE_03"},
+	{V21_CONTENNE_04,		M21_CONTENNE_04_MP3,		"V21_CONTENNE_04"},
+	{V21_CONTENNE_05,		M21_CONTENNE_05_MP3,		"V21_CONTENNE_05"},
+	{V21_CONTENNE_06,		M21_CONTENNE_06_MP3,		"V21_CONTENNE_06"},
+	{V21_CONTENNE_07,		M21_CONTENNE_07_MP3,		"V21_CONTENNE_07"},
+	{V21_COUHOUSE_01,		M21_COUHOUSE_01_MP3,		"V21_COUHOUSE_01"},
+	{V21_COUHOUSE_02,		M21_COUHOUSE_02_MP3,		"V21_COUHOUSE_02"},
+	{V21_COUHOUSE_03,		M21_COUHOUSE_03_MP3,		"V21_COUHOUSE_03"},
+	{V21_DEBENSHIRE_01,		M21_DEBENSHIRE_01_MP3,		"V21_DEBENSHIRE_01"},
+	{V21_DEBENSHIRE_02,		M21_DEBENSHIRE_02_MP3,		"V21_DEBENSHIRE_02"},
+	{V21_DEBENSHIRE_03,		M21_DEBENSHIRE_03_MP3,		"V21_DEBENSHIRE_03"},
+	{V21_DEBENSHIRE_04,		M21_DEBENSHIRE_04_MP3,		"V21_DEBENSHIRE_04"},
+	{V21_FEMURIA_01,		M21_FEMURIA_01_MP3,		"V21_FEMURIA_01"},
+	{V21_FEMURIA_02,		M21_FEMURIA_02_MP3,		"V21_FEMURIA_02"},
+	{V21_FEMURIA_03,		M21_FEMURIA_03_MP3,		"V21_FEMURIA_03"},
+	{V21_FEMURIA_04,		M21_FEMURIA_04_MP3,		"V21_FEMURIA_04"},
+	{V21_FEMURIA_05,		M21_FEMURIA_05_MP3,		"V21_FEMURIA_05"},
+	{V21_GLARATTE_01,		M21_GLARATTE_01_MP3,		"V21_GLARATTE_01"},
+	{V21_GLARATTE_02,		M21_GLARATTE_02_MP3,		"V21_GLARATTE_02"},
+	{V21_GLARATTE_03,		M21_GLARATTE_03_MP3,		"V21_GLARATTE_03"},
+	{V21_GLARATTE_04,		M21_GLARATTE_04_MP3,		"V21_GLARATTE_04"},
+	{V21_GUY_01,				M21_GUY_01_MP3,		"V21_GUY_01"},
+	{V21_GUY_02,				M21_GUY_02_MP3,		"V21_GUY_02"},
+	{V21_GUY_03,				M21_GUY_03_MP3,		"V21_GUY_03"},
+	{V21_GUY_04,				M21_GUY_04_MP3,		"V21_GUY_04"},
+	{V21_GUY_05,				M21_GUY_05_MP3,		"V21_GUY_05"},
+	{V21_GUY_06,				M21_GUY_06_MP3,		"V21_GUY_06"},
+	{V21_GUY_07,				M21_GUY_07_MP3,		"V21_GUY_07"},
+	{V21_GUY_08,		M21_GUY_08_MP3,		"V21_GUY_08"},
+	{V21_GUY_09,		M21_GUY_09_MP3,		"V21_GUY_09"},
+	{V21_HYPERBOLE_01,		M21_HYPERBOLE_01_MP3,		"V21_HYPERBOLE_01"},
+	{V21_KREN_KREN_01,		M21_KREN_KREN_01_MP3,		"V21_KREN_KREN_01"},
+	{V21_KREN_KREN_02,		M21_KREN_KREN_02_MP3,		"V21_KREN_KREN_02"},
+	{V21_KREN_KREN_03,		M21_KREN_KREN_03_MP3,		"V21_KREN_KREN_03"},
+	{V21_KREN_KREN_04,		M21_KREN_KREN_04_MP3,		"V21_KREN_KREN_04"},
+	{V21_KREN_KREN_05,		M21_KREN_KREN_05_MP3,		"V21_KREN_KREN_05"},
+	{V21_LITOTE_01,		M21_LITOTE_01_MP3,		"V21_LITOTE_01"},
+	{V21_PERIOUS_01,		M21_PERIOUS_01_MP3,		"V21_PERIOUS_01"},
+	{V21_PERIOUS_02,		M21_PERIOUS_02_MP3,		"V21_PERIOUS_02"},
+	{V21_PERIOUS_03,		M21_PERIOUS_03_MP3,		"V21_PERIOUS_03"},
+	{V21_PHAEDRUS_01,		M21_PHAEDRUS_01_MP3,		"V21_PHAEDRUS_01"},
+	{V21_PHAEDRUS_02,		M21_PHAEDRUS_02_MP3,		"V21_PHAEDRUS_02"},
+	{V21_PHAEDRUS_04,		M21_PHAEDRUS_04_MP3,		"V21_PHAEDRUS_04"},
+	{V21_PHAEDRUS_05,		M21_PHAEDRUS_05_MP3,		"V21_PHAEDRUS_05"},
+	{V21_PHAEDRUS_06,		M21_PHAEDRUS_06_MP3,		"V21_PHAEDRUS_06"},
+	{V21_PHAEDRUS_07,		M21_PHAEDRUS_07_MP3,		"V21_PHAEDRUS_07"},
+	{V21_PHAEDRUS_08,		M21_PHAEDRUS_08_MP3,		"V21_PHAEDRUS_08"},
+	{V21_PHAEDRUS_09,		M21_PHAEDRUS_09_MP3,		"V21_PHAEDRUS_09"},
+	{V21_PHAEDRUS_10,		M21_PHAEDRUS_10_MP3,		"V21_PHAEDRUS_10"},
+	{V21_PHAEDRUS_11,		M21_PHAEDRUS_11_MP3,		"V21_PHAEDRUS_11"},
+	{V21_PHAEDRUS_12,		M21_PHAEDRUS_12_MP3,		"V21_PHAEDRUS_12"},
+	{V21_PHAEDRUS_13,		M21_PHAEDRUS_13_MP3,		"V21_PHAEDRUS_13"},
+	{V21_PHAEDRUS_14,		M21_PHAEDRUS_14_MP3,		"V21_PHAEDRUS_14"},
+	{V21_PHAEDRUS_15,		M21_PHAEDRUS_15_MP3,		"V21_PHAEDRUS_15"},
+	{V21_PHAEDRUS_16,		M21_PHAEDRUS_16_MP3,		"V21_PHAEDRUS_16"},
+	{V21_PHAEDRUS_17,		M21_PHAEDRUS_17_MP3,		"V21_PHAEDRUS_17"},
+	{V21_PHAEDRUS_18,		M21_PHAEDRUS_18_MP3,		"V21_PHAEDRUS_18"},
+	{V21_PHAEDRUS_19,		M21_PHAEDRUS_19_MP3,		"V21_PHAEDRUS_19"},
+	{V21_PHAEDRUS_20,		M21_PHAEDRUS_20_MP3,		"V21_PHAEDRUS_20"},
+	{V21_PHAEDRUS_21,		M21_PHAEDRUS_21_MP3,		"V21_PHAEDRUS_21"},
+	{V21_PHAEDRUS_22,		M21_PHAEDRUS_22_MP3,		"V21_PHAEDRUS_22"},
+	{V21_PHAEDRUS_23,		M21_PHAEDRUS_23_MP3,		"V21_PHAEDRUS_23"},
+	{V21_PHAEDRUS_24,		M21_PHAEDRUS_24_MP3,		"V21_PHAEDRUS_24"},
+	{V21_PHAEDRUS_25,		M21_PHAEDRUS_25_MP3,		"V21_PHAEDRUS_25"},
+	{V21_PHAEDRUS_26,		M21_PHAEDRUS_26_MP3,		"V21_PHAEDRUS_26"},
+	{V21_PHIPOLOSSI_01,		M21_PHIPOLOSSI_01_MP3,		"V21_PHIPOLOSSI_01"},
+	{V21_PHIPOLOSSI_02,		M21_PHIPOLOSSI_02_MP3,		"V21_PHIPOLOSSI_02"},
+	{V21_PHIPOLOSSI_03,		M21_PHIPOLOSSI_03_MP3,		"V21_PHIPOLOSSI_03"},
+	{V21_PHIPOLOSSI_04,		M21_PHIPOLOSSI_04_MP3,		"V21_PHIPOLOSSI_04"},
+	{V21_PHIPOLOSSI_05,		M21_PHIPOLOSSI_05_MP3,		"V21_PHIPOLOSSI_05"},
+	{V21_PHIPOLOSSI_06,		M21_PHIPOLOSSI_06_MP3,		"V21_PHIPOLOSSI_06"},
+	{V21_PLODDER_01,			M21_PLODDER_01_MP3,			"V21_PLODDER_01"},
+	{V21_PLODDER_02,			M21_PLODDER_02_MP3,			"V21_PLODDER_02"},
+	{V21_PLODDER_03,			M21_PLODDER_03_MP3,			"V21_PLODDER_03"},
+	{V21_PLODDER_04,			M21_PLODDER_04_MP3,			"V21_PLODDER_04"},
+	{V21_SARGE_01,		M21_SARGE_01_MP3,		"V21_SARGE_01"},
+	{V21_SARGE_02,		M21_SARGE_02_MP3,		"V21_SARGE_02"},
+	{V21_SARGE_03,		M21_SARGE_03_MP3,		"V21_SARGE_03"},
+	{V21_SARGE_04,		M21_SARGE_04_MP3,		"V21_SARGE_04"},
+	{V21_SARGE_05,		M21_SARGE_05_MP3,		"V21_SARGE_05"},
+	{V21_SARGE_06,		M21_SARGE_06_MP3,		"V21_SARGE_06"},
+	{V21_SARGE_07,		M21_SARGE_07_MP3,		"V21_SARGE_07"},
+	{V21_SARGE_08,		M21_SARGE_08_MP3,		"V21_SARGE_08"},
+	{V21_SATIRE_01,			M21_SATIRE_01_MP3,			"V21_SATIRE_01"},
+	{V21_SATIRE_02,			M21_SATIRE_02_MP3,			"V21_SATIRE_02"},
+	{V21_SHELLEY_01,			M21_SHELLEY_01_MP3,			"V21_SHELLEY_01"},
+	{V21_SHELLEY_02,			M21_SHELLEY_02_MP3,			"V21_SHELLEY_02"},
+	{V21_SHELLEY_03,			M21_SHELLEY_03_MP3,			"V21_SHELLEY_03"},
+	{V21_SHELLEY_04,			M21_SHELLEY_04_MP3,			"V21_SHELLEY_04"},
+	{V21_SHELLEY_05,			M21_SHELLEY_05_MP3,			"V21_SHELLEY_05"},
+	{V21_VERILITH_01,			M21_VERILITH_01_MP3,			"V21_VERILITH_01"},
+	{V21_VERILITH_02,			M21_VERILITH_02_MP3,			"V21_VERILITH_02"},
+	{V21_VERILITH_03,			M21_VERILITH_03_MP3,			"V21_VERILITH_03"},
+	{V21_VERILITH_04,			M21_VERILITH_04_MP3,			"V21_VERILITH_04"},
+	{V21_VERILITH_05,			M21_VERILITH_05_MP3,			"V21_VERILITH_05"},
+	{V22_GUY_01,			M22_GUY_01_MP3,			"V22_GUY_01"},
+	{V22_OSCURO_01,			M22_OSCURO_01_MP3,			"V22_OSCURO_01"},
+	{V22_OSCURO_02,			M22_OSCURO_02_MP3,			"V22_OSCURO_02"},
+	{V22_VERILITH_01,			M22_VERILITH_01_MP3,			"V22_VERILITH_01"},
+	{V22_VERILITH_02,			M22_VERILITH_02_MP3,			"V22_VERILITH_02"},
+	{V22_VERILITH_03,			M22_VERILITH_03_MP3,			"V22_VERILITH_03"},
+	{V22_VERILITH_04,			M22_VERILITH_04_MP3,			"V22_VERILITH_04"},
+	{V23_GUY_01,		M23_GUY_01_MP3,		"V23_GUY_01"},
+	{V23_GUY_02,		M23_GUY_02_MP3,		"V23_GUY_02"},
+	{V23_GUY_03,		M23_GUY_03_MP3,		"V23_GUY_03"},
+	{V23_INSANITO_01,		M23_INSANITO_01_MP3,		"V23_INSANITO_01"},
+	{V23_INSANITO_02,		M23_INSANITO_02_MP3,		"V23_INSANITO_02"},
+	{V23_INSANITO_03,		M23_INSANITO_03_MP3,		"V23_INSANITO_03"},
+	{V23_INSANITO_04,		M23_INSANITO_04_MP3,		"V23_INSANITO_04"},
+	{V23_INSANITO_05,		M23_INSANITO_05_MP3,		"V23_INSANITO_05"},
+	{V23_VERILITH_01,		M23_VERILITH_01_MP3,		"V23_VERILITH_01"},
+	{V24_GUY_01,		M24_GUY_01_MP3,		"V24_GUY_01"},
+	{V24_GUY_02,		M24_GUY_02_MP3,		"V24_GUY_02"},
+	{V24_GUY_03,		M24_GUY_03_MP3,		"V24_GUY_03"},
+	{V24_MANAGOTA_01,		M24_MANAGOTA_01_MP3,		"V24_MANAGOTA_01"},
+	{V24_MANAGOTA_02,		M24_MANAGOTA_02_MP3,		"V24_MANAGOTA_02"},
+	{V24_MANAGOTA_03,		M24_MANAGOTA_03_MP3,		"V24_MANAGOTA_03"},
+	{V24_MANAGOTA_04,		M24_MANAGOTA_04_MP3,		"V24_MANAGOTA_04"},
+	{V25_BBOW_01,			M25_BBOW_01_MP3,			"V25_BBOW_01"},
+	{V25_BBOW_02,			M25_BBOW_02_MP3,			"V25_BBOW_02"},
+	{V25_BBOW_03,			M25_BBOW_03_MP3,			"V25_BBOW_03"},
+	{V25_BBOW_04,			M25_BBOW_04_MP3,			"V25_BBOW_04"},
+	{V25_GUY_01,			M25_GUY_01_MP3,			"V25_GUY_01"},
+	{V25_GUY_02,			M25_GUY_02_MP3,			"V25_GUY_02"},
+	{V25_VERILITH_01,			M25_VERILITH_01_MP3,			"V25_VERILITH_01"},
+	{V26_GUY_01,			M26_GUY_01_MP3,			"V26_GUY_01"},
+	{V26_GUY_02,			M26_GUY_02_MP3,			"V26_GUY_02"},
+	{V26_GUY_03,			M26_GUY_03_MP3,			"V26_GUY_03"},
+	{V26_GUY_04,			M26_GUY_04_MP3,			"V26_GUY_04"},
+	{V26_GUY_05,			M26_GUY_05_MP3,			"V26_GUY_05"},
+	{V26_FDOE_01,			M26_FDOE_01_MP3,			"V26_FDOE_01"},
+	{V26_FDOE_02,			M26_FDOE_02_MP3,			"V26_FDOE_02"},
+	{V26_FDOE_03,			M26_FDOE_03_MP3,			"V26_FDOE_03"},
+	{V26_FDOE_04,			M26_FDOE_04_MP3,			"V26_FDOE_04"},
+	{V27_AYONN_01,			M27_AYONN_01_MP3,			"V27_AYONN_01"},
+	{V27_AYONN_02,			M27_AYONN_02_MP3,			"V27_AYONN_02"},
+	{V27_AYONN_03,			M27_AYONN_03_MP3,			"V27_AYONN_03"},
+	{V27_AYONN_04,			M27_AYONN_04_MP3,			"V27_AYONN_04"},
+	{V27_BALE_01,			M27_BALE_01_MP3,			"V27_BALE_01"},
+	{V27_BALE_02,			M27_BALE_02_MP3,			"V27_BALE_02"},
+	{V27_BALE_03,			M27_BALE_03_MP3,			"V27_BALE_03"},
+	{V27_GUY_01,			M27_GUY_01_MP3,			"V27_GUY_01"},
+	{V27_GUY_02,			M27_GUY_02_MP3,			"V27_GUY_02"},
+	{V27_GUY_03,			M27_GUY_03_MP3,			"V27_GUY_03"},
+	{V27_ONABILDEN_01,			M27_ONABILDEN_01_MP3,			"V27_ONABILDEN_01"},
+	{V27_ONABILDEN_02,			M27_ONABILDEN_02_MP3,			"V27_ONABILDEN_02"},
+	{V27_ONABILDEN_03,			M27_ONABILDEN_03_MP3,			"V27_ONABILDEN_03"},
+	{V27_ONABILDEN_04,			M27_ONABILDEN_04_MP3,			"V27_ONABILDEN_04"},
+	{V28_FINN_01,			M28_FINN_01_MP3,			"V28_FINN_01"},
+	{V28_FINN_02,			M28_FINN_02_MP3,			"V28_FINN_02"},
+	{V28_FINN_03,			M28_FINN_03_MP3,			"V28_FINN_03"},
+	{V28_GUY_01,				M28_GUY_01_MP3,				"V28_GUY_01"},
+	{V28_GUY_02,				M28_GUY_02_MP3,				"V28_GUY_02"},
+	{V28_GUY_03,				M28_GUY_03_MP3,				"V28_GUY_03"},
+	{V29_ALERE_01,			M29_ALERE_01_MP3,			"V29_ALERE_01"},
+	{V29_ALERE_02,			M29_ALERE_02_MP3,			"V29_ALERE_02"},
+	{V29_ALERE_03,			M29_ALERE_03_MP3,			"V29_ALERE_03"},
+	{V29_AOLOS_01,			M29_AOLOS_01_MP3,			"V29_AOLOS_01"},
+	{V29_AOLOS_02,			M29_AOLOS_02_MP3,			"V29_AOLOS_02"},
+	{V29_AOLOS_03,			M29_AOLOS_03_MP3,			"V29_AOLOS_03"},
+	{V29_AOLOS_04,			M29_AOLOS_04_MP3,			"V29_AOLOS_04"},
+	{V29_AOLOS_05,			M29_AOLOS_05_MP3,			"V29_AOLOS_05"},
+	{V29_GUY_01,		M29_GUY_01_MP3,		"V29_GUY_01"},
+	{V29_GUY_02,		M29_GUY_02_MP3,		"V29_GUY_02"},
+	{V29_GUY_03,		M29_GUY_03_MP3,		"V29_GUY_03"},
+	{V29_GUY_04,		M29_GUY_04_MP3,		"V29_GUY_04"},
+	{V29_GUY_05,		M29_GUY_05_MP3,		"V29_GUY_05"},
+	{V29_GUY_06,		M29_GUY_06_MP3,		"V29_GUY_06"},
+	{V29_GUY_07,		M29_GUY_07_MP3,		"V29_GUY_07"},
+	{V29_GUY_08,		M29_GUY_08_MP3,		"V29_GUY_08"},
+	{V29_GUY_09,		M29_GUY_09_MP3,		"V29_GUY_09"},
+	{V29_GUY_10,		M29_GUY_10_MP3,		"V29_GUY_10"},
+	{V29_GUY_11,		M29_GUY_11_MP3,		"V29_GUY_11"},
+	{V29_GUY_12,		M29_GUY_12_MP3,		"V29_GUY_12"},
+	{V29_GUY_13,		M29_GUY_13_MP3,		"V29_GUY_13"},
+	{V29_GUY_14,		M29_GUY_14_MP3,		"V29_GUY_14"},
+	{V29_GUY_15,		M29_GUY_15_MP3,		"V29_GUY_15"},
+	{V29_KORENAAR_01,		M29_KORENAAR_01_MP3,		"V29_KORENAAR_01"},
+	{V29_KORENAAR_02,		M29_KORENAAR_02_MP3,		"V29_KORENAAR_02"},
+	{V29_KORENAAR_03,		M29_KORENAAR_03_MP3,		"V29_KORENAAR_03"},
+	{V29_KORENAAR_04,		M29_KORENAAR_04_MP3,		"V29_KORENAAR_04"},
+	{V29_KORENAAR_05,		M29_KORENAAR_05_MP3,		"V29_KORENAAR_05"},
+	{V29_PHARIBOS_01,		M29_PHARIBOS_01_MP3,		"V29_PHARIBOS_01"},
+	{V29_PHARIBOS_02,		M29_PHARIBOS_02_MP3,		"V29_PHARIBOS_02"},
+	{V29_VELEGAL_01,		M29_VELEGAL_01_MP3,		"V29_VELEGAL_01"},
+	{V29_VELEGAL_02,		M29_VELEGAL_02_MP3,		"V29_VELEGAL_02"},
+	{V30_AOLOS_01,		M30_AOLOS_01_MP3,		"V30_AOLOS_01"},
+	{V30_AOLOS_02,		M30_AOLOS_02_MP3,		"V30_AOLOS_02"},
+	{V30_AOLOS_03,		M30_AOLOS_03_MP3,		"V30_AOLOS_03"},
+	{V30_AOLOS_04,		M30_AOLOS_04_MP3,		"V30_AOLOS_04"},
+	{V30_AOLOS_05,		M30_AOLOS_05_MP3,		"V30_AOLOS_05"},
+	{V30_AOLOS_06,		M30_AOLOS_06_MP3,		"V30_AOLOS_06"},
+	{V30_AOLOS_07,		M30_AOLOS_07_MP3,		"V30_AOLOS_07"},
+	{V30_AOLOS_08,		M30_AOLOS_08_MP3,		"V30_AOLOS_08"},
+	{V30_AOLOS_09,		M30_AOLOS_09_MP3,		"V30_AOLOS_09"},
+	{V30_AOLOS_11,		M30_AOLOS_11_MP3,		"V30_AOLOS_11"},
+	{V30_AOLOS_12,		M30_AOLOS_12_MP3,		"V30_AOLOS_12"},
+	{V30_AOLOS_13,		M30_AOLOS_13_MP3,		"V30_AOLOS_13"},
+	{V30_AOLOS_14,		M30_AOLOS_14_MP3,		"V30_AOLOS_14"},
+	{V30_AOLOS_15,		M30_AOLOS_15_MP3,		"V30_AOLOS_15"},
+	{V30_AOLOS_16,		M30_AOLOS_16_MP3,		"V30_AOLOS_16"},
+	{V30_AOLOS_17,		M30_AOLOS_17_MP3,		"V30_AOLOS_17"},
+	{V30_AOLOS_18,		M30_AOLOS_18_MP3,		"V30_AOLOS_18"},
+	{V30_AOLOS_19,		M30_AOLOS_19_MP3,		"V30_AOLOS_19"},
+	{V30_AOLOS_20,		M30_AOLOS_20_MP3,		"V30_AOLOS_20"},
+	{V30_CASINOX_01,		M30_CASINOX_01_MP3,		"V30_CASINOX_01"},
+	{V30_CASINOX_02,		M30_CASINOX_02_MP3,		"V30_CASINOX_02"},
+	{V30_CASINOX_03,		M30_CASINOX_03_MP3,		"V30_CASINOX_03"},
+	{V30_CASINOX_04,		M30_CASINOX_04_MP3,		"V30_CASINOX_04"},
+	{V30_CASINOX_05,		M30_CASINOX_05_MP3,		"V30_CASINOX_05"},
+	{V30_CASINOX_06,		M30_CASINOX_06_MP3,		"V30_CASINOX_06"},
+	{V30_CHICKEN_EXPLOSION_01,		M30_CHICKEN_EXPLOSION_01_MP3,		"V30_CHICKEN_EXPLOSION_01"},
+	{V30_CHICKEN_EXPLOSION_02,		M30_CHICKEN_EXPLOSION_02_MP3,		"V30_CHICKEN_EXPLOSION_02"},
+	{V30_DOPEFISH_01,		M30_DOPEFISH_01_MP3,		"V30_DOPEFISH_01"},
+	{V30_DOPEFISH_02,		M30_DOPEFISH_02_MP3,		"V30_DOPEFISH_02"},
+	{V30_DOPEFISH_03,		M30_DOPEFISH_03_MP3,		"V30_DOPEFISH_03"},
+	{V30_DOPEFISH_04,		M30_DOPEFISH_04_MP3,		"V30_DOPEFISH_04"},
+	{V30_GUY_01,		M30_GUY_01_MP3,		"V30_GUY_01"},
+	{V30_GUY_02,		M30_GUY_02_MP3,		"V30_GUY_02"},
+	{V30_JOHN_01,		M30_JOHN_01_MP3,		"V30_JOHN_01"},
+	{V30_JOHN_02,		M30_JOHN_02_MP3,		"V30_JOHN_02"},
+	{V30_JOHN_03,		M30_JOHN_03_MP3,		"V30_JOHN_03"},
+	{V30_JOHN_04,		M30_JOHN_04_MP3,		"V30_JOHN_04"},
+	{V30_JOHN_05,		M30_JOHN_05_MP3,		"V30_JOHN_05"},
+	{V30_LUCAS_01,		M30_LUCAS_01_MP3,		"V30_LUCAS_01"},
+	{V30_LUCAS_02,		M30_LUCAS_02_MP3,		"V30_LUCAS_02"},
+	{V30_LUCAS_03,		M30_LUCAS_03_MP3,		"V30_LUCAS_03"},
+	{V30_LUCAS_04,		M30_LUCAS_04_MP3,		"V30_LUCAS_04"},
+	{V30_STEVIE_01,		M30_STEVIE_01_MP3,		"V30_STEVIE_01"},
+	{V30_STEVIE_02,		M30_STEVIE_02_MP3,		"V30_STEVIE_02"},
+	{V30_STEVIE_03,		M30_STEVIE_03_MP3,		"V30_STEVIE_03"},
+	{V30_STEVIE_04,		M30_STEVIE_04_MP3,		"V30_STEVIE_04"},
+	{V30_STEVIE_05,		M30_STEVIE_05_MP3,		"V30_STEVIE_05"},
+	{V30_STEVIE_06,		M30_STEVIE_06_MP3,		"V30_STEVIE_06"},
+	{V30_STEVIE_07,		M30_STEVIE_07_MP3,		"V30_STEVIE_07"},
+	{V30_STEVIE_08,		M30_STEVIE_08_MP3,		"V30_STEVIE_08"},
+	{V30_STEVIE_09,		M30_STEVIE_09_MP3,		"V30_STEVIE_09"},
+	{V30_STEVIE_10,		M30_STEVIE_10_MP3,		"V30_STEVIE_10"},
+	{V30_TOM_01,		M30_TOM_01_MP3,		"V30_TOM_01"},
+	{V30_TOM_02,		M30_TOM_02_MP3,		"V30_TOM_02"},
+	{V30_TOM_03,		M30_TOM_03_MP3,		"V30_TOM_03"},
+	{V30_TOM_04,		M30_TOM_04_MP3,		"V30_TOM_04"},
+	{V30_TOM_05,		M30_TOM_05_MP3,		"V30_TOM_05"},
+	{V30_TOM_06,		M30_TOM_06_MP3,		"V30_TOM_06"},
+	{V30_VERILITH_01,		M30_VERILITH_01_MP3,		"V30_VERILITH_01"},
+	{V30_VERILITH_02,		M30_VERILITH_02_MP3,		"V30_VERILITH_02"},
+	{V30_VERILITH_03,		M30_VERILITH_03_MP3,		"V30_VERILITH_03"},
+	{V30_VERILITH_04,		M30_VERILITH_04_MP3,		"V30_VERILITH_04"},
+	{V30_VERILITH_05,		M30_VERILITH_05_MP3,		"V30_VERILITH_05"},
+	{V30_VERILITH_06,		M30_VERILITH_06_MP3,		"V30_VERILITH_06"},
+	{V30_VERILITH_07,		M30_VERILITH_07_MP3,		"V30_VERILITH_07"},
+	{OUTRO_DOLLY_01,			OUTRO_DOLLY_01_MP3,			"OUTRO_DOLLY_01"},
+	{OUTRO_DOLLY_02,			OUTRO_DOLLY_02_MP3,			"OUTRO_DOLLY_02"},
+	{OUTRO_DOLLY_03,			OUTRO_DOLLY_03_MP3,			"OUTRO_DOLLY_03"},
+	{OUTRO_DOLLY_04,			OUTRO_DOLLY_04_MP3,			"OUTRO_DOLLY_04"},
+	{OUTRO_DOLLY_05,			OUTRO_DOLLY_05_MP3,			"OUTRO_DOLLY_05"},
+	{OUTRO_DOLLY_06,			OUTRO_DOLLY_06_MP3,			"OUTRO_DOLLY_06"},
+	{OUTRO_DOLLY_07,			OUTRO_DOLLY_07_MP3,			"OUTRO_DOLLY_07"},
+	{OUTRO_DOLLY_08,			OUTRO_DOLLY_08_MP3,			"OUTRO_DOLLY_08"},
+	{OUTRO_DOLLY_09,			OUTRO_DOLLY_09_MP3,			"OUTRO_DOLLY_09"},
+	{OUTRO_DOLLY_10,			OUTRO_DOLLY_10_MP3,			"OUTRO_DOLLY_10"},
+	{OUTRO_DOLLY_11,			OUTRO_DOLLY_11_MP3,			"OUTRO_DOLLY_11"},
+	{OUTRO_DOLLY_12,			OUTRO_DOLLY_12_MP3,			"OUTRO_DOLLY_12"},
+	{OUTRO_DOLLY_13,			OUTRO_DOLLY_13_MP3,			"OUTRO_DOLLY_13"},
+	{OUTRO_DOLLY_14,			OUTRO_DOLLY_14_MP3,			"OUTRO_DOLLY_14"},
+	{OUTRO_DOLLY_15,			OUTRO_DOLLY_15_MP3,			"OUTRO_DOLLY_15"},
+	{OUTRO_DOLLY_16,			OUTRO_DOLLY_16_MP3,			"OUTRO_DOLLY_16"},
+	{OUTRO_DOLLY_17,			OUTRO_DOLLY_17_MP3,			"OUTRO_DOLLY_17"},
+	{OUTRO_DOLLY_18,			OUTRO_DOLLY_18_MP3,			"OUTRO_DOLLY_18"},
+	{OUTRO_DOREK_01,			OUTRO_DOREK_01_MP3,			"OUTRO_DOREK_01"},
+	{OUTRO_DOREK_02,			OUTRO_DOREK_02_MP3,			"OUTRO_DOREK_02"},
+	{OUTRO_DOREK_03,			OUTRO_DOREK_03_MP3,			"OUTRO_DOREK_03"},
+	{OUTRO_DOREK_04,			OUTRO_DOREK_04_MP3,			"OUTRO_DOREK_04"},
+	{OUTRO_DOREK_05,			OUTRO_DOREK_05_MP3,			"OUTRO_DOREK_05"},
+	{OUTRO_DOREK_06,			OUTRO_DOREK_06_MP3,			"OUTRO_DOREK_06"},
+	{OUTRO_GUY_01,			OUTRO_GUY_01_MP3,			"OUTRO_GUY_01"},
+	{OUTRO_GUY_02,			OUTRO_GUY_02_MP3,			"OUTRO_GUY_02"},
+	{OUTRO_GUY_03,			OUTRO_GUY_03_MP3,			"OUTRO_GUY_03"},
+	{OUTRO_GUY_04,			OUTRO_GUY_04_MP3,			"OUTRO_GUY_04"},
+	{OUTRO_GUY_05,			OUTRO_GUY_05_MP3,			"OUTRO_GUY_05"},
+	{OUTRO_GUY_06,			OUTRO_GUY_06_MP3,			"OUTRO_GUY_06"},
+	{OUTRO_JENKINS_01,		OUTRO_JENKINS_01_MP3,		"OUTRO_JENKINS_01"},
+	{OUTRO_JENKINS_02,		OUTRO_JENKINS_02_MP3,		"OUTRO_JENKINS_02"},
+	{OUTRO_JENKINS_03,		OUTRO_JENKINS_03_MP3,		"OUTRO_JENKINS_03"},
+	{OUTRO_JENKINS_04,		OUTRO_JENKINS_04_MP3,		"OUTRO_JENKINS_04"},
+	{OUTRO_JENKINS_05,		OUTRO_JENKINS_05_MP3,		"OUTRO_JENKINS_05"},
+	{OUTRO_SARGE_01,			OUTRO_SARGE_01_MP3,			"OUTRO_SARGE_01"},
+	{OUTRO_SARGE_02,			OUTRO_SARGE_02_MP3,			"OUTRO_SARGE_02"},
+	{OUTRO_SARGE_03,			OUTRO_SARGE_03_MP3,			"OUTRO_SARGE_03"},
+	{OUTRO_SARGE_04,			OUTRO_SARGE_04_MP3,			"OUTRO_SARGE_04"},
+	{OUTRO_SARGE_05,			OUTRO_SARGE_05_MP3,			"OUTRO_SARGE_05"},
+	{OUTRO_SARGE_06,			OUTRO_SARGE_06_MP3,			"OUTRO_SARGE_06"},
+	{GUY_GOT_A_JOB,			GUY_GOT_A_JOB_MP3,			"GUY_GOT_A_JOB"},
+	{GUY_WINS,				GUY_WINS_MP3,				"GUY_WINS"},
+	{GUY_ENERGY_CELL,		GUY_ENERGY_CELL_MP3,		"GUY_ENERGY_CELL"},
+	{GUY_COMPLETED,			GUY_COMPLETED_MP3,			"GUY_COMPLETED"},
+	{GUY_GOT_SOMETHING,		GUY_GOT_SOMETHING_MP3,		"GUY_GOT_SOMETHING"},
+	{HDB_INTRO,				HDB_INTRO_MP3,				"HDB_INTRO"},
+
+	{LAST_SOUND,			NULL,						NULL}
+};
+
 bool Sound::init() {
 	warning("STUB: Sound::init()");
 	return true;
diff --git a/engines/hdb/sound.h b/engines/hdb/sound.h
index 3cbb5fb..5774a67 100644
--- a/engines/hdb/sound.h
+++ b/engines/hdb/sound.h
@@ -23,6 +23,30 @@
 #ifndef HDB_SOUND_H
 #define HDB_SOUND_H
 
+#define	SFNAME_TITLE		"jungle"
+#define	SFNAME_MENU			"on_a_mission"
+#define	SFNAME_ROBO			"low_techno"
+#define	SFNAME_MEXI			"ambient_mexi_howl"
+#define	SFNAME_BASSO		"amb_walkin_basso"
+#define	SFNAME_WIND			"dangerous_wind"
+#define	SFNAME_INDUSTRO		"industro_hunch"
+#define	SFNAME_JACKIN		"jaround"
+#define	SFNAME_SNEAKERS		"lost_my_sneakers"
+#define	SFNAME_QUIET		"mysterious_quiet"
+#define	SFNAME_JEEBIES		"jeebies5B"
+#define	SFNAME_VIBRACIOUS	"vibracious_(dope_delivery_mix)"
+#define	SFNAME_ROMANTIC		"romantic"
+#define	SFNAME_ARETHERE		"AreWeThereYet_(extended)"
+
+#define	SFNAME_CORRIDOR		"corridor(extended)"
+#define SFNAME_MOKE			"moke_a_doke_doke"
+#define	SFNAME_TILES		"tilesache(extended)"
+#define SFNAME_DARKVIB		"vibracious_(Dark_Delivery_Mix)"
+#define SFNAME_EXPER		"experimentatus_(extended)"
+
+#define		FIRST_VOICE		V00_AIRLOCK_01
+#define		NUM_VOICES		( LAST_SOUND - FIRST_VOICE )
+
 namespace HDB {
 
 enum {
@@ -1381,7 +1405,7 @@ enum SoundType {
 struct SoundLookUp {
 	SoundType idx;
 	char *name;			// name from MSD .h file
-	char*luaName;		// name for Lua code to use
+	char *luaName;		// name for Lua code to use
 };
 
 class Sound {


Commit: 4c012861bcf9b9babb95df2d2faaed380d914859
    https://github.com/scummvm/scummvm/commit/4c012861bcf9b9babb95df2d2faaed380d914859
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:27+02:00

Commit Message:
HDB: Play a MP3 sound from hdb.cpp

Changed paths:
    engines/hdb/hdb.cpp
    engines/hdb/hdb.h


diff --git a/engines/hdb/hdb.cpp b/engines/hdb/hdb.cpp
index ec99b7e..cde6aa3 100644
--- a/engines/hdb/hdb.cpp
+++ b/engines/hdb/hdb.cpp
@@ -858,6 +858,13 @@ Common::Error HDBGame::run() {
 	initGraphics(kScreenWidth, kScreenHeight, &_format);
 	_console = new Console();
 
+#if USE_MAD
+	Common::SeekableReadStream *soundStream = _fileMan->findFirstData("M00_AIRLOCK_01_MP3", TYPE_BINARY);
+	Audio::SeekableAudioStream *audioStream = Audio::makeMP3Stream(soundStream, DisposeAfterUse::YES);
+	Audio::SoundHandle *handle = new Audio::SoundHandle();
+	g_hdb->_mixer->playStream(Audio::Mixer::kPlainSoundType, handle, audioStream);
+#endif
+
 	start();
 
 #if 0
diff --git a/engines/hdb/hdb.h b/engines/hdb/hdb.h
index cea8ab3..c6c26f9 100644
--- a/engines/hdb/hdb.h
+++ b/engines/hdb/hdb.h
@@ -36,6 +36,10 @@
 #include "common/config-manager.h"
 #include "graphics/surface.h"
 #include "graphics/thumbnail.h"
+#include "audio/mixer.h"
+#include "audio/audiostream.h"
+#include "audio/decoders/wave.h"
+#include "audio/decoders/mp3.h"
 
 #include "gui/debugger.h"
 #include "engines/engine.h"


Commit: c131e7c8903be4e782c48736b6d9cdb82b768b87
    https://github.com/scummvm/scummvm/commit/c131e7c8903be4e782c48736b6d9cdb82b768b87
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:27+02:00

Commit Message:
HDB: Fix compilation

Changed paths:
    engines/hdb/hdb.cpp


diff --git a/engines/hdb/hdb.cpp b/engines/hdb/hdb.cpp
index cde6aa3..d85b548 100644
--- a/engines/hdb/hdb.cpp
+++ b/engines/hdb/hdb.cpp
@@ -858,7 +858,7 @@ Common::Error HDBGame::run() {
 	initGraphics(kScreenWidth, kScreenHeight, &_format);
 	_console = new Console();
 
-#if USE_MAD
+#ifdef USE_MAD
 	Common::SeekableReadStream *soundStream = _fileMan->findFirstData("M00_AIRLOCK_01_MP3", TYPE_BINARY);
 	Audio::SeekableAudioStream *audioStream = Audio::makeMP3Stream(soundStream, DisposeAfterUse::YES);
 	Audio::SoundHandle *handle = new Audio::SoundHandle();


Commit: f7713df735d185848912d156f0c8615523052d8a
    https://github.com/scummvm/scummvm/commit/f7713df735d185848912d156f0c8615523052d8a
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:27+02:00

Commit Message:
HDB: Fix warnings

Changed paths:
    engines/hdb/sound.h


diff --git a/engines/hdb/sound.h b/engines/hdb/sound.h
index 5774a67..56702c0 100644
--- a/engines/hdb/sound.h
+++ b/engines/hdb/sound.h
@@ -1404,8 +1404,8 @@ enum SoundType {
 
 struct SoundLookUp {
 	SoundType idx;
-	char *name;			// name from MSD .h file
-	char *luaName;		// name for Lua code to use
+	const char *name;			// name from MSD .h file
+	const char *luaName;		// name for Lua code to use
 };
 
 class Sound {


Commit: 0c8e483d091a40d0011934213d2e8087a52eb810
    https://github.com/scummvm/scummvm/commit/0c8e483d091a40d0011934213d2e8087a52eb810
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:27+02:00

Commit Message:
HDB: const'ness

Changed paths:
    engines/hdb/sound.cpp


diff --git a/engines/hdb/sound.cpp b/engines/hdb/sound.cpp
index 7dab388..78b765a 100644
--- a/engines/hdb/sound.cpp
+++ b/engines/hdb/sound.cpp
@@ -24,7 +24,7 @@
 
 namespace HDB {
 
-SoundLookUp soundList[] =  {
+const SoundLookUp soundList[] =  {
 	//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 	//
 	// List of all the sounds we need


Commit: b845e70102afff09e2377e37ea5831380549bb0d
    https://github.com/scummvm/scummvm/commit/b845e70102afff09e2377e37ea5831380549bb0d
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:27+02:00

Commit Message:
HDB: Reduce header dependency

Changed paths:
    engines/hdb/ai-bots.cpp
    engines/hdb/ai-funcs.cpp
    engines/hdb/ai-init.cpp
    engines/hdb/ai-player.cpp
    engines/hdb/gfx.cpp
    engines/hdb/hdb.cpp
    engines/hdb/hdb.h
    engines/hdb/lua-script.cpp
    engines/hdb/menu.cpp
    engines/hdb/sound.cpp
    engines/hdb/window.cpp


diff --git a/engines/hdb/ai-bots.cpp b/engines/hdb/ai-bots.cpp
index e9cb229..b9e761b 100644
--- a/engines/hdb/ai-bots.cpp
+++ b/engines/hdb/ai-bots.cpp
@@ -21,6 +21,7 @@
  */
 
 #include "hdb/hdb.h"
+#include "hdb/mpc.h"
 
 namespace HDB {
 
@@ -2546,7 +2547,7 @@ void aiGatePuddleInit2(AIEntity *e) {
 void aiGatePuddleAction(AIEntity *e) {
 	static const int xva[5] = {9, 0, 0,-1, 1};
 	static const int yva[5] = {9,-1, 1, 0, 0};
-	
+
 	AIEntity *p = g_hdb->_ai->getPlayer();
 
 	if (e->goalX) {
diff --git a/engines/hdb/ai-funcs.cpp b/engines/hdb/ai-funcs.cpp
index e383670..d8d2b71 100644
--- a/engines/hdb/ai-funcs.cpp
+++ b/engines/hdb/ai-funcs.cpp
@@ -21,6 +21,7 @@
  */
 
 #include "hdb/hdb.h"
+#include "hdb/mpc.h"
 
 namespace HDB {
 
diff --git a/engines/hdb/ai-init.cpp b/engines/hdb/ai-init.cpp
index b0e27f3..f66a1d6 100644
--- a/engines/hdb/ai-init.cpp
+++ b/engines/hdb/ai-init.cpp
@@ -21,6 +21,7 @@
  */
 
 #include "hdb/hdb.h"
+#include "hdb/mpc.h"
 
 namespace HDB {
 
diff --git a/engines/hdb/ai-player.cpp b/engines/hdb/ai-player.cpp
index 86d22b2..dbd4439 100644
--- a/engines/hdb/ai-player.cpp
+++ b/engines/hdb/ai-player.cpp
@@ -22,6 +22,7 @@
 
 #include "hdb/hdb.h"
 #include "hdb/menu.h"
+#include "hdb/mpc.h"
 
 namespace HDB {
 
diff --git a/engines/hdb/gfx.cpp b/engines/hdb/gfx.cpp
index 641f179..873ca72 100644
--- a/engines/hdb/gfx.cpp
+++ b/engines/hdb/gfx.cpp
@@ -21,6 +21,7 @@
  */
 
 #include "hdb/hdb.h"
+#include "hdb/mpc.h"
 
 namespace HDB {
 
diff --git a/engines/hdb/hdb.cpp b/engines/hdb/hdb.cpp
index d85b548..15240f6 100644
--- a/engines/hdb/hdb.cpp
+++ b/engines/hdb/hdb.cpp
@@ -33,6 +33,7 @@
 #include "hdb/hdb.h"
 #include "hdb/console.h"
 #include "hdb/menu.h"
+#include "hdb/mpc.h"
 
 #define CHEAT_PATCHES 0
 
diff --git a/engines/hdb/hdb.h b/engines/hdb/hdb.h
index c6c26f9..29f46db 100644
--- a/engines/hdb/hdb.h
+++ b/engines/hdb/hdb.h
@@ -46,7 +46,6 @@
 #include "engines/util.h"
 #include "console.h"
 
-#include "hdb/mpc.h"
 #include "hdb/gfx.h"
 #include "hdb/ai.h"
 #include "hdb/ai-player.h"
diff --git a/engines/hdb/lua-script.cpp b/engines/hdb/lua-script.cpp
index c0e3a57..83eb87a 100644
--- a/engines/hdb/lua-script.cpp
+++ b/engines/hdb/lua-script.cpp
@@ -26,6 +26,7 @@
 #include "common/debug.h"
 
 #include "hdb/lua-script.h"
+#include "hdb/mpc.h"
 
 namespace HDB {
 
diff --git a/engines/hdb/menu.cpp b/engines/hdb/menu.cpp
index f97cacf..d65402b 100644
--- a/engines/hdb/menu.cpp
+++ b/engines/hdb/menu.cpp
@@ -22,6 +22,7 @@
 
 #include "hdb/hdb.h"
 #include "hdb/menu.h"
+#include "hdb/mpc.h"
 
 namespace HDB {
 
diff --git a/engines/hdb/sound.cpp b/engines/hdb/sound.cpp
index 78b765a..5fdd016 100644
--- a/engines/hdb/sound.cpp
+++ b/engines/hdb/sound.cpp
@@ -21,6 +21,7 @@
  */
 
 #include "hdb/hdb.h"
+#include "hdb/mpc.h"
 
 namespace HDB {
 
diff --git a/engines/hdb/window.cpp b/engines/hdb/window.cpp
index b717a0e..52442bd 100644
--- a/engines/hdb/window.cpp
+++ b/engines/hdb/window.cpp
@@ -21,6 +21,7 @@
  */
 
 #include "hdb/hdb.h"
+#include "hdb/mpc.h"
 
 namespace HDB {
 


Commit: c3d0f49538a441069d42944b52b73bd7d1c5952b
    https://github.com/scummvm/scummvm/commit/c3d0f49538a441069d42944b52b73bd7d1c5952b
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:27+02:00

Commit Message:
HDB: Reduce header dependency

Changed paths:
    engines/hdb/ai-bots.cpp
    engines/hdb/ai-cinematic.cpp
    engines/hdb/ai-funcs.cpp
    engines/hdb/ai-init.cpp
    engines/hdb/ai-lists.cpp
    engines/hdb/ai-player.cpp
    engines/hdb/ai-waypoint.cpp
    engines/hdb/gfx.cpp
    engines/hdb/gfx.h
    engines/hdb/hdb.cpp
    engines/hdb/hdb.h
    engines/hdb/input.cpp
    engines/hdb/lua-script.cpp
    engines/hdb/map.cpp
    engines/hdb/menu.cpp
    engines/hdb/saveload.cpp
    engines/hdb/window.cpp


diff --git a/engines/hdb/ai-bots.cpp b/engines/hdb/ai-bots.cpp
index b9e761b..16a52ab 100644
--- a/engines/hdb/ai-bots.cpp
+++ b/engines/hdb/ai-bots.cpp
@@ -21,6 +21,7 @@
  */
 
 #include "hdb/hdb.h"
+#include "hdb/gfx.h"
 #include "hdb/mpc.h"
 
 namespace HDB {
diff --git a/engines/hdb/ai-cinematic.cpp b/engines/hdb/ai-cinematic.cpp
index 05986ca..2c05ad1 100644
--- a/engines/hdb/ai-cinematic.cpp
+++ b/engines/hdb/ai-cinematic.cpp
@@ -21,6 +21,7 @@
  */
 
 #include "hdb/hdb.h"
+#include "hdb/gfx.h"
 
 namespace HDB {
 
diff --git a/engines/hdb/ai-funcs.cpp b/engines/hdb/ai-funcs.cpp
index d8d2b71..5a35e2a 100644
--- a/engines/hdb/ai-funcs.cpp
+++ b/engines/hdb/ai-funcs.cpp
@@ -21,6 +21,7 @@
  */
 
 #include "hdb/hdb.h"
+#include "hdb/gfx.h"
 #include "hdb/mpc.h"
 
 namespace HDB {
diff --git a/engines/hdb/ai-init.cpp b/engines/hdb/ai-init.cpp
index f66a1d6..bcc38f2 100644
--- a/engines/hdb/ai-init.cpp
+++ b/engines/hdb/ai-init.cpp
@@ -21,6 +21,7 @@
  */
 
 #include "hdb/hdb.h"
+#include "hdb/gfx.h"
 #include "hdb/mpc.h"
 
 namespace HDB {
diff --git a/engines/hdb/ai-lists.cpp b/engines/hdb/ai-lists.cpp
index b2f3a69..2fc2112 100644
--- a/engines/hdb/ai-lists.cpp
+++ b/engines/hdb/ai-lists.cpp
@@ -21,6 +21,7 @@
  */
 
 #include "hdb/hdb.h"
+#include "hdb/gfx.h"
 
 namespace HDB {
 
diff --git a/engines/hdb/ai-player.cpp b/engines/hdb/ai-player.cpp
index dbd4439..8492726 100644
--- a/engines/hdb/ai-player.cpp
+++ b/engines/hdb/ai-player.cpp
@@ -21,6 +21,7 @@
  */
 
 #include "hdb/hdb.h"
+#include "hdb/gfx.h"
 #include "hdb/menu.h"
 #include "hdb/mpc.h"
 
diff --git a/engines/hdb/ai-waypoint.cpp b/engines/hdb/ai-waypoint.cpp
index 312c2cf..eed404e 100644
--- a/engines/hdb/ai-waypoint.cpp
+++ b/engines/hdb/ai-waypoint.cpp
@@ -21,6 +21,7 @@
  */
 
 #include "hdb/hdb.h"
+#include "hdb/gfx.h"
 
 namespace HDB {
 
diff --git a/engines/hdb/gfx.cpp b/engines/hdb/gfx.cpp
index 873ca72..5bb557f 100644
--- a/engines/hdb/gfx.cpp
+++ b/engines/hdb/gfx.cpp
@@ -21,6 +21,7 @@
  */
 
 #include "hdb/hdb.h"
+#include "hdb/gfx.h"
 #include "hdb/mpc.h"
 
 namespace HDB {
diff --git a/engines/hdb/gfx.h b/engines/hdb/gfx.h
index 26b0810..9805fc9 100644
--- a/engines/hdb/gfx.h
+++ b/engines/hdb/gfx.h
@@ -29,28 +29,6 @@
 
 namespace HDB {
 
-enum {
-	kScreenWidth = 640,
-	kScreenHeight = 480,
-	kScreenDrawWidth = (kScreenWidth - 160), // visible pixels wide
-	kScreenDrawHeight = 480,
-	kTileWidth = 32,
-	kTileHeight = 32,
-	kMaxSkies = 10,
-	kNum3DStars = 300,
-	kFontSpace = 5,
-	kFontIncrement = 1,
-	kGameFPS = 60,
-	kAnimFrameDelay = kGameFPS / 30,
-	kAnimSlowFrames = kAnimFrameDelay * 10,
-	kAnimMediumFrames = kAnimFrameDelay * 6,
-	kAnimFastFrames = kAnimFrameDelay * 2,
-	kProgressY = (kScreenHeight - 64)
-};
-
-class Tile;
-class Picture;
-
 struct TileLookup {
 	const char *filename;
 	Tile *tData;
diff --git a/engines/hdb/hdb.cpp b/engines/hdb/hdb.cpp
index 15240f6..f2f20a2 100644
--- a/engines/hdb/hdb.cpp
+++ b/engines/hdb/hdb.cpp
@@ -31,6 +31,7 @@
 #include "common/memstream.h"
 
 #include "hdb/hdb.h"
+#include "hdb/gfx.h"
 #include "hdb/console.h"
 #include "hdb/menu.h"
 #include "hdb/mpc.h"
diff --git a/engines/hdb/hdb.h b/engines/hdb/hdb.h
index 29f46db..af04c3b 100644
--- a/engines/hdb/hdb.h
+++ b/engines/hdb/hdb.h
@@ -46,7 +46,33 @@
 #include "engines/util.h"
 #include "console.h"
 
-#include "hdb/gfx.h"
+namespace HDB {
+class Tile;
+class Picture;
+class Menu;
+class Gfx;
+
+enum {
+	kScreenWidth = 640,
+	kScreenHeight = 480,
+	kScreenDrawWidth = (kScreenWidth - 160), // visible pixels wide
+	kScreenDrawHeight = 480,
+	kTileWidth = 32,
+	kTileHeight = 32,
+	kMaxSkies = 10,
+	kNum3DStars = 300,
+	kFontSpace = 5,
+	kFontIncrement = 1,
+	kGameFPS = 60,
+	kAnimFrameDelay = kGameFPS / 30,
+	kAnimSlowFrames = kAnimFrameDelay * 10,
+	kAnimMediumFrames = kAnimFrameDelay * 6,
+	kAnimFastFrames = kAnimFrameDelay * 2,
+	kProgressY = (kScreenHeight - 64)
+};
+
+}
+
 #include "hdb/ai.h"
 #include "hdb/ai-player.h"
 #include "hdb/file-manager.h"
@@ -60,8 +86,6 @@ struct ADGameDescription;
 
 namespace HDB {
 
-class Menu;
-
 enum GameFeatures {
 	ADGF_TALKIE = 1 << 0
 };
diff --git a/engines/hdb/input.cpp b/engines/hdb/input.cpp
index e345032..b9ab6fe 100644
--- a/engines/hdb/input.cpp
+++ b/engines/hdb/input.cpp
@@ -21,6 +21,7 @@
  */
 
 #include "hdb/hdb.h"
+#include "hdb/gfx.h"
 #include "hdb/menu.h"
 
 namespace HDB {
diff --git a/engines/hdb/lua-script.cpp b/engines/hdb/lua-script.cpp
index 83eb87a..b35caa1 100644
--- a/engines/hdb/lua-script.cpp
+++ b/engines/hdb/lua-script.cpp
@@ -26,6 +26,7 @@
 #include "common/debug.h"
 
 #include "hdb/lua-script.h"
+#include "hdb/gfx.h"
 #include "hdb/mpc.h"
 
 namespace HDB {
diff --git a/engines/hdb/map.cpp b/engines/hdb/map.cpp
index 4467a9f..80db498 100644
--- a/engines/hdb/map.cpp
+++ b/engines/hdb/map.cpp
@@ -21,6 +21,7 @@
  */
 
 #include "hdb/hdb.h"
+#include "hdb/gfx.h"
 
 namespace HDB {
 
diff --git a/engines/hdb/menu.cpp b/engines/hdb/menu.cpp
index d65402b..639adb6 100644
--- a/engines/hdb/menu.cpp
+++ b/engines/hdb/menu.cpp
@@ -21,6 +21,7 @@
  */
 
 #include "hdb/hdb.h"
+#include "hdb/gfx.h"
 #include "hdb/menu.h"
 #include "hdb/mpc.h"
 
diff --git a/engines/hdb/saveload.cpp b/engines/hdb/saveload.cpp
index ef086f4..4f5fd06 100644
--- a/engines/hdb/saveload.cpp
+++ b/engines/hdb/saveload.cpp
@@ -21,6 +21,7 @@
  */
 
 #include "hdb/hdb.h"
+#include "hdb/gfx.h"
 
 namespace HDB {
 
diff --git a/engines/hdb/window.cpp b/engines/hdb/window.cpp
index 52442bd..3499077 100644
--- a/engines/hdb/window.cpp
+++ b/engines/hdb/window.cpp
@@ -21,6 +21,7 @@
  */
 
 #include "hdb/hdb.h"
+#include "hdb/gfx.h"
 #include "hdb/mpc.h"
 
 namespace HDB {


Commit: 17ef555e2d81c2d59a108f9fbecb49f99f392762
    https://github.com/scummvm/scummvm/commit/17ef555e2d81c2d59a108f9fbecb49f99f392762
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:27+02:00

Commit Message:
HDB: Reduce header dependency

Changed paths:
    engines/hdb/gfx.h
    engines/hdb/input.h
    engines/hdb/lua-script.cpp
    engines/hdb/lua-script.h
    engines/hdb/map.h


diff --git a/engines/hdb/gfx.h b/engines/hdb/gfx.h
index 9805fc9..21ccdc9 100644
--- a/engines/hdb/gfx.h
+++ b/engines/hdb/gfx.h
@@ -25,8 +25,6 @@
 
 #include "graphics/managed_surface.h"
 
-#include "hdb/hdb.h"
-
 namespace HDB {
 
 struct TileLookup {
diff --git a/engines/hdb/input.h b/engines/hdb/input.h
index ffd6c0d..11b854a 100644
--- a/engines/hdb/input.h
+++ b/engines/hdb/input.h
@@ -23,8 +23,6 @@
 #ifndef HDB_INPUT_H
 #define HDB_INPUT_H
 
-#include "common/system.h"
-
 namespace HDB {
 
 enum Button {
@@ -88,4 +86,3 @@ private:
 } // End of Namespace
 
 #endif // !HDB_INPUT_H
-
diff --git a/engines/hdb/lua-script.cpp b/engines/hdb/lua-script.cpp
index b35caa1..fc86596 100644
--- a/engines/hdb/lua-script.cpp
+++ b/engines/hdb/lua-script.cpp
@@ -25,6 +25,7 @@
 #include "common/lua/lualib.h"
 #include "common/debug.h"
 
+#include "hdb/hdb.h"
 #include "hdb/lua-script.h"
 #include "hdb/gfx.h"
 #include "hdb/mpc.h"
diff --git a/engines/hdb/lua-script.h b/engines/hdb/lua-script.h
index 10d68c8..3e1ab50 100644
--- a/engines/hdb/lua-script.h
+++ b/engines/hdb/lua-script.h
@@ -20,11 +20,6 @@
  *
  */
 
-#include "common/system.h"
-#include "common/file.h"
-
-#include "hdb/hdb.h"
-
 #ifndef HDB_LUA_SCRIPT_H
 #define HDB_LUA_SCRIPT_H
 
diff --git a/engines/hdb/map.h b/engines/hdb/map.h
index 91cecf1..f80f2d2 100644
--- a/engines/hdb/map.h
+++ b/engines/hdb/map.h
@@ -23,8 +23,6 @@
 #ifndef HDB_MAP_LOADER_H
 #define HDB_MAP_LOADER_H
 
-#include "common/system.h"
-
 namespace HDB {
 
 enum {


Commit: 01d114e5c1992b7ba1bd8c72b9ab48a1ceed99b7
    https://github.com/scummvm/scummvm/commit/01d114e5c1992b7ba1bd8c72b9ab48a1ceed99b7
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:27+02:00

Commit Message:
HDB: Remove leftover file

Changed paths:
  R engines/hdb/font.h


diff --git a/engines/hdb/font.h b/engines/hdb/font.h
deleted file mode 100644
index 6f70f09..0000000
--- a/engines/hdb/font.h
+++ /dev/null
@@ -1 +0,0 @@
-#pragma once


Commit: e53367e2256889f1c6a8fa7adfd96cd20a3e55a8
    https://github.com/scummvm/scummvm/commit/e53367e2256889f1c6a8fa7adfd96cd20a3e55a8
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:27+02:00

Commit Message:
HDB: Fix guard defines

Changed paths:
    engines/hdb/gfx.h
    engines/hdb/map.h
    engines/hdb/window.h


diff --git a/engines/hdb/gfx.h b/engines/hdb/gfx.h
index 21ccdc9..38243c2 100644
--- a/engines/hdb/gfx.h
+++ b/engines/hdb/gfx.h
@@ -20,8 +20,8 @@
  *
  */
 
-#ifndef HDB_DRAW_MANAGER_H
-#define HDB_DRAW_MANAGER_H
+#ifndef HDB_GFX_H
+#define HDB_GFX_H
 
 #include "graphics/managed_surface.h"
 
@@ -269,4 +269,4 @@ private:
 
 } // End of Namespace HDB
 
-#endif // !HDB_DRAW_MANAGER_H
+#endif // !HDB_GFX_H
diff --git a/engines/hdb/map.h b/engines/hdb/map.h
index f80f2d2..89b9b86 100644
--- a/engines/hdb/map.h
+++ b/engines/hdb/map.h
@@ -20,8 +20,8 @@
  *
  */
 
-#ifndef HDB_MAP_LOADER_H
-#define HDB_MAP_LOADER_H
+#ifndef HDB_MAP_H
+#define HDB_MAP_H
 
 namespace HDB {
 
@@ -183,4 +183,4 @@ private:
 };
 }
 
-#endif // !HDB_MAP_LOADER_H
+#endif // !HDB_MAP_H
diff --git a/engines/hdb/window.h b/engines/hdb/window.h
index e230477..672cae5 100644
--- a/engines/hdb/window.h
+++ b/engines/hdb/window.h
@@ -142,7 +142,7 @@ struct DlvsInfo {
 	uint32 delay1, delay2, delay3;
 	bool go1, go2, go3;
 
-	DlvsInfo() : x(0), y(0), width(0), height(0), active(false), selected(0), 
+	DlvsInfo() : x(0), y(0), width(0), height(0), active(false), selected(0),
 		animate(false), delay1(0), delay2(0), delay3(0), go1(false), go2(false), go3(false) {}
 };
 


Commit: 9ea453bc4c54f547972ad05404bde8029ab1219e
    https://github.com/scummvm/scummvm/commit/9ea453bc4c54f547972ad05404bde8029ab1219e
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:27+02:00

Commit Message:
HDB: Reduce header dependency

Changed paths:
    engines/hdb/gfx.cpp
    engines/hdb/gfx.h
    engines/hdb/hdb.h


diff --git a/engines/hdb/gfx.cpp b/engines/hdb/gfx.cpp
index 5bb557f..c59964c 100644
--- a/engines/hdb/gfx.cpp
+++ b/engines/hdb/gfx.cpp
@@ -20,6 +20,9 @@
  *
  */
 
+#include "common/cosinetables.h"
+#include "common/sinetables.h"
+
 #include "hdb/hdb.h"
 #include "hdb/gfx.h"
 #include "hdb/mpc.h"
@@ -220,6 +223,13 @@ void Gfx::loadSaveFile(Common::InSaveFile *in) {
 		turnOnSnow();
 }
 
+double Gfx::getSin(int index) {
+	return _sines->at(index);
+}
+double Gfx::getCos(int index) {
+	return _cosines->at(index);
+}
+
 void Gfx::fillScreen(uint32 color) {
 	_globalSurface.fillRect(Common::Rect(kScreenWidth, kScreenHeight), color);
 	g_system->fillScreen(color);
diff --git a/engines/hdb/gfx.h b/engines/hdb/gfx.h
index 38243c2..903b579 100644
--- a/engines/hdb/gfx.h
+++ b/engines/hdb/gfx.h
@@ -25,6 +25,11 @@
 
 #include "graphics/managed_surface.h"
 
+namespace Common {
+	class SineTable;
+	class CosineTable;
+}
+
 namespace HDB {
 
 struct TileLookup {
@@ -137,12 +142,8 @@ public:
 
 	// Trig Functions
 
-	double getSin(int index) {
-		return _sines->at(index);
-	}
-	double getCos(int index) {
-		return _cosines->at(index);
-	}
+	double getSin(int index);
+	double getCos(int index);
 
 	// Bonus star functions
 
diff --git a/engines/hdb/hdb.h b/engines/hdb/hdb.h
index af04c3b..36f5142 100644
--- a/engines/hdb/hdb.h
+++ b/engines/hdb/hdb.h
@@ -25,14 +25,10 @@
 
 #include "common/scummsys.h"
 #include "common/array.h"
-#include "common/error.h"
-#include "common/file.h"
 #include "common/events.h"
 #include "common/str.h"
 #include "common/random.h"
 #include "common/savefile.h"
-#include "common/sinetables.h"
-#include "common/cosinetables.h"
 #include "common/config-manager.h"
 #include "graphics/surface.h"
 #include "graphics/thumbnail.h"
@@ -44,7 +40,6 @@
 #include "gui/debugger.h"
 #include "engines/engine.h"
 #include "engines/util.h"
-#include "console.h"
 
 namespace HDB {
 class Tile;
@@ -75,6 +70,7 @@ enum {
 
 #include "hdb/ai.h"
 #include "hdb/ai-player.h"
+#include "hdb/console.h"
 #include "hdb/file-manager.h"
 #include "hdb/input.h"
 #include "hdb/lua-script.h"


Commit: 0c29eff799934fb3d624f3d0318c2a9617820a55
    https://github.com/scummvm/scummvm/commit/0c29eff799934fb3d624f3d0318c2a9617820a55
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:27+02:00

Commit Message:
HDB: Remove unused console.cpp

Changed paths:
  R engines/hdb/console.cpp
  R engines/hdb/console.h
    engines/hdb/hdb.cpp
    engines/hdb/hdb.h
    engines/hdb/module.mk


diff --git a/engines/hdb/console.cpp b/engines/hdb/console.cpp
deleted file mode 100644
index 5cb45cf..0000000
--- a/engines/hdb/console.cpp
+++ /dev/null
@@ -1,38 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- */
-
-#include "gui/debugger.h"
-
-#include "hdb/hdb.h"
-#include "hdb/console.h"
-
-namespace HDB {
-
-Console::Console() {
-	_visible = true;
-}
-
-Console::~Console() {
-	_visible = false;
-}
-
-} // End of namespace HDB
diff --git a/engines/hdb/console.h b/engines/hdb/console.h
deleted file mode 100644
index 9b77d41..0000000
--- a/engines/hdb/console.h
+++ /dev/null
@@ -1,40 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
-*
-* ScummVM is the legal property of its developers, whose names
-* are too numerous to list here. Please refer to the COPYRIGHT
-* file distributed with this source distribution.
-*
-* This program is free software; you can redistribute it and/or
-* modify it under the terms of the GNU General Public License
-* as published by the Free Software Foundation; either version 2
-* of the License, or (at your option) any later version.
-*
-* This program is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-* GNU General Public License for more details.
-*
-* You should have received a copy of the GNU General Public License
-* along with this program; if not, write to the Free Software
-* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-*
-*/
-
-#ifndef HDB_CONSOLE_H
-#define HDB_CONSOLE_H
-
-#include "gui/debugger.h"
-
-namespace HDB {
-
-class Game;
-
-class Console : public GUI::Debugger {
-public:
-	explicit Console();
-	virtual ~Console();
-private:
-	bool _visible;
-};
-}
-#endif
diff --git a/engines/hdb/hdb.cpp b/engines/hdb/hdb.cpp
index f2f20a2..67978f0 100644
--- a/engines/hdb/hdb.cpp
+++ b/engines/hdb/hdb.cpp
@@ -32,7 +32,6 @@
 
 #include "hdb/hdb.h"
 #include "hdb/gfx.h"
-#include "hdb/console.h"
 #include "hdb/menu.h"
 #include "hdb/mpc.h"
 
@@ -43,7 +42,6 @@ namespace HDB {
 HDBGame* g_hdb;
 
 HDBGame::HDBGame(OSystem *syst, const ADGameDescription *gameDesc) : Engine(syst), _gameDescription(gameDesc) {
-	_console = nullptr;
 	_format = Graphics::PixelFormat(2, 5, 6, 5, 0, 11, 5, 0, 0);
 	_systemInit = false;
 	g_hdb = this;
@@ -77,7 +75,6 @@ HDBGame::HDBGame(OSystem *syst, const ADGameDescription *gameDesc) : Engine(syst
 }
 
 HDBGame::~HDBGame() {
-	delete _console;
 	delete _fileMan;
 	delete _gfx;
 	delete _lua;
@@ -858,7 +855,6 @@ Common::Error HDBGame::run() {
 
 	// Initializes Graphics
 	initGraphics(kScreenWidth, kScreenHeight, &_format);
-	_console = new Console();
 
 #ifdef USE_MAD
 	Common::SeekableReadStream *soundStream = _fileMan->findFirstData("M00_AIRLOCK_01_MP3", TYPE_BINARY);
diff --git a/engines/hdb/hdb.h b/engines/hdb/hdb.h
index 36f5142..d20f40d 100644
--- a/engines/hdb/hdb.h
+++ b/engines/hdb/hdb.h
@@ -70,7 +70,6 @@ enum {
 
 #include "hdb/ai.h"
 #include "hdb/ai-player.h"
-#include "hdb/console.h"
 #include "hdb/file-manager.h"
 #include "hdb/input.h"
 #include "hdb/lua-script.h"
@@ -339,8 +338,6 @@ private:
 
 	uint32 _tiempo;
 
-	Console *_console;
-
 	// Game Variables
 
 	bool _systemInit;
diff --git a/engines/hdb/module.mk b/engines/hdb/module.mk
index e3e56eb..e3d95db 100644
--- a/engines/hdb/module.mk
+++ b/engines/hdb/module.mk
@@ -10,7 +10,6 @@ MODULE_OBJS := \
 	ai-player.o \
 	ai-use.o \
 	ai-waypoint.o \
-	console.o \
 	detection.o \
 	file-manager.o \
 	gfx.o \


Commit: 99fc798b2eba492931a15f4208aa412f82be8ecd
    https://github.com/scummvm/scummvm/commit/99fc798b2eba492931a15f4208aa412f82be8ecd
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:27+02:00

Commit Message:
HDB: Reduce header dependency

Changed paths:
    engines/hdb/ai-funcs.cpp
    engines/hdb/ai-lists.cpp
    engines/hdb/ai-player.cpp
    engines/hdb/file-manager.cpp
    engines/hdb/gfx.cpp
    engines/hdb/hdb.cpp
    engines/hdb/hdb.h
    engines/hdb/lua-script.cpp
    engines/hdb/map.cpp


diff --git a/engines/hdb/ai-funcs.cpp b/engines/hdb/ai-funcs.cpp
index 5a35e2a..82f9b3b 100644
--- a/engines/hdb/ai-funcs.cpp
+++ b/engines/hdb/ai-funcs.cpp
@@ -21,6 +21,7 @@
  */
 
 #include "hdb/hdb.h"
+#include "hdb/file-manager.h"
 #include "hdb/gfx.h"
 #include "hdb/mpc.h"
 
diff --git a/engines/hdb/ai-lists.cpp b/engines/hdb/ai-lists.cpp
index 2fc2112..326d18c 100644
--- a/engines/hdb/ai-lists.cpp
+++ b/engines/hdb/ai-lists.cpp
@@ -21,6 +21,7 @@
  */
 
 #include "hdb/hdb.h"
+#include "hdb/file-manager.h"
 #include "hdb/gfx.h"
 
 namespace HDB {
diff --git a/engines/hdb/ai-player.cpp b/engines/hdb/ai-player.cpp
index 8492726..9f32651 100644
--- a/engines/hdb/ai-player.cpp
+++ b/engines/hdb/ai-player.cpp
@@ -21,6 +21,7 @@
  */
 
 #include "hdb/hdb.h"
+#include "hdb/file-manager.h"
 #include "hdb/gfx.h"
 #include "hdb/menu.h"
 #include "hdb/mpc.h"
diff --git a/engines/hdb/file-manager.cpp b/engines/hdb/file-manager.cpp
index 1d74db4..fc5f2f8 100644
--- a/engines/hdb/file-manager.cpp
+++ b/engines/hdb/file-manager.cpp
@@ -24,6 +24,7 @@
 #include "common/error.h"
 
 #include "hdb/hdb.h"
+#include "hdb/file-manager.h"
 
 namespace HDB {
 
diff --git a/engines/hdb/gfx.cpp b/engines/hdb/gfx.cpp
index c59964c..2c4423c 100644
--- a/engines/hdb/gfx.cpp
+++ b/engines/hdb/gfx.cpp
@@ -24,6 +24,7 @@
 #include "common/sinetables.h"
 
 #include "hdb/hdb.h"
+#include "hdb/file-manager.h"
 #include "hdb/gfx.h"
 #include "hdb/mpc.h"
 
diff --git a/engines/hdb/hdb.cpp b/engines/hdb/hdb.cpp
index 67978f0..cf8d579 100644
--- a/engines/hdb/hdb.cpp
+++ b/engines/hdb/hdb.cpp
@@ -31,6 +31,7 @@
 #include "common/memstream.h"
 
 #include "hdb/hdb.h"
+#include "hdb/file-manager.h"
 #include "hdb/gfx.h"
 #include "hdb/menu.h"
 #include "hdb/mpc.h"
diff --git a/engines/hdb/hdb.h b/engines/hdb/hdb.h
index d20f40d..7359024 100644
--- a/engines/hdb/hdb.h
+++ b/engines/hdb/hdb.h
@@ -42,10 +42,11 @@
 #include "engines/util.h"
 
 namespace HDB {
+class FileMan;
+class Gfx;
+class Menu;
 class Tile;
 class Picture;
-class Menu;
-class Gfx;
 
 enum {
 	kScreenWidth = 640,
@@ -70,7 +71,6 @@ enum {
 
 #include "hdb/ai.h"
 #include "hdb/ai-player.h"
-#include "hdb/file-manager.h"
 #include "hdb/input.h"
 #include "hdb/lua-script.h"
 #include "hdb/map.h"
diff --git a/engines/hdb/lua-script.cpp b/engines/hdb/lua-script.cpp
index fc86596..0160f7f 100644
--- a/engines/hdb/lua-script.cpp
+++ b/engines/hdb/lua-script.cpp
@@ -26,6 +26,7 @@
 #include "common/debug.h"
 
 #include "hdb/hdb.h"
+#include "hdb/file-manager.h"
 #include "hdb/lua-script.h"
 #include "hdb/gfx.h"
 #include "hdb/mpc.h"
diff --git a/engines/hdb/map.cpp b/engines/hdb/map.cpp
index 80db498..5307069 100644
--- a/engines/hdb/map.cpp
+++ b/engines/hdb/map.cpp
@@ -21,6 +21,7 @@
  */
 
 #include "hdb/hdb.h"
+#include "hdb/file-manager.h"
 #include "hdb/gfx.h"
 
 namespace HDB {


Commit: 2844b48ac1f04609c20b6170019f8f6d9ed6c11b
    https://github.com/scummvm/scummvm/commit/2844b48ac1f04609c20b6170019f8f6d9ed6c11b
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:27+02:00

Commit Message:
HDB: Reduce header dependency

Changed paths:
    engines/hdb/ai-bots.cpp
    engines/hdb/ai-cinematic.cpp
    engines/hdb/ai-funcs.cpp
    engines/hdb/ai-lists.cpp
    engines/hdb/ai-player.cpp
    engines/hdb/gfx.cpp
    engines/hdb/hdb.cpp
    engines/hdb/hdb.h
    engines/hdb/input.cpp
    engines/hdb/menu.cpp
    engines/hdb/saveload.cpp
    engines/hdb/window.cpp


diff --git a/engines/hdb/ai-bots.cpp b/engines/hdb/ai-bots.cpp
index 16a52ab..83c96c4 100644
--- a/engines/hdb/ai-bots.cpp
+++ b/engines/hdb/ai-bots.cpp
@@ -22,6 +22,7 @@
 
 #include "hdb/hdb.h"
 #include "hdb/gfx.h"
+#include "hdb/lua-script.h"
 #include "hdb/mpc.h"
 
 namespace HDB {
diff --git a/engines/hdb/ai-cinematic.cpp b/engines/hdb/ai-cinematic.cpp
index 2c05ad1..9570854 100644
--- a/engines/hdb/ai-cinematic.cpp
+++ b/engines/hdb/ai-cinematic.cpp
@@ -22,6 +22,7 @@
 
 #include "hdb/hdb.h"
 #include "hdb/gfx.h"
+#include "hdb/lua-script.h"
 
 namespace HDB {
 
diff --git a/engines/hdb/ai-funcs.cpp b/engines/hdb/ai-funcs.cpp
index 82f9b3b..719dca2 100644
--- a/engines/hdb/ai-funcs.cpp
+++ b/engines/hdb/ai-funcs.cpp
@@ -23,6 +23,8 @@
 #include "hdb/hdb.h"
 #include "hdb/file-manager.h"
 #include "hdb/gfx.h"
+#include "hdb/input.h"
+#include "hdb/lua-script.h"
 #include "hdb/mpc.h"
 
 namespace HDB {
diff --git a/engines/hdb/ai-lists.cpp b/engines/hdb/ai-lists.cpp
index 326d18c..4941a3f 100644
--- a/engines/hdb/ai-lists.cpp
+++ b/engines/hdb/ai-lists.cpp
@@ -23,6 +23,7 @@
 #include "hdb/hdb.h"
 #include "hdb/file-manager.h"
 #include "hdb/gfx.h"
+#include "hdb/lua-script.h"
 
 namespace HDB {
 
diff --git a/engines/hdb/ai-player.cpp b/engines/hdb/ai-player.cpp
index 9f32651..5992385 100644
--- a/engines/hdb/ai-player.cpp
+++ b/engines/hdb/ai-player.cpp
@@ -24,6 +24,7 @@
 #include "hdb/file-manager.h"
 #include "hdb/gfx.h"
 #include "hdb/menu.h"
+#include "hdb/lua-script.h"
 #include "hdb/mpc.h"
 
 namespace HDB {
diff --git a/engines/hdb/gfx.cpp b/engines/hdb/gfx.cpp
index 2c4423c..643451d 100644
--- a/engines/hdb/gfx.cpp
+++ b/engines/hdb/gfx.cpp
@@ -26,6 +26,7 @@
 #include "hdb/hdb.h"
 #include "hdb/file-manager.h"
 #include "hdb/gfx.h"
+#include "hdb/input.h"
 #include "hdb/mpc.h"
 
 namespace HDB {
diff --git a/engines/hdb/hdb.cpp b/engines/hdb/hdb.cpp
index cf8d579..36d15a3 100644
--- a/engines/hdb/hdb.cpp
+++ b/engines/hdb/hdb.cpp
@@ -33,6 +33,8 @@
 #include "hdb/hdb.h"
 #include "hdb/file-manager.h"
 #include "hdb/gfx.h"
+#include "hdb/input.h"
+#include "hdb/lua-script.h"
 #include "hdb/menu.h"
 #include "hdb/mpc.h"
 
diff --git a/engines/hdb/hdb.h b/engines/hdb/hdb.h
index 7359024..aeaf022 100644
--- a/engines/hdb/hdb.h
+++ b/engines/hdb/hdb.h
@@ -44,6 +44,8 @@
 namespace HDB {
 class FileMan;
 class Gfx;
+class Input;
+class LuaScript;
 class Menu;
 class Tile;
 class Picture;
@@ -71,8 +73,6 @@ enum {
 
 #include "hdb/ai.h"
 #include "hdb/ai-player.h"
-#include "hdb/input.h"
-#include "hdb/lua-script.h"
 #include "hdb/map.h"
 #include "hdb/sound.h"
 #include "hdb/window.h"
diff --git a/engines/hdb/input.cpp b/engines/hdb/input.cpp
index b9ab6fe..92f56b5 100644
--- a/engines/hdb/input.cpp
+++ b/engines/hdb/input.cpp
@@ -22,6 +22,7 @@
 
 #include "hdb/hdb.h"
 #include "hdb/gfx.h"
+#include "hdb/input.h"
 #include "hdb/menu.h"
 
 namespace HDB {
diff --git a/engines/hdb/menu.cpp b/engines/hdb/menu.cpp
index 639adb6..a191d88 100644
--- a/engines/hdb/menu.cpp
+++ b/engines/hdb/menu.cpp
@@ -22,6 +22,8 @@
 
 #include "hdb/hdb.h"
 #include "hdb/gfx.h"
+#include "hdb/input.h"
+#include "hdb/lua-script.h"
 #include "hdb/menu.h"
 #include "hdb/mpc.h"
 
diff --git a/engines/hdb/saveload.cpp b/engines/hdb/saveload.cpp
index 4f5fd06..e2f264e 100644
--- a/engines/hdb/saveload.cpp
+++ b/engines/hdb/saveload.cpp
@@ -22,6 +22,7 @@
 
 #include "hdb/hdb.h"
 #include "hdb/gfx.h"
+#include "hdb/lua-script.h"
 
 namespace HDB {
 
diff --git a/engines/hdb/window.cpp b/engines/hdb/window.cpp
index 3499077..38100ef 100644
--- a/engines/hdb/window.cpp
+++ b/engines/hdb/window.cpp
@@ -22,6 +22,7 @@
 
 #include "hdb/hdb.h"
 #include "hdb/gfx.h"
+#include "hdb/lua-script.h"
 #include "hdb/mpc.h"
 
 namespace HDB {


Commit: a0817b0b5a68844c86f59898f6dddc4bd9cc06a9
    https://github.com/scummvm/scummvm/commit/a0817b0b5a68844c86f59898f6dddc4bd9cc06a9
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:27+02:00

Commit Message:
HDB: Reduce header dependency

Changed paths:
    engines/hdb/ai-bots.cpp
    engines/hdb/ai-cinematic.cpp
    engines/hdb/ai-funcs.cpp
    engines/hdb/ai-init.cpp
    engines/hdb/ai-lists.cpp
    engines/hdb/ai-player.cpp
    engines/hdb/ai-use.cpp
    engines/hdb/ai-waypoint.cpp
    engines/hdb/hdb.cpp
    engines/hdb/hdb.h
    engines/hdb/input.cpp
    engines/hdb/lua-script.cpp
    engines/hdb/map.cpp
    engines/hdb/menu.cpp
    engines/hdb/saveload.cpp
    engines/hdb/window.cpp


diff --git a/engines/hdb/ai-bots.cpp b/engines/hdb/ai-bots.cpp
index 83c96c4..cd031d4 100644
--- a/engines/hdb/ai-bots.cpp
+++ b/engines/hdb/ai-bots.cpp
@@ -23,6 +23,7 @@
 #include "hdb/hdb.h"
 #include "hdb/gfx.h"
 #include "hdb/lua-script.h"
+#include "hdb/map.h"
 #include "hdb/mpc.h"
 
 namespace HDB {
diff --git a/engines/hdb/ai-cinematic.cpp b/engines/hdb/ai-cinematic.cpp
index 9570854..77ad844 100644
--- a/engines/hdb/ai-cinematic.cpp
+++ b/engines/hdb/ai-cinematic.cpp
@@ -23,6 +23,7 @@
 #include "hdb/hdb.h"
 #include "hdb/gfx.h"
 #include "hdb/lua-script.h"
+#include "hdb/map.h"
 
 namespace HDB {
 
diff --git a/engines/hdb/ai-funcs.cpp b/engines/hdb/ai-funcs.cpp
index 719dca2..3fcb78e 100644
--- a/engines/hdb/ai-funcs.cpp
+++ b/engines/hdb/ai-funcs.cpp
@@ -25,6 +25,7 @@
 #include "hdb/gfx.h"
 #include "hdb/input.h"
 #include "hdb/lua-script.h"
+#include "hdb/map.h"
 #include "hdb/mpc.h"
 
 namespace HDB {
diff --git a/engines/hdb/ai-init.cpp b/engines/hdb/ai-init.cpp
index bcc38f2..f717842 100644
--- a/engines/hdb/ai-init.cpp
+++ b/engines/hdb/ai-init.cpp
@@ -22,6 +22,7 @@
 
 #include "hdb/hdb.h"
 #include "hdb/gfx.h"
+#include "hdb/map.h"
 #include "hdb/mpc.h"
 
 namespace HDB {
diff --git a/engines/hdb/ai-lists.cpp b/engines/hdb/ai-lists.cpp
index 4941a3f..6af61fa 100644
--- a/engines/hdb/ai-lists.cpp
+++ b/engines/hdb/ai-lists.cpp
@@ -24,6 +24,7 @@
 #include "hdb/file-manager.h"
 #include "hdb/gfx.h"
 #include "hdb/lua-script.h"
+#include "hdb/map.h"
 
 namespace HDB {
 
diff --git a/engines/hdb/ai-player.cpp b/engines/hdb/ai-player.cpp
index 5992385..16b6055 100644
--- a/engines/hdb/ai-player.cpp
+++ b/engines/hdb/ai-player.cpp
@@ -25,6 +25,7 @@
 #include "hdb/gfx.h"
 #include "hdb/menu.h"
 #include "hdb/lua-script.h"
+#include "hdb/map.h"
 #include "hdb/mpc.h"
 
 namespace HDB {
diff --git a/engines/hdb/ai-use.cpp b/engines/hdb/ai-use.cpp
index 21c331b..e57ef7c 100644
--- a/engines/hdb/ai-use.cpp
+++ b/engines/hdb/ai-use.cpp
@@ -21,6 +21,7 @@
  */
 
 #include "hdb/hdb.h"
+#include "hdb/map.h"
 
 namespace HDB {
 
diff --git a/engines/hdb/ai-waypoint.cpp b/engines/hdb/ai-waypoint.cpp
index eed404e..bab7ee8 100644
--- a/engines/hdb/ai-waypoint.cpp
+++ b/engines/hdb/ai-waypoint.cpp
@@ -22,6 +22,7 @@
 
 #include "hdb/hdb.h"
 #include "hdb/gfx.h"
+#include "hdb/map.h"
 
 namespace HDB {
 
diff --git a/engines/hdb/hdb.cpp b/engines/hdb/hdb.cpp
index 36d15a3..ebe8b28 100644
--- a/engines/hdb/hdb.cpp
+++ b/engines/hdb/hdb.cpp
@@ -35,6 +35,7 @@
 #include "hdb/gfx.h"
 #include "hdb/input.h"
 #include "hdb/lua-script.h"
+#include "hdb/map.h"
 #include "hdb/menu.h"
 #include "hdb/mpc.h"
 
diff --git a/engines/hdb/hdb.h b/engines/hdb/hdb.h
index aeaf022..82d028b 100644
--- a/engines/hdb/hdb.h
+++ b/engines/hdb/hdb.h
@@ -46,6 +46,7 @@ class FileMan;
 class Gfx;
 class Input;
 class LuaScript;
+class Map;
 class Menu;
 class Tile;
 class Picture;
@@ -73,7 +74,6 @@ enum {
 
 #include "hdb/ai.h"
 #include "hdb/ai-player.h"
-#include "hdb/map.h"
 #include "hdb/sound.h"
 #include "hdb/window.h"
 
diff --git a/engines/hdb/input.cpp b/engines/hdb/input.cpp
index 92f56b5..4143858 100644
--- a/engines/hdb/input.cpp
+++ b/engines/hdb/input.cpp
@@ -23,6 +23,7 @@
 #include "hdb/hdb.h"
 #include "hdb/gfx.h"
 #include "hdb/input.h"
+#include "hdb/map.h"
 #include "hdb/menu.h"
 
 namespace HDB {
diff --git a/engines/hdb/lua-script.cpp b/engines/hdb/lua-script.cpp
index 0160f7f..5216aa3 100644
--- a/engines/hdb/lua-script.cpp
+++ b/engines/hdb/lua-script.cpp
@@ -29,6 +29,7 @@
 #include "hdb/file-manager.h"
 #include "hdb/lua-script.h"
 #include "hdb/gfx.h"
+#include "hdb/map.h"
 #include "hdb/mpc.h"
 
 namespace HDB {
diff --git a/engines/hdb/map.cpp b/engines/hdb/map.cpp
index 5307069..12c8e01 100644
--- a/engines/hdb/map.cpp
+++ b/engines/hdb/map.cpp
@@ -23,6 +23,7 @@
 #include "hdb/hdb.h"
 #include "hdb/file-manager.h"
 #include "hdb/gfx.h"
+#include "hdb/map.h"
 
 namespace HDB {
 
diff --git a/engines/hdb/menu.cpp b/engines/hdb/menu.cpp
index a191d88..24eaf25 100644
--- a/engines/hdb/menu.cpp
+++ b/engines/hdb/menu.cpp
@@ -25,6 +25,7 @@
 #include "hdb/input.h"
 #include "hdb/lua-script.h"
 #include "hdb/menu.h"
+#include "hdb/map.h"
 #include "hdb/mpc.h"
 
 namespace HDB {
diff --git a/engines/hdb/saveload.cpp b/engines/hdb/saveload.cpp
index e2f264e..ca65dc1 100644
--- a/engines/hdb/saveload.cpp
+++ b/engines/hdb/saveload.cpp
@@ -23,6 +23,7 @@
 #include "hdb/hdb.h"
 #include "hdb/gfx.h"
 #include "hdb/lua-script.h"
+#include "hdb/map.h"
 
 namespace HDB {
 
diff --git a/engines/hdb/window.cpp b/engines/hdb/window.cpp
index 38100ef..87810f6 100644
--- a/engines/hdb/window.cpp
+++ b/engines/hdb/window.cpp
@@ -23,6 +23,7 @@
 #include "hdb/hdb.h"
 #include "hdb/gfx.h"
 #include "hdb/lua-script.h"
+#include "hdb/map.h"
 #include "hdb/mpc.h"
 
 namespace HDB {


Commit: 91da8c7aab9c8a396f37d99ad019d40084856dfc
    https://github.com/scummvm/scummvm/commit/91da8c7aab9c8a396f37d99ad019d40084856dfc
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:27+02:00

Commit Message:
HDB: Reduce header dependency

Changed paths:
    engines/hdb/ai-bots.cpp
    engines/hdb/ai-cinematic.cpp
    engines/hdb/ai-funcs.cpp
    engines/hdb/ai-init.cpp
    engines/hdb/ai-inventory.cpp
    engines/hdb/ai-lists.cpp
    engines/hdb/ai-player.cpp
    engines/hdb/ai-player.h
    engines/hdb/ai-use.cpp
    engines/hdb/ai-waypoint.cpp
    engines/hdb/gfx.cpp
    engines/hdb/hdb.cpp
    engines/hdb/hdb.h
    engines/hdb/input.cpp
    engines/hdb/lua-script.cpp
    engines/hdb/menu.cpp
    engines/hdb/saveload.cpp
    engines/hdb/sound.cpp
    engines/hdb/window.cpp


diff --git a/engines/hdb/ai-bots.cpp b/engines/hdb/ai-bots.cpp
index cd031d4..41e21b7 100644
--- a/engines/hdb/ai-bots.cpp
+++ b/engines/hdb/ai-bots.cpp
@@ -25,6 +25,8 @@
 #include "hdb/lua-script.h"
 #include "hdb/map.h"
 #include "hdb/mpc.h"
+#include "hdb/sound.h"
+#include "hdb/window.h"
 
 namespace HDB {
 
diff --git a/engines/hdb/ai-cinematic.cpp b/engines/hdb/ai-cinematic.cpp
index 77ad844..93ed898 100644
--- a/engines/hdb/ai-cinematic.cpp
+++ b/engines/hdb/ai-cinematic.cpp
@@ -24,6 +24,8 @@
 #include "hdb/gfx.h"
 #include "hdb/lua-script.h"
 #include "hdb/map.h"
+#include "hdb/sound.h"
+#include "hdb/window.h"
 
 namespace HDB {
 
diff --git a/engines/hdb/ai-funcs.cpp b/engines/hdb/ai-funcs.cpp
index 3fcb78e..147dc5c 100644
--- a/engines/hdb/ai-funcs.cpp
+++ b/engines/hdb/ai-funcs.cpp
@@ -27,6 +27,8 @@
 #include "hdb/lua-script.h"
 #include "hdb/map.h"
 #include "hdb/mpc.h"
+#include "hdb/sound.h"
+#include "hdb/window.h"
 
 namespace HDB {
 
diff --git a/engines/hdb/ai-init.cpp b/engines/hdb/ai-init.cpp
index f717842..e8325fb 100644
--- a/engines/hdb/ai-init.cpp
+++ b/engines/hdb/ai-init.cpp
@@ -24,6 +24,7 @@
 #include "hdb/gfx.h"
 #include "hdb/map.h"
 #include "hdb/mpc.h"
+#include "hdb/window.h"
 
 namespace HDB {
 
diff --git a/engines/hdb/ai-inventory.cpp b/engines/hdb/ai-inventory.cpp
index 7449697..c8133b7 100644
--- a/engines/hdb/ai-inventory.cpp
+++ b/engines/hdb/ai-inventory.cpp
@@ -21,6 +21,8 @@
  */
 
 #include "hdb/hdb.h"
+#include "hdb/sound.h"
+#include "hdb/window.h"
 
 namespace HDB {
 
diff --git a/engines/hdb/ai-lists.cpp b/engines/hdb/ai-lists.cpp
index 6af61fa..f29104f 100644
--- a/engines/hdb/ai-lists.cpp
+++ b/engines/hdb/ai-lists.cpp
@@ -25,6 +25,8 @@
 #include "hdb/gfx.h"
 #include "hdb/lua-script.h"
 #include "hdb/map.h"
+#include "hdb/sound.h"
+#include "hdb/window.h"
 
 namespace HDB {
 
diff --git a/engines/hdb/ai-player.cpp b/engines/hdb/ai-player.cpp
index 16b6055..e4b54b9 100644
--- a/engines/hdb/ai-player.cpp
+++ b/engines/hdb/ai-player.cpp
@@ -23,10 +23,12 @@
 #include "hdb/hdb.h"
 #include "hdb/file-manager.h"
 #include "hdb/gfx.h"
+#include "hdb/sound.h"
 #include "hdb/menu.h"
 #include "hdb/lua-script.h"
 #include "hdb/map.h"
 #include "hdb/mpc.h"
+#include "hdb/window.h"
 
 namespace HDB {
 
diff --git a/engines/hdb/ai-player.h b/engines/hdb/ai-player.h
index 0ab9c16..b878782 100644
--- a/engines/hdb/ai-player.h
+++ b/engines/hdb/ai-player.h
@@ -23,8 +23,6 @@
 #ifndef HDB_AI_PLAYER_H
 #define HDB_AI_PLAYER_H
 
-#include "hdb/hdb.h"
-
 namespace HDB {
 
 void aiPlayerInit(AIEntity *e);
diff --git a/engines/hdb/ai-use.cpp b/engines/hdb/ai-use.cpp
index e57ef7c..6f04728 100644
--- a/engines/hdb/ai-use.cpp
+++ b/engines/hdb/ai-use.cpp
@@ -22,6 +22,8 @@
 
 #include "hdb/hdb.h"
 #include "hdb/map.h"
+#include "hdb/sound.h"
+#include "hdb/window.h"
 
 namespace HDB {
 
diff --git a/engines/hdb/ai-waypoint.cpp b/engines/hdb/ai-waypoint.cpp
index bab7ee8..86480eb 100644
--- a/engines/hdb/ai-waypoint.cpp
+++ b/engines/hdb/ai-waypoint.cpp
@@ -23,6 +23,7 @@
 #include "hdb/hdb.h"
 #include "hdb/gfx.h"
 #include "hdb/map.h"
+#include "hdb/sound.h"
 
 namespace HDB {
 
diff --git a/engines/hdb/gfx.cpp b/engines/hdb/gfx.cpp
index 643451d..842bdcf 100644
--- a/engines/hdb/gfx.cpp
+++ b/engines/hdb/gfx.cpp
@@ -28,6 +28,7 @@
 #include "hdb/gfx.h"
 #include "hdb/input.h"
 #include "hdb/mpc.h"
+#include "hdb/sound.h"
 
 namespace HDB {
 
diff --git a/engines/hdb/hdb.cpp b/engines/hdb/hdb.cpp
index ebe8b28..4fad19c 100644
--- a/engines/hdb/hdb.cpp
+++ b/engines/hdb/hdb.cpp
@@ -36,8 +36,10 @@
 #include "hdb/input.h"
 #include "hdb/lua-script.h"
 #include "hdb/map.h"
+#include "hdb/sound.h"
 #include "hdb/menu.h"
 #include "hdb/mpc.h"
+#include "hdb/window.h"
 
 #define CHEAT_PATCHES 0
 
diff --git a/engines/hdb/hdb.h b/engines/hdb/hdb.h
index 82d028b..b489f3d 100644
--- a/engines/hdb/hdb.h
+++ b/engines/hdb/hdb.h
@@ -50,6 +50,8 @@ class Map;
 class Menu;
 class Tile;
 class Picture;
+class Sound;
+class Window;
 
 enum {
 	kScreenWidth = 640,
@@ -74,8 +76,7 @@ enum {
 
 #include "hdb/ai.h"
 #include "hdb/ai-player.h"
-#include "hdb/sound.h"
-#include "hdb/window.h"
+//#include "hdb/window.h"
 
 struct ADGameDescription;
 
diff --git a/engines/hdb/input.cpp b/engines/hdb/input.cpp
index 4143858..df2f8e8 100644
--- a/engines/hdb/input.cpp
+++ b/engines/hdb/input.cpp
@@ -24,7 +24,9 @@
 #include "hdb/gfx.h"
 #include "hdb/input.h"
 #include "hdb/map.h"
+#include "hdb/sound.h"
 #include "hdb/menu.h"
+#include "hdb/window.h"
 
 namespace HDB {
 
diff --git a/engines/hdb/lua-script.cpp b/engines/hdb/lua-script.cpp
index 5216aa3..71de7b1 100644
--- a/engines/hdb/lua-script.cpp
+++ b/engines/hdb/lua-script.cpp
@@ -31,6 +31,8 @@
 #include "hdb/gfx.h"
 #include "hdb/map.h"
 #include "hdb/mpc.h"
+#include "hdb/sound.h"
+#include "hdb/window.h"
 
 namespace HDB {
 
diff --git a/engines/hdb/menu.cpp b/engines/hdb/menu.cpp
index 24eaf25..d77f0d8 100644
--- a/engines/hdb/menu.cpp
+++ b/engines/hdb/menu.cpp
@@ -24,6 +24,7 @@
 #include "hdb/gfx.h"
 #include "hdb/input.h"
 #include "hdb/lua-script.h"
+#include "hdb/sound.h"
 #include "hdb/menu.h"
 #include "hdb/map.h"
 #include "hdb/mpc.h"
diff --git a/engines/hdb/saveload.cpp b/engines/hdb/saveload.cpp
index ca65dc1..01432b6 100644
--- a/engines/hdb/saveload.cpp
+++ b/engines/hdb/saveload.cpp
@@ -24,6 +24,8 @@
 #include "hdb/gfx.h"
 #include "hdb/lua-script.h"
 #include "hdb/map.h"
+#include "hdb/sound.h"
+#include "hdb/window.h"
 
 namespace HDB {
 
diff --git a/engines/hdb/sound.cpp b/engines/hdb/sound.cpp
index 5fdd016..cd81ab4 100644
--- a/engines/hdb/sound.cpp
+++ b/engines/hdb/sound.cpp
@@ -22,6 +22,7 @@
 
 #include "hdb/hdb.h"
 #include "hdb/mpc.h"
+#include "hdb/sound.h"
 
 namespace HDB {
 
diff --git a/engines/hdb/window.cpp b/engines/hdb/window.cpp
index 87810f6..26d8682 100644
--- a/engines/hdb/window.cpp
+++ b/engines/hdb/window.cpp
@@ -25,6 +25,8 @@
 #include "hdb/lua-script.h"
 #include "hdb/map.h"
 #include "hdb/mpc.h"
+#include "hdb/sound.h"
+#include "hdb/window.h"
 
 namespace HDB {
 


Commit: c63d207d63c9c66ca7f233b18345ec6d34fc69c7
    https://github.com/scummvm/scummvm/commit/c63d207d63c9c66ca7f233b18345ec6d34fc69c7
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:28+02:00

Commit Message:
HDB: Reduce header dependency

Changed paths:
    engines/hdb/hdb.cpp
    engines/hdb/lua-script.cpp


diff --git a/engines/hdb/hdb.cpp b/engines/hdb/hdb.cpp
index 4fad19c..cc92ad7 100644
--- a/engines/hdb/hdb.cpp
+++ b/engines/hdb/hdb.cpp
@@ -20,16 +20,6 @@
  *
  */
 
-#include "common/scummsys.h"
-#include "common/system.h"
-#include "common/config-manager.h"
-#include "common/debug.h"
-#include "common/debug-channels.h"
-#include "common/file.h"
-#include "common/error.h"
-#include "common/stream.h"
-#include "common/memstream.h"
-
 #include "hdb/hdb.h"
 #include "hdb/file-manager.h"
 #include "hdb/gfx.h"
@@ -104,8 +94,6 @@ HDBGame::~HDBGame() {
 	}
 	delete _debugLogo;
 	_debugLogo = NULL;
-
-	DebugMan.clearAllDebugChannels();
 }
 
 bool HDBGame::init() {
diff --git a/engines/hdb/lua-script.cpp b/engines/hdb/lua-script.cpp
index 71de7b1..015f855 100644
--- a/engines/hdb/lua-script.cpp
+++ b/engines/hdb/lua-script.cpp
@@ -23,7 +23,6 @@
 #include "common/lua/lua.h"
 #include "common/lua/lauxlib.h"
 #include "common/lua/lualib.h"
-#include "common/debug.h"
 
 #include "hdb/hdb.h"
 #include "hdb/file-manager.h"


Commit: a0856c6c3a55734e624599c19a95fba50da42dd8
    https://github.com/scummvm/scummvm/commit/a0856c6c3a55734e624599c19a95fba50da42dd8
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:28+02:00

Commit Message:
HDB: Reduce header dependency

Changed paths:
    engines/hdb/ai-bots.cpp
    engines/hdb/ai-funcs.cpp
    engines/hdb/ai-init.cpp
    engines/hdb/ai-lists.cpp
    engines/hdb/ai-player.cpp
    engines/hdb/hdb.h


diff --git a/engines/hdb/ai-bots.cpp b/engines/hdb/ai-bots.cpp
index 41e21b7..ebe200a 100644
--- a/engines/hdb/ai-bots.cpp
+++ b/engines/hdb/ai-bots.cpp
@@ -21,6 +21,7 @@
  */
 
 #include "hdb/hdb.h"
+#include "hdb/ai-player.h"
 #include "hdb/gfx.h"
 #include "hdb/lua-script.h"
 #include "hdb/map.h"
diff --git a/engines/hdb/ai-funcs.cpp b/engines/hdb/ai-funcs.cpp
index 147dc5c..78ab996 100644
--- a/engines/hdb/ai-funcs.cpp
+++ b/engines/hdb/ai-funcs.cpp
@@ -21,6 +21,7 @@
  */
 
 #include "hdb/hdb.h"
+#include "hdb/ai-player.h"
 #include "hdb/file-manager.h"
 #include "hdb/gfx.h"
 #include "hdb/input.h"
diff --git a/engines/hdb/ai-init.cpp b/engines/hdb/ai-init.cpp
index e8325fb..3200e62 100644
--- a/engines/hdb/ai-init.cpp
+++ b/engines/hdb/ai-init.cpp
@@ -21,6 +21,7 @@
  */
 
 #include "hdb/hdb.h"
+#include "hdb/ai-player.h"
 #include "hdb/gfx.h"
 #include "hdb/map.h"
 #include "hdb/mpc.h"
diff --git a/engines/hdb/ai-lists.cpp b/engines/hdb/ai-lists.cpp
index f29104f..e24b4f8 100644
--- a/engines/hdb/ai-lists.cpp
+++ b/engines/hdb/ai-lists.cpp
@@ -21,6 +21,7 @@
  */
 
 #include "hdb/hdb.h"
+#include "hdb/ai-player.h"
 #include "hdb/file-manager.h"
 #include "hdb/gfx.h"
 #include "hdb/lua-script.h"
diff --git a/engines/hdb/ai-player.cpp b/engines/hdb/ai-player.cpp
index e4b54b9..8dd8149 100644
--- a/engines/hdb/ai-player.cpp
+++ b/engines/hdb/ai-player.cpp
@@ -21,6 +21,7 @@
  */
 
 #include "hdb/hdb.h"
+#include "hdb/ai-player.h"
 #include "hdb/file-manager.h"
 #include "hdb/gfx.h"
 #include "hdb/sound.h"
diff --git a/engines/hdb/hdb.h b/engines/hdb/hdb.h
index b489f3d..e75420e 100644
--- a/engines/hdb/hdb.h
+++ b/engines/hdb/hdb.h
@@ -75,8 +75,6 @@ enum {
 }
 
 #include "hdb/ai.h"
-#include "hdb/ai-player.h"
-//#include "hdb/window.h"
 
 struct ADGameDescription;
 


Commit: 810ac81b0fc4960f5ef0ac3361223db9d3c5f2ac
    https://github.com/scummvm/scummvm/commit/810ac81b0fc4960f5ef0ac3361223db9d3c5f2ac
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:28+02:00

Commit Message:
HDB: Reduce header dependency

Changed paths:
    engines/hdb/ai-bots.cpp
    engines/hdb/ai-cinematic.cpp
    engines/hdb/ai-funcs.cpp
    engines/hdb/ai-init.cpp
    engines/hdb/ai-inventory.cpp
    engines/hdb/ai-lists.cpp
    engines/hdb/ai-player.cpp
    engines/hdb/ai-use.cpp
    engines/hdb/ai-waypoint.cpp
    engines/hdb/ai.h
    engines/hdb/gfx.cpp
    engines/hdb/hdb.cpp
    engines/hdb/hdb.h
    engines/hdb/input.cpp
    engines/hdb/lua-script.cpp
    engines/hdb/map.cpp
    engines/hdb/menu.cpp
    engines/hdb/saveload.cpp
    engines/hdb/window.cpp


diff --git a/engines/hdb/ai-bots.cpp b/engines/hdb/ai-bots.cpp
index ebe200a..fd9ee27 100644
--- a/engines/hdb/ai-bots.cpp
+++ b/engines/hdb/ai-bots.cpp
@@ -21,6 +21,7 @@
  */
 
 #include "hdb/hdb.h"
+#include "hdb/ai.h"
 #include "hdb/ai-player.h"
 #include "hdb/gfx.h"
 #include "hdb/lua-script.h"
diff --git a/engines/hdb/ai-cinematic.cpp b/engines/hdb/ai-cinematic.cpp
index 93ed898..80226be 100644
--- a/engines/hdb/ai-cinematic.cpp
+++ b/engines/hdb/ai-cinematic.cpp
@@ -21,6 +21,7 @@
  */
 
 #include "hdb/hdb.h"
+#include "hdb/ai.h"
 #include "hdb/gfx.h"
 #include "hdb/lua-script.h"
 #include "hdb/map.h"
diff --git a/engines/hdb/ai-funcs.cpp b/engines/hdb/ai-funcs.cpp
index 78ab996..aa0876f 100644
--- a/engines/hdb/ai-funcs.cpp
+++ b/engines/hdb/ai-funcs.cpp
@@ -21,6 +21,7 @@
  */
 
 #include "hdb/hdb.h"
+#include "hdb/ai.h"
 #include "hdb/ai-player.h"
 #include "hdb/file-manager.h"
 #include "hdb/gfx.h"
diff --git a/engines/hdb/ai-init.cpp b/engines/hdb/ai-init.cpp
index 3200e62..3ad935c 100644
--- a/engines/hdb/ai-init.cpp
+++ b/engines/hdb/ai-init.cpp
@@ -21,6 +21,7 @@
  */
 
 #include "hdb/hdb.h"
+#include "hdb/ai.h"
 #include "hdb/ai-player.h"
 #include "hdb/gfx.h"
 #include "hdb/map.h"
diff --git a/engines/hdb/ai-inventory.cpp b/engines/hdb/ai-inventory.cpp
index c8133b7..dbb7f3d 100644
--- a/engines/hdb/ai-inventory.cpp
+++ b/engines/hdb/ai-inventory.cpp
@@ -21,6 +21,7 @@
  */
 
 #include "hdb/hdb.h"
+#include "hdb/ai.h"
 #include "hdb/sound.h"
 #include "hdb/window.h"
 
diff --git a/engines/hdb/ai-lists.cpp b/engines/hdb/ai-lists.cpp
index e24b4f8..638d351 100644
--- a/engines/hdb/ai-lists.cpp
+++ b/engines/hdb/ai-lists.cpp
@@ -21,6 +21,7 @@
  */
 
 #include "hdb/hdb.h"
+#include "hdb/ai.h"
 #include "hdb/ai-player.h"
 #include "hdb/file-manager.h"
 #include "hdb/gfx.h"
diff --git a/engines/hdb/ai-player.cpp b/engines/hdb/ai-player.cpp
index 8dd8149..591a9ec 100644
--- a/engines/hdb/ai-player.cpp
+++ b/engines/hdb/ai-player.cpp
@@ -21,6 +21,7 @@
  */
 
 #include "hdb/hdb.h"
+#include "hdb/ai.h"
 #include "hdb/ai-player.h"
 #include "hdb/file-manager.h"
 #include "hdb/gfx.h"
diff --git a/engines/hdb/ai-use.cpp b/engines/hdb/ai-use.cpp
index 6f04728..1b4b08c 100644
--- a/engines/hdb/ai-use.cpp
+++ b/engines/hdb/ai-use.cpp
@@ -21,6 +21,7 @@
  */
 
 #include "hdb/hdb.h"
+#include "hdb/ai.h"
 #include "hdb/map.h"
 #include "hdb/sound.h"
 #include "hdb/window.h"
diff --git a/engines/hdb/ai-waypoint.cpp b/engines/hdb/ai-waypoint.cpp
index 86480eb..cbeb246 100644
--- a/engines/hdb/ai-waypoint.cpp
+++ b/engines/hdb/ai-waypoint.cpp
@@ -21,6 +21,7 @@
  */
 
 #include "hdb/hdb.h"
+#include "hdb/ai.h"
 #include "hdb/gfx.h"
 #include "hdb/map.h"
 #include "hdb/sound.h"
diff --git a/engines/hdb/ai.h b/engines/hdb/ai.h
index 43f857d..dfa22bb 100644
--- a/engines/hdb/ai.h
+++ b/engines/hdb/ai.h
@@ -23,8 +23,6 @@
 #ifndef HDB_AI_H
 #define HDB_AI_H
 
-#include "common/system.h"
-
 #define STARS_MONKEYSTONE_7			0xfe257d	// magic value in the config file for the unlocking of the Monkeystone secret #7
 #define STARS_MONKEYSTONE_7_FAKE	0x11887e	// fake value that means it hasn't been unlocked
 #define STARS_MONKEYSTONE_14		0x3341fe	// <same> for the Monkeystone #14
diff --git a/engines/hdb/gfx.cpp b/engines/hdb/gfx.cpp
index 842bdcf..7ff3ba8 100644
--- a/engines/hdb/gfx.cpp
+++ b/engines/hdb/gfx.cpp
@@ -24,6 +24,7 @@
 #include "common/sinetables.h"
 
 #include "hdb/hdb.h"
+#include "hdb/ai.h"
 #include "hdb/file-manager.h"
 #include "hdb/gfx.h"
 #include "hdb/input.h"
diff --git a/engines/hdb/hdb.cpp b/engines/hdb/hdb.cpp
index cc92ad7..2114178 100644
--- a/engines/hdb/hdb.cpp
+++ b/engines/hdb/hdb.cpp
@@ -21,6 +21,7 @@
  */
 
 #include "hdb/hdb.h"
+#include "hdb/ai.h"
 #include "hdb/file-manager.h"
 #include "hdb/gfx.h"
 #include "hdb/input.h"
diff --git a/engines/hdb/hdb.h b/engines/hdb/hdb.h
index e75420e..bef4ac6 100644
--- a/engines/hdb/hdb.h
+++ b/engines/hdb/hdb.h
@@ -24,6 +24,7 @@
 #define HDB_HDB_H
 
 #include "common/scummsys.h"
+#include "common/system.h"
 #include "common/array.h"
 #include "common/events.h"
 #include "common/str.h"
@@ -42,6 +43,8 @@
 #include "engines/util.h"
 
 namespace HDB {
+class AI;
+struct AIEntity;
 class FileMan;
 class Gfx;
 class Input;
@@ -74,8 +77,6 @@ enum {
 
 }
 
-#include "hdb/ai.h"
-
 struct ADGameDescription;
 
 namespace HDB {
diff --git a/engines/hdb/input.cpp b/engines/hdb/input.cpp
index df2f8e8..8c02d1e 100644
--- a/engines/hdb/input.cpp
+++ b/engines/hdb/input.cpp
@@ -21,6 +21,7 @@
  */
 
 #include "hdb/hdb.h"
+#include "hdb/ai.h"
 #include "hdb/gfx.h"
 #include "hdb/input.h"
 #include "hdb/map.h"
diff --git a/engines/hdb/lua-script.cpp b/engines/hdb/lua-script.cpp
index 015f855..4d3e0ef 100644
--- a/engines/hdb/lua-script.cpp
+++ b/engines/hdb/lua-script.cpp
@@ -25,6 +25,7 @@
 #include "common/lua/lualib.h"
 
 #include "hdb/hdb.h"
+#include "hdb/ai.h"
 #include "hdb/file-manager.h"
 #include "hdb/lua-script.h"
 #include "hdb/gfx.h"
diff --git a/engines/hdb/map.cpp b/engines/hdb/map.cpp
index 12c8e01..8c2de33 100644
--- a/engines/hdb/map.cpp
+++ b/engines/hdb/map.cpp
@@ -21,6 +21,7 @@
  */
 
 #include "hdb/hdb.h"
+#include "hdb/ai.h"
 #include "hdb/file-manager.h"
 #include "hdb/gfx.h"
 #include "hdb/map.h"
diff --git a/engines/hdb/menu.cpp b/engines/hdb/menu.cpp
index d77f0d8..8d42f9c 100644
--- a/engines/hdb/menu.cpp
+++ b/engines/hdb/menu.cpp
@@ -21,6 +21,7 @@
  */
 
 #include "hdb/hdb.h"
+#include "hdb/ai.h"
 #include "hdb/gfx.h"
 #include "hdb/input.h"
 #include "hdb/lua-script.h"
diff --git a/engines/hdb/saveload.cpp b/engines/hdb/saveload.cpp
index 01432b6..02a0fca 100644
--- a/engines/hdb/saveload.cpp
+++ b/engines/hdb/saveload.cpp
@@ -21,6 +21,7 @@
  */
 
 #include "hdb/hdb.h"
+#include "hdb/ai.h"
 #include "hdb/gfx.h"
 #include "hdb/lua-script.h"
 #include "hdb/map.h"
diff --git a/engines/hdb/window.cpp b/engines/hdb/window.cpp
index 26d8682..7809c07 100644
--- a/engines/hdb/window.cpp
+++ b/engines/hdb/window.cpp
@@ -21,6 +21,7 @@
  */
 
 #include "hdb/hdb.h"
+#include "hdb/ai.h"
 #include "hdb/gfx.h"
 #include "hdb/lua-script.h"
 #include "hdb/map.h"


Commit: 951943ececf0b2c27c19adbd6b60c020eee6d13a
    https://github.com/scummvm/scummvm/commit/951943ececf0b2c27c19adbd6b60c020eee6d13a
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:28+02:00

Commit Message:
HDB: Reduce header dependency

Changed paths:
    engines/hdb/ai-bots.cpp
    engines/hdb/ai-player.cpp
    engines/hdb/file-manager.cpp
    engines/hdb/file-manager.h
    engines/hdb/gfx.cpp
    engines/hdb/hdb.cpp
    engines/hdb/hdb.h
    engines/hdb/input.h
    engines/hdb/lua-script.cpp
    engines/hdb/menu.cpp
    engines/hdb/menu.h
    engines/hdb/sound.cpp
    engines/hdb/sound.h
    engines/hdb/window.cpp


diff --git a/engines/hdb/ai-bots.cpp b/engines/hdb/ai-bots.cpp
index fd9ee27..482ae87 100644
--- a/engines/hdb/ai-bots.cpp
+++ b/engines/hdb/ai-bots.cpp
@@ -20,6 +20,8 @@
  *
  */
 
+#include "common/random.h"
+
 #include "hdb/hdb.h"
 #include "hdb/ai.h"
 #include "hdb/ai-player.h"
diff --git a/engines/hdb/ai-player.cpp b/engines/hdb/ai-player.cpp
index 591a9ec..aef00e1 100644
--- a/engines/hdb/ai-player.cpp
+++ b/engines/hdb/ai-player.cpp
@@ -20,6 +20,8 @@
  *
  */
 
+#include "common/random.h"
+
 #include "hdb/hdb.h"
 #include "hdb/ai.h"
 #include "hdb/ai-player.h"
diff --git a/engines/hdb/file-manager.cpp b/engines/hdb/file-manager.cpp
index fc5f2f8..575e66a 100644
--- a/engines/hdb/file-manager.cpp
+++ b/engines/hdb/file-manager.cpp
@@ -21,7 +21,7 @@
  */
 #include "common/debug.h"
 #include "common/file.h"
-#include "common/error.h"
+#include "common/memstream.h"
 
 #include "hdb/hdb.h"
 #include "hdb/file-manager.h"
diff --git a/engines/hdb/file-manager.h b/engines/hdb/file-manager.h
index a83512e..d4cae4d 100644
--- a/engines/hdb/file-manager.h
+++ b/engines/hdb/file-manager.h
@@ -23,11 +23,9 @@
 #ifndef HDB_FILE_MANAGER_H
 #define HDB_FILE_MANAGER_H
 
-#include "common/array.h"
-#include "common/file.h"
-#include "common/error.h"
-#include "common/stream.h"
-#include "common/memstream.h"
+namespace Common {
+	class File;
+}
 
 #define MPCIterator Common::Array<MPCEntry *>::iterator
 
@@ -70,7 +68,7 @@ public:
 		uint32 id;
 		uint32 dirSize;
 	} _dataHeader;
-	
+
 	bool openMPC(const Common::String &filename);
 	void closeMPC();
 	void seek(int32 offset, int flag);
diff --git a/engines/hdb/gfx.cpp b/engines/hdb/gfx.cpp
index 7ff3ba8..7c83bf1 100644
--- a/engines/hdb/gfx.cpp
+++ b/engines/hdb/gfx.cpp
@@ -22,6 +22,7 @@
 
 #include "common/cosinetables.h"
 #include "common/sinetables.h"
+#include "common/random.h"
 
 #include "hdb/hdb.h"
 #include "hdb/ai.h"
diff --git a/engines/hdb/hdb.cpp b/engines/hdb/hdb.cpp
index 2114178..f26b558 100644
--- a/engines/hdb/hdb.cpp
+++ b/engines/hdb/hdb.cpp
@@ -20,6 +20,8 @@
  *
  */
 
+#include "common/random.h"
+
 #include "hdb/hdb.h"
 #include "hdb/ai.h"
 #include "hdb/file-manager.h"
diff --git a/engines/hdb/hdb.h b/engines/hdb/hdb.h
index bef4ac6..6474d5e 100644
--- a/engines/hdb/hdb.h
+++ b/engines/hdb/hdb.h
@@ -25,10 +25,10 @@
 
 #include "common/scummsys.h"
 #include "common/system.h"
-#include "common/array.h"
-#include "common/events.h"
-#include "common/str.h"
-#include "common/random.h"
+//#include "common/array.h"
+//#include "common/events.h"
+//#include "common/str.h"
+//#include "common/random.h"
 #include "common/savefile.h"
 #include "common/config-manager.h"
 #include "graphics/surface.h"
@@ -42,6 +42,10 @@
 #include "engines/engine.h"
 #include "engines/util.h"
 
+namespace Common {
+	class RandomSource;
+}
+
 namespace HDB {
 class AI;
 struct AIEntity;
diff --git a/engines/hdb/input.h b/engines/hdb/input.h
index 11b854a..9ea364a 100644
--- a/engines/hdb/input.h
+++ b/engines/hdb/input.h
@@ -23,6 +23,8 @@
 #ifndef HDB_INPUT_H
 #define HDB_INPUT_H
 
+#include "common/events.h"
+
 namespace HDB {
 
 enum Button {
diff --git a/engines/hdb/lua-script.cpp b/engines/hdb/lua-script.cpp
index 4d3e0ef..fb8a2bf 100644
--- a/engines/hdb/lua-script.cpp
+++ b/engines/hdb/lua-script.cpp
@@ -20,6 +20,7 @@
  *
  */
 
+#include "common/file.h"
 #include "common/lua/lua.h"
 #include "common/lua/lauxlib.h"
 #include "common/lua/lualib.h"
diff --git a/engines/hdb/menu.cpp b/engines/hdb/menu.cpp
index 8d42f9c..68d1f3c 100644
--- a/engines/hdb/menu.cpp
+++ b/engines/hdb/menu.cpp
@@ -20,6 +20,8 @@
  *
  */
 
+#include "common/random.h"
+
 #include "hdb/hdb.h"
 #include "hdb/ai.h"
 #include "hdb/gfx.h"
diff --git a/engines/hdb/menu.h b/engines/hdb/menu.h
index a17d2cb..5f846b0 100644
--- a/engines/hdb/menu.h
+++ b/engines/hdb/menu.h
@@ -23,6 +23,8 @@
 #ifndef HDB_MENU_H
 #define HDB_MENU_H
 
+#include "common/events.h"
+
 namespace HDB {
 
 #define	CONFIG_MUSICVOL		"music_volume"
diff --git a/engines/hdb/sound.cpp b/engines/hdb/sound.cpp
index cd81ab4..97805e1 100644
--- a/engines/hdb/sound.cpp
+++ b/engines/hdb/sound.cpp
@@ -20,6 +20,8 @@
  *
  */
 
+#include "common/debug.h"
+
 #include "hdb/hdb.h"
 #include "hdb/mpc.h"
 #include "hdb/sound.h"
diff --git a/engines/hdb/sound.h b/engines/hdb/sound.h
index 56702c0..c5350af 100644
--- a/engines/hdb/sound.h
+++ b/engines/hdb/sound.h
@@ -1416,24 +1416,24 @@ public:
 	void loadSaveFile(Common::InSaveFile *in);
 	void clearPersistent();
 	void setMusicVolume(int value) {
-		debug(9, "STUB: Add Music System Variables");
+		//debug(9, "STUB: Add Music System Variables");
 	}
 	int getMusicVolume() {
-		debug(9, "STUB: Add Music System Variables");
+		//debug(9, "STUB: Add Music System Variables");
 		return 1;
 	}
 	void setSFXVolume(int value) {
-		debug(9, "STUB: Add Music System Variables");
+		//debug(9, "STUB: Add Music System Variables");
 	}
 	int getSFXVolume() {
-		debug(9, "STUB: Add Music System Variables");
+		//debug(9, "STUB: Add Music System Variables");
 		return 1;
 	}
 	void setVoiceStatus(int value) {
-		debug(9, "STUB: Add Music System Variables");
+		//debug(9, "STUB: Add Music System Variables");
 	}
 	int getVoiceStatus() {
-		debug(9, "STUB: Add Music System Variables");
+		//debug(9, "STUB: Add Music System Variables");
 		return 1;
 	}
 
diff --git a/engines/hdb/window.cpp b/engines/hdb/window.cpp
index 7809c07..5a1e673 100644
--- a/engines/hdb/window.cpp
+++ b/engines/hdb/window.cpp
@@ -20,6 +20,8 @@
  *
  */
 
+#include "common/random.h"
+
 #include "hdb/hdb.h"
 #include "hdb/ai.h"
 #include "hdb/gfx.h"


Commit: e0b0d85f5b1c02136cf834b7eec181901faf2fc6
    https://github.com/scummvm/scummvm/commit/e0b0d85f5b1c02136cf834b7eec181901faf2fc6
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:28+02:00

Commit Message:
HDB: Reduce header dependency

Changed paths:
    engines/hdb/detection.cpp
    engines/hdb/hdb.cpp
    engines/hdb/hdb.h
    engines/hdb/menu.cpp
    engines/hdb/saveload.cpp
    engines/hdb/sound.cpp
    engines/hdb/sound.h


diff --git a/engines/hdb/detection.cpp b/engines/hdb/detection.cpp
index b0895aa..3a4a45e 100644
--- a/engines/hdb/detection.cpp
+++ b/engines/hdb/detection.cpp
@@ -23,6 +23,7 @@
 #include "base/plugins.h"
 
 #include "engines/advancedDetector.h"
+#include "graphics/thumbnail.h"
 
 #include "hdb/hdb.h"
 
diff --git a/engines/hdb/hdb.cpp b/engines/hdb/hdb.cpp
index f26b558..c2c9f51 100644
--- a/engines/hdb/hdb.cpp
+++ b/engines/hdb/hdb.cpp
@@ -20,6 +20,7 @@
  *
  */
 
+#include "common/config-manager.h"
 #include "common/random.h"
 
 #include "hdb/hdb.h"
@@ -853,12 +854,7 @@ Common::Error HDBGame::run() {
 	// Initializes Graphics
 	initGraphics(kScreenWidth, kScreenHeight, &_format);
 
-#ifdef USE_MAD
-	Common::SeekableReadStream *soundStream = _fileMan->findFirstData("M00_AIRLOCK_01_MP3", TYPE_BINARY);
-	Audio::SeekableAudioStream *audioStream = Audio::makeMP3Stream(soundStream, DisposeAfterUse::YES);
-	Audio::SoundHandle *handle = new Audio::SoundHandle();
-	g_hdb->_mixer->playStream(Audio::Mixer::kPlainSoundType, handle, audioStream);
-#endif
+	_sound->test();
 
 	start();
 
diff --git a/engines/hdb/hdb.h b/engines/hdb/hdb.h
index 6474d5e..680d891 100644
--- a/engines/hdb/hdb.h
+++ b/engines/hdb/hdb.h
@@ -25,15 +25,7 @@
 
 #include "common/scummsys.h"
 #include "common/system.h"
-//#include "common/array.h"
-//#include "common/events.h"
-//#include "common/str.h"
-//#include "common/random.h"
 #include "common/savefile.h"
-#include "common/config-manager.h"
-#include "graphics/surface.h"
-#include "graphics/thumbnail.h"
-#include "audio/mixer.h"
 #include "audio/audiostream.h"
 #include "audio/decoders/wave.h"
 #include "audio/decoders/mp3.h"
diff --git a/engines/hdb/menu.cpp b/engines/hdb/menu.cpp
index 68d1f3c..64cf040 100644
--- a/engines/hdb/menu.cpp
+++ b/engines/hdb/menu.cpp
@@ -20,7 +20,9 @@
  *
  */
 
+#include "common/config-manager.h"
 #include "common/random.h"
+#include "graphics/thumbnail.h"
 
 #include "hdb/hdb.h"
 #include "hdb/ai.h"
diff --git a/engines/hdb/saveload.cpp b/engines/hdb/saveload.cpp
index 02a0fca..d53404b 100644
--- a/engines/hdb/saveload.cpp
+++ b/engines/hdb/saveload.cpp
@@ -20,6 +20,8 @@
  *
  */
 
+#include "graphics/thumbnail.h"
+
 #include "hdb/hdb.h"
 #include "hdb/ai.h"
 #include "hdb/gfx.h"
diff --git a/engines/hdb/sound.cpp b/engines/hdb/sound.cpp
index 97805e1..d1a73e0 100644
--- a/engines/hdb/sound.cpp
+++ b/engines/hdb/sound.cpp
@@ -21,8 +21,10 @@
  */
 
 #include "common/debug.h"
+#include "audio/mixer.h"
 
 #include "hdb/hdb.h"
+#include "hdb/file-manager.h"
 #include "hdb/mpc.h"
 #include "hdb/sound.h"
 
@@ -1387,6 +1389,15 @@ const SoundLookUp soundList[] =  {
 	{LAST_SOUND,			NULL,						NULL}
 };
 
+void Sound::test() {
+	#ifdef USE_MAD
+		Common::SeekableReadStream *soundStream = g_hdb->_fileMan->findFirstData("M00_AIRLOCK_01_MP3", TYPE_BINARY);
+		Audio::SeekableAudioStream *audioStream = Audio::makeMP3Stream(soundStream, DisposeAfterUse::YES);
+		Audio::SoundHandle *handle = new Audio::SoundHandle();
+		g_hdb->_mixer->playStream(Audio::Mixer::kPlainSoundType, handle, audioStream);
+	#endif
+}
+
 bool Sound::init() {
 	warning("STUB: Sound::init()");
 	return true;
diff --git a/engines/hdb/sound.h b/engines/hdb/sound.h
index c5350af..a5a23fd 100644
--- a/engines/hdb/sound.h
+++ b/engines/hdb/sound.h
@@ -1411,6 +1411,8 @@ struct SoundLookUp {
 class Sound {
 public:
 
+	void test(); // FIXME. Remove
+
 	bool init();
 	void save(Common::OutSaveFile *out);
 	void loadSaveFile(Common::InSaveFile *in);


Commit: a50e1469b7530bab111b9dd68999cdffe4e827b9
    https://github.com/scummvm/scummvm/commit/a50e1469b7530bab111b9dd68999cdffe4e827b9
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:28+02:00

Commit Message:
HDB: Reduce header dependency

Changed paths:
    engines/hdb/hdb.cpp
    engines/hdb/hdb.h
    engines/hdb/sound.cpp


diff --git a/engines/hdb/hdb.cpp b/engines/hdb/hdb.cpp
index c2c9f51..11c10cc 100644
--- a/engines/hdb/hdb.cpp
+++ b/engines/hdb/hdb.cpp
@@ -23,6 +23,8 @@
 #include "common/config-manager.h"
 #include "common/random.h"
 
+#include "engines/util.h"
+
 #include "hdb/hdb.h"
 #include "hdb/ai.h"
 #include "hdb/file-manager.h"
diff --git a/engines/hdb/hdb.h b/engines/hdb/hdb.h
index 680d891..6d23bde 100644
--- a/engines/hdb/hdb.h
+++ b/engines/hdb/hdb.h
@@ -26,13 +26,8 @@
 #include "common/scummsys.h"
 #include "common/system.h"
 #include "common/savefile.h"
-#include "audio/audiostream.h"
-#include "audio/decoders/wave.h"
-#include "audio/decoders/mp3.h"
 
-#include "gui/debugger.h"
 #include "engines/engine.h"
-#include "engines/util.h"
 
 namespace Common {
 	class RandomSource;
diff --git a/engines/hdb/sound.cpp b/engines/hdb/sound.cpp
index d1a73e0..878f007 100644
--- a/engines/hdb/sound.cpp
+++ b/engines/hdb/sound.cpp
@@ -21,7 +21,10 @@
  */
 
 #include "common/debug.h"
+#include "audio/audiostream.h"
 #include "audio/mixer.h"
+#include "audio/decoders/wave.h"
+#include "audio/decoders/mp3.h"
 
 #include "hdb/hdb.h"
 #include "hdb/file-manager.h"


Commit: 1a7fc846cf2b62c9a91615b207ba2c8e6e60111a
    https://github.com/scummvm/scummvm/commit/1a7fc846cf2b62c9a91615b207ba2c8e6e60111a
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:28+02:00

Commit Message:
HDB: Add Sound Cache

Changed paths:
    engines/hdb/sound.cpp
    engines/hdb/sound.h


diff --git a/engines/hdb/sound.cpp b/engines/hdb/sound.cpp
index 878f007..b10c5d5 100644
--- a/engines/hdb/sound.cpp
+++ b/engines/hdb/sound.cpp
@@ -1392,6 +1392,10 @@ const SoundLookUp soundList[] =  {
 	{LAST_SOUND,			NULL,						NULL}
 };
 
+Sound::Sound() {
+	_sfxVolume = 255;
+}
+
 void Sound::test() {
 	#ifdef USE_MAD
 		Common::SeekableReadStream *soundStream = g_hdb->_fileMan->findFirstData("M00_AIRLOCK_01_MP3", TYPE_BINARY);
@@ -1402,7 +1406,27 @@ void Sound::test() {
 }
 
 bool Sound::init() {
-	warning("STUB: Sound::init()");
+	warning("STUB: Initialize songs");
+
+	//
+	// init sound caching system
+	//
+	int index = 0;
+	while (soundList[index].idx != LAST_SOUND) {
+		int index2 = soundList[index].idx;
+		_soundCache[index2].loaded = false;
+		_soundCache[index2].name = soundList[index].name;
+		_soundCache[index2].luaName = soundList[index].luaName;
+		debug(9, "sName: %s, sLuaName: %s", soundList[index].name, soundList[index].luaName);
+		index++;
+		if (index > kMaxSounds)
+			error("Reached MAX_SOUNDS in Sound::Init() !");
+	}
+	_numSounds = index;
+
+	// voices are on by default
+	warning("STUB: Initialize voices");
+
 	return true;
 }
 
@@ -1463,13 +1487,46 @@ void Sound::stopMusic() {
 }
 
 int Sound::registerSound(const char *name) {
-	debug(9, "STUB: Register Sound");
-	return 0;
+	int		index = 0;
+
+	while (_soundCache[index].name) {
+		index++;
+		if (index == kMaxSounds)
+			return -1;
+	}
+
+	_soundCache[index].name = name;
+	_soundCache[index].loaded = 0;		// just to be sure!
+
+	return index;
 }
 
 bool Sound::freeSound(int index) {
-	debug(9, "STUB: Free Sound");
-	return true;
+	if (_soundCache[index].loaded == 1) {
+		warning("STUB: Free the audio stream in cache");
+		_soundCache[index].loaded = 0;
+		return true;
+	}
+	return false;
+}
+
+const char *Sound::getSNDLuaName(int index) {
+	if (index >= kMaxSounds || !_soundCache[index].luaName)
+		return nullptr;
+
+	return _soundCache[index].luaName;
+}
+
+int Sound::getSNDIndex(const char *name) {
+	int		i = 0;
+
+	while (soundList[i].idx != LAST_SOUND) {
+		if (!scumm_stricmp(soundList[i].luaName, name))
+			return i;
+		i++;
+	}
+
+	return 0;
 }
 
 SoundType Sound::whatSongIsPlaying() {
@@ -1478,7 +1535,11 @@ SoundType Sound::whatSongIsPlaying() {
 }
 
 void Sound::markSoundCacheFreeable() {
-	warning("STUB: Sound::markSoundCacheFreeable() ");
+	int	i;
+	for (i = 0; i < kMaxSounds; i++) {
+		if (_soundCache[i].loaded == 1)
+			_soundCache[i].loaded = -1;
+	}
 }
 
 } // End of Namespace
diff --git a/engines/hdb/sound.h b/engines/hdb/sound.h
index a5a23fd..0dbb1cf 100644
--- a/engines/hdb/sound.h
+++ b/engines/hdb/sound.h
@@ -51,7 +51,7 @@ namespace HDB {
 
 enum {
 	kMaxSNDChannels = 32,
-	kSNDFrequency = 22050,
+	kMaxSounds = 5000,
 	kLaserChannel = kMaxSNDChannels - 1,
 	kMusicChannel = kMaxSNDChannels - 2,
 	kVoiceChannel = kMaxSNDChannels - 5
@@ -1408,9 +1408,24 @@ struct SoundLookUp {
 	const char *luaName;		// name for Lua code to use
 };
 
+struct SoundCache {
+	int	loaded;				// -1 = freeable; in memory, 0 = not cached, 1 = cached
+	int32 size;				// size of sound
+	const char *name;				// filename / MSD name
+	const char *luaName;			// name used by Lua for i.d.
+	//void *data;				// actual file data
+	//FSOUND_SAMPLE *sample;			// used to play sound in FMOD
+
+	SoundCache() : loaded(0), size(0), name(nullptr), luaName(nullptr) {
+
+	}
+};
+
 class Sound {
 public:
 
+	Sound();
+
 	void test(); // FIXME. Remove
 
 	bool init();
@@ -1450,10 +1465,22 @@ public:
 	bool stopChannel(int channel);
 	int registerSound(const char *name);
 	bool freeSound(int index);
+	const char *getSNDLuaName(int index);
+	int getSNDIndex(const char *name);
+	int getNumSounds() {
+		return _numSounds;
+	}
 
 	SoundType whatSongIsPlaying();
 
 	void markSoundCacheFreeable();
+
+	// Sound Caching System Variables
+
+	SoundCache _soundCache[kMaxSounds];
+	int _numSounds;
+	int _sfxVolume;
+
 };
 
 } // End of Namespace


Commit: 2ba18da94dd0c4fc3bfac59c1d57d760e80bf9ad
    https://github.com/scummvm/scummvm/commit/2ba18da94dd0c4fc3bfac59c1d57d760e80bf9ad
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:28+02:00

Commit Message:
HDB: Stick Sound names in Lua

Changed paths:
    engines/hdb/lua-script.cpp


diff --git a/engines/hdb/lua-script.cpp b/engines/hdb/lua-script.cpp
index fb8a2bf..d0dc52f 100644
--- a/engines/hdb/lua-script.cpp
+++ b/engines/hdb/lua-script.cpp
@@ -1758,7 +1758,11 @@ bool LuaScript::initScript(Common::SeekableReadStream *stream, const char *scrip
 	lua_pushnumber(_state, 480 - 14);
 	lua_setglobal(_state, "BOTTOM_Y");
 
-	warning("STUB: Stick Sound Names into Lua");
+	for (int j = 0; j < g_hdb->_sound->getNumSounds(); j++) {
+		const char *name = g_hdb->_sound->getSNDLuaName(j);
+		lua_pushnumber(_state, j);
+		lua_setglobal(_state, name);
+	}
 
 	// Set the Entity Spawn Names  in Lua
 	int j = 0;


Commit: 4a44f62b10f7744a363ce448822b71d4abae95e6
    https://github.com/scummvm/scummvm/commit/4a44f62b10f7744a363ce448822b71d4abae95e6
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:28+02:00

Commit Message:
HDB: Add extension field to SoundCache

Changed paths:
    engines/hdb/sound.cpp
    engines/hdb/sound.h


diff --git a/engines/hdb/sound.cpp b/engines/hdb/sound.cpp
index b10c5d5..5eda133 100644
--- a/engines/hdb/sound.cpp
+++ b/engines/hdb/sound.cpp
@@ -1417,7 +1417,12 @@ bool Sound::init() {
 		_soundCache[index2].loaded = false;
 		_soundCache[index2].name = soundList[index].name;
 		_soundCache[index2].luaName = soundList[index].luaName;
-		debug(9, "sName: %s, sLuaName: %s", soundList[index].name, soundList[index].luaName);
+		// FIXME: Create an intuitive way to include #166
+		if (index2 < SND_UNLOCKED_ITEM || index == 166)
+			_soundCache[index2].ext = -1;	// WAV
+		else
+			_soundCache[index2].ext = 1;		// MP3
+		debug(9, "Registering sound: sName: %s, \tsLuaName: %s, \tExtension: %s", soundList[index2].name, soundList[index2].luaName, _soundCache[index2].ext == 1 ? "MP3" : "WAV");
 		index++;
 		if (index > kMaxSounds)
 			error("Reached MAX_SOUNDS in Sound::Init() !");
@@ -1497,7 +1502,6 @@ int Sound::registerSound(const char *name) {
 
 	_soundCache[index].name = name;
 	_soundCache[index].loaded = 0;		// just to be sure!
-
 	return index;
 }
 
@@ -1505,6 +1509,7 @@ bool Sound::freeSound(int index) {
 	if (_soundCache[index].loaded == 1) {
 		warning("STUB: Free the audio stream in cache");
 		_soundCache[index].loaded = 0;
+		_soundCache[index].ext = 0;
 		return true;
 	}
 	return false;
diff --git a/engines/hdb/sound.h b/engines/hdb/sound.h
index 0dbb1cf..67b8d10 100644
--- a/engines/hdb/sound.h
+++ b/engines/hdb/sound.h
@@ -1413,10 +1413,11 @@ struct SoundCache {
 	int32 size;				// size of sound
 	const char *name;				// filename / MSD name
 	const char *luaName;			// name used by Lua for i.d.
+	int ext;					// 0 = Uninitialized, -1 = WAV, 1 = MP3
 	//void *data;				// actual file data
 	//FSOUND_SAMPLE *sample;			// used to play sound in FMOD
 
-	SoundCache() : loaded(0), size(0), name(nullptr), luaName(nullptr) {
+	SoundCache() : loaded(0), size(0), name(nullptr), luaName(nullptr), ext(0) {
 
 	}
 };


Commit: 236318ce0cef0ed50d4c6876a74ebe1994567a98
    https://github.com/scummvm/scummvm/commit/236318ce0cef0ed50d4c6876a74ebe1994567a98
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:28+02:00

Commit Message:
HDB: Update Sound Names in mpc.h

Changed paths:
    engines/hdb/mpc.h


diff --git a/engines/hdb/mpc.h b/engines/hdb/mpc.h
index 94d7800..b90deb8 100644
--- a/engines/hdb/mpc.h
+++ b/engines/hdb/mpc.h
@@ -847,1153 +847,1153 @@ namespace HDB {
 #define		MONKEY_WIN_WAV		"monkey_win.wav"
 #define		BYE_WAV		"bye.wav"
 #define		HDB_WAV		"hdb.wav"
-#define		VORTEXIAN_SAVE_WAV		"vortexian_save.wav"
-#define		UNLOCKED_ITEM_WAV		"unlocked_item.wav"
-#define		BEEPBEEPBEEP_WAV		"beepbeepbeep.wav"
-#define		MACHINE_AMBIENT1_WAV		"machine_ambient1.wav"
-#define		M00_AIRLOCK_01_MP3		"m00_airlock_01.mp3"
-#define		M00_ARNIE_01_MP3		"m00_arnie_01.mp3"
-#define		M00_BRAD_01_MP3		"m00_brad_01.mp3"
-#define		M00_BRAD_02_MP3		"m00_brad_02.mp3"
-#define		M00_BRAD_03_MP3		"m00_brad_03.mp3"
-#define		M00_BUSTER_01_MP3		"m00_buster_01.mp3"
-#define		M00_BUSTER_02_MP3		"m00_buster_02.mp3"
-#define		M00_BUSTER_03_MP3		"m00_buster_03.mp3"
-#define		M00_BUSTER_04_MP3		"m00_buster_04.mp3"
-#define		M00_BUSTER_05_MP3		"m00_buster_05.mp3"
-#define		M00_BUSTER_06_MP3		"m00_buster_06.mp3"
-#define		M00_BUSTER_07_MP3		"m00_buster_07.mp3"
-#define		M00_BUSTER_08_MP3		"m00_buster_08.mp3"
-#define		M00_BUSTER_09_MP3		"m00_buster_09.mp3"
-#define		M00_BUSTER_10_MP3		"m00_buster_10.mp3"
-#define		M00_BUSTER_11_MP3		"m00_buster_11.mp3"
-#define		M00_BUSTER_12_MP3		"m00_buster_12.mp3"
-#define		M00_BUSTER_13A_MP3		"m00_buster_13a.mp3"
-#define		M00_BUSTER_13B_MP3		"m00_buster_13b.mp3"
-#define		M00_BUSTER_14_MP3		"m00_buster_14.mp3"
-#define		M00_BUSTER_15_MP3		"m00_buster_15.mp3"
-#define		M00_BUSTER_16_MP3		"m00_buster_16.mp3"
-#define		M00_BUSTER_17_MP3		"m00_buster_17.mp3"
-#define		M00_BUSTER_18_MP3		"m00_buster_18.mp3"
-#define		M00_BUSTER_19_MP3		"m00_buster_19.mp3"
-#define		M00_CHICKEN_01_MP3		"m00_chicken_01.mp3"
-#define		M00_CHUTEGUARD_01_MP3		"m00_chuteguard_01.mp3"
-#define		M00_CHUTEGUARD_02_MP3		"m00_chuteguard_02.mp3"
-#define		M00_CHUTEGUARD_03_MP3		"m00_chuteguard_03.mp3"
-#define		M00_CHUTEGUARD_04_MP3		"m00_chuteguard_04.mp3"
-#define		M00_CHUTEGUARD_05_MP3		"m00_chuteguard_05.mp3"
-#define		M00_COOPER_01_MP3		"m00_cooper_01.mp3"
-#define		M00_COOPER_02_MP3		"m00_cooper_02.mp3"
-#define		M00_COOPER_03_MP3		"m00_cooper_03.mp3"
-#define		M00_COOPER_04_MP3		"m00_cooper_04.mp3"
-#define		M00_COOPER_05_MP3		"m00_cooper_05.mp3"
-#define		M00_DINERS_01_MP3		"m00_diners_01.mp3"
-#define		M00_DINERS_02_MP3		"m00_diners_02.mp3"
-#define		M00_DINERS_03_MP3		"m00_diners_03.mp3"
-#define		M00_DINERS_04_MP3		"m00_diners_04.mp3"
-#define		M00_DINERS_05_MP3		"m00_diners_05.mp3"
-#define		M00_DINERS_06_MP3		"m00_diners_06.mp3"
-#define		M00_DOLLY_01_MP3		"m00_dolly_01.mp3"
-#define		M00_DOLLY_02_MP3		"m00_dolly_02.mp3"
-#define		M00_DOLLY_03_MP3		"m00_dolly_03.mp3"
-#define		M00_DOLLY_04_MP3		"m00_dolly_04.mp3"
-#define		M00_DOLLY_05_MP3		"m00_dolly_05.mp3"
-#define		M00_DOLLY_06_MP3		"m00_dolly_06.mp3"
-#define		M00_DOLLY_07_MP3		"m00_dolly_07.mp3"
-#define		M00_DOLLY_08_MP3		"m00_dolly_08.mp3"
-#define		M00_DOLLY_09_MP3		"m00_dolly_09.mp3"
-#define		M00_DOREK_01_MP3		"m00_dorek_01.mp3"
-#define		M00_DOREK_02_MP3		"m00_dorek_02.mp3"
-#define		M00_DOREK_03_MP3		"m00_dorek_03.mp3"
-#define		M00_DOREK_04_MP3		"m00_dorek_04.mp3"
-#define		M00_ENGCOMPUTER_01_MP3		"m00_engcomputer_01.mp3"
-#define		M00_ENGCOMPUTER_02_MP3		"m00_engcomputer_02.mp3"
-#define		M00_FARBLE_01_MP3		"m00_farble_01.mp3"
-#define		M00_FARBLE_02_MP3		"m00_farble_02.mp3"
-#define		M00_FARBLE_03_MP3		"m00_farble_03.mp3"
-#define		M00_FARBLE_04_MP3		"m00_farble_04.mp3"
-#define		M00_FARBLE_05_MP3		"m00_farble_05.mp3"
-#define		M00_FARBLE_06_MP3		"m00_farble_06.mp3"
-#define		M00_FARBLE_07_MP3		"m00_farble_07.mp3"
-#define		M00_FARBLE_08_MP3		"m00_farble_08.mp3"
-#define		M00_GRUNETT_01_MP3		"m00_grunett_01.mp3"
-#define		M00_GRUNETT_02_MP3		"m00_grunett_02.mp3"
-#define		M00_GRUNETT_03_MP3		"m00_grunett_03.mp3"
-#define		M00_GRUNETT_04_MP3		"m00_grunett_04.mp3"
-#define		M00_GUY_01_MP3		"m00_guy_01.mp3"
-#define		M00_GUY_02_MP3		"m00_guy_02.mp3"
-#define		M00_GUY_03_MP3		"m00_guy_03.mp3"
-#define		M00_GUY_04_MP3		"m00_guy_04.mp3"
-#define		M00_GUY_05_MP3		"m00_guy_05.mp3"
-#define		M00_GUY_06_MP3		"m00_guy_06.mp3"
-#define		M00_GUY_07_MP3		"m00_guy_07.mp3"
-#define		M00_GUY_08_MP3		"m00_guy_08.mp3"
-#define		M00_GUY_09_MP3		"m00_guy_09.mp3"
-#define		M00_GUY_10A_MP3		"m00_guy_10a.mp3"
-#define		M00_GUY_10B_MP3		"m00_guy_10b.mp3"
-#define		M00_GUY_11_MP3		"m00_guy_11.mp3"
-#define		M00_GUY_12_MP3		"m00_guy_12.mp3"
-#define		M00_GUY_13_MP3		"m00_guy_13.mp3"
-#define		M00_GUY_14_MP3		"m00_guy_14.mp3"
-#define		M00_GUY_15_MP3		"m00_guy_15.mp3"
-#define		M00_GUY_16_MP3		"m00_guy_16.mp3"
-#define		M00_GUY_17_MP3		"m00_guy_17.mp3"
-#define		M00_GUY_18_MP3		"m00_guy_18.mp3"
-#define		M00_HUMBERT_01_MP3		"m00_humbert_01.mp3"
-#define		M00_HUMBERT_02_MP3		"m00_humbert_02.mp3"
-#define		M00_ILLIAC_01_MP3		"m00_illiac_01.mp3"
-#define		M00_INFOCOMP_01_MP3		"m00_infocomp_01.mp3"
-#define		M00_JAQUES_01_MP3		"m00_jaques_01.mp3"
-#define		M00_JAQUES_03_MP3		"m00_jaques_03.mp3"
-#define		M00_JAQUES_04_MP3		"m00_jaques_04.mp3"
-#define		M00_JAQUES_05_MP3		"m00_jaques_05.mp3"
-#define		M00_LUMBAR_01_MP3		"m00_lumbar_01.mp3"
-#define		M00_MAILSORTER_01_MP3		"m00_mailsorter_01.mp3"
-#define		M00_MAILSORTER_02_MP3		"m00_mailsorter_02.mp3"
-#define		M00_MAILSORTER_03_MP3		"m00_mailsorter_03.mp3"
-#define		M00_MAILSORTER_04_MP3		"m00_mailsorter_04.mp3"
-#define		M00_MAILSORTER_05_MP3		"m00_mailsorter_05.mp3"
-#define		M00_MAILSORTER_06_MP3		"m00_mailsorter_06.mp3"
-#define		M00_MAILSORTER_07_MP3		"m00_mailsorter_07.mp3"
-#define		M00_MAILSORTER_08_MP3		"m00_mailsorter_08.mp3"
-#define		M00_MAILSORTER_09_MP3		"m00_mailsorter_09.mp3"
-#define		M00_MAILSORTER_10_MP3		"m00_mailsorter_10.mp3"
-#define		M00_MAILSORTER_11_MP3		"m00_mailsorter_11.mp3"
-#define		M00_MAILSORTER_12_MP3		"m00_mailsorter_12.mp3"
-#define		M00_MAILSORTER_13_MP3		"m00_mailsorter_13.mp3"
-#define		M00_MAILSORTER_14_MP3		"m00_mailsorter_14.mp3"
-#define		M00_MAILSORTER_15_MP3		"m00_mailsorter_15.mp3"
-#define		M00_MANNY_01_MP3		"m00_manny_01.mp3"
-#define		M00_MANNY_02_MP3		"m00_manny_02.mp3"
-#define		M00_MANNY_03_MP3		"m00_manny_03.mp3"
-#define		M00_MANNY_04_MP3		"m00_manny_04.mp3"
-#define		M00_MANNY_05_MP3		"m00_manny_05.mp3"
-#define		M00_MANNY_06_MP3		"m00_manny_06.mp3"
-#define		M00_MANNY_07_MP3		"m00_manny_07.mp3"
-#define		M00_MANNY_08_MP3		"m00_manny_08.mp3"
-#define		M00_MANNY_09_MP3		"m00_manny_09.mp3"
-#define		M00_MANNY_10_MP3		"m00_manny_10.mp3"
-#define		M00_MANNY_11_MP3		"m00_manny_11.mp3"
-#define		M00_MANNY_12_MP3		"m00_manny_12.mp3"
-#define		M00_MANNY_13_MP3		"m00_manny_13.mp3"
-#define		M00_MANNY_14_MP3		"m00_manny_14.mp3"
-#define		M00_MANNY_15_MP3		"m00_manny_15.mp3"
-#define		M00_MANNY_16_MP3		"m00_manny_16.mp3"
-#define		M00_MANNY_17_MP3		"m00_manny_17.mp3"
-#define		M00_MANNY_18_MP3		"m00_manny_18.mp3"
-#define		M00_NOTEBRICK_01_MP3		"m00_notebrick_01.mp3"
-#define		M00_PILOTS_01_MP3		"m00_pilots_01.mp3"
-#define		M00_PILOTS_02_MP3		"m00_pilots_02.mp3"
-#define		M00_POLONEY_01_MP3		"m00_poloney_01.mp3"
-#define		M00_POLONEY_02_MP3		"m00_poloney_02.mp3"
-#define		M00_POLONEY_03_MP3		"m00_poloney_03.mp3"
-#define		M00_POLONEY_04_MP3		"m00_poloney_04.mp3"
-#define		M00_POLONEY_05_MP3		"m00_poloney_05.mp3"
-#define		M00_POLONEY_06_MP3		"m00_poloney_06.mp3"
-#define		M00_SARGE_01_MP3		"m00_sarge_01.mp3"
-#define		M00_SARGE_02_MP3		"m00_sarge_02.mp3"
-#define		M00_SARGE_03_MP3		"m00_sarge_03.mp3"
-#define		M00_SARGE_04_MP3		"m00_sarge_04.mp3"
-#define		M00_SARGE_05_MP3		"m00_sarge_05.mp3"
-#define		M00_SARGE_06_MP3		"m00_sarge_06.mp3"
-#define		M00_SARGE_07_MP3		"m00_sarge_07.mp3"
-#define		M00_SARGE_08_MP3		"m00_sarge_08.mp3"
-#define		M00_SARGE_09_MP3		"m00_sarge_09.mp3"
-#define		M00_SARGE_10_MP3		"m00_sarge_10.mp3"
-#define		M00_SARGE_11_MP3		"m00_sarge_11.mp3"
-#define		M00_SARGE_12_MP3		"m00_sarge_12.mp3"
-#define		M00_SARGE_13_MP3		"m00_sarge_13.mp3"
-#define		M00_SARGE_14_MP3		"m00_sarge_14.mp3"
-#define		M00_SARGE_15_MP3		"m00_sarge_15.mp3"
-#define		M00_SARGE_16_MP3		"m00_sarge_16.mp3"
-#define		M01_ALABASTER_01_MP3		"m01_alabaster_01.mp3"
-#define		M01_ALABASTER_02_MP3		"m01_alabaster_02.mp3"
-#define		M01_ALABASTER_03_MP3		"m01_alabaster_03.mp3"
-#define		M01_ALABASTER_04_MP3		"m01_alabaster_04.mp3"
-#define		M01_ALABASTER_05_MP3		"m01_alabaster_05.mp3"
-#define		M01_ALABASTER_06_MP3		"m01_alabaster_06.mp3"
-#define		M01_BRAKER_01_MP3		"m01_braker_01.mp3"
-#define		M01_BRAKER_02_MP3		"m01_braker_02.mp3"
-#define		M01_BRAKER_03_MP3		"m01_braker_03.mp3"
-#define		M01_BRAKER_04_MP3		"m01_braker_04.mp3"
-#define		M01_CHISTE_01_MP3		"m01_chiste_01.mp3"
-#define		M01_CHISTE_02_MP3		"m01_chiste_02.mp3"
-#define		M01_CHISTE_03_MP3		"m01_chiste_03.mp3"
-#define		M01_CHISTE_04_MP3		"m01_chiste_04.mp3"
-#define		M01_CHISTE_05_MP3		"m01_chiste_05.mp3"
-#define		M01_CHISTE_06_MP3		"m01_chiste_06.mp3"
-#define		M01_CHISTE_07_MP3		"m01_chiste_07.mp3"
-#define		M01_CHISTE_08_MP3		"m01_chiste_08.mp3"
-#define		M01_CHISTE_09_MP3		"m01_chiste_09.mp3"
-#define		M01_CHISTE_10_MP3		"m01_chiste_10.mp3"
-#define		M01_CHISTE_11_MP3		"m01_chiste_11.mp3"
-#define		M01_CHISTE_12_MP3		"m01_chiste_12.mp3"
-#define		M01_CHISTE_13_MP3		"m01_chiste_13.mp3"
-#define		M01_CHISTE_14_MP3		"m01_chiste_14.mp3"
-#define		M01_COVERT_01_MP3		"m01_covert_01.mp3"
-#define		M01_COVERT_02_MP3		"m01_covert_02.mp3"
-#define		M01_COVERT_03_MP3		"m01_covert_03.mp3"
-#define		M01_COVERT_04_MP3		"m01_covert_04.mp3"
-#define		M01_COVERT_05_MP3		"m01_covert_05.mp3"
-#define		M01_COVERT_06_MP3		"m01_covert_06.mp3"
-#define		M01_COVERT_07_MP3		"m01_covert_07.mp3"
-#define		M01_COVERT_08_MP3		"m01_covert_08.mp3"
-#define		M01_COVERT_09_MP3		"m01_covert_09.mp3"
-#define		M01_COVERT_10_MP3		"m01_covert_10.mp3"
-#define		M01_COVERT_11_MP3		"m01_covert_11.mp3"
-#define		M01_COVERT_12_MP3		"m01_covert_12.mp3"
-#define		M01_COVERT_13_MP3		"m01_covert_13.mp3"
-#define		M01_DAGEAUBE_01_MP3		"m01_dageaube_01.mp3"
-#define		M01_DAGEAUBE_02_MP3		"m01_dageaube_02.mp3"
-#define		M01_DAGEAUBE_03_MP3		"m01_dageaube_03.mp3"
-#define		M01_DAGEAUBE_04_MP3		"m01_dageaube_04.mp3"
-#define		M01_DAGEAUBE_05_MP3		"m01_dageaube_05.mp3"
-#define		M01_EMC2_01_MP3		"m01_emc2_01.mp3"
-#define		M01_EMC2_02_MP3		"m01_emc2_02.mp3"
-#define		M01_GIZZARD_01_MP3		"m01_gizzard_01.mp3"
-#define		M01_GIZZARD_02_MP3		"m01_gizzard_02.mp3"
-#define		M01_GUY_01_MP3		"m01_guy_01.mp3"
-#define		M01_GUY_02_MP3		"m01_guy_02.mp3"
-#define		M01_GUY_03_MP3		"m01_guy_03.mp3"
-#define		M01_GUY_04_MP3		"m01_guy_04.mp3"
-#define		M01_GUY_05_MP3		"m01_guy_05.mp3"
-#define		M01_HIDROW_01_MP3		"m01_hidrow_01.mp3"
-#define		M01_HIDROW_02_MP3		"m01_hidrow_02.mp3"
-#define		M01_HIDROW_03_MP3		"m01_hidrow_03.mp3"
-#define		M01_KEBOTTLE_01_MP3		"m01_kebottle_01.mp3"
-#define		M01_KEBOTTLE_02_MP3		"m01_kebottle_02.mp3"
-#define		M01_KEBOTTLE_03_MP3		"m01_kebottle_03.mp3"
-#define		M01_KEBOTTLE_04_MP3		"m01_kebottle_04.mp3"
-#define		M01_KEBOTTLE_05_MP3		"m01_kebottle_05.mp3"
-#define		M01_KEBOTTLE_06_MP3		"m01_kebottle_06.mp3"
-#define		M01_KEBOTTLE_07_MP3		"m01_kebottle_07.mp3"
-#define		M01_PONTE_01_MP3		"m01_ponte_01.mp3"
-#define		M01_PONTE_02_MP3		"m01_ponte_02.mp3"
-#define		M01_PONTE_03_MP3		"m01_ponte_03.mp3"
-#define		M01_PONTE_04_MP3		"m01_ponte_04.mp3"
-#define		M01_PONTE_05_MP3		"m01_ponte_05.mp3"
-#define		M01_PONTE_06_MP3		"m01_ponte_06.mp3"
-#define		M01_PONTE_07_MP3		"m01_ponte_07.mp3"
-#define		M01_PONTE_08_MP3		"m01_ponte_08.mp3"
-#define		M01_PONTE_09_MP3		"m01_ponte_09.mp3"
-#define		M01_PONTE_10_MP3		"m01_ponte_10.mp3"
-#define		M01_POPOPOLIS_01_MP3		"m01_popopolis_01.mp3"
-#define		M01_POPOPOLIS_02_MP3		"m01_popopolis_02.mp3"
-#define		M01_POPOPOLIS_03_MP3		"m01_popopolis_03.mp3"
-#define		M01_POPOPOLIS_04_MP3		"m01_popopolis_04.mp3"
-#define		M01_POPOPOLIS_05_MP3		"m01_popopolis_05.mp3"
-#define		M01_POPOPOLIS_06_MP3		"m01_popopolis_06.mp3"
-#define		M01_POPOPOLIS_07_MP3		"m01_popopolis_07.mp3"
-#define		M01_POPOPOLIS_08_MP3		"m01_popopolis_08.mp3"
-#define		M01_POPOPOLIS_09_MP3		"m01_popopolis_09.mp3"
-#define		M01_POPOPOLIS_10_MP3		"m01_popopolis_10.mp3"
-#define		M01_POPOPOLIS_11_MP3		"m01_popopolis_11.mp3"
-#define		M01_POPOPOLIS_12_MP3		"m01_popopolis_12.mp3"
-#define		M01_POPOPOLIS_13_MP3		"m01_popopolis_13.mp3"
-#define		M01_POPOPOLIS_14_MP3		"m01_popopolis_14.mp3"
-#define		M01_POPOPOLIS_15_MP3		"m01_popopolis_15.mp3"
-#define		M01_POPOPOLIS_16_MP3		"m01_popopolis_16.mp3"
-#define		M01_POPOPOLIS_17_MP3		"m01_popopolis_17.mp3"
-#define		M01_POPOPOLIS_18_MP3		"m01_popopolis_18.mp3"
-#define		M01_POPOPOLIS_19_MP3		"m01_popopolis_19.mp3"
-#define		M01_POPOPOLIS_20_MP3		"m01_popopolis_20.mp3"
-#define		M01_POPOPOLIS_21_MP3		"m01_popopolis_21.mp3"
-#define		M01_POPOPOLIS_22_MP3		"m01_popopolis_22.mp3"
-#define		M01_POPOPOLIS_23_MP3		"m01_popopolis_23.mp3"
-#define		M01_POPOPOLIS_24_MP3		"m01_popopolis_24.mp3"
-#define		M01_POPOPOLIS_25_MP3		"m01_popopolis_25.mp3"
-#define		M01_POPOPOLIS_26_MP3		"m01_popopolis_26.mp3"
-#define		M01_POPOPOLIS_27_MP3		"m01_popopolis_27.mp3"
-#define		M01_POPOPOLIS_28_MP3		"m01_popopolis_28.mp3"
-#define		M01_POPOPOLIS_29_MP3		"m01_popopolis_29.mp3"
-#define		M01_POPOPOLIS_30_MP3		"m01_popopolis_30.mp3"
-#define		M01_POPOPOLIS_31_MP3		"m01_popopolis_31.mp3"
-#define		M01_POPOPOLIS_32_MP3		"m01_popopolis_32.mp3"
-#define		M01_POPOPOLIS_33_MP3		"m01_popopolis_33.mp3"
-#define		M01_POPOPOLIS_34_MP3		"m01_popopolis_34.mp3"
-#define		M01_POPOPOLIS_35_MP3		"m01_popopolis_35.mp3"
-#define		M01_POPOPOLIS_36_MP3		"m01_popopolis_36.mp3"
-#define		M01_POPOPOLIS_37_MP3		"m01_popopolis_37.mp3"
-#define		M01_SARGE_01_MP3		"m01_sarge_01.mp3"
-#define		M01_SARGE_02_MP3		"m01_sarge_02.mp3"
-#define		M01_SARGE_03_MP3		"m01_sarge_03.mp3"
-#define		M01_SARGE_04_MP3		"m01_sarge_04.mp3"
-#define		M01_SOBREDELLE_01_MP3		"m01_sobredelle_01.mp3"
-#define		M01_SOBREDELLE_02_MP3		"m01_sobredelle_02.mp3"
-#define		M01_SOBREDELLE_03_MP3		"m01_sobredelle_03.mp3"
-#define		M01_WAYNE_01_MP3		"m01_wayne_01.mp3"
-#define		M01_WAYNE_02_MP3		"m01_wayne_02.mp3"
-#define		M01_ZIQUOZ_01_MP3		"m01_ziquoz_01.mp3"
-#define		M01_ZIQUOZ_02_MP3		"m01_ziquoz_02.mp3"
-#define		M01_ZIQUOZ_03_MP3		"m01_ziquoz_03.mp3"
-#define		M02_AGUSTO_01_MP3		"m02_agusto_01.mp3"
-#define		M02_AGUSTO_02_MP3		"m02_agusto_02.mp3"
-#define		M02_ALBONDIGAS_01_MP3		"m02_albondigas_01.mp3"
-#define		M02_ALBONDIGAS_02_MP3		"m02_albondigas_02.mp3"
-#define		M02_BUMPER_01_MP3		"m02_bumper_01.mp3"
-#define		M02_BUMPER_02_MP3		"m02_bumper_02.mp3"
-#define		M02_BUMPER_03_MP3		"m02_bumper_03.mp3"
-#define		M02_BUMPER_04_MP3		"m02_bumper_04.mp3"
-#define		M02_BUMPER_05_MP3		"m02_bumper_05.mp3"
-#define		M02_BUMPER_06_MP3		"m02_bumper_06.mp3"
-#define		M02_BUMPER_07_MP3		"m02_bumper_07.mp3"
-#define		M02_DELGADO_01_MP3		"m02_delgado_01.mp3"
-#define		M02_FEBRARO_01_MP3		"m02_febraro_01.mp3"
-#define		M02_GUY_01_MP3		"m02_guy_01.mp3"
-#define		M02_GUY_02_MP3		"m02_guy_02.mp3"
-#define		M03_ACROPHO_01_MP3		"m03_acropho_01.mp3"
-#define		M03_ACROPHO_02_MP3		"m03_acropho_02.mp3"
-#define		M03_ACROPHO_03_MP3		"m03_acropho_03.mp3"
-#define		M03_ACROPHO_04_MP3		"m03_acropho_04.mp3"
-#define		M03_ENERO_01_MP3		"m03_enero_01.mp3"
-#define		M03_ENERO_02_MP3		"m03_enero_02.mp3"
-#define		M03_ENERO_03_MP3		"m03_enero_03.mp3"
-#define		M03_ENERO_04_MP3		"m03_enero_04.mp3"
-#define		M03_ENERO_05_MP3		"m03_enero_05.mp3"
-#define		M03_GAIA_01_MP3		"m03_gaia_01.mp3"
-#define		M03_GAIA_02_MP3		"m03_gaia_02.mp3"
-#define		M03_GAIA_03_MP3		"m03_gaia_03.mp3"
-#define		M03_GAIA_04_MP3		"m03_gaia_04.mp3"
-#define		M03_GAIA_05_MP3		"m03_gaia_05.mp3"
-#define		M03_GAIA_06_MP3		"m03_gaia_06.mp3"
-#define		M03_LAGO_01_MP3		"m03_lago_01.mp3"
-#define		M03_LAGO_02_MP3		"m03_lago_02.mp3"
-#define		M03_LAGO_04_MP3		"m03_lago_04.mp3"
-#define		M03_LAGO_05_MP3		"m03_lago_05.mp3"
-#define		M03_LAGO_06_MP3		"m03_lago_06.mp3"
-#define		M03_LAGO_07_MP3		"m03_lago_07.mp3"
-#define		M04_BONIFACE_01_MP3		"m04_boniface_01.mp3"
-#define		M04_BONIFACE_02_MP3		"m04_boniface_02.mp3"
-#define		M04_BONIFACE_03_MP3		"m04_boniface_03.mp3"
-#define		M04_BONIFACE_04_MP3		"m04_boniface_04.mp3"
-#define		M04_BONIFACE_05_MP3		"m04_boniface_05.mp3"
-#define		M04_BONIFACE_06_MP3		"m04_boniface_06.mp3"
-#define		M04_BONIFACE_07_MP3		"m04_boniface_07.mp3"
-#define		M04_JULIO_01_MP3		"m04_julio_01.mp3"
-#define		M04_JULIO_02_MP3		"m04_julio_02.mp3"
-#define		M04_JULIO_04_MP3		"m04_julio_04.mp3"
-#define		M04_MARZO_01_MP3		"m04_marzo_01.mp3"
-#define		M04_OCTUBRE_01_MP3		"m04_octubre_01.mp3"
-#define		M04_OCTUBRE_02_MP3		"m04_octubre_02.mp3"
-#define		M04_OCTUBRE_03_MP3		"m04_octubre_03.mp3"
-#define		M05_ABRIL_01_MP3		"m05_abril_01.mp3"
-#define		M05_ABRIL_02_MP3		"m05_abril_02.mp3"
-#define		M05_ABRIL_03_MP3		"m05_abril_03.mp3"
-#define		M05_ABRIL_04_MP3		"m05_abril_04.mp3"
-#define		M05_ABRIL_05_MP3		"m05_abril_05.mp3"
-#define		M05_EVERLOO_01_MP3		"m05_everloo_01.mp3"
-#define		M05_EVERLOO_02_MP3		"m05_everloo_02.mp3"
-#define		M05_EVERLOO_03_MP3		"m05_everloo_03.mp3"
-#define		M05_EVERLOO_04_MP3		"m05_everloo_04.mp3"
-#define		M05_GELIGELLA_01_MP3		"m05_geligella_01.mp3"
-#define		M05_GELIGELLA_02_MP3		"m05_geligella_02.mp3"
-#define		M05_RAILRIDER_01_MP3		"m05_railrider_01.mp3"
-#define		M05_RAILRIDER_02_MP3		"m05_railrider_02.mp3"
-#define		M05_RAILRIDER_03_MP3		"m05_railrider_03.mp3"
-#define		M05_RAILRIDER_04_MP3		"m05_railrider_04.mp3"
-#define		M06_AZUL_01_MP3		"m06_azul_01.mp3"
-#define		M06_AZUL_02_MP3		"m06_azul_02.mp3"
-#define		M06_AZUL_03_MP3		"m06_azul_03.mp3"
-#define		M06_AZUL_04_MP3		"m06_azul_04.mp3"
-#define		M06_AZUL_05_MP3		"m06_azul_05.mp3"
-#define		M06_AZUL_06_MP3		"m06_azul_06.mp3"
-#define		M06_AZUL_07_MP3		"m06_azul_07.mp3"
-#define		M06_AZUL_08_MP3		"m06_azul_08.mp3"
-#define		M06_GUY_01_MP3		"m06_guy_01.mp3"
-#define		M06_GUY_02_MP3		"m06_guy_02.mp3"
-#define		M06_GUY_03_MP3		"m06_guy_03.mp3"
-#define		M06_GUY_04_MP3		"m06_guy_04.mp3"
-#define		M06_HANSON_01_MP3		"m06_hanson_01.mp3"
-#define		M06_HANSON_03_MP3		"m06_hanson_03.mp3"
-#define		M06_HANSON_04_MP3		"m06_hanson_04.mp3"
-#define		M06_HANSON_05_MP3		"m06_hanson_05.mp3"
-#define		M06_HANSON_06_MP3		"m06_hanson_06.mp3"
-#define		M06_HANSON_07_MP3		"m06_hanson_07.mp3"
-#define		M06_HANSON_08_MP3		"m06_hanson_08.mp3"
-#define		M06_HANSON_09_MP3		"m06_hanson_09.mp3"
-#define		M06_HANSON_10_MP3		"m06_hanson_10.mp3"
-#define		M06_HANSON_11_MP3		"m06_hanson_11.mp3"
-#define		M06_HANSON_12_MP3		"m06_hanson_12.mp3"
-#define		M06_JUNIO_01_MP3		"m06_junio_01.mp3"
-#define		M06_JUNIO_02_MP3		"m06_junio_02.mp3"
-#define		M06_JUNIO_03_MP3		"m06_junio_03.mp3"
-#define		M06_JUNIO_04_MP3		"m06_junio_04.mp3"
-#define		M06_JUNIO_05_MP3		"m06_junio_05.mp3"
-#define		M06_JUNIO_06_MP3		"m06_junio_06.mp3"
-#define		M06_JUNIO_07_MP3		"m06_junio_07.mp3"
-#define		M06_JUNIO_08_MP3		"m06_junio_08.mp3"
-#define		M06_JUNIO_09_MP3		"m06_junio_09.mp3"
-#define		M06_NARANJA_01_MP3		"m06_naranja_01.mp3"
-#define		M06_NARANJA_02_MP3		"m06_naranja_02.mp3"
-#define		M06_NARANJA_03_MP3		"m06_naranja_03.mp3"
-#define		M06_NARANJA_04_MP3		"m06_naranja_04.mp3"
-#define		M06_NARANJA_05_MP3		"m06_naranja_05.mp3"
-#define		M06_SEPTEMBRE_01_MP3		"m06_septembre_01.mp3"
-#define		M06_SEPTEMBRE_02_MP3		"m06_septembre_02.mp3"
-#define		M06_SEPTEMBRE_03_MP3		"m06_septembre_03.mp3"
-#define		M06_SEPTEMBRE_04_MP3		"m06_septembre_04.mp3"
-#define		M06_SEPTEMBRE_05_MP3		"m06_septembre_05.mp3"
-#define		M06_SEPTEMBRE_06_MP3		"m06_septembre_06.mp3"
-#define		M06_SEPTEMBRE_07_MP3		"m06_septembre_07.mp3"
-#define		M06_SEPTEMBRE_08_MP3		"m06_septembre_08.mp3"
-#define		M06_SEPTEMBRE_09_MP3		"m06_septembre_09.mp3"
-#define		M06_WORKER_01_MP3		"m06_worker_01.mp3"
-#define		M06_WORKER_02_MP3		"m06_worker_02.mp3"
-#define		M06_WORKER_03_MP3		"m06_worker_03.mp3"
-#define		M06_WORKER_04_MP3		"m06_worker_04.mp3"
-#define		M07_CERCO_01_MP3		"m07_cerco_01.mp3"
-#define		M07_CERCO_02_MP3		"m07_cerco_02.mp3"
-#define		M07_COMPUTER_01_MP3		"m07_computer_01.mp3"
-#define		M07_MAYO_01_MP3		"m07_mayo_01.mp3"
-#define		M07_MAYO_02_MP3		"m07_mayo_02.mp3"
-#define		M07_NOVIEMBRE_01_MP3		"m07_noviembre_01.mp3"
-#define		M07_NOVIEMBRE_02_MP3		"m07_noviembre_02.mp3"
-#define		M07_NOVIEMBRE_03_MP3		"m07_noviembre_03.mp3"
-#define		M07_PANITO_01_MP3		"m07_panito_01.mp3"
-#define		M07_PANITO_02_MP3		"m07_panito_02.mp3"
-#define		M07_PANITO_03_MP3		"m07_panito_03.mp3"
-#define		M07_PANITO_04_MP3		"m07_panito_04.mp3"
-#define		M07_PANITO_05_MP3		"m07_panito_05.mp3"
-#define		M08_COOKIE_01_MP3		"m08_cookie_01.mp3"
-#define		M08_COOKIE_02_MP3		"m08_cookie_02.mp3"
-#define		M08_DICIEMBRE_01_MP3		"m08_diciembre_01.mp3"
-#define		M08_GUY_01_MP3		"m08_guy_01.mp3"
-#define		M08_GUY_02_MP3		"m08_guy_02.mp3"
-#define		M08_GUY_03_MP3		"m08_guy_03.mp3"
-#define		M08_MACHINA_01_MP3		"m08_machina_01.mp3"
-#define		M08_MACHINA_02_MP3		"m08_machina_02.mp3"
-#define		M08_MACHINA_03_MP3		"m08_machina_03.mp3"
-#define		M08_MACHINA_04_MP3		"m08_machina_04.mp3"
-#define		M08_MACHINA_05_MP3		"m08_machina_05.mp3"
-#define		M08_MACHINA_06_MP3		"m08_machina_06.mp3"
-#define		M08_MACHINA_07_MP3		"m08_machina_07.mp3"
-#define		M08_MACHINA_08_MP3		"m08_machina_08.mp3"
-#define		M08_MACHINA_09_MP3		"m08_machina_09.mp3"
-#define		M08_MESA_01_MP3		"m08_mesa_01.mp3"
-#define		M08_MESA_02_MP3		"m08_mesa_02.mp3"
-#define		M08_MESA_03_MP3		"m08_mesa_03.mp3"
-#define		M08_MESA_04_MP3		"m08_mesa_04.mp3"
-#define		M08_SHAKIR_01_MP3		"m08_shakir_01.mp3"
-#define		M08_SHAKIR_02_MP3		"m08_shakir_02.mp3"
-#define		M08_SHAKIR_03_MP3		"m08_shakir_03.mp3"
-#define		M09_VIOLETA_01_MP3		"m09_violeta_01.mp3"
-#define		M09_VIOLETA_02_MP3		"m09_violeta_02.mp3"
-#define		M09_VIOLETA_03_MP3		"m09_violeta_03.mp3"
-#define		M09_VIOLETA_04_MP3		"m09_violeta_04.mp3"
-#define		M10_CHICKEN_01_MP3		"m10_chicken_01.mp3"
-#define		M10_COOPER_01_MP3		"m10_cooper_01.mp3"
-#define		M10_COOPER_02_MP3		"m10_cooper_02.mp3"
-#define		M10_COOPER_03_MP3		"m10_cooper_03.mp3"
-#define		M10_COOPER_04_MP3		"m10_cooper_04.mp3"
-#define		M10_COOPER_05_MP3		"m10_cooper_05.mp3"
-#define		M10_COOPER_06_MP3		"m10_cooper_06.mp3"
-#define		M10_COOPER_07_MP3		"m10_cooper_07.mp3"
-#define		M10_COOPER_08_MP3		"m10_cooper_08.mp3"
-#define		M10_COOPER_09_MP3		"m10_cooper_09.mp3"
-#define		M10_DOLLY_01_MP3		"m10_dolly_01.mp3"
-#define		M10_DOLLY_02_MP3		"m10_dolly_02.mp3"
-#define		M10_DOLLY_03_MP3		"m10_dolly_03.mp3"
-#define		M10_DOLLY_04_MP3		"m10_dolly_04.mp3"
-#define		M10_DOLLY_05_MP3		"m10_dolly_05.mp3"
-#define		M10_DOLLY_06_MP3		"m10_dolly_06.mp3"
-#define		M10_DOLLY_07_MP3		"m10_dolly_07.mp3"
-#define		M10_DOLLY_08_MP3		"m10_dolly_08.mp3"
-#define		M10_DOLLY_09_MP3		"m10_dolly_09.mp3"
-#define		M10_DOLLY_10_MP3		"m10_dolly_10.mp3"
-#define		M10_ENGCOMPUTER_01_MP3		"m10_engcomputer_01.mp3"
-#define		M10_FARBLE_01_MP3		"m10_farble_01.mp3"
-#define		M10_FARBLE_02_MP3		"m10_farble_02.mp3"
-#define		M10_FARBLE_03_MP3		"m10_farble_03.mp3"
-#define		M10_FARBLE_04_MP3		"m10_farble_04.mp3"
-#define		M10_FARBLE_05_MP3		"m10_farble_05.mp3"
-#define		M10_FARBLE_06_MP3		"m10_farble_06.mp3"
-#define		M10_GRUNETT_01_MP3		"m10_grunett_01.mp3"
-#define		M10_GRUNETT_02_MP3		"m10_grunett_02.mp3"
-#define		M10_GRUNETT_03_MP3		"m10_grunett_03.mp3"
-#define		M10_GRUNETT_04_MP3		"m10_grunett_04.mp3"
-#define		M10_GRUNETT_05_MP3		"m10_grunett_05.mp3"
-#define		M10_GRUNETT_06_MP3		"m10_grunett_06.mp3"
-#define		M10_GUY_01_MP3		"m10_guy_01.mp3"
-#define		M10_GUY_02_MP3		"m10_guy_02.mp3"
-#define		M10_GUY_03_MP3		"m10_guy_03.mp3"
-#define		M10_GUY_04_MP3		"m10_guy_04.mp3"
-#define		M10_GUY_05_MP3		"m10_guy_05.mp3"
-#define		M10_GUY_06_MP3		"m10_guy_06.mp3"
-#define		M10_GUY_07_MP3		"m10_guy_07.mp3"
-#define		M10_GUY_08_MP3		"m10_guy_08.mp3"
-#define		M10_INFOCOMP_01_MP3		"m10_infocomp_01.mp3"
-#define		M10_NOTEBRICK_01_MP3		"m10_notebrick_01.mp3"
-#define		M10_PILOTS_01_MP3		"m10_pilots_01.mp3"
-#define		M10_PILOTS_02_MP3		"m10_pilots_02.mp3"
-#define		M10_PILOTS_03_MP3		"m10_pilots_03.mp3"
-#define		M10_PILOTS_04_MP3		"m10_pilots_04.mp3"
-#define		M10_PILOTS_05_MP3		"m10_pilots_05.mp3"
-#define		M10_SARGE_01_MP3		"m10_sarge_01.mp3"
-#define		M10_SARGE_02_MP3		"m10_sarge_02.mp3"
-#define		M10_SARGE_03_MP3		"m10_sarge_03.mp3"
-#define		M10_SARGE_04_MP3		"m10_sarge_04.mp3"
-#define		M10_SARGE_05_MP3		"m10_sarge_05.mp3"
-#define		M11_ANCHOVY_01_MP3		"m11_anchovy_01.mp3"
-#define		M11_ANCHOVY_02_MP3		"m11_anchovy_02.mp3"
-#define		M11_ANCHOVY_03_MP3		"m11_anchovy_03.mp3"
-#define		M11_ANCHOVY_04_MP3		"m11_anchovy_04.mp3"
-#define		M11_ANCHOVY_05_MP3		"m11_anchovy_05.mp3"
-#define		M11_ARBIVALL_01_MP3		"m11_arbivall_01.mp3"
-#define		M11_ARBIVALL_02_MP3		"m11_arbivall_02.mp3"
-#define		M11_ARBIVALL_03_MP3		"m11_arbivall_03.mp3"
-#define		M11_ARBIVALL_04_MP3		"m11_arbivall_04.mp3"
-#define		M11_ARBIVALL_05_MP3		"m11_arbivall_05.mp3"
-#define		M11_ARBIVALL_06_MP3		"m11_arbivall_06.mp3"
-#define		M11_ARBIVALL_07_MP3		"m11_arbivall_07.mp3"
-#define		M11_ARNIE_01_MP3		"m11_arnie_01.mp3"
-#define		M11_BELINDA_01_MP3		"m11_belinda_01.mp3"
-#define		M11_BLOCK_01_MP3		"m11_block_01.mp3"
-#define		M11_BLOCK_02_MP3		"m11_block_02.mp3"
-#define		M11_BLOCK_03_MP3		"m11_block_03.mp3"
-#define		M11_BRAD_01_MP3		"m11_brad_01.mp3"
-#define		M11_BRAD_02_MP3		"m11_brad_02.mp3"
-#define		M11_BRAD_03_MP3		"m11_brad_03.mp3"
-#define		M11_BUSTER_01_MP3		"m11_buster_01.mp3"
-#define		M11_BUSTER_02_MP3		"m11_buster_02.mp3"
-#define		M11_BUSTER_03_MP3		"m11_buster_03.mp3"
-#define		M11_DINERS_01_MP3		"m11_diners_01.mp3"
-#define		M11_DINERS_02_MP3		"m11_diners_02.mp3"
-#define		M11_DOPPLER_01_MP3		"m11_doppler_01.mp3"
-#define		M11_DOPPLER_02_MP3		"m11_doppler_02.mp3"
-#define		M11_DOPPLER_03_MP3		"m11_doppler_03.mp3"
-#define		M11_DOPPLER_04_MP3		"m11_doppler_04.mp3"
-#define		M11_DOPPLER_05_MP3		"m11_doppler_05.mp3"
-#define		M11_DOREK_01_MP3		"m11_dorek_01.mp3"
-#define		M11_DOREK_02_MP3		"m11_dorek_02.mp3"
-#define		M11_DOREK_03_MP3		"m11_dorek_03.mp3"
-#define		M11_DOZER_01_MP3		"m11_dozer_01.mp3"
-#define		M11_DOZER_02_MP3		"m11_dozer_02.mp3"
-#define		M11_DOZER_03_MP3		"m11_dozer_03.mp3"
-#define		M11_DOZER_04_MP3		"m11_dozer_04.mp3"
-#define		M11_GNAPPE_01_MP3		"m11_gnappe_01.mp3"
-#define		M11_GNAPPE_02_MP3		"m11_gnappe_02.mp3"
-#define		M11_GNAPPE_03_MP3		"m11_gnappe_03.mp3"
-#define		M11_GNAPPE_04_MP3		"m11_gnappe_04.mp3"
-#define		M11_GNAPPE_05_MP3		"m11_gnappe_05.mp3"
-#define		M11_GNODIMY_01_MP3		"m11_gnodimy_01.mp3"
-#define		M11_GNODIMY_02_MP3		"m11_gnodimy_02.mp3"
-#define		M11_GNODIMY_03_MP3		"m11_gnodimy_03.mp3"
-#define		M11_GNODIMY_04_MP3		"m11_gnodimy_04.mp3"
-#define		M11_GUY_01_MP3		"m11_guy_01.mp3"
-#define		M11_GUY_02_MP3		"m11_guy_02.mp3"
-#define		M11_GUY_03_MP3		"m11_guy_03.mp3"
-#define		M11_GUY_04_MP3		"m11_guy_04.mp3"
-#define		M11_GUY_05_MP3		"m11_guy_05.mp3"
-#define		M11_GUY_06_MP3		"m11_guy_06.mp3"
-#define		M11_GUY_07_MP3		"m11_guy_07.mp3"
-#define		M11_GUY_08_MP3		"m11_guy_08.mp3"
-#define		M11_GUY_09_MP3		"m11_guy_09.mp3"
-#define		M11_GUY_10_MP3		"m11_guy_10.mp3"
-#define		M11_GUY_11_MP3		"m11_guy_11.mp3"
-#define		M11_GUY_12_MP3		"m11_guy_12.mp3"
-#define		M11_GUY_13_MP3		"m11_guy_13.mp3"
-#define		M11_GUY_15_MP3		"m11_guy_15.mp3"
-#define		M11_GUY_16_MP3		"m11_guy_16.mp3"
-#define		M11_GUY_17_MP3		"m11_guy_17.mp3"
-#define		M11_HAMBRE_01_MP3		"m11_hambre_01.mp3"
-#define		M11_HAMBRE_02_MP3		"m11_hambre_02.mp3"
-#define		M11_HAMBRE_03_MP3		"m11_hambre_03.mp3"
-#define		M11_HAMBRE_04_MP3		"m11_hambre_04.mp3"
-#define		M11_HAMBRE_05_MP3		"m11_hambre_05.mp3"
-#define		M11_HUMBERT_01_MP3		"m11_humbert_01.mp3"
-#define		M11_ILLIAC_01_MP3		"m11_illiac_01.mp3"
-#define		M11_JAQUES_01_MP3		"m11_jaques_01.mp3"
-#define		M11_JAQUES_02_MP3		"m11_jaques_02.mp3"
-#define		M11_JAQUES_03_MP3		"m11_jaques_03.mp3"
-#define		M11_JAQUES_04_MP3		"m11_jaques_04.mp3"
-#define		M11_LUMBAR_01_MP3		"m11_lumbar_01.mp3"
-#define		M11_MAN_IN_STALL_01_MP3		"m11_man_in_stall_01.mp3"
-#define		M11_MAN_IN_STALL_02_MP3		"m11_man_in_stall_02.mp3"
-#define		M11_MAN_IN_STALL_03_MP3		"m11_man_in_stall_03.mp3"
-#define		M11_MAN_IN_STALL_04_MP3		"m11_man_in_stall_04.mp3"
-#define		M11_MAN_IN_STALL_05_MP3		"m11_man_in_stall_05.mp3"
-#define		M11_MANNY_01_MP3		"m11_manny_01.mp3"
-#define		M11_MUMPS_01_MP3		"m11_mumps_01.mp3"
-#define		M11_MUMPS_02_MP3		"m11_mumps_02.mp3"
-#define		M11_MUMPS_03_MP3		"m11_mumps_03.mp3"
-#define		M11_MUMPS_04_MP3		"m11_mumps_04.mp3"
-#define		M11_MUMPS_05_MP3		"m11_mumps_05.mp3"
-#define		M11_MUMPS_06_MP3		"m11_mumps_06.mp3"
-#define		M11_MUMPS_07_MP3		"m11_mumps_07.mp3"
-#define		M11_MUMPS_08_MP3		"m11_mumps_08.mp3"
-#define		M11_MUMPS_09_MP3		"m11_mumps_09.mp3"
-#define		M11_MUMPS_10_MP3		"m11_mumps_10.mp3"
-#define		M11_MUMPS_11_MP3		"m11_mumps_11.mp3"
-#define		M11_MUMPS_12_MP3		"m11_mumps_12.mp3"
-#define		M11_MUMPS_13_MP3		"m11_mumps_13.mp3"
-#define		M11_MUMPS_14_MP3		"m11_mumps_14.mp3"
-#define		M11_MUMPS_15_MP3		"m11_mumps_15.mp3"
-#define		M11_MUMPS_16_MP3		"m11_mumps_16.mp3"
-#define		M11_MUMPS_17_MP3		"m11_mumps_17.mp3"
-#define		M11_MUMPS_18_MP3		"m11_mumps_18.mp3"
-#define		M11_MUMPS_19_MP3		"m11_mumps_19.mp3"
-#define		M11_MUMPS_20_MP3		"m11_mumps_20.mp3"
-#define		M11_MUMPS_22_MP3		"m11_mumps_22.mp3"
-#define		M11_MUMPS_23_MP3		"m11_mumps_23.mp3"
-#define		M11_MUMPS_24_MP3		"m11_mumps_24.mp3"
-#define		M11_MUMPS_25_MP3		"m11_mumps_25.mp3"
-#define		M11_MUMPS_26_MP3		"m11_mumps_26.mp3"
-#define		M11_PEDIMENT_01_MP3		"m11_pediment_01.mp3"
-#define		M11_PEDIMENT_02_MP3		"m11_pediment_02.mp3"
-#define		M11_PEDIMENT_03_MP3		"m11_pediment_03.mp3"
-#define		M11_PEDIMENT_04_MP3		"m11_pediment_04.mp3"
-#define		M11_PEDIMENT_05_MP3		"m11_pediment_05.mp3"
-#define		M11_PEDIMENT_06_MP3		"m11_pediment_06.mp3"
-#define		M11_PEDIMENT_07_MP3		"m11_pediment_07.mp3"
-#define		M11_PEDIMENT_08_MP3		"m11_pediment_08.mp3"
-#define		M11_POLONEY_01_MP3		"m11_poloney_01.mp3"
-#define		M11_POLONEY_02_MP3		"m11_poloney_02.mp3"
-#define		M11_POLONEY_03_MP3		"m11_poloney_03.mp3"
-#define		M11_SAUSAGE_01_MP3		"m11_sausage_01.mp3"
-#define		M11_SAUSAGE_02_MP3		"m11_sausage_02.mp3"
-#define		M11_SAUSAGE_03_MP3		"m11_sausage_03.mp3"
-#define		M11_SAUSAGE_04_MP3		"m11_sausage_04.mp3"
-#define		M11_SAUSAGE_05_MP3		"m11_sausage_05.mp3"
-#define		M11_SAUSAGE_06_MP3		"m11_sausage_06.mp3"
-#define		M11_SAUSAGE_07_MP3		"m11_sausage_07.mp3"
-#define		M11_SAUSAGE_08_MP3		"m11_sausage_08.mp3"
-#define		M11_SAUSAGE_09_MP3		"m11_sausage_09.mp3"
-#define		M11_SAUSAGE_10_MP3		"m11_sausage_10.mp3"
-#define		M12_ABLE_01_MP3		"m12_able_01.mp3"
-#define		M12_ABLE_02_MP3		"m12_able_02.mp3"
-#define		M12_ABLE_03_MP3		"m12_able_03.mp3"
-#define		M12_BUSY_01_MP3		"m12_busy_01.mp3"
-#define		M12_BUSY_02_MP3		"m12_busy_02.mp3"
-#define		M12_BUSY_03_MP3		"m12_busy_03.mp3"
-#define		M12_BUSY_04_MP3		"m12_busy_04.mp3"
-#define		M12_BUSY_05_MP3		"m12_busy_05.mp3"
-#define		M12_BUSY_06_MP3		"m12_busy_06.mp3"
-#define		M12_BUSY_07_MP3		"m12_busy_07.mp3"
-#define		M12_BUSY_08_MP3		"m12_busy_08.mp3"
-#define		M12_CHARLIE_01_MP3		"m12_charlie_01.mp3"
-#define		M12_CHARLIE_02_MP3		"m12_charlie_02.mp3"
-#define		M12_CONUNDRUM_01_MP3		"m12_conundrum_01.mp3"
-#define		M12_CONUNDRUM_02_MP3		"m12_conundrum_02.mp3"
-#define		M12_CONUNDRUM_03_MP3		"m12_conundrum_03.mp3"
-#define		M12_CONUNDRUM_04_MP3		"m12_conundrum_04.mp3"
-#define		M12_CONUNDRUM_05_MP3		"m12_conundrum_05.mp3"
-#define		M12_FOXTROT_01_MP3		"m12_foxtrot_01.mp3"
-#define		M12_FOXTROT_02_MP3		"m12_foxtrot_02.mp3"
-#define		M12_GUY_01_MP3		"m12_guy_01.mp3"
-#define		M12_GUY_02_MP3		"m12_guy_02.mp3"
-#define		M12_GUY_03_MP3		"m12_guy_03.mp3"
-#define		M12_HAUTE_01_MP3		"m12_haute_01.mp3"
-#define		M12_HAUTE_02_MP3		"m12_haute_02.mp3"
-#define		M12_HAUTE_03_MP3		"m12_haute_03.mp3"
-#define		M12_HAUTE_04_MP3		"m12_haute_04.mp3"
-#define		M12_HAUTE_05_MP3		"m12_haute_05.mp3"
-#define		M12_HAUTE_06_MP3		"m12_haute_06.mp3"
-#define		M12_HOVER_01_MP3		"m12_hover_01.mp3"
-#define		M12_HOVER_02_MP3		"m12_hover_02.mp3"
-#define		M12_RUBE_01_MP3		"m12_rube_01.mp3"
-#define		M12_RUBE_02_MP3		"m12_rube_02.mp3"
-#define		M12_RUBE_03_MP3		"m12_rube_03.mp3"
-#define		M12_RUBE_04_MP3		"m12_rube_04.mp3"
-#define		M12_RUBE_05_MP3		"m12_rube_05.mp3"
-#define		M12_RUBE_06_MP3		"m12_rube_06.mp3"
-#define		M12_RUBE_07_MP3		"m12_rube_07.mp3"
-#define		M12_RUBE_08_MP3		"m12_rube_08.mp3"
-#define		M12_RUBE_09_MP3		"m12_rube_09.mp3"
-#define		M12_RUBE_10_MP3		"m12_rube_10.mp3"
-#define		M12_TEKT_01_MP3		"m12_tekt_01.mp3"
-#define		M12_TEKT_02_MP3		"m12_tekt_02.mp3"
-#define		M12_TEKT_03_MP3		"m12_tekt_03.mp3"
-#define		M12_TEKT_04_MP3		"m12_tekt_04.mp3"
-#define		M12_TEKT_05_MP3		"m12_tekt_05.mp3"
-#define		M12_TEKT_06_MP3		"m12_tekt_06.mp3"
-#define		M12_TEKT_07_MP3		"m12_tekt_07.mp3"
-#define		M13_ANIBLE_01_MP3		"m13_anible_01.mp3"
-#define		M13_ANIBLE_02_MP3		"m13_anible_02.mp3"
-#define		M13_FLOWER_01_MP3		"m13_flower_01.mp3"
-#define		M13_FLOWER_02_MP3		"m13_flower_02.mp3"
-#define		M13_FOOCHANE_01_MP3		"m13_foochane_01.mp3"
-#define		M13_FOOCHANE_02_MP3		"m13_foochane_02.mp3"
-#define		M13_FOOCHANE_03_MP3		"m13_foochane_03.mp3"
-#define		M13_FOOCHANE_04_MP3		"m13_foochane_04.mp3"
-#define		M13_GHULABUL_01_MP3		"m13_ghulabul_01.mp3"
-#define		M13_GHULABUL_02_MP3		"m13_ghulabul_02.mp3"
-#define		M13_GHULABUL_03_MP3		"m13_ghulabul_03.mp3"
-#define		M13_GHULABUL_04_MP3		"m13_ghulabul_04.mp3"
-#define		M13_GHULABUL_05_MP3		"m13_ghulabul_05.mp3"
-#define		M13_GHULABUL_06_MP3		"m13_ghulabul_06.mp3"
-#define		M13_GHULABUL_07_MP3		"m13_ghulabul_07.mp3"
-#define		M13_GUY_01_MP3		"m13_guy_01.mp3"
-#define		M13_GUY_02_MP3		"m13_guy_02.mp3"
-#define		M13_HAVENGIN_01_MP3		"m13_havengin_01.mp3"
-#define		M13_MELO_01_MP3		"m13_melo_01.mp3"
-#define		M13_MELO_02_MP3		"m13_melo_02.mp3"
-#define		M13_MELO_03_MP3		"m13_melo_03.mp3"
-#define		M13_MITAKO_01_MP3		"m13_mitako_01.mp3"
-#define		M13_MITAKO_02_MP3		"m13_mitako_02.mp3"
-#define		M13_MITAKO_03_MP3		"m13_mitako_03.mp3"
-#define		M13_SPOONIE_01_MP3		"m13_spoonie_01.mp3"
-#define		M13_SPOONIE_02_MP3		"m13_spoonie_02.mp3"
-#define		M13_SPOONIE_03_MP3		"m13_spoonie_03.mp3"
-#define		M13_SPOONIE_04_MP3		"m13_spoonie_04.mp3"
-#define		M13_SPOONIE_05_MP3		"m13_spoonie_05.mp3"
-#define		M13_ZYGOTE_01_MP3		"m13_zygote_01.mp3"
-#define		M13_ZYGOTE_02_MP3		"m13_zygote_02.mp3"
-#define		M13_ZYGOTE_03_MP3		"m13_zygote_03.mp3"
-#define		M13_ZYGOTE_04_MP3		"m13_zygote_04.mp3"
-#define		M13_ZYGOTE_05_MP3		"m13_zygote_05.mp3"
-#define		M14_LAMORTE_01_MP3		"m14_lamorte_01.mp3"
-#define		M14_LAMORTE_02_MP3		"m14_lamorte_02.mp3"
-#define		M15_COPROITE_01_MP3		"m15_coproite_01.mp3"
-#define		M15_COPROITE_02_MP3		"m15_coproite_02.mp3"
-#define		M15_COPROITE_03_MP3		"m15_coproite_03.mp3"
-#define		M15_COPROITE_04_MP3		"m15_coproite_04.mp3"
-#define		M15_COPROITE_05_MP3		"m15_coproite_05.mp3"
-#define		M15_COPROITE_06_MP3		"m15_coproite_06.mp3"
-#define		M15_COPROITE_07_MP3		"m15_coproite_07.mp3"
-#define		M15_COPROITE_08_MP3		"m15_coproite_08.mp3"
-#define		M15_COPROITE_09_MP3		"m15_coproite_09.mp3"
-#define		M15_COPROITE_10_MP3		"m15_coproite_10.mp3"
-#define		M15_COPROITE_11_MP3		"m15_coproite_11.mp3"
-#define		M15_COPROITE_12_MP3		"m15_coproite_12.mp3"
-#define		M15_COPROITE_13_MP3		"m15_coproite_13.mp3"
-#define		M15_COPROITE_14_MP3		"m15_coproite_14.mp3"
-#define		M15_COPROITE_15_MP3		"m15_coproite_15.mp3"
-#define		M15_COPROITE_16_MP3		"m15_coproite_16.mp3"
-#define		M15_COPROITE_17_MP3		"m15_coproite_17.mp3"
-#define		M15_COPROITE_18_MP3		"m15_coproite_18.mp3"
-#define		M15_GUY_01_MP3		"m15_guy_01.mp3"
-#define		M15_GUY_02_MP3		"m15_guy_02.mp3"
-#define		M15_REED_01_MP3		"m15_reed_01.mp3"
-#define		M15_REED_02_MP3		"m15_reed_02.mp3"
-#define		M15_REED_03_MP3		"m15_reed_03.mp3"
-#define		M16_DYING_01_MP3		"m16_dying_01.mp3"
-#define		M16_DYING_02_MP3		"m16_dying_02.mp3"
-#define		M16_GUY_01_MP3		"m16_guy_01.mp3"
-#define		M16_GUY_02_MP3		"m16_guy_02.mp3"
-#define		M16_GUY_03_MP3		"m16_guy_03.mp3"
-#define		M17_ANDERSON_01_MP3		"m17_anderson_01.mp3"
-#define		M17_BARBER_01_MP3		"m17_barber_01.mp3"
-#define		M17_CAMPBELL_01_MP3		"m17_campbell_01.mp3"
-#define		M17_DEVONSHIRE_01_MP3		"m17_devonshire_01.mp3"
-#define		M17_EGGER_01_MP3		"m17_egger_01.mp3"
-#define		M17_EMERALD_01_MP3		"m17_emerald_01.mp3"
-#define		M17_FLINGBESTER_01_MP3		"m17_flingbester_01.mp3"
-#define		M17_GERSHWIN_01_MP3		"m17_gershwin_01.mp3"
-#define		M17_GUY_01_MP3		"m17_guy_01.mp3"
-#define		M17_GUY_02_MP3		"m17_guy_02.mp3"
-#define		M17_GUY_03_MP3		"m17_guy_03.mp3"
-#define		M17_GUY_04_MP3		"m17_guy_04.mp3"
-#define		M17_HEPHASTUS_01_MP3		"m17_hephastus_01.mp3"
-#define		M17_INIWA_01_MP3		"m17_iniwa_01.mp3"
-#define		M17_INIWA_02_MP3		"m17_iniwa_02.mp3"
-#define		M17_INIWA_03_MP3		"m17_iniwa_03.mp3"
-#define		M17_KEYCODE_01_MP3		"m17_keycode_01.mp3"
-#define		M17_KEYCODE_02_MP3		"m17_keycode_02.mp3"
-#define		M17_KEYCODE_03_MP3		"m17_keycode_03.mp3"
-#define		M17_KEYCODE_04_MP3		"m17_keycode_04.mp3"
-#define		M17_TOERIG_01_MP3		"m17_toerig_01.mp3"
-#define		M17_TOERIG_02_MP3		"m17_toerig_02.mp3"
-#define		M17_WARNER_01_MP3		"m17_warner_01.mp3"
-#define		M17_WARNER_02_MP3		"m17_warner_02.mp3"
-#define		M17_WARNER_03_MP3		"m17_warner_03.mp3"
-#define		M17_WARNER_04_MP3		"m17_warner_04.mp3"
-#define		M17_YORP_01_MP3		"m17_yorp_01.mp3"
-#define		M17_YORP_02_MP3		"m17_yorp_02.mp3"
-#define		M18_DERECHA_01_MP3		"m18_derecha_01.mp3"
-#define		M18_GUY_01_MP3		"m18_guy_01.mp3"
-#define		M18_IZQUIERDA_01_MP3		"m18_izquierda_01.mp3"
-#define		M18_IZQUIERDA_02_MP3		"m18_izquierda_02.mp3"
-#define		M18_IZQUIERDA_03_MP3		"m18_izquierda_03.mp3"
-#define		M18_IZQUIERDA_04_MP3		"m18_izquierda_04.mp3"
-#define		M18_IZQUIERDA_05_MP3		"m18_izquierda_05.mp3"
-#define		M18_IZQUIERDA_06_MP3		"m18_izquierda_06.mp3"
-#define		M19_CAVEAT_01_MP3		"m19_caveat_01.mp3"
-#define		M19_CAVEAT_02_MP3		"m19_caveat_02.mp3"
-#define		M19_ENDER_01_MP3		"m19_ender_01.mp3"
-#define		M19_ENDER_02_MP3		"m19_ender_02.mp3"
-#define		M19_FRUSTRATO_01_MP3		"m19_frustrato_01.mp3"
-#define		M19_FRUSTRATO_02_MP3		"m19_frustrato_02.mp3"
-#define		M19_FRUSTRATO_03_MP3		"m19_frustrato_03.mp3"
-#define		M19_FRUSTRATO_04_MP3		"m19_frustrato_04.mp3"
-#define		M19_FRUSTRATO_05_MP3		"m19_frustrato_05.mp3"
-#define		M19_FRUSTRATO_06_MP3		"m19_frustrato_06.mp3"
-#define		M19_FRUSTRATO_07_MP3		"m19_frustrato_07.mp3"
-#define		M19_FRUSTRATO_08_MP3		"m19_frustrato_08.mp3"
-#define		M19_FRUSTRATO_09_MP3		"m19_frustrato_09.mp3"
-#define		M19_FRUSTRATO_10_MP3		"m19_frustrato_10.mp3"
-#define		M19_GUY_01_MP3		"m19_guy_01.mp3"
-#define		M19_GUY_02_MP3		"m19_guy_02.mp3"
-#define		M19_GUY_03_MP3		"m19_guy_03.mp3"
-#define		M19_INTER_01_MP3		"m19_inter_01.mp3"
-#define		M19_INTER_02_MP3		"m19_inter_02.mp3"
-#define		M19_LONE_01_MP3		"m19_lone_01.mp3"
-#define		M19_LONE_02_MP3		"m19_lone_02.mp3"
-#define		M19_LONE_03_MP3		"m19_lone_03.mp3"
-#define		M19_PHILLIPS_01_MP3		"m19_phillips_01.mp3"
-#define		M19_PHILLIPS_02_MP3		"m19_phillips_02.mp3"
-#define		M19_PHILLIPS_03_MP3		"m19_phillips_03.mp3"
-#define		M19_PHILLIPS_04_MP3		"m19_phillips_04.mp3"
-#define		M19_PHILLIPS_05_MP3		"m19_phillips_05.mp3"
-#define		M19_RAILRIDER_01_MP3		"m19_railrider_01.mp3"
-#define		M19_RAILRIDER_02_MP3		"m19_railrider_02.mp3"
-#define		M19_RAILRIDER_03_MP3		"m19_railrider_03.mp3"
-#define		M19_RAILRIDER_04_MP3		"m19_railrider_04.mp3"
-#define		M19_REDRUM_01_MP3		"m19_redrum_01.mp3"
-#define		M19_REDRUM_02_MP3		"m19_redrum_02.mp3"
-#define		M19_REDRUM_03_MP3		"m19_redrum_03.mp3"
-#define		M19_REDRUM_04_MP3		"m19_redrum_04.mp3"
-#define		M19_REDRUM_05_MP3		"m19_redrum_05.mp3"
-#define		M19_REDRUM_06_MP3		"m19_redrum_06.mp3"
-#define		M19_STANDARD_01_MP3		"m19_standard_01.mp3"
-#define		M19_STANDARD_02_MP3		"m19_standard_02.mp3"
-#define		M20_ARNIE_01_MP3		"m20_arnie_01.mp3"
-#define		M20_ARNIE_02_MP3		"m20_arnie_02.mp3"
-#define		M20_BRAD_01_MP3		"m20_brad_01.mp3"
-#define		M20_BRAD_02_MP3		"m20_brad_02.mp3"
-#define		M20_BUSTER_01_MP3		"m20_buster_01.mp3"
-#define		M20_BUSTER_02_MP3		"m20_buster_02.mp3"
-#define		M20_BUSTER_03_MP3		"m20_buster_03.mp3"
-#define		M20_COOPER_01_MP3		"m20_cooper_01.mp3"
-#define		M20_COOPER_02_MP3		"m20_cooper_02.mp3"
-#define		M20_DINERS_01_MP3		"m20_diners_01.mp3"
-#define		M20_DINERS_02_MP3		"m20_diners_02.mp3"
-#define		M20_DOLLY_01_MP3		"m20_dolly_01.mp3"
-#define		M20_DOREK_01_MP3		"m20_dorek_01.mp3"
-#define		M20_DOREK_02_MP3		"m20_dorek_02.mp3"
-#define		M20_DOREK_03_MP3		"m20_dorek_03.mp3"
-#define		M20_FARBLE_01_MP3		"m20_farble_01.mp3"
-#define		M20_FARBLE_02_MP3		"m20_farble_02.mp3"
-#define		M20_GRUNETT_01_MP3		"m20_grunett_01.mp3"
-#define		M20_GRUNETT_02_MP3		"m20_grunett_02.mp3"
-#define		M20_GUY_01_MP3		"m20_guy_01.mp3"
-#define		M20_GUY_02_MP3		"m20_guy_02.mp3"
-#define		M20_GUY_03_MP3		"m20_guy_03.mp3"
-#define		M20_GUY_04_MP3		"m20_guy_04.mp3"
-#define		M20_GUY_05_MP3		"m20_guy_05.mp3"
-#define		M20_GUY_06_MP3		"m20_guy_06.mp3"
-#define		M20_HUMBERT_01_MP3		"m20_humbert_01.mp3"
-#define		M20_ILLIAC_01_MP3		"m20_illiac_01.mp3"
-#define		M20_JAQUES_01_MP3		"m20_jaques_01.mp3"
-#define		M20_JAQUES_02_MP3		"m20_jaques_02.mp3"
-#define		M20_LUMBAR_01_MP3		"m20_lumbar_01.mp3"
-#define		M20_MANNY_01_MP3		"m20_manny_01.mp3"
-#define		M20_POLONEY_01_MP3		"m20_poloney_01.mp3"
-#define		M20_POLONEY_02_MP3		"m20_poloney_02.mp3"
-#define		M20_SARGE_01_MP3		"m20_sarge_01.mp3"
-#define		M20_SARGE_02_MP3		"m20_sarge_02.mp3"
-#define		M20_SARGE_03_MP3		"m20_sarge_03.mp3"
-#define		M20_SARGE_04_MP3		"m20_sarge_04.mp3"
-#define		M20_SARGE_05_MP3		"m20_sarge_05.mp3"
-#define		M21_ANTIMA_01_MP3		"m21_antima_01.mp3"
-#define		M21_ANTIMA_02_MP3		"m21_antima_02.mp3"
-#define		M21_ANTIMA_03_MP3		"m21_antima_03.mp3"
-#define		M21_ANTIMA_04_MP3		"m21_antima_04.mp3"
-#define		M21_ANTIMA_05_MP3		"m21_antima_05.mp3"
-#define		M21_ANTIMA_06_MP3		"m21_antima_06.mp3"
-#define		M21_ANTIMA_07_MP3		"m21_antima_07.mp3"
-#define		M21_BRAN_ONOMI_01_MP3		"m21_bran_onomi_01.mp3"
-#define		M21_BRAN_ONOMI_02_MP3		"m21_bran_onomi_02.mp3"
-#define		M21_BRAN_ONOMI_03_MP3		"m21_bran_onomi_03.mp3"
-#define		M21_CONTENNE_01_MP3		"m21_contenne_01.mp3"
-#define		M21_CONTENNE_02_MP3		"m21_contenne_02.mp3"
-#define		M21_CONTENNE_03_MP3		"m21_contenne_03.mp3"
-#define		M21_CONTENNE_04_MP3		"m21_contenne_04.mp3"
-#define		M21_CONTENNE_05_MP3		"m21_contenne_05.mp3"
-#define		M21_CONTENNE_06_MP3		"m21_contenne_06.mp3"
-#define		M21_CONTENNE_07_MP3		"m21_contenne_07.mp3"
-#define		M21_COUHOUSE_01_MP3		"m21_couhouse_01.mp3"
-#define		M21_COUHOUSE_02_MP3		"m21_couhouse_02.mp3"
-#define		M21_COUHOUSE_03_MP3		"m21_couhouse_03.mp3"
-#define		M21_DEBENSHIRE_01_MP3		"m21_debenshire_01.mp3"
-#define		M21_DEBENSHIRE_02_MP3		"m21_debenshire_02.mp3"
-#define		M21_DEBENSHIRE_03_MP3		"m21_debenshire_03.mp3"
-#define		M21_DEBENSHIRE_04_MP3		"m21_debenshire_04.mp3"
-#define		M21_FEMURIA_01_MP3		"m21_femuria_01.mp3"
-#define		M21_FEMURIA_02_MP3		"m21_femuria_02.mp3"
-#define		M21_FEMURIA_03_MP3		"m21_femuria_03.mp3"
-#define		M21_FEMURIA_04_MP3		"m21_femuria_04.mp3"
-#define		M21_FEMURIA_05_MP3		"m21_femuria_05.mp3"
-#define		M21_GLARATTE_01_MP3		"m21_glaratte_01.mp3"
-#define		M21_GLARATTE_02_MP3		"m21_glaratte_02.mp3"
-#define		M21_GLARATTE_03_MP3		"m21_glaratte_03.mp3"
-#define		M21_GLARATTE_04_MP3		"m21_glaratte_04.mp3"
-#define		M21_GUY_01_MP3		"m21_guy_01.mp3"
-#define		M21_GUY_02_MP3		"m21_guy_02.mp3"
-#define		M21_GUY_03_MP3		"m21_guy_03.mp3"
-#define		M21_GUY_04_MP3		"m21_guy_04.mp3"
-#define		M21_GUY_05_MP3		"m21_guy_05.mp3"
-#define		M21_GUY_06_MP3		"m21_guy_06.mp3"
-#define		M21_GUY_07_MP3		"m21_guy_07.mp3"
-#define		M21_GUY_08_MP3		"m21_guy_08.mp3"
-#define		M21_GUY_09_MP3		"m21_guy_09.mp3"
-#define		M21_HYPERBOLE_01_MP3		"m21_hyperbole_01.mp3"
-#define		M21_KREN_KREN_01_MP3		"m21_kren_kren_01.mp3"
-#define		M21_KREN_KREN_02_MP3		"m21_kren_kren_02.mp3"
-#define		M21_KREN_KREN_03_MP3		"m21_kren_kren_03.mp3"
-#define		M21_KREN_KREN_04_MP3		"m21_kren_kren_04.mp3"
-#define		M21_KREN_KREN_05_MP3		"m21_kren_kren_05.mp3"
-#define		M21_LITOTE_01_MP3		"m21_litote_01.mp3"
-#define		M21_PERIOUS_01_MP3		"m21_perious_01.mp3"
-#define		M21_PERIOUS_02_MP3		"m21_perious_02.mp3"
-#define		M21_PERIOUS_03_MP3		"m21_perious_03.mp3"
-#define		M21_PHAEDRUS_01_MP3		"m21_phaedrus_01.mp3"
-#define		M21_PHAEDRUS_02_MP3		"m21_phaedrus_02.mp3"
-#define		M21_PHAEDRUS_04_MP3		"m21_phaedrus_04.mp3"
-#define		M21_PHAEDRUS_05_MP3		"m21_phaedrus_05.mp3"
-#define		M21_PHAEDRUS_06_MP3		"m21_phaedrus_06.mp3"
-#define		M21_PHAEDRUS_07_MP3		"m21_phaedrus_07.mp3"
-#define		M21_PHAEDRUS_08_MP3		"m21_phaedrus_08.mp3"
-#define		M21_PHAEDRUS_09_MP3		"m21_phaedrus_09.mp3"
-#define		M21_PHAEDRUS_10_MP3		"m21_phaedrus_10.mp3"
-#define		M21_PHAEDRUS_11_MP3		"m21_phaedrus_11.mp3"
-#define		M21_PHAEDRUS_12_MP3		"m21_phaedrus_12.mp3"
-#define		M21_PHAEDRUS_13_MP3		"m21_phaedrus_13.mp3"
-#define		M21_PHAEDRUS_14_MP3		"m21_phaedrus_14.mp3"
-#define		M21_PHAEDRUS_15_MP3		"m21_phaedrus_15.mp3"
-#define		M21_PHAEDRUS_16_MP3		"m21_phaedrus_16.mp3"
-#define		M21_PHAEDRUS_17_MP3		"m21_phaedrus_17.mp3"
-#define		M21_PHAEDRUS_18_MP3		"m21_phaedrus_18.mp3"
-#define		M21_PHAEDRUS_19_MP3		"m21_phaedrus_19.mp3"
-#define		M21_PHAEDRUS_20_MP3		"m21_phaedrus_20.mp3"
-#define		M21_PHAEDRUS_21_MP3		"m21_phaedrus_21.mp3"
-#define		M21_PHAEDRUS_22_MP3		"m21_phaedrus_22.mp3"
-#define		M21_PHAEDRUS_23_MP3		"m21_phaedrus_23.mp3"
-#define		M21_PHAEDRUS_24_MP3		"m21_phaedrus_24.mp3"
-#define		M21_PHAEDRUS_25_MP3		"m21_phaedrus_25.mp3"
-#define		M21_PHAEDRUS_26_MP3		"m21_phaedrus_26.mp3"
-#define		M21_PHIPOLOSSI_01_MP3		"m21_phipolossi_01.mp3"
-#define		M21_PHIPOLOSSI_02_MP3		"m21_phipolossi_02.mp3"
-#define		M21_PHIPOLOSSI_03_MP3		"m21_phipolossi_03.mp3"
-#define		M21_PHIPOLOSSI_04_MP3		"m21_phipolossi_04.mp3"
-#define		M21_PHIPOLOSSI_05_MP3		"m21_phipolossi_05.mp3"
-#define		M21_PHIPOLOSSI_06_MP3		"m21_phipolossi_06.mp3"
-#define		M21_PLODDER_01_MP3		"m21_plodder_01.mp3"
-#define		M21_PLODDER_02_MP3		"m21_plodder_02.mp3"
-#define		M21_PLODDER_03_MP3		"m21_plodder_03.mp3"
-#define		M21_PLODDER_04_MP3		"m21_plodder_04.mp3"
-#define		M21_SARGE_01_MP3		"m21_sarge_01.mp3"
-#define		M21_SARGE_02_MP3		"m21_sarge_02.mp3"
-#define		M21_SARGE_03_MP3		"m21_sarge_03.mp3"
-#define		M21_SARGE_04_MP3		"m21_sarge_04.mp3"
-#define		M21_SARGE_05_MP3		"m21_sarge_05.mp3"
-#define		M21_SARGE_06_MP3		"m21_sarge_06.mp3"
-#define		M21_SARGE_07_MP3		"m21_sarge_07.mp3"
-#define		M21_SARGE_08_MP3		"m21_sarge_08.mp3"
-#define		M21_SATIRE_01_MP3		"m21_satire_01.mp3"
-#define		M21_SATIRE_02_MP3		"m21_satire_02.mp3"
-#define		M21_SHELLEY_01_MP3		"m21_shelley_01.mp3"
-#define		M21_SHELLEY_02_MP3		"m21_shelley_02.mp3"
-#define		M21_SHELLEY_03_MP3		"m21_shelley_03.mp3"
-#define		M21_SHELLEY_04_MP3		"m21_shelley_04.mp3"
-#define		M21_SHELLEY_05_MP3		"m21_shelley_05.mp3"
-#define		M21_VERILITH_01_MP3		"m21_verilith_01.mp3"
-#define		M21_VERILITH_02_MP3		"m21_verilith_02.mp3"
-#define		M21_VERILITH_03_MP3		"m21_verilith_03.mp3"
-#define		M21_VERILITH_04_MP3		"m21_verilith_04.mp3"
-#define		M21_VERILITH_05_MP3		"m21_verilith_05.mp3"
-#define		M22_GUY_01_MP3		"m22_guy_01.mp3"
-#define		M22_OSCURO_01_MP3		"m22_oscuro_01.mp3"
-#define		M22_OSCURO_02_MP3		"m22_oscuro_02.mp3"
-#define		M22_VERILITH_01_MP3		"m22_verilith_01.mp3"
-#define		M22_VERILITH_02_MP3		"m22_verilith_02.mp3"
-#define		M22_VERILITH_03_MP3		"m22_verilith_03.mp3"
-#define		M22_VERILITH_04_MP3		"m22_verilith_04.mp3"
-#define		M23_GUY_01_MP3		"m23_guy_01.mp3"
-#define		M23_GUY_02_MP3		"m23_guy_02.mp3"
-#define		M23_GUY_03_MP3		"m23_guy_03.mp3"
-#define		M23_INSANITO_01_MP3		"m23_insanito_01.mp3"
-#define		M23_INSANITO_02_MP3		"m23_insanito_02.mp3"
-#define		M23_INSANITO_03_MP3		"m23_insanito_03.mp3"
-#define		M23_INSANITO_04_MP3		"m23_insanito_04.mp3"
-#define		M23_INSANITO_05_MP3		"m23_insanito_05.mp3"
-#define		M23_VERILITH_01_MP3		"m23_verilith_01.mp3"
-#define		M24_GUY_01_MP3		"m24_guy_01.mp3"
-#define		M24_GUY_02_MP3		"m24_guy_02.mp3"
-#define		M24_GUY_03_MP3		"m24_guy_03.mp3"
-#define		M24_MANAGOTA_01_MP3		"m24_managota_01.mp3"
-#define		M24_MANAGOTA_02_MP3		"m24_managota_02.mp3"
-#define		M24_MANAGOTA_03_MP3		"m24_managota_03.mp3"
-#define		M24_MANAGOTA_04_MP3		"m24_managota_04.mp3"
-#define		M25_BBOW_01_MP3		"m25_bbow_01.mp3"
-#define		M25_BBOW_02_MP3		"m25_bbow_02.mp3"
-#define		M25_BBOW_03_MP3		"m25_bbow_03.mp3"
-#define		M25_BBOW_04_MP3		"m25_bbow_04.mp3"
-#define		M25_GUY_01_MP3		"m25_guy_01.mp3"
-#define		M25_GUY_02_MP3		"m25_guy_02.mp3"
-#define		M25_VERILITH_01_MP3		"m25_verilith_01.mp3"
-#define		M26_GUY_01_MP3		"m26_guy_01.mp3"
-#define		M26_GUY_02_MP3		"m26_guy_02.mp3"
-#define		M26_GUY_03_MP3		"m26_guy_03.mp3"
-#define		M26_GUY_04_MP3		"m26_guy_04.mp3"
-#define		M26_GUY_05_MP3		"m26_guy_05.mp3"
-#define		M26_FDOE_01_MP3		"m26_fdoe_01.mp3"
-#define		M26_FDOE_02_MP3		"m26_fdoe_02.mp3"
-#define		M26_FDOE_03_MP3		"m26_fdoe_03.mp3"
-#define		M26_FDOE_04_MP3		"m26_fdoe_04.mp3"
-#define		M27_AYONN_01_MP3		"m27_ayonn_01.mp3"
-#define		M27_AYONN_02_MP3		"m27_ayonn_02.mp3"
-#define		M27_AYONN_03_MP3		"m27_ayonn_03.mp3"
-#define		M27_AYONN_04_MP3		"m27_ayonn_04.mp3"
-#define		M27_BALE_01_MP3		"m27_bale_01.mp3"
-#define		M27_BALE_02_MP3		"m27_bale_02.mp3"
-#define		M27_BALE_03_MP3		"m27_bale_03.mp3"
-#define		M27_GUY_01_MP3		"m27_guy_01.mp3"
-#define		M27_GUY_02_MP3		"m27_guy_02.mp3"
-#define		M27_GUY_03_MP3		"m27_guy_03.mp3"
-#define		M27_ONABILDEN_01_MP3		"m27_onabilden_01.mp3"
-#define		M27_ONABILDEN_02_MP3		"m27_onabilden_02.mp3"
-#define		M27_ONABILDEN_03_MP3		"m27_onabilden_03.mp3"
-#define		M27_ONABILDEN_04_MP3		"m27_onabilden_04.mp3"
-#define		M28_FINN_01_MP3		"m28_finn_01.mp3"
-#define		M28_FINN_02_MP3		"m28_finn_02.mp3"
-#define		M28_FINN_03_MP3		"m28_finn_03.mp3"
-#define		M28_GUY_01_MP3		"m28_guy_01.mp3"
-#define		M28_GUY_02_MP3		"m28_guy_02.mp3"
-#define		M28_GUY_03_MP3		"m28_guy_03.mp3"
-#define		M29_ALERE_01_MP3		"m29_alere_01.mp3"
-#define		M29_ALERE_02_MP3		"m29_alere_02.mp3"
-#define		M29_ALERE_03_MP3		"m29_alere_03.mp3"
-#define		M29_AOLOS_01_MP3		"m29_aolos_01.mp3"
-#define		M29_AOLOS_02_MP3		"m29_aolos_02.mp3"
-#define		M29_AOLOS_03_MP3		"m29_aolos_03.mp3"
-#define		M29_AOLOS_04_MP3		"m29_aolos_04.mp3"
-#define		M29_AOLOS_05_MP3		"m29_aolos_05.mp3"
-#define		M29_GUY_01_MP3		"m29_guy_01.mp3"
-#define		M29_GUY_02_MP3		"m29_guy_02.mp3"
-#define		M29_GUY_03_MP3		"m29_guy_03.mp3"
-#define		M29_GUY_04_MP3		"m29_guy_04.mp3"
-#define		M29_GUY_05_MP3		"m29_guy_05.mp3"
-#define		M29_GUY_06_MP3		"m29_guy_06.mp3"
-#define		M29_GUY_07_MP3		"m29_guy_07.mp3"
-#define		M29_GUY_08_MP3		"m29_guy_08.mp3"
-#define		M29_GUY_09_MP3		"m29_guy_09.mp3"
-#define		M29_GUY_10_MP3		"m29_guy_10.mp3"
-#define		M29_GUY_11_MP3		"m29_guy_11.mp3"
-#define		M29_GUY_12_MP3		"m29_guy_12.mp3"
-#define		M29_GUY_13_MP3		"m29_guy_13.mp3"
-#define		M29_GUY_14_MP3		"m29_guy_14.mp3"
-#define		M29_GUY_15_MP3		"m29_guy_15.mp3"
-#define		M29_KORENAAR_01_MP3		"m29_korenaar_01.mp3"
-#define		M29_KORENAAR_02_MP3		"m29_korenaar_02.mp3"
-#define		M29_KORENAAR_03_MP3		"m29_korenaar_03.mp3"
-#define		M29_KORENAAR_04_MP3		"m29_korenaar_04.mp3"
-#define		M29_KORENAAR_05_MP3		"m29_korenaar_05.mp3"
-#define		M29_PHARIBOS_01_MP3		"m29_pharibos_01.mp3"
-#define		M29_PHARIBOS_02_MP3		"m29_pharibos_02.mp3"
-#define		M29_VELEGAL_01_MP3		"m29_velegal_01.mp3"
-#define		M29_VELEGAL_02_MP3		"m29_velegal_02.mp3"
-#define		M30_AOLOS_01_MP3		"m30_aolos_01.mp3"
-#define		M30_AOLOS_02_MP3		"m30_aolos_02.mp3"
-#define		M30_AOLOS_03_MP3		"m30_aolos_03.mp3"
-#define		M30_AOLOS_04_MP3		"m30_aolos_04.mp3"
-#define		M30_AOLOS_05_MP3		"m30_aolos_05.mp3"
-#define		M30_AOLOS_06_MP3		"m30_aolos_06.mp3"
-#define		M30_AOLOS_07_MP3		"m30_aolos_07.mp3"
-#define		M30_AOLOS_08_MP3		"m30_aolos_08.mp3"
-#define		M30_AOLOS_09_MP3		"m30_aolos_09.mp3"
-#define		M30_AOLOS_11_MP3		"m30_aolos_11.mp3"
-#define		M30_AOLOS_12_MP3		"m30_aolos_12.mp3"
-#define		M30_AOLOS_13_MP3		"m30_aolos_13.mp3"
-#define		M30_AOLOS_14_MP3		"m30_aolos_14.mp3"
-#define		M30_AOLOS_15_MP3		"m30_aolos_15.mp3"
-#define		M30_AOLOS_16_MP3		"m30_aolos_16.mp3"
-#define		M30_AOLOS_17_MP3		"m30_aolos_17.mp3"
-#define		M30_AOLOS_18_MP3		"m30_aolos_18.mp3"
-#define		M30_AOLOS_19_MP3		"m30_aolos_19.mp3"
-#define		M30_AOLOS_20_MP3		"m30_aolos_20.mp3"
-#define		M30_CASINOX_01_MP3		"m30_casinox_01.mp3"
-#define		M30_CASINOX_02_MP3		"m30_casinox_02.mp3"
-#define		M30_CASINOX_03_MP3		"m30_casinox_03.mp3"
-#define		M30_CASINOX_04_MP3		"m30_casinox_04.mp3"
-#define		M30_CASINOX_05_MP3		"m30_casinox_05.mp3"
-#define		M30_CASINOX_06_MP3		"m30_casinox_06.mp3"
-#define		M30_CHICKEN_EXPLOSION_01_MP3		"m30_chicken_explosion_01.mp3"
-#define		M30_CHICKEN_EXPLOSION_02_MP3		"m30_chicken_explosion_02.mp3"
-#define		M30_DOPEFISH_01_MP3		"m30_dopefish_01.mp3"
-#define		M30_DOPEFISH_02_MP3		"m30_dopefish_02.mp3"
-#define		M30_DOPEFISH_03_MP3		"m30_dopefish_03.mp3"
-#define		M30_DOPEFISH_04_MP3		"m30_dopefish_04.mp3"
-#define		M30_GUY_01_MP3		"m30_guy_01.mp3"
-#define		M30_GUY_02_MP3		"m30_guy_02.mp3"
-#define		M30_JOHN_01_MP3		"m30_john_01.mp3"
-#define		M30_JOHN_02_MP3		"m30_john_02.mp3"
-#define		M30_JOHN_03_MP3		"m30_john_03.mp3"
-#define		M30_JOHN_04_MP3		"m30_john_04.mp3"
-#define		M30_JOHN_05_MP3		"m30_john_05.mp3"
-#define		M30_LUCAS_01_MP3		"m30_lucas_01.mp3"
-#define		M30_LUCAS_02_MP3		"m30_lucas_02.mp3"
-#define		M30_LUCAS_03_MP3		"m30_lucas_03.mp3"
-#define		M30_LUCAS_04_MP3		"m30_lucas_04.mp3"
-#define		M30_STEVIE_01_MP3		"m30_stevie_01.mp3"
-#define		M30_STEVIE_02_MP3		"m30_stevie_02.mp3"
-#define		M30_STEVIE_03_MP3		"m30_stevie_03.mp3"
-#define		M30_STEVIE_04_MP3		"m30_stevie_04.mp3"
-#define		M30_STEVIE_05_MP3		"m30_stevie_05.mp3"
-#define		M30_STEVIE_06_MP3		"m30_stevie_06.mp3"
-#define		M30_STEVIE_07_MP3		"m30_stevie_07.mp3"
-#define		M30_STEVIE_08_MP3		"m30_stevie_08.mp3"
-#define		M30_STEVIE_09_MP3		"m30_stevie_09.mp3"
-#define		M30_STEVIE_10_MP3		"m30_stevie_10.mp3"
-#define		M30_TOM_01_MP3		"m30_tom_01.mp3"
-#define		M30_TOM_02_MP3		"m30_tom_02.mp3"
-#define		M30_TOM_03_MP3		"m30_tom_03.mp3"
-#define		M30_TOM_04_MP3		"m30_tom_04.mp3"
-#define		M30_TOM_05_MP3		"m30_tom_05.mp3"
-#define		M30_TOM_06_MP3		"m30_tom_06.mp3"
-#define		M30_VERILITH_01_MP3		"m30_verilith_01.mp3"
-#define		M30_VERILITH_02_MP3		"m30_verilith_02.mp3"
-#define		M30_VERILITH_03_MP3		"m30_verilith_03.mp3"
-#define		M30_VERILITH_04_MP3		"m30_verilith_04.mp3"
-#define		M30_VERILITH_05_MP3		"m30_verilith_05.mp3"
-#define		M30_VERILITH_06_MP3		"m30_verilith_06.mp3"
-#define		M30_VERILITH_07_MP3		"m30_verilith_07.mp3"
-#define		OUTRO_DOLLY_01_MP3		"outro_dolly_01.mp3"
-#define		OUTRO_DOLLY_02_MP3		"outro_dolly_02.mp3"
-#define		OUTRO_DOLLY_03_MP3		"outro_dolly_03.mp3"
-#define		OUTRO_DOLLY_04_MP3		"outro_dolly_04.mp3"
-#define		OUTRO_DOLLY_05_MP3		"outro_dolly_05.mp3"
-#define		OUTRO_DOLLY_06_MP3		"outro_dolly_06.mp3"
-#define		OUTRO_DOLLY_07_MP3		"outro_dolly_07.mp3"
-#define		OUTRO_DOLLY_08_MP3		"outro_dolly_08.mp3"
-#define		OUTRO_DOLLY_09_MP3		"outro_dolly_09.mp3"
-#define		OUTRO_DOLLY_10_MP3		"outro_dolly_10.mp3"
-#define		OUTRO_DOLLY_11_MP3		"outro_dolly_11.mp3"
-#define		OUTRO_DOLLY_12_MP3		"outro_dolly_12.mp3"
-#define		OUTRO_DOLLY_13_MP3		"outro_dolly_13.mp3"
-#define		OUTRO_DOLLY_14_MP3		"outro_dolly_14.mp3"
-#define		OUTRO_DOLLY_15_MP3		"outro_dolly_15.mp3"
-#define		OUTRO_DOLLY_16_MP3		"outro_dolly_16.mp3"
-#define		OUTRO_DOLLY_17_MP3		"outro_dolly_17.mp3"
-#define		OUTRO_DOLLY_18_MP3		"outro_dolly_18.mp3"
-#define		OUTRO_DOREK_01_MP3		"outro_dorek_01.mp3"
-#define		OUTRO_DOREK_02_MP3		"outro_dorek_02.mp3"
-#define		OUTRO_DOREK_03_MP3		"outro_dorek_03.mp3"
-#define		OUTRO_DOREK_04_MP3		"outro_dorek_04.mp3"
-#define		OUTRO_DOREK_05_MP3		"outro_dorek_05.mp3"
-#define		OUTRO_DOREK_06_MP3		"outro_dorek_06.mp3"
-#define		OUTRO_GUY_01_MP3		"outro_guy_01.mp3"
-#define		OUTRO_GUY_02_MP3		"outro_guy_02.mp3"
-#define		OUTRO_GUY_03_MP3		"outro_guy_03.mp3"
-#define		OUTRO_GUY_04_MP3		"outro_guy_04.mp3"
-#define		OUTRO_GUY_05_MP3		"outro_guy_05.mp3"
-#define		OUTRO_GUY_06_MP3		"outro_guy_06.mp3"
-#define		OUTRO_JENKINS_01_MP3		"outro_jenkins_01.mp3"
-#define		OUTRO_JENKINS_02_MP3		"outro_jenkins_02.mp3"
-#define		OUTRO_JENKINS_03_MP3		"outro_jenkins_03.mp3"
-#define		OUTRO_JENKINS_04_MP3		"outro_jenkins_04.mp3"
-#define		OUTRO_JENKINS_05_MP3		"outro_jenkins_05.mp3"
-#define		OUTRO_SARGE_01_MP3		"outro_sarge_01.mp3"
-#define		OUTRO_SARGE_02_MP3		"outro_sarge_02.mp3"
-#define		OUTRO_SARGE_03_MP3		"outro_sarge_03.mp3"
-#define		OUTRO_SARGE_04_MP3		"outro_sarge_04.mp3"
-#define		OUTRO_SARGE_05_MP3		"outro_sarge_05.mp3"
-#define		OUTRO_SARGE_06_MP3		"outro_sarge_06.mp3"
-#define		GUY_ENERGY_CELL_MP3		"guy_energy_cell.mp3"
-#define		GUY_GOT_A_JOB_MP3		"guy_got_a_job.mp3"
-#define		GUY_COMPLETED_MP3		"guy_completed.mp3"
-#define		GUY_GOT_SOMETHING_MP3		"guy_got_something.mp3"
-#define		GUY_WINS_MP3		"guy_wins.mp3"
-#define		HDB_INTRO_MP3		"hdb_intro.mp3"
+#define		VORTEXIAN_SAVE_WAV		"VORTEXIAN_SAVE.WAV"
+#define		UNLOCKED_ITEM_WAV		"UNLOCKED_ITEM.WAV"
+#define		BEEPBEEPBEEP_WAV		"BEEPBEEPBEEP.WAV"
+#define		MACHINE_AMBIENT1_WAV		"MACHINE_AMBIENT1.WAV"
+#define		M00_AIRLOCK_01_MP3		"M00_AIRLOCK_01_MP3"
+#define		M00_ARNIE_01_MP3		"M00_ARNIE_01_MP3"
+#define		M00_BRAD_01_MP3		"M00_BRAD_01_MP3"
+#define		M00_BRAD_02_MP3		"M00_BRAD_02_MP3"
+#define		M00_BRAD_03_MP3		"M00_BRAD_03_MP3"
+#define		M00_BUSTER_01_MP3		"M00_BUSTER_01_MP3"
+#define		M00_BUSTER_02_MP3		"M00_BUSTER_02_MP3"
+#define		M00_BUSTER_03_MP3		"M00_BUSTER_03_MP3"
+#define		M00_BUSTER_04_MP3		"M00_BUSTER_04_MP3"
+#define		M00_BUSTER_05_MP3		"M00_BUSTER_05_MP3"
+#define		M00_BUSTER_06_MP3		"M00_BUSTER_06_MP3"
+#define		M00_BUSTER_07_MP3		"M00_BUSTER_07_MP3"
+#define		M00_BUSTER_08_MP3		"M00_BUSTER_08_MP3"
+#define		M00_BUSTER_09_MP3		"M00_BUSTER_09_MP3"
+#define		M00_BUSTER_10_MP3		"M00_BUSTER_10_MP3"
+#define		M00_BUSTER_11_MP3		"M00_BUSTER_11_MP3"
+#define		M00_BUSTER_12_MP3		"M00_BUSTER_12_MP3"
+#define		M00_BUSTER_13A_MP3		"M00_BUSTER_13A_MP3"
+#define		M00_BUSTER_13B_MP3		"M00_BUSTER_13B_MP3"
+#define		M00_BUSTER_14_MP3		"M00_BUSTER_14_MP3"
+#define		M00_BUSTER_15_MP3		"M00_BUSTER_15_MP3"
+#define		M00_BUSTER_16_MP3		"M00_BUSTER_16_MP3"
+#define		M00_BUSTER_17_MP3		"M00_BUSTER_17_MP3"
+#define		M00_BUSTER_18_MP3		"M00_BUSTER_18_MP3"
+#define		M00_BUSTER_19_MP3		"M00_BUSTER_19_MP3"
+#define		M00_CHICKEN_01_MP3		"M00_CHICKEN_01_MP3"
+#define		M00_CHUTEGUARD_01_MP3		"M00_CHUTEGUARD_01_MP3"
+#define		M00_CHUTEGUARD_02_MP3		"M00_CHUTEGUARD_02_MP3"
+#define		M00_CHUTEGUARD_03_MP3		"M00_CHUTEGUARD_03_MP3"
+#define		M00_CHUTEGUARD_04_MP3		"M00_CHUTEGUARD_04_MP3"
+#define		M00_CHUTEGUARD_05_MP3		"M00_CHUTEGUARD_05_MP3"
+#define		M00_COOPER_01_MP3		"M00_COOPER_01_MP3"
+#define		M00_COOPER_02_MP3		"M00_COOPER_02_MP3"
+#define		M00_COOPER_03_MP3		"M00_COOPER_03_MP3"
+#define		M00_COOPER_04_MP3		"M00_COOPER_04_MP3"
+#define		M00_COOPER_05_MP3		"M00_COOPER_05_MP3"
+#define		M00_DINERS_01_MP3		"M00_DINERS_01_MP3"
+#define		M00_DINERS_02_MP3		"M00_DINERS_02_MP3"
+#define		M00_DINERS_03_MP3		"M00_DINERS_03_MP3"
+#define		M00_DINERS_04_MP3		"M00_DINERS_04_MP3"
+#define		M00_DINERS_05_MP3		"M00_DINERS_05_MP3"
+#define		M00_DINERS_06_MP3		"M00_DINERS_06_MP3"
+#define		M00_DOLLY_01_MP3		"M00_DOLLY_01_MP3"
+#define		M00_DOLLY_02_MP3		"M00_DOLLY_02_MP3"
+#define		M00_DOLLY_03_MP3		"M00_DOLLY_03_MP3"
+#define		M00_DOLLY_04_MP3		"M00_DOLLY_04_MP3"
+#define		M00_DOLLY_05_MP3		"M00_DOLLY_05_MP3"
+#define		M00_DOLLY_06_MP3		"M00_DOLLY_06_MP3"
+#define		M00_DOLLY_07_MP3		"M00_DOLLY_07_MP3"
+#define		M00_DOLLY_08_MP3		"M00_DOLLY_08_MP3"
+#define		M00_DOLLY_09_MP3		"M00_DOLLY_09_MP3"
+#define		M00_DOREK_01_MP3		"M00_DOREK_01_MP3"
+#define		M00_DOREK_02_MP3		"M00_DOREK_02_MP3"
+#define		M00_DOREK_03_MP3		"M00_DOREK_03_MP3"
+#define		M00_DOREK_04_MP3		"M00_DOREK_04_MP3"
+#define		M00_ENGCOMPUTER_01_MP3		"M00_ENGCOMPUTER_01_MP3"
+#define		M00_ENGCOMPUTER_02_MP3		"M00_ENGCOMPUTER_02_MP3"
+#define		M00_FARBLE_01_MP3		"M00_FARBLE_01_MP3"
+#define		M00_FARBLE_02_MP3		"M00_FARBLE_02_MP3"
+#define		M00_FARBLE_03_MP3		"M00_FARBLE_03_MP3"
+#define		M00_FARBLE_04_MP3		"M00_FARBLE_04_MP3"
+#define		M00_FARBLE_05_MP3		"M00_FARBLE_05_MP3"
+#define		M00_FARBLE_06_MP3		"M00_FARBLE_06_MP3"
+#define		M00_FARBLE_07_MP3		"M00_FARBLE_07_MP3"
+#define		M00_FARBLE_08_MP3		"M00_FARBLE_08_MP3"
+#define		M00_GRUNETT_01_MP3		"M00_GRUNETT_01_MP3"
+#define		M00_GRUNETT_02_MP3		"M00_GRUNETT_02_MP3"
+#define		M00_GRUNETT_03_MP3		"M00_GRUNETT_03_MP3"
+#define		M00_GRUNETT_04_MP3		"M00_GRUNETT_04_MP3"
+#define		M00_GUY_01_MP3		"M00_GUY_01_MP3"
+#define		M00_GUY_02_MP3		"M00_GUY_02_MP3"
+#define		M00_GUY_03_MP3		"M00_GUY_03_MP3"
+#define		M00_GUY_04_MP3		"M00_GUY_04_MP3"
+#define		M00_GUY_05_MP3		"M00_GUY_05_MP3"
+#define		M00_GUY_06_MP3		"M00_GUY_06_MP3"
+#define		M00_GUY_07_MP3		"M00_GUY_07_MP3"
+#define		M00_GUY_08_MP3		"M00_GUY_08_MP3"
+#define		M00_GUY_09_MP3		"M00_GUY_09_MP3"
+#define		M00_GUY_10A_MP3		"M00_GUY_10A_MP3"
+#define		M00_GUY_10B_MP3		"M00_GUY_10B_MP3"
+#define		M00_GUY_11_MP3		"M00_GUY_11_MP3"
+#define		M00_GUY_12_MP3		"M00_GUY_12_MP3"
+#define		M00_GUY_13_MP3		"M00_GUY_13_MP3"
+#define		M00_GUY_14_MP3		"M00_GUY_14_MP3"
+#define		M00_GUY_15_MP3		"M00_GUY_15_MP3"
+#define		M00_GUY_16_MP3		"M00_GUY_16_MP3"
+#define		M00_GUY_17_MP3		"M00_GUY_17_MP3"
+#define		M00_GUY_18_MP3		"M00_GUY_18_MP3"
+#define		M00_HUMBERT_01_MP3		"M00_HUMBERT_01_MP3"
+#define		M00_HUMBERT_02_MP3		"M00_HUMBERT_02_MP3"
+#define		M00_ILLIAC_01_MP3		"M00_ILLIAC_01_MP3"
+#define		M00_INFOCOMP_01_MP3		"M00_INFOCOMP_01_MP3"
+#define		M00_JAQUES_01_MP3		"M00_JAQUES_01_MP3"
+#define		M00_JAQUES_03_MP3		"M00_JAQUES_03_MP3"
+#define		M00_JAQUES_04_MP3		"M00_JAQUES_04_MP3"
+#define		M00_JAQUES_05_MP3		"M00_JAQUES_05_MP3"
+#define		M00_LUMBAR_01_MP3		"M00_LUMBAR_01_MP3"
+#define		M00_MAILSORTER_01_MP3		"M00_MAILSORTER_01_MP3"
+#define		M00_MAILSORTER_02_MP3		"M00_MAILSORTER_02_MP3"
+#define		M00_MAILSORTER_03_MP3		"M00_MAILSORTER_03_MP3"
+#define		M00_MAILSORTER_04_MP3		"M00_MAILSORTER_04_MP3"
+#define		M00_MAILSORTER_05_MP3		"M00_MAILSORTER_05_MP3"
+#define		M00_MAILSORTER_06_MP3		"M00_MAILSORTER_06_MP3"
+#define		M00_MAILSORTER_07_MP3		"M00_MAILSORTER_07_MP3"
+#define		M00_MAILSORTER_08_MP3		"M00_MAILSORTER_08_MP3"
+#define		M00_MAILSORTER_09_MP3		"M00_MAILSORTER_09_MP3"
+#define		M00_MAILSORTER_10_MP3		"M00_MAILSORTER_10_MP3"
+#define		M00_MAILSORTER_11_MP3		"M00_MAILSORTER_11_MP3"
+#define		M00_MAILSORTER_12_MP3		"M00_MAILSORTER_12_MP3"
+#define		M00_MAILSORTER_13_MP3		"M00_MAILSORTER_13_MP3"
+#define		M00_MAILSORTER_14_MP3		"M00_MAILSORTER_14_MP3"
+#define		M00_MAILSORTER_15_MP3		"M00_MAILSORTER_15_MP3"
+#define		M00_MANNY_01_MP3		"M00_MANNY_01_MP3"
+#define		M00_MANNY_02_MP3		"M00_MANNY_02_MP3"
+#define		M00_MANNY_03_MP3		"M00_MANNY_03_MP3"
+#define		M00_MANNY_04_MP3		"M00_MANNY_04_MP3"
+#define		M00_MANNY_05_MP3		"M00_MANNY_05_MP3"
+#define		M00_MANNY_06_MP3		"M00_MANNY_06_MP3"
+#define		M00_MANNY_07_MP3		"M00_MANNY_07_MP3"
+#define		M00_MANNY_08_MP3		"M00_MANNY_08_MP3"
+#define		M00_MANNY_09_MP3		"M00_MANNY_09_MP3"
+#define		M00_MANNY_10_MP3		"M00_MANNY_10_MP3"
+#define		M00_MANNY_11_MP3		"M00_MANNY_11_MP3"
+#define		M00_MANNY_12_MP3		"M00_MANNY_12_MP3"
+#define		M00_MANNY_13_MP3		"M00_MANNY_13_MP3"
+#define		M00_MANNY_14_MP3		"M00_MANNY_14_MP3"
+#define		M00_MANNY_15_MP3		"M00_MANNY_15_MP3"
+#define		M00_MANNY_16_MP3		"M00_MANNY_16_MP3"
+#define		M00_MANNY_17_MP3		"M00_MANNY_17_MP3"
+#define		M00_MANNY_18_MP3		"M00_MANNY_18_MP3"
+#define		M00_NOTEBRICK_01_MP3		"M00_NOTEBRICK_01_MP3"
+#define		M00_PILOTS_01_MP3		"M00_PILOTS_01_MP3"
+#define		M00_PILOTS_02_MP3		"M00_PILOTS_02_MP3"
+#define		M00_POLONEY_01_MP3		"M00_POLONEY_01_MP3"
+#define		M00_POLONEY_02_MP3		"M00_POLONEY_02_MP3"
+#define		M00_POLONEY_03_MP3		"M00_POLONEY_03_MP3"
+#define		M00_POLONEY_04_MP3		"M00_POLONEY_04_MP3"
+#define		M00_POLONEY_05_MP3		"M00_POLONEY_05_MP3"
+#define		M00_POLONEY_06_MP3		"M00_POLONEY_06_MP3"
+#define		M00_SARGE_01_MP3		"M00_SARGE_01_MP3"
+#define		M00_SARGE_02_MP3		"M00_SARGE_02_MP3"
+#define		M00_SARGE_03_MP3		"M00_SARGE_03_MP3"
+#define		M00_SARGE_04_MP3		"M00_SARGE_04_MP3"
+#define		M00_SARGE_05_MP3		"M00_SARGE_05_MP3"
+#define		M00_SARGE_06_MP3		"M00_SARGE_06_MP3"
+#define		M00_SARGE_07_MP3		"M00_SARGE_07_MP3"
+#define		M00_SARGE_08_MP3		"M00_SARGE_08_MP3"
+#define		M00_SARGE_09_MP3		"M00_SARGE_09_MP3"
+#define		M00_SARGE_10_MP3		"M00_SARGE_10_MP3"
+#define		M00_SARGE_11_MP3		"M00_SARGE_11_MP3"
+#define		M00_SARGE_12_MP3		"M00_SARGE_12_MP3"
+#define		M00_SARGE_13_MP3		"M00_SARGE_13_MP3"
+#define		M00_SARGE_14_MP3		"M00_SARGE_14_MP3"
+#define		M00_SARGE_15_MP3		"M00_SARGE_15_MP3"
+#define		M00_SARGE_16_MP3		"M00_SARGE_16_MP3"
+#define		M01_ALABASTER_01_MP3		"M01_ALABASTER_01_MP3"
+#define		M01_ALABASTER_02_MP3		"M01_ALABASTER_02_MP3"
+#define		M01_ALABASTER_03_MP3		"M01_ALABASTER_03_MP3"
+#define		M01_ALABASTER_04_MP3		"M01_ALABASTER_04_MP3"
+#define		M01_ALABASTER_05_MP3		"M01_ALABASTER_05_MP3"
+#define		M01_ALABASTER_06_MP3		"M01_ALABASTER_06_MP3"
+#define		M01_BRAKER_01_MP3		"M01_BRAKER_01_MP3"
+#define		M01_BRAKER_02_MP3		"M01_BRAKER_02_MP3"
+#define		M01_BRAKER_03_MP3		"M01_BRAKER_03_MP3"
+#define		M01_BRAKER_04_MP3		"M01_BRAKER_04_MP3"
+#define		M01_CHISTE_01_MP3		"M01_CHISTE_01_MP3"
+#define		M01_CHISTE_02_MP3		"M01_CHISTE_02_MP3"
+#define		M01_CHISTE_03_MP3		"M01_CHISTE_03_MP3"
+#define		M01_CHISTE_04_MP3		"M01_CHISTE_04_MP3"
+#define		M01_CHISTE_05_MP3		"M01_CHISTE_05_MP3"
+#define		M01_CHISTE_06_MP3		"M01_CHISTE_06_MP3"
+#define		M01_CHISTE_07_MP3		"M01_CHISTE_07_MP3"
+#define		M01_CHISTE_08_MP3		"M01_CHISTE_08_MP3"
+#define		M01_CHISTE_09_MP3		"M01_CHISTE_09_MP3"
+#define		M01_CHISTE_10_MP3		"M01_CHISTE_10_MP3"
+#define		M01_CHISTE_11_MP3		"M01_CHISTE_11_MP3"
+#define		M01_CHISTE_12_MP3		"M01_CHISTE_12_MP3"
+#define		M01_CHISTE_13_MP3		"M01_CHISTE_13_MP3"
+#define		M01_CHISTE_14_MP3		"M01_CHISTE_14_MP3"
+#define		M01_COVERT_01_MP3		"M01_COVERT_01_MP3"
+#define		M01_COVERT_02_MP3		"M01_COVERT_02_MP3"
+#define		M01_COVERT_03_MP3		"M01_COVERT_03_MP3"
+#define		M01_COVERT_04_MP3		"M01_COVERT_04_MP3"
+#define		M01_COVERT_05_MP3		"M01_COVERT_05_MP3"
+#define		M01_COVERT_06_MP3		"M01_COVERT_06_MP3"
+#define		M01_COVERT_07_MP3		"M01_COVERT_07_MP3"
+#define		M01_COVERT_08_MP3		"M01_COVERT_08_MP3"
+#define		M01_COVERT_09_MP3		"M01_COVERT_09_MP3"
+#define		M01_COVERT_10_MP3		"M01_COVERT_10_MP3"
+#define		M01_COVERT_11_MP3		"M01_COVERT_11_MP3"
+#define		M01_COVERT_12_MP3		"M01_COVERT_12_MP3"
+#define		M01_COVERT_13_MP3		"M01_COVERT_13_MP3"
+#define		M01_DAGEAUBE_01_MP3		"M01_DAGEAUBE_01_MP3"
+#define		M01_DAGEAUBE_02_MP3		"M01_DAGEAUBE_02_MP3"
+#define		M01_DAGEAUBE_03_MP3		"M01_DAGEAUBE_03_MP3"
+#define		M01_DAGEAUBE_04_MP3		"M01_DAGEAUBE_04_MP3"
+#define		M01_DAGEAUBE_05_MP3		"M01_DAGEAUBE_05_MP3"
+#define		M01_EMC2_01_MP3		"M01_EMC2_01_MP3"
+#define		M01_EMC2_02_MP3		"M01_EMC2_02_MP3"
+#define		M01_GIZZARD_01_MP3		"M01_GIZZARD_01_MP3"
+#define		M01_GIZZARD_02_MP3		"M01_GIZZARD_02_MP3"
+#define		M01_GUY_01_MP3		"M01_GUY_01_MP3"
+#define		M01_GUY_02_MP3		"M01_GUY_02_MP3"
+#define		M01_GUY_03_MP3		"M01_GUY_03_MP3"
+#define		M01_GUY_04_MP3		"M01_GUY_04_MP3"
+#define		M01_GUY_05_MP3		"M01_GUY_05_MP3"
+#define		M01_HIDROW_01_MP3		"M01_HIDROW_01_MP3"
+#define		M01_HIDROW_02_MP3		"M01_HIDROW_02_MP3"
+#define		M01_HIDROW_03_MP3		"M01_HIDROW_03_MP3"
+#define		M01_KEBOTTLE_01_MP3		"M01_KEBOTTLE_01_MP3"
+#define		M01_KEBOTTLE_02_MP3		"M01_KEBOTTLE_02_MP3"
+#define		M01_KEBOTTLE_03_MP3		"M01_KEBOTTLE_03_MP3"
+#define		M01_KEBOTTLE_04_MP3		"M01_KEBOTTLE_04_MP3"
+#define		M01_KEBOTTLE_05_MP3		"M01_KEBOTTLE_05_MP3"
+#define		M01_KEBOTTLE_06_MP3		"M01_KEBOTTLE_06_MP3"
+#define		M01_KEBOTTLE_07_MP3		"M01_KEBOTTLE_07_MP3"
+#define		M01_PONTE_01_MP3		"M01_PONTE_01_MP3"
+#define		M01_PONTE_02_MP3		"M01_PONTE_02_MP3"
+#define		M01_PONTE_03_MP3		"M01_PONTE_03_MP3"
+#define		M01_PONTE_04_MP3		"M01_PONTE_04_MP3"
+#define		M01_PONTE_05_MP3		"M01_PONTE_05_MP3"
+#define		M01_PONTE_06_MP3		"M01_PONTE_06_MP3"
+#define		M01_PONTE_07_MP3		"M01_PONTE_07_MP3"
+#define		M01_PONTE_08_MP3		"M01_PONTE_08_MP3"
+#define		M01_PONTE_09_MP3		"M01_PONTE_09_MP3"
+#define		M01_PONTE_10_MP3		"M01_PONTE_10_MP3"
+#define		M01_POPOPOLIS_01_MP3		"M01_POPOPOLIS_01_MP3"
+#define		M01_POPOPOLIS_02_MP3		"M01_POPOPOLIS_02_MP3"
+#define		M01_POPOPOLIS_03_MP3		"M01_POPOPOLIS_03_MP3"
+#define		M01_POPOPOLIS_04_MP3		"M01_POPOPOLIS_04_MP3"
+#define		M01_POPOPOLIS_05_MP3		"M01_POPOPOLIS_05_MP3"
+#define		M01_POPOPOLIS_06_MP3		"M01_POPOPOLIS_06_MP3"
+#define		M01_POPOPOLIS_07_MP3		"M01_POPOPOLIS_07_MP3"
+#define		M01_POPOPOLIS_08_MP3		"M01_POPOPOLIS_08_MP3"
+#define		M01_POPOPOLIS_09_MP3		"M01_POPOPOLIS_09_MP3"
+#define		M01_POPOPOLIS_10_MP3		"M01_POPOPOLIS_10_MP3"
+#define		M01_POPOPOLIS_11_MP3		"M01_POPOPOLIS_11_MP3"
+#define		M01_POPOPOLIS_12_MP3		"M01_POPOPOLIS_12_MP3"
+#define		M01_POPOPOLIS_13_MP3		"M01_POPOPOLIS_13_MP3"
+#define		M01_POPOPOLIS_14_MP3		"M01_POPOPOLIS_14_MP3"
+#define		M01_POPOPOLIS_15_MP3		"M01_POPOPOLIS_15_MP3"
+#define		M01_POPOPOLIS_16_MP3		"M01_POPOPOLIS_16_MP3"
+#define		M01_POPOPOLIS_17_MP3		"M01_POPOPOLIS_17_MP3"
+#define		M01_POPOPOLIS_18_MP3		"M01_POPOPOLIS_18_MP3"
+#define		M01_POPOPOLIS_19_MP3		"M01_POPOPOLIS_19_MP3"
+#define		M01_POPOPOLIS_20_MP3		"M01_POPOPOLIS_20_MP3"
+#define		M01_POPOPOLIS_21_MP3		"M01_POPOPOLIS_21_MP3"
+#define		M01_POPOPOLIS_22_MP3		"M01_POPOPOLIS_22_MP3"
+#define		M01_POPOPOLIS_23_MP3		"M01_POPOPOLIS_23_MP3"
+#define		M01_POPOPOLIS_24_MP3		"M01_POPOPOLIS_24_MP3"
+#define		M01_POPOPOLIS_25_MP3		"M01_POPOPOLIS_25_MP3"
+#define		M01_POPOPOLIS_26_MP3		"M01_POPOPOLIS_26_MP3"
+#define		M01_POPOPOLIS_27_MP3		"M01_POPOPOLIS_27_MP3"
+#define		M01_POPOPOLIS_28_MP3		"M01_POPOPOLIS_28_MP3"
+#define		M01_POPOPOLIS_29_MP3		"M01_POPOPOLIS_29_MP3"
+#define		M01_POPOPOLIS_30_MP3		"M01_POPOPOLIS_30_MP3"
+#define		M01_POPOPOLIS_31_MP3		"M01_POPOPOLIS_31_MP3"
+#define		M01_POPOPOLIS_32_MP3		"M01_POPOPOLIS_32_MP3"
+#define		M01_POPOPOLIS_33_MP3		"M01_POPOPOLIS_33_MP3"
+#define		M01_POPOPOLIS_34_MP3		"M01_POPOPOLIS_34_MP3"
+#define		M01_POPOPOLIS_35_MP3		"M01_POPOPOLIS_35_MP3"
+#define		M01_POPOPOLIS_36_MP3		"M01_POPOPOLIS_36_MP3"
+#define		M01_POPOPOLIS_37_MP3		"M01_POPOPOLIS_37_MP3"
+#define		M01_SARGE_01_MP3		"M01_SARGE_01_MP3"
+#define		M01_SARGE_02_MP3		"M01_SARGE_02_MP3"
+#define		M01_SARGE_03_MP3		"M01_SARGE_03_MP3"
+#define		M01_SARGE_04_MP3		"M01_SARGE_04_MP3"
+#define		M01_SOBREDELLE_01_MP3		"M01_SOBREDELLE_01_MP3"
+#define		M01_SOBREDELLE_02_MP3		"M01_SOBREDELLE_02_MP3"
+#define		M01_SOBREDELLE_03_MP3		"M01_SOBREDELLE_03_MP3"
+#define		M01_WAYNE_01_MP3		"M01_WAYNE_01_MP3"
+#define		M01_WAYNE_02_MP3		"M01_WAYNE_02_MP3"
+#define		M01_ZIQUOZ_01_MP3		"M01_ZIQUOZ_01_MP3"
+#define		M01_ZIQUOZ_02_MP3		"M01_ZIQUOZ_02_MP3"
+#define		M01_ZIQUOZ_03_MP3		"M01_ZIQUOZ_03_MP3"
+#define		M02_AGUSTO_01_MP3		"M02_AGUSTO_01_MP3"
+#define		M02_AGUSTO_02_MP3		"M02_AGUSTO_02_MP3"
+#define		M02_ALBONDIGAS_01_MP3		"M02_ALBONDIGAS_01_MP3"
+#define		M02_ALBONDIGAS_02_MP3		"M02_ALBONDIGAS_02_MP3"
+#define		M02_BUMPER_01_MP3		"M02_BUMPER_01_MP3"
+#define		M02_BUMPER_02_MP3		"M02_BUMPER_02_MP3"
+#define		M02_BUMPER_03_MP3		"M02_BUMPER_03_MP3"
+#define		M02_BUMPER_04_MP3		"M02_BUMPER_04_MP3"
+#define		M02_BUMPER_05_MP3		"M02_BUMPER_05_MP3"
+#define		M02_BUMPER_06_MP3		"M02_BUMPER_06_MP3"
+#define		M02_BUMPER_07_MP3		"M02_BUMPER_07_MP3"
+#define		M02_DELGADO_01_MP3		"M02_DELGADO_01_MP3"
+#define		M02_FEBRARO_01_MP3		"M02_FEBRARO_01_MP3"
+#define		M02_GUY_01_MP3		"M02_GUY_01_MP3"
+#define		M02_GUY_02_MP3		"M02_GUY_02_MP3"
+#define		M03_ACROPHO_01_MP3		"M03_ACROPHO_01_MP3"
+#define		M03_ACROPHO_02_MP3		"M03_ACROPHO_02_MP3"
+#define		M03_ACROPHO_03_MP3		"M03_ACROPHO_03_MP3"
+#define		M03_ACROPHO_04_MP3		"M03_ACROPHO_04_MP3"
+#define		M03_ENERO_01_MP3		"M03_ENERO_01_MP3"
+#define		M03_ENERO_02_MP3		"M03_ENERO_02_MP3"
+#define		M03_ENERO_03_MP3		"M03_ENERO_03_MP3"
+#define		M03_ENERO_04_MP3		"M03_ENERO_04_MP3"
+#define		M03_ENERO_05_MP3		"M03_ENERO_05_MP3"
+#define		M03_GAIA_01_MP3		"M03_GAIA_01_MP3"
+#define		M03_GAIA_02_MP3		"M03_GAIA_02_MP3"
+#define		M03_GAIA_03_MP3		"M03_GAIA_03_MP3"
+#define		M03_GAIA_04_MP3		"M03_GAIA_04_MP3"
+#define		M03_GAIA_05_MP3		"M03_GAIA_05_MP3"
+#define		M03_GAIA_06_MP3		"M03_GAIA_06_MP3"
+#define		M03_LAGO_01_MP3		"M03_LAGO_01_MP3"
+#define		M03_LAGO_02_MP3		"M03_LAGO_02_MP3"
+#define		M03_LAGO_04_MP3		"M03_LAGO_04_MP3"
+#define		M03_LAGO_05_MP3		"M03_LAGO_05_MP3"
+#define		M03_LAGO_06_MP3		"M03_LAGO_06_MP3"
+#define		M03_LAGO_07_MP3		"M03_LAGO_07_MP3"
+#define		M04_BONIFACE_01_MP3		"M04_BONIFACE_01_MP3"
+#define		M04_BONIFACE_02_MP3		"M04_BONIFACE_02_MP3"
+#define		M04_BONIFACE_03_MP3		"M04_BONIFACE_03_MP3"
+#define		M04_BONIFACE_04_MP3		"M04_BONIFACE_04_MP3"
+#define		M04_BONIFACE_05_MP3		"M04_BONIFACE_05_MP3"
+#define		M04_BONIFACE_06_MP3		"M04_BONIFACE_06_MP3"
+#define		M04_BONIFACE_07_MP3		"M04_BONIFACE_07_MP3"
+#define		M04_JULIO_01_MP3		"M04_JULIO_01_MP3"
+#define		M04_JULIO_02_MP3		"M04_JULIO_02_MP3"
+#define		M04_JULIO_04_MP3		"M04_JULIO_04_MP3"
+#define		M04_MARZO_01_MP3		"M04_MARZO_01_MP3"
+#define		M04_OCTUBRE_01_MP3		"M04_OCTUBRE_01_MP3"
+#define		M04_OCTUBRE_02_MP3		"M04_OCTUBRE_02_MP3"
+#define		M04_OCTUBRE_03_MP3		"M04_OCTUBRE_03_MP3"
+#define		M05_ABRIL_01_MP3		"M05_ABRIL_01_MP3"
+#define		M05_ABRIL_02_MP3		"M05_ABRIL_02_MP3"
+#define		M05_ABRIL_03_MP3		"M05_ABRIL_03_MP3"
+#define		M05_ABRIL_04_MP3		"M05_ABRIL_04_MP3"
+#define		M05_ABRIL_05_MP3		"M05_ABRIL_05_MP3"
+#define		M05_EVERLOO_01_MP3		"M05_EVERLOO_01_MP3"
+#define		M05_EVERLOO_02_MP3		"M05_EVERLOO_02_MP3"
+#define		M05_EVERLOO_03_MP3		"M05_EVERLOO_03_MP3"
+#define		M05_EVERLOO_04_MP3		"M05_EVERLOO_04_MP3"
+#define		M05_GELIGELLA_01_MP3		"M05_GELIGELLA_01_MP3"
+#define		M05_GELIGELLA_02_MP3		"M05_GELIGELLA_02_MP3"
+#define		M05_RAILRIDER_01_MP3		"M05_RAILRIDER_01_MP3"
+#define		M05_RAILRIDER_02_MP3		"M05_RAILRIDER_02_MP3"
+#define		M05_RAILRIDER_03_MP3		"M05_RAILRIDER_03_MP3"
+#define		M05_RAILRIDER_04_MP3		"M05_RAILRIDER_04_MP3"
+#define		M06_AZUL_01_MP3		"M06_AZUL_01_MP3"
+#define		M06_AZUL_02_MP3		"M06_AZUL_02_MP3"
+#define		M06_AZUL_03_MP3		"M06_AZUL_03_MP3"
+#define		M06_AZUL_04_MP3		"M06_AZUL_04_MP3"
+#define		M06_AZUL_05_MP3		"M06_AZUL_05_MP3"
+#define		M06_AZUL_06_MP3		"M06_AZUL_06_MP3"
+#define		M06_AZUL_07_MP3		"M06_AZUL_07_MP3"
+#define		M06_AZUL_08_MP3		"M06_AZUL_08_MP3"
+#define		M06_GUY_01_MP3		"M06_GUY_01_MP3"
+#define		M06_GUY_02_MP3		"M06_GUY_02_MP3"
+#define		M06_GUY_03_MP3		"M06_GUY_03_MP3"
+#define		M06_GUY_04_MP3		"M06_GUY_04_MP3"
+#define		M06_HANSON_01_MP3		"M06_HANSON_01_MP3"
+#define		M06_HANSON_03_MP3		"M06_HANSON_03_MP3"
+#define		M06_HANSON_04_MP3		"M06_HANSON_04_MP3"
+#define		M06_HANSON_05_MP3		"M06_HANSON_05_MP3"
+#define		M06_HANSON_06_MP3		"M06_HANSON_06_MP3"
+#define		M06_HANSON_07_MP3		"M06_HANSON_07_MP3"
+#define		M06_HANSON_08_MP3		"M06_HANSON_08_MP3"
+#define		M06_HANSON_09_MP3		"M06_HANSON_09_MP3"
+#define		M06_HANSON_10_MP3		"M06_HANSON_10_MP3"
+#define		M06_HANSON_11_MP3		"M06_HANSON_11_MP3"
+#define		M06_HANSON_12_MP3		"M06_HANSON_12_MP3"
+#define		M06_JUNIO_01_MP3		"M06_JUNIO_01_MP3"
+#define		M06_JUNIO_02_MP3		"M06_JUNIO_02_MP3"
+#define		M06_JUNIO_03_MP3		"M06_JUNIO_03_MP3"
+#define		M06_JUNIO_04_MP3		"M06_JUNIO_04_MP3"
+#define		M06_JUNIO_05_MP3		"M06_JUNIO_05_MP3"
+#define		M06_JUNIO_06_MP3		"M06_JUNIO_06_MP3"
+#define		M06_JUNIO_07_MP3		"M06_JUNIO_07_MP3"
+#define		M06_JUNIO_08_MP3		"M06_JUNIO_08_MP3"
+#define		M06_JUNIO_09_MP3		"M06_JUNIO_09_MP3"
+#define		M06_NARANJA_01_MP3		"M06_NARANJA_01_MP3"
+#define		M06_NARANJA_02_MP3		"M06_NARANJA_02_MP3"
+#define		M06_NARANJA_03_MP3		"M06_NARANJA_03_MP3"
+#define		M06_NARANJA_04_MP3		"M06_NARANJA_04_MP3"
+#define		M06_NARANJA_05_MP3		"M06_NARANJA_05_MP3"
+#define		M06_SEPTEMBRE_01_MP3		"M06_SEPTEMBRE_01_MP3"
+#define		M06_SEPTEMBRE_02_MP3		"M06_SEPTEMBRE_02_MP3"
+#define		M06_SEPTEMBRE_03_MP3		"M06_SEPTEMBRE_03_MP3"
+#define		M06_SEPTEMBRE_04_MP3		"M06_SEPTEMBRE_04_MP3"
+#define		M06_SEPTEMBRE_05_MP3		"M06_SEPTEMBRE_05_MP3"
+#define		M06_SEPTEMBRE_06_MP3		"M06_SEPTEMBRE_06_MP3"
+#define		M06_SEPTEMBRE_07_MP3		"M06_SEPTEMBRE_07_MP3"
+#define		M06_SEPTEMBRE_08_MP3		"M06_SEPTEMBRE_08_MP3"
+#define		M06_SEPTEMBRE_09_MP3		"M06_SEPTEMBRE_09_MP3"
+#define		M06_WORKER_01_MP3		"M06_WORKER_01_MP3"
+#define		M06_WORKER_02_MP3		"M06_WORKER_02_MP3"
+#define		M06_WORKER_03_MP3		"M06_WORKER_03_MP3"
+#define		M06_WORKER_04_MP3		"M06_WORKER_04_MP3"
+#define		M07_CERCO_01_MP3		"M07_CERCO_01_MP3"
+#define		M07_CERCO_02_MP3		"M07_CERCO_02_MP3"
+#define		M07_COMPUTER_01_MP3		"M07_COMPUTER_01_MP3"
+#define		M07_MAYO_01_MP3		"M07_MAYO_01_MP3"
+#define		M07_MAYO_02_MP3		"M07_MAYO_02_MP3"
+#define		M07_NOVIEMBRE_01_MP3		"M07_NOVIEMBRE_01_MP3"
+#define		M07_NOVIEMBRE_02_MP3		"M07_NOVIEMBRE_02_MP3"
+#define		M07_NOVIEMBRE_03_MP3		"M07_NOVIEMBRE_03_MP3"
+#define		M07_PANITO_01_MP3		"M07_PANITO_01_MP3"
+#define		M07_PANITO_02_MP3		"M07_PANITO_02_MP3"
+#define		M07_PANITO_03_MP3		"M07_PANITO_03_MP3"
+#define		M07_PANITO_04_MP3		"M07_PANITO_04_MP3"
+#define		M07_PANITO_05_MP3		"M07_PANITO_05_MP3"
+#define		M08_COOKIE_01_MP3		"M08_COOKIE_01_MP3"
+#define		M08_COOKIE_02_MP3		"M08_COOKIE_02_MP3"
+#define		M08_DICIEMBRE_01_MP3		"M08_DICIEMBRE_01_MP3"
+#define		M08_GUY_01_MP3		"M08_GUY_01_MP3"
+#define		M08_GUY_02_MP3		"M08_GUY_02_MP3"
+#define		M08_GUY_03_MP3		"M08_GUY_03_MP3"
+#define		M08_MACHINA_01_MP3		"M08_MACHINA_01_MP3"
+#define		M08_MACHINA_02_MP3		"M08_MACHINA_02_MP3"
+#define		M08_MACHINA_03_MP3		"M08_MACHINA_03_MP3"
+#define		M08_MACHINA_04_MP3		"M08_MACHINA_04_MP3"
+#define		M08_MACHINA_05_MP3		"M08_MACHINA_05_MP3"
+#define		M08_MACHINA_06_MP3		"M08_MACHINA_06_MP3"
+#define		M08_MACHINA_07_MP3		"M08_MACHINA_07_MP3"
+#define		M08_MACHINA_08_MP3		"M08_MACHINA_08_MP3"
+#define		M08_MACHINA_09_MP3		"M08_MACHINA_09_MP3"
+#define		M08_MESA_01_MP3		"M08_MESA_01_MP3"
+#define		M08_MESA_02_MP3		"M08_MESA_02_MP3"
+#define		M08_MESA_03_MP3		"M08_MESA_03_MP3"
+#define		M08_MESA_04_MP3		"M08_MESA_04_MP3"
+#define		M08_SHAKIR_01_MP3		"M08_SHAKIR_01_MP3"
+#define		M08_SHAKIR_02_MP3		"M08_SHAKIR_02_MP3"
+#define		M08_SHAKIR_03_MP3		"M08_SHAKIR_03_MP3"
+#define		M09_VIOLETA_01_MP3		"M09_VIOLETA_01_MP3"
+#define		M09_VIOLETA_02_MP3		"M09_VIOLETA_02_MP3"
+#define		M09_VIOLETA_03_MP3		"M09_VIOLETA_03_MP3"
+#define		M09_VIOLETA_04_MP3		"M09_VIOLETA_04_MP3"
+#define		M10_CHICKEN_01_MP3		"M10_CHICKEN_01_MP3"
+#define		M10_COOPER_01_MP3		"M10_COOPER_01_MP3"
+#define		M10_COOPER_02_MP3		"M10_COOPER_02_MP3"
+#define		M10_COOPER_03_MP3		"M10_COOPER_03_MP3"
+#define		M10_COOPER_04_MP3		"M10_COOPER_04_MP3"
+#define		M10_COOPER_05_MP3		"M10_COOPER_05_MP3"
+#define		M10_COOPER_06_MP3		"M10_COOPER_06_MP3"
+#define		M10_COOPER_07_MP3		"M10_COOPER_07_MP3"
+#define		M10_COOPER_08_MP3		"M10_COOPER_08_MP3"
+#define		M10_COOPER_09_MP3		"M10_COOPER_09_MP3"
+#define		M10_DOLLY_01_MP3		"M10_DOLLY_01_MP3"
+#define		M10_DOLLY_02_MP3		"M10_DOLLY_02_MP3"
+#define		M10_DOLLY_03_MP3		"M10_DOLLY_03_MP3"
+#define		M10_DOLLY_04_MP3		"M10_DOLLY_04_MP3"
+#define		M10_DOLLY_05_MP3		"M10_DOLLY_05_MP3"
+#define		M10_DOLLY_06_MP3		"M10_DOLLY_06_MP3"
+#define		M10_DOLLY_07_MP3		"M10_DOLLY_07_MP3"
+#define		M10_DOLLY_08_MP3		"M10_DOLLY_08_MP3"
+#define		M10_DOLLY_09_MP3		"M10_DOLLY_09_MP3"
+#define		M10_DOLLY_10_MP3		"M10_DOLLY_10_MP3"
+#define		M10_ENGCOMPUTER_01_MP3		"M10_ENGCOMPUTER_01_MP3"
+#define		M10_FARBLE_01_MP3		"M10_FARBLE_01_MP3"
+#define		M10_FARBLE_02_MP3		"M10_FARBLE_02_MP3"
+#define		M10_FARBLE_03_MP3		"M10_FARBLE_03_MP3"
+#define		M10_FARBLE_04_MP3		"M10_FARBLE_04_MP3"
+#define		M10_FARBLE_05_MP3		"M10_FARBLE_05_MP3"
+#define		M10_FARBLE_06_MP3		"M10_FARBLE_06_MP3"
+#define		M10_GRUNETT_01_MP3		"M10_GRUNETT_01_MP3"
+#define		M10_GRUNETT_02_MP3		"M10_GRUNETT_02_MP3"
+#define		M10_GRUNETT_03_MP3		"M10_GRUNETT_03_MP3"
+#define		M10_GRUNETT_04_MP3		"M10_GRUNETT_04_MP3"
+#define		M10_GRUNETT_05_MP3		"M10_GRUNETT_05_MP3"
+#define		M10_GRUNETT_06_MP3		"M10_GRUNETT_06_MP3"
+#define		M10_GUY_01_MP3		"M10_GUY_01_MP3"
+#define		M10_GUY_02_MP3		"M10_GUY_02_MP3"
+#define		M10_GUY_03_MP3		"M10_GUY_03_MP3"
+#define		M10_GUY_04_MP3		"M10_GUY_04_MP3"
+#define		M10_GUY_05_MP3		"M10_GUY_05_MP3"
+#define		M10_GUY_06_MP3		"M10_GUY_06_MP3"
+#define		M10_GUY_07_MP3		"M10_GUY_07_MP3"
+#define		M10_GUY_08_MP3		"M10_GUY_08_MP3"
+#define		M10_INFOCOMP_01_MP3		"M10_INFOCOMP_01_MP3"
+#define		M10_NOTEBRICK_01_MP3		"M10_NOTEBRICK_01_MP3"
+#define		M10_PILOTS_01_MP3		"M10_PILOTS_01_MP3"
+#define		M10_PILOTS_02_MP3		"M10_PILOTS_02_MP3"
+#define		M10_PILOTS_03_MP3		"M10_PILOTS_03_MP3"
+#define		M10_PILOTS_04_MP3		"M10_PILOTS_04_MP3"
+#define		M10_PILOTS_05_MP3		"M10_PILOTS_05_MP3"
+#define		M10_SARGE_01_MP3		"M10_SARGE_01_MP3"
+#define		M10_SARGE_02_MP3		"M10_SARGE_02_MP3"
+#define		M10_SARGE_03_MP3		"M10_SARGE_03_MP3"
+#define		M10_SARGE_04_MP3		"M10_SARGE_04_MP3"
+#define		M10_SARGE_05_MP3		"M10_SARGE_05_MP3"
+#define		M11_ANCHOVY_01_MP3		"M11_ANCHOVY_01_MP3"
+#define		M11_ANCHOVY_02_MP3		"M11_ANCHOVY_02_MP3"
+#define		M11_ANCHOVY_03_MP3		"M11_ANCHOVY_03_MP3"
+#define		M11_ANCHOVY_04_MP3		"M11_ANCHOVY_04_MP3"
+#define		M11_ANCHOVY_05_MP3		"M11_ANCHOVY_05_MP3"
+#define		M11_ARBIVALL_01_MP3		"M11_ARBIVALL_01_MP3"
+#define		M11_ARBIVALL_02_MP3		"M11_ARBIVALL_02_MP3"
+#define		M11_ARBIVALL_03_MP3		"M11_ARBIVALL_03_MP3"
+#define		M11_ARBIVALL_04_MP3		"M11_ARBIVALL_04_MP3"
+#define		M11_ARBIVALL_05_MP3		"M11_ARBIVALL_05_MP3"
+#define		M11_ARBIVALL_06_MP3		"M11_ARBIVALL_06_MP3"
+#define		M11_ARBIVALL_07_MP3		"M11_ARBIVALL_07_MP3"
+#define		M11_ARNIE_01_MP3		"M11_ARNIE_01_MP3"
+#define		M11_BELINDA_01_MP3		"M11_BELINDA_01_MP3"
+#define		M11_BLOCK_01_MP3		"M11_BLOCK_01_MP3"
+#define		M11_BLOCK_02_MP3		"M11_BLOCK_02_MP3"
+#define		M11_BLOCK_03_MP3		"M11_BLOCK_03_MP3"
+#define		M11_BRAD_01_MP3		"M11_BRAD_01_MP3"
+#define		M11_BRAD_02_MP3		"M11_BRAD_02_MP3"
+#define		M11_BRAD_03_MP3		"M11_BRAD_03_MP3"
+#define		M11_BUSTER_01_MP3		"M11_BUSTER_01_MP3"
+#define		M11_BUSTER_02_MP3		"M11_BUSTER_02_MP3"
+#define		M11_BUSTER_03_MP3		"M11_BUSTER_03_MP3"
+#define		M11_DINERS_01_MP3		"M11_DINERS_01_MP3"
+#define		M11_DINERS_02_MP3		"M11_DINERS_02_MP3"
+#define		M11_DOPPLER_01_MP3		"M11_DOPPLER_01_MP3"
+#define		M11_DOPPLER_02_MP3		"M11_DOPPLER_02_MP3"
+#define		M11_DOPPLER_03_MP3		"M11_DOPPLER_03_MP3"
+#define		M11_DOPPLER_04_MP3		"M11_DOPPLER_04_MP3"
+#define		M11_DOPPLER_05_MP3		"M11_DOPPLER_05_MP3"
+#define		M11_DOREK_01_MP3		"M11_DOREK_01_MP3"
+#define		M11_DOREK_02_MP3		"M11_DOREK_02_MP3"
+#define		M11_DOREK_03_MP3		"M11_DOREK_03_MP3"
+#define		M11_DOZER_01_MP3		"M11_DOZER_01_MP3"
+#define		M11_DOZER_02_MP3		"M11_DOZER_02_MP3"
+#define		M11_DOZER_03_MP3		"M11_DOZER_03_MP3"
+#define		M11_DOZER_04_MP3		"M11_DOZER_04_MP3"
+#define		M11_GNAPPE_01_MP3		"M11_GNAPPE_01_MP3"
+#define		M11_GNAPPE_02_MP3		"M11_GNAPPE_02_MP3"
+#define		M11_GNAPPE_03_MP3		"M11_GNAPPE_03_MP3"
+#define		M11_GNAPPE_04_MP3		"M11_GNAPPE_04_MP3"
+#define		M11_GNAPPE_05_MP3		"M11_GNAPPE_05_MP3"
+#define		M11_GNODIMY_01_MP3		"M11_GNODIMY_01_MP3"
+#define		M11_GNODIMY_02_MP3		"M11_GNODIMY_02_MP3"
+#define		M11_GNODIMY_03_MP3		"M11_GNODIMY_03_MP3"
+#define		M11_GNODIMY_04_MP3		"M11_GNODIMY_04_MP3"
+#define		M11_GUY_01_MP3		"M11_GUY_01_MP3"
+#define		M11_GUY_02_MP3		"M11_GUY_02_MP3"
+#define		M11_GUY_03_MP3		"M11_GUY_03_MP3"
+#define		M11_GUY_04_MP3		"M11_GUY_04_MP3"
+#define		M11_GUY_05_MP3		"M11_GUY_05_MP3"
+#define		M11_GUY_06_MP3		"M11_GUY_06_MP3"
+#define		M11_GUY_07_MP3		"M11_GUY_07_MP3"
+#define		M11_GUY_08_MP3		"M11_GUY_08_MP3"
+#define		M11_GUY_09_MP3		"M11_GUY_09_MP3"
+#define		M11_GUY_10_MP3		"M11_GUY_10_MP3"
+#define		M11_GUY_11_MP3		"M11_GUY_11_MP3"
+#define		M11_GUY_12_MP3		"M11_GUY_12_MP3"
+#define		M11_GUY_13_MP3		"M11_GUY_13_MP3"
+#define		M11_GUY_15_MP3		"M11_GUY_15_MP3"
+#define		M11_GUY_16_MP3		"M11_GUY_16_MP3"
+#define		M11_GUY_17_MP3		"M11_GUY_17_MP3"
+#define		M11_HAMBRE_01_MP3		"M11_HAMBRE_01_MP3"
+#define		M11_HAMBRE_02_MP3		"M11_HAMBRE_02_MP3"
+#define		M11_HAMBRE_03_MP3		"M11_HAMBRE_03_MP3"
+#define		M11_HAMBRE_04_MP3		"M11_HAMBRE_04_MP3"
+#define		M11_HAMBRE_05_MP3		"M11_HAMBRE_05_MP3"
+#define		M11_HUMBERT_01_MP3		"M11_HUMBERT_01_MP3"
+#define		M11_ILLIAC_01_MP3		"M11_ILLIAC_01_MP3"
+#define		M11_JAQUES_01_MP3		"M11_JAQUES_01_MP3"
+#define		M11_JAQUES_02_MP3		"M11_JAQUES_02_MP3"
+#define		M11_JAQUES_03_MP3		"M11_JAQUES_03_MP3"
+#define		M11_JAQUES_04_MP3		"M11_JAQUES_04_MP3"
+#define		M11_LUMBAR_01_MP3		"M11_LUMBAR_01_MP3"
+#define		M11_MAN_IN_STALL_01_MP3		"M11_MAN_IN_STALL_01_MP3"
+#define		M11_MAN_IN_STALL_02_MP3		"M11_MAN_IN_STALL_02_MP3"
+#define		M11_MAN_IN_STALL_03_MP3		"M11_MAN_IN_STALL_03_MP3"
+#define		M11_MAN_IN_STALL_04_MP3		"M11_MAN_IN_STALL_04_MP3"
+#define		M11_MAN_IN_STALL_05_MP3		"M11_MAN_IN_STALL_05_MP3"
+#define		M11_MANNY_01_MP3		"M11_MANNY_01_MP3"
+#define		M11_MUMPS_01_MP3		"M11_MUMPS_01_MP3"
+#define		M11_MUMPS_02_MP3		"M11_MUMPS_02_MP3"
+#define		M11_MUMPS_03_MP3		"M11_MUMPS_03_MP3"
+#define		M11_MUMPS_04_MP3		"M11_MUMPS_04_MP3"
+#define		M11_MUMPS_05_MP3		"M11_MUMPS_05_MP3"
+#define		M11_MUMPS_06_MP3		"M11_MUMPS_06_MP3"
+#define		M11_MUMPS_07_MP3		"M11_MUMPS_07_MP3"
+#define		M11_MUMPS_08_MP3		"M11_MUMPS_08_MP3"
+#define		M11_MUMPS_09_MP3		"M11_MUMPS_09_MP3"
+#define		M11_MUMPS_10_MP3		"M11_MUMPS_10_MP3"
+#define		M11_MUMPS_11_MP3		"M11_MUMPS_11_MP3"
+#define		M11_MUMPS_12_MP3		"M11_MUMPS_12_MP3"
+#define		M11_MUMPS_13_MP3		"M11_MUMPS_13_MP3"
+#define		M11_MUMPS_14_MP3		"M11_MUMPS_14_MP3"
+#define		M11_MUMPS_15_MP3		"M11_MUMPS_15_MP3"
+#define		M11_MUMPS_16_MP3		"M11_MUMPS_16_MP3"
+#define		M11_MUMPS_17_MP3		"M11_MUMPS_17_MP3"
+#define		M11_MUMPS_18_MP3		"M11_MUMPS_18_MP3"
+#define		M11_MUMPS_19_MP3		"M11_MUMPS_19_MP3"
+#define		M11_MUMPS_20_MP3		"M11_MUMPS_20_MP3"
+#define		M11_MUMPS_22_MP3		"M11_MUMPS_22_MP3"
+#define		M11_MUMPS_23_MP3		"M11_MUMPS_23_MP3"
+#define		M11_MUMPS_24_MP3		"M11_MUMPS_24_MP3"
+#define		M11_MUMPS_25_MP3		"M11_MUMPS_25_MP3"
+#define		M11_MUMPS_26_MP3		"M11_MUMPS_26_MP3"
+#define		M11_PEDIMENT_01_MP3		"M11_PEDIMENT_01_MP3"
+#define		M11_PEDIMENT_02_MP3		"M11_PEDIMENT_02_MP3"
+#define		M11_PEDIMENT_03_MP3		"M11_PEDIMENT_03_MP3"
+#define		M11_PEDIMENT_04_MP3		"M11_PEDIMENT_04_MP3"
+#define		M11_PEDIMENT_05_MP3		"M11_PEDIMENT_05_MP3"
+#define		M11_PEDIMENT_06_MP3		"M11_PEDIMENT_06_MP3"
+#define		M11_PEDIMENT_07_MP3		"M11_PEDIMENT_07_MP3"
+#define		M11_PEDIMENT_08_MP3		"M11_PEDIMENT_08_MP3"
+#define		M11_POLONEY_01_MP3		"M11_POLONEY_01_MP3"
+#define		M11_POLONEY_02_MP3		"M11_POLONEY_02_MP3"
+#define		M11_POLONEY_03_MP3		"M11_POLONEY_03_MP3"
+#define		M11_SAUSAGE_01_MP3		"M11_SAUSAGE_01_MP3"
+#define		M11_SAUSAGE_02_MP3		"M11_SAUSAGE_02_MP3"
+#define		M11_SAUSAGE_03_MP3		"M11_SAUSAGE_03_MP3"
+#define		M11_SAUSAGE_04_MP3		"M11_SAUSAGE_04_MP3"
+#define		M11_SAUSAGE_05_MP3		"M11_SAUSAGE_05_MP3"
+#define		M11_SAUSAGE_06_MP3		"M11_SAUSAGE_06_MP3"
+#define		M11_SAUSAGE_07_MP3		"M11_SAUSAGE_07_MP3"
+#define		M11_SAUSAGE_08_MP3		"M11_SAUSAGE_08_MP3"
+#define		M11_SAUSAGE_09_MP3		"M11_SAUSAGE_09_MP3"
+#define		M11_SAUSAGE_10_MP3		"M11_SAUSAGE_10_MP3"
+#define		M12_ABLE_01_MP3		"M12_ABLE_01_MP3"
+#define		M12_ABLE_02_MP3		"M12_ABLE_02_MP3"
+#define		M12_ABLE_03_MP3		"M12_ABLE_03_MP3"
+#define		M12_BUSY_01_MP3		"M12_BUSY_01_MP3"
+#define		M12_BUSY_02_MP3		"M12_BUSY_02_MP3"
+#define		M12_BUSY_03_MP3		"M12_BUSY_03_MP3"
+#define		M12_BUSY_04_MP3		"M12_BUSY_04_MP3"
+#define		M12_BUSY_05_MP3		"M12_BUSY_05_MP3"
+#define		M12_BUSY_06_MP3		"M12_BUSY_06_MP3"
+#define		M12_BUSY_07_MP3		"M12_BUSY_07_MP3"
+#define		M12_BUSY_08_MP3		"M12_BUSY_08_MP3"
+#define		M12_CHARLIE_01_MP3		"M12_CHARLIE_01_MP3"
+#define		M12_CHARLIE_02_MP3		"M12_CHARLIE_02_MP3"
+#define		M12_CONUNDRUM_01_MP3		"M12_CONUNDRUM_01_MP3"
+#define		M12_CONUNDRUM_02_MP3		"M12_CONUNDRUM_02_MP3"
+#define		M12_CONUNDRUM_03_MP3		"M12_CONUNDRUM_03_MP3"
+#define		M12_CONUNDRUM_04_MP3		"M12_CONUNDRUM_04_MP3"
+#define		M12_CONUNDRUM_05_MP3		"M12_CONUNDRUM_05_MP3"
+#define		M12_FOXTROT_01_MP3		"M12_FOXTROT_01_MP3"
+#define		M12_FOXTROT_02_MP3		"M12_FOXTROT_02_MP3"
+#define		M12_GUY_01_MP3		"M12_GUY_01_MP3"
+#define		M12_GUY_02_MP3		"M12_GUY_02_MP3"
+#define		M12_GUY_03_MP3		"M12_GUY_03_MP3"
+#define		M12_HAUTE_01_MP3		"M12_HAUTE_01_MP3"
+#define		M12_HAUTE_02_MP3		"M12_HAUTE_02_MP3"
+#define		M12_HAUTE_03_MP3		"M12_HAUTE_03_MP3"
+#define		M12_HAUTE_04_MP3		"M12_HAUTE_04_MP3"
+#define		M12_HAUTE_05_MP3		"M12_HAUTE_05_MP3"
+#define		M12_HAUTE_06_MP3		"M12_HAUTE_06_MP3"
+#define		M12_HOVER_01_MP3		"M12_HOVER_01_MP3"
+#define		M12_HOVER_02_MP3		"M12_HOVER_02_MP3"
+#define		M12_RUBE_01_MP3		"M12_RUBE_01_MP3"
+#define		M12_RUBE_02_MP3		"M12_RUBE_02_MP3"
+#define		M12_RUBE_03_MP3		"M12_RUBE_03_MP3"
+#define		M12_RUBE_04_MP3		"M12_RUBE_04_MP3"
+#define		M12_RUBE_05_MP3		"M12_RUBE_05_MP3"
+#define		M12_RUBE_06_MP3		"M12_RUBE_06_MP3"
+#define		M12_RUBE_07_MP3		"M12_RUBE_07_MP3"
+#define		M12_RUBE_08_MP3		"M12_RUBE_08_MP3"
+#define		M12_RUBE_09_MP3		"M12_RUBE_09_MP3"
+#define		M12_RUBE_10_MP3		"M12_RUBE_10_MP3"
+#define		M12_TEKT_01_MP3		"M12_TEKT_01_MP3"
+#define		M12_TEKT_02_MP3		"M12_TEKT_02_MP3"
+#define		M12_TEKT_03_MP3		"M12_TEKT_03_MP3"
+#define		M12_TEKT_04_MP3		"M12_TEKT_04_MP3"
+#define		M12_TEKT_05_MP3		"M12_TEKT_05_MP3"
+#define		M12_TEKT_06_MP3		"M12_TEKT_06_MP3"
+#define		M12_TEKT_07_MP3		"M12_TEKT_07_MP3"
+#define		M13_ANIBLE_01_MP3		"M13_ANIBLE_01_MP3"
+#define		M13_ANIBLE_02_MP3		"M13_ANIBLE_02_MP3"
+#define		M13_FLOWER_01_MP3		"M13_FLOWER_01_MP3"
+#define		M13_FLOWER_02_MP3		"M13_FLOWER_02_MP3"
+#define		M13_FOOCHANE_01_MP3		"M13_FOOCHANE_01_MP3"
+#define		M13_FOOCHANE_02_MP3		"M13_FOOCHANE_02_MP3"
+#define		M13_FOOCHANE_03_MP3		"M13_FOOCHANE_03_MP3"
+#define		M13_FOOCHANE_04_MP3		"M13_FOOCHANE_04_MP3"
+#define		M13_GHULABUL_01_MP3		"M13_GHULABUL_01_MP3"
+#define		M13_GHULABUL_02_MP3		"M13_GHULABUL_02_MP3"
+#define		M13_GHULABUL_03_MP3		"M13_GHULABUL_03_MP3"
+#define		M13_GHULABUL_04_MP3		"M13_GHULABUL_04_MP3"
+#define		M13_GHULABUL_05_MP3		"M13_GHULABUL_05_MP3"
+#define		M13_GHULABUL_06_MP3		"M13_GHULABUL_06_MP3"
+#define		M13_GHULABUL_07_MP3		"M13_GHULABUL_07_MP3"
+#define		M13_GUY_01_MP3		"M13_GUY_01_MP3"
+#define		M13_GUY_02_MP3		"M13_GUY_02_MP3"
+#define		M13_HAVENGIN_01_MP3		"M13_HAVENGIN_01_MP3"
+#define		M13_MELO_01_MP3		"M13_MELO_01_MP3"
+#define		M13_MELO_02_MP3		"M13_MELO_02_MP3"
+#define		M13_MELO_03_MP3		"M13_MELO_03_MP3"
+#define		M13_MITAKO_01_MP3		"M13_MITAKO_01_MP3"
+#define		M13_MITAKO_02_MP3		"M13_MITAKO_02_MP3"
+#define		M13_MITAKO_03_MP3		"M13_MITAKO_03_MP3"
+#define		M13_SPOONIE_01_MP3		"M13_SPOONIE_01_MP3"
+#define		M13_SPOONIE_02_MP3		"M13_SPOONIE_02_MP3"
+#define		M13_SPOONIE_03_MP3		"M13_SPOONIE_03_MP3"
+#define		M13_SPOONIE_04_MP3		"M13_SPOONIE_04_MP3"
+#define		M13_SPOONIE_05_MP3		"M13_SPOONIE_05_MP3"
+#define		M13_ZYGOTE_01_MP3		"M13_ZYGOTE_01_MP3"
+#define		M13_ZYGOTE_02_MP3		"M13_ZYGOTE_02_MP3"
+#define		M13_ZYGOTE_03_MP3		"M13_ZYGOTE_03_MP3"
+#define		M13_ZYGOTE_04_MP3		"M13_ZYGOTE_04_MP3"
+#define		M13_ZYGOTE_05_MP3		"M13_ZYGOTE_05_MP3"
+#define		M14_LAMORTE_01_MP3		"M14_LAMORTE_01_MP3"
+#define		M14_LAMORTE_02_MP3		"M14_LAMORTE_02_MP3"
+#define		M15_COPROITE_01_MP3		"M15_COPROITE_01_MP3"
+#define		M15_COPROITE_02_MP3		"M15_COPROITE_02_MP3"
+#define		M15_COPROITE_03_MP3		"M15_COPROITE_03_MP3"
+#define		M15_COPROITE_04_MP3		"M15_COPROITE_04_MP3"
+#define		M15_COPROITE_05_MP3		"M15_COPROITE_05_MP3"
+#define		M15_COPROITE_06_MP3		"M15_COPROITE_06_MP3"
+#define		M15_COPROITE_07_MP3		"M15_COPROITE_07_MP3"
+#define		M15_COPROITE_08_MP3		"M15_COPROITE_08_MP3"
+#define		M15_COPROITE_09_MP3		"M15_COPROITE_09_MP3"
+#define		M15_COPROITE_10_MP3		"M15_COPROITE_10_MP3"
+#define		M15_COPROITE_11_MP3		"M15_COPROITE_11_MP3"
+#define		M15_COPROITE_12_MP3		"M15_COPROITE_12_MP3"
+#define		M15_COPROITE_13_MP3		"M15_COPROITE_13_MP3"
+#define		M15_COPROITE_14_MP3		"M15_COPROITE_14_MP3"
+#define		M15_COPROITE_15_MP3		"M15_COPROITE_15_MP3"
+#define		M15_COPROITE_16_MP3		"M15_COPROITE_16_MP3"
+#define		M15_COPROITE_17_MP3		"M15_COPROITE_17_MP3"
+#define		M15_COPROITE_18_MP3		"M15_COPROITE_18_MP3"
+#define		M15_GUY_01_MP3		"M15_GUY_01_MP3"
+#define		M15_GUY_02_MP3		"M15_GUY_02_MP3"
+#define		M15_REED_01_MP3		"M15_REED_01_MP3"
+#define		M15_REED_02_MP3		"M15_REED_02_MP3"
+#define		M15_REED_03_MP3		"M15_REED_03_MP3"
+#define		M16_DYING_01_MP3		"M16_DYING_01_MP3"
+#define		M16_DYING_02_MP3		"M16_DYING_02_MP3"
+#define		M16_GUY_01_MP3		"M16_GUY_01_MP3"
+#define		M16_GUY_02_MP3		"M16_GUY_02_MP3"
+#define		M16_GUY_03_MP3		"M16_GUY_03_MP3"
+#define		M17_ANDERSON_01_MP3		"M17_ANDERSON_01_MP3"
+#define		M17_BARBER_01_MP3		"M17_BARBER_01_MP3"
+#define		M17_CAMPBELL_01_MP3		"M17_CAMPBELL_01_MP3"
+#define		M17_DEVONSHIRE_01_MP3		"M17_DEVONSHIRE_01_MP3"
+#define		M17_EGGER_01_MP3		"M17_EGGER_01_MP3"
+#define		M17_EMERALD_01_MP3		"M17_EMERALD_01_MP3"
+#define		M17_FLINGBESTER_01_MP3		"M17_FLINGBESTER_01_MP3"
+#define		M17_GERSHWIN_01_MP3		"M17_GERSHWIN_01_MP3"
+#define		M17_GUY_01_MP3		"M17_GUY_01_MP3"
+#define		M17_GUY_02_MP3		"M17_GUY_02_MP3"
+#define		M17_GUY_03_MP3		"M17_GUY_03_MP3"
+#define		M17_GUY_04_MP3		"M17_GUY_04_MP3"
+#define		M17_HEPHASTUS_01_MP3		"M17_HEPHASTUS_01_MP3"
+#define		M17_INIWA_01_MP3		"M17_INIWA_01_MP3"
+#define		M17_INIWA_02_MP3		"M17_INIWA_02_MP3"
+#define		M17_INIWA_03_MP3		"M17_INIWA_03_MP3"
+#define		M17_KEYCODE_01_MP3		"M17_KEYCODE_01_MP3"
+#define		M17_KEYCODE_02_MP3		"M17_KEYCODE_02_MP3"
+#define		M17_KEYCODE_03_MP3		"M17_KEYCODE_03_MP3"
+#define		M17_KEYCODE_04_MP3		"M17_KEYCODE_04_MP3"
+#define		M17_TOERIG_01_MP3		"M17_TOERIG_01_MP3"
+#define		M17_TOERIG_02_MP3		"M17_TOERIG_02_MP3"
+#define		M17_WARNER_01_MP3		"M17_WARNER_01_MP3"
+#define		M17_WARNER_02_MP3		"M17_WARNER_02_MP3"
+#define		M17_WARNER_03_MP3		"M17_WARNER_03_MP3"
+#define		M17_WARNER_04_MP3		"M17_WARNER_04_MP3"
+#define		M17_YORP_01_MP3		"M17_YORP_01_MP3"
+#define		M17_YORP_02_MP3		"M17_YORP_02_MP3"
+#define		M18_DERECHA_01_MP3		"M18_DERECHA_01_MP3"
+#define		M18_GUY_01_MP3		"M18_GUY_01_MP3"
+#define		M18_IZQUIERDA_01_MP3		"M18_IZQUIERDA_01_MP3"
+#define		M18_IZQUIERDA_02_MP3		"M18_IZQUIERDA_02_MP3"
+#define		M18_IZQUIERDA_03_MP3		"M18_IZQUIERDA_03_MP3"
+#define		M18_IZQUIERDA_04_MP3		"M18_IZQUIERDA_04_MP3"
+#define		M18_IZQUIERDA_05_MP3		"M18_IZQUIERDA_05_MP3"
+#define		M18_IZQUIERDA_06_MP3		"M18_IZQUIERDA_06_MP3"
+#define		M19_CAVEAT_01_MP3		"M19_CAVEAT_01_MP3"
+#define		M19_CAVEAT_02_MP3		"M19_CAVEAT_02_MP3"
+#define		M19_ENDER_01_MP3		"M19_ENDER_01_MP3"
+#define		M19_ENDER_02_MP3		"M19_ENDER_02_MP3"
+#define		M19_FRUSTRATO_01_MP3		"M19_FRUSTRATO_01_MP3"
+#define		M19_FRUSTRATO_02_MP3		"M19_FRUSTRATO_02_MP3"
+#define		M19_FRUSTRATO_03_MP3		"M19_FRUSTRATO_03_MP3"
+#define		M19_FRUSTRATO_04_MP3		"M19_FRUSTRATO_04_MP3"
+#define		M19_FRUSTRATO_05_MP3		"M19_FRUSTRATO_05_MP3"
+#define		M19_FRUSTRATO_06_MP3		"M19_FRUSTRATO_06_MP3"
+#define		M19_FRUSTRATO_07_MP3		"M19_FRUSTRATO_07_MP3"
+#define		M19_FRUSTRATO_08_MP3		"M19_FRUSTRATO_08_MP3"
+#define		M19_FRUSTRATO_09_MP3		"M19_FRUSTRATO_09_MP3"
+#define		M19_FRUSTRATO_10_MP3		"M19_FRUSTRATO_10_MP3"
+#define		M19_GUY_01_MP3		"M19_GUY_01_MP3"
+#define		M19_GUY_02_MP3		"M19_GUY_02_MP3"
+#define		M19_GUY_03_MP3		"M19_GUY_03_MP3"
+#define		M19_INTER_01_MP3		"M19_INTER_01_MP3"
+#define		M19_INTER_02_MP3		"M19_INTER_02_MP3"
+#define		M19_LONE_01_MP3		"M19_LONE_01_MP3"
+#define		M19_LONE_02_MP3		"M19_LONE_02_MP3"
+#define		M19_LONE_03_MP3		"M19_LONE_03_MP3"
+#define		M19_PHILLIPS_01_MP3		"M19_PHILLIPS_01_MP3"
+#define		M19_PHILLIPS_02_MP3		"M19_PHILLIPS_02_MP3"
+#define		M19_PHILLIPS_03_MP3		"M19_PHILLIPS_03_MP3"
+#define		M19_PHILLIPS_04_MP3		"M19_PHILLIPS_04_MP3"
+#define		M19_PHILLIPS_05_MP3		"M19_PHILLIPS_05_MP3"
+#define		M19_RAILRIDER_01_MP3		"M19_RAILRIDER_01_MP3"
+#define		M19_RAILRIDER_02_MP3		"M19_RAILRIDER_02_MP3"
+#define		M19_RAILRIDER_03_MP3		"M19_RAILRIDER_03_MP3"
+#define		M19_RAILRIDER_04_MP3		"M19_RAILRIDER_04_MP3"
+#define		M19_REDRUM_01_MP3		"M19_REDRUM_01_MP3"
+#define		M19_REDRUM_02_MP3		"M19_REDRUM_02_MP3"
+#define		M19_REDRUM_03_MP3		"M19_REDRUM_03_MP3"
+#define		M19_REDRUM_04_MP3		"M19_REDRUM_04_MP3"
+#define		M19_REDRUM_05_MP3		"M19_REDRUM_05_MP3"
+#define		M19_REDRUM_06_MP3		"M19_REDRUM_06_MP3"
+#define		M19_STANDARD_01_MP3		"M19_STANDARD_01_MP3"
+#define		M19_STANDARD_02_MP3		"M19_STANDARD_02_MP3"
+#define		M20_ARNIE_01_MP3		"M20_ARNIE_01_MP3"
+#define		M20_ARNIE_02_MP3		"M20_ARNIE_02_MP3"
+#define		M20_BRAD_01_MP3		"M20_BRAD_01_MP3"
+#define		M20_BRAD_02_MP3		"M20_BRAD_02_MP3"
+#define		M20_BUSTER_01_MP3		"M20_BUSTER_01_MP3"
+#define		M20_BUSTER_02_MP3		"M20_BUSTER_02_MP3"
+#define		M20_BUSTER_03_MP3		"M20_BUSTER_03_MP3"
+#define		M20_COOPER_01_MP3		"M20_COOPER_01_MP3"
+#define		M20_COOPER_02_MP3		"M20_COOPER_02_MP3"
+#define		M20_DINERS_01_MP3		"M20_DINERS_01_MP3"
+#define		M20_DINERS_02_MP3		"M20_DINERS_02_MP3"
+#define		M20_DOLLY_01_MP3		"M20_DOLLY_01_MP3"
+#define		M20_DOREK_01_MP3		"M20_DOREK_01_MP3"
+#define		M20_DOREK_02_MP3		"M20_DOREK_02_MP3"
+#define		M20_DOREK_03_MP3		"M20_DOREK_03_MP3"
+#define		M20_FARBLE_01_MP3		"M20_FARBLE_01_MP3"
+#define		M20_FARBLE_02_MP3		"M20_FARBLE_02_MP3"
+#define		M20_GRUNETT_01_MP3		"M20_GRUNETT_01_MP3"
+#define		M20_GRUNETT_02_MP3		"M20_GRUNETT_02_MP3"
+#define		M20_GUY_01_MP3		"M20_GUY_01_MP3"
+#define		M20_GUY_02_MP3		"M20_GUY_02_MP3"
+#define		M20_GUY_03_MP3		"M20_GUY_03_MP3"
+#define		M20_GUY_04_MP3		"M20_GUY_04_MP3"
+#define		M20_GUY_05_MP3		"M20_GUY_05_MP3"
+#define		M20_GUY_06_MP3		"M20_GUY_06_MP3"
+#define		M20_HUMBERT_01_MP3		"M20_HUMBERT_01_MP3"
+#define		M20_ILLIAC_01_MP3		"M20_ILLIAC_01_MP3"
+#define		M20_JAQUES_01_MP3		"M20_JAQUES_01_MP3"
+#define		M20_JAQUES_02_MP3		"M20_JAQUES_02_MP3"
+#define		M20_LUMBAR_01_MP3		"M20_LUMBAR_01_MP3"
+#define		M20_MANNY_01_MP3		"M20_MANNY_01_MP3"
+#define		M20_POLONEY_01_MP3		"M20_POLONEY_01_MP3"
+#define		M20_POLONEY_02_MP3		"M20_POLONEY_02_MP3"
+#define		M20_SARGE_01_MP3		"M20_SARGE_01_MP3"
+#define		M20_SARGE_02_MP3		"M20_SARGE_02_MP3"
+#define		M20_SARGE_03_MP3		"M20_SARGE_03_MP3"
+#define		M20_SARGE_04_MP3		"M20_SARGE_04_MP3"
+#define		M20_SARGE_05_MP3		"M20_SARGE_05_MP3"
+#define		M21_ANTIMA_01_MP3		"M21_ANTIMA_01_MP3"
+#define		M21_ANTIMA_02_MP3		"M21_ANTIMA_02_MP3"
+#define		M21_ANTIMA_03_MP3		"M21_ANTIMA_03_MP3"
+#define		M21_ANTIMA_04_MP3		"M21_ANTIMA_04_MP3"
+#define		M21_ANTIMA_05_MP3		"M21_ANTIMA_05_MP3"
+#define		M21_ANTIMA_06_MP3		"M21_ANTIMA_06_MP3"
+#define		M21_ANTIMA_07_MP3		"M21_ANTIMA_07_MP3"
+#define		M21_BRAN_ONOMI_01_MP3		"M21_BRAN_ONOMI_01_MP3"
+#define		M21_BRAN_ONOMI_02_MP3		"M21_BRAN_ONOMI_02_MP3"
+#define		M21_BRAN_ONOMI_03_MP3		"M21_BRAN_ONOMI_03_MP3"
+#define		M21_CONTENNE_01_MP3		"M21_CONTENNE_01_MP3"
+#define		M21_CONTENNE_02_MP3		"M21_CONTENNE_02_MP3"
+#define		M21_CONTENNE_03_MP3		"M21_CONTENNE_03_MP3"
+#define		M21_CONTENNE_04_MP3		"M21_CONTENNE_04_MP3"
+#define		M21_CONTENNE_05_MP3		"M21_CONTENNE_05_MP3"
+#define		M21_CONTENNE_06_MP3		"M21_CONTENNE_06_MP3"
+#define		M21_CONTENNE_07_MP3		"M21_CONTENNE_07_MP3"
+#define		M21_COUHOUSE_01_MP3		"M21_COUHOUSE_01_MP3"
+#define		M21_COUHOUSE_02_MP3		"M21_COUHOUSE_02_MP3"
+#define		M21_COUHOUSE_03_MP3		"M21_COUHOUSE_03_MP3"
+#define		M21_DEBENSHIRE_01_MP3		"M21_DEBENSHIRE_01_MP3"
+#define		M21_DEBENSHIRE_02_MP3		"M21_DEBENSHIRE_02_MP3"
+#define		M21_DEBENSHIRE_03_MP3		"M21_DEBENSHIRE_03_MP3"
+#define		M21_DEBENSHIRE_04_MP3		"M21_DEBENSHIRE_04_MP3"
+#define		M21_FEMURIA_01_MP3		"M21_FEMURIA_01_MP3"
+#define		M21_FEMURIA_02_MP3		"M21_FEMURIA_02_MP3"
+#define		M21_FEMURIA_03_MP3		"M21_FEMURIA_03_MP3"
+#define		M21_FEMURIA_04_MP3		"M21_FEMURIA_04_MP3"
+#define		M21_FEMURIA_05_MP3		"M21_FEMURIA_05_MP3"
+#define		M21_GLARATTE_01_MP3		"M21_GLARATTE_01_MP3"
+#define		M21_GLARATTE_02_MP3		"M21_GLARATTE_02_MP3"
+#define		M21_GLARATTE_03_MP3		"M21_GLARATTE_03_MP3"
+#define		M21_GLARATTE_04_MP3		"M21_GLARATTE_04_MP3"
+#define		M21_GUY_01_MP3		"M21_GUY_01_MP3"
+#define		M21_GUY_02_MP3		"M21_GUY_02_MP3"
+#define		M21_GUY_03_MP3		"M21_GUY_03_MP3"
+#define		M21_GUY_04_MP3		"M21_GUY_04_MP3"
+#define		M21_GUY_05_MP3		"M21_GUY_05_MP3"
+#define		M21_GUY_06_MP3		"M21_GUY_06_MP3"
+#define		M21_GUY_07_MP3		"M21_GUY_07_MP3"
+#define		M21_GUY_08_MP3		"M21_GUY_08_MP3"
+#define		M21_GUY_09_MP3		"M21_GUY_09_MP3"
+#define		M21_HYPERBOLE_01_MP3		"M21_HYPERBOLE_01_MP3"
+#define		M21_KREN_KREN_01_MP3		"M21_KREN_KREN_01_MP3"
+#define		M21_KREN_KREN_02_MP3		"M21_KREN_KREN_02_MP3"
+#define		M21_KREN_KREN_03_MP3		"M21_KREN_KREN_03_MP3"
+#define		M21_KREN_KREN_04_MP3		"M21_KREN_KREN_04_MP3"
+#define		M21_KREN_KREN_05_MP3		"M21_KREN_KREN_05_MP3"
+#define		M21_LITOTE_01_MP3		"M21_LITOTE_01_MP3"
+#define		M21_PERIOUS_01_MP3		"M21_PERIOUS_01_MP3"
+#define		M21_PERIOUS_02_MP3		"M21_PERIOUS_02_MP3"
+#define		M21_PERIOUS_03_MP3		"M21_PERIOUS_03_MP3"
+#define		M21_PHAEDRUS_01_MP3		"M21_PHAEDRUS_01_MP3"
+#define		M21_PHAEDRUS_02_MP3		"M21_PHAEDRUS_02_MP3"
+#define		M21_PHAEDRUS_04_MP3		"M21_PHAEDRUS_04_MP3"
+#define		M21_PHAEDRUS_05_MP3		"M21_PHAEDRUS_05_MP3"
+#define		M21_PHAEDRUS_06_MP3		"M21_PHAEDRUS_06_MP3"
+#define		M21_PHAEDRUS_07_MP3		"M21_PHAEDRUS_07_MP3"
+#define		M21_PHAEDRUS_08_MP3		"M21_PHAEDRUS_08_MP3"
+#define		M21_PHAEDRUS_09_MP3		"M21_PHAEDRUS_09_MP3"
+#define		M21_PHAEDRUS_10_MP3		"M21_PHAEDRUS_10_MP3"
+#define		M21_PHAEDRUS_11_MP3		"M21_PHAEDRUS_11_MP3"
+#define		M21_PHAEDRUS_12_MP3		"M21_PHAEDRUS_12_MP3"
+#define		M21_PHAEDRUS_13_MP3		"M21_PHAEDRUS_13_MP3"
+#define		M21_PHAEDRUS_14_MP3		"M21_PHAEDRUS_14_MP3"
+#define		M21_PHAEDRUS_15_MP3		"M21_PHAEDRUS_15_MP3"
+#define		M21_PHAEDRUS_16_MP3		"M21_PHAEDRUS_16_MP3"
+#define		M21_PHAEDRUS_17_MP3		"M21_PHAEDRUS_17_MP3"
+#define		M21_PHAEDRUS_18_MP3		"M21_PHAEDRUS_18_MP3"
+#define		M21_PHAEDRUS_19_MP3		"M21_PHAEDRUS_19_MP3"
+#define		M21_PHAEDRUS_20_MP3		"M21_PHAEDRUS_20_MP3"
+#define		M21_PHAEDRUS_21_MP3		"M21_PHAEDRUS_21_MP3"
+#define		M21_PHAEDRUS_22_MP3		"M21_PHAEDRUS_22_MP3"
+#define		M21_PHAEDRUS_23_MP3		"M21_PHAEDRUS_23_MP3"
+#define		M21_PHAEDRUS_24_MP3		"M21_PHAEDRUS_24_MP3"
+#define		M21_PHAEDRUS_25_MP3		"M21_PHAEDRUS_25_MP3"
+#define		M21_PHAEDRUS_26_MP3		"M21_PHAEDRUS_26_MP3"
+#define		M21_PHIPOLOSSI_01_MP3		"M21_PHIPOLOSSI_01_MP3"
+#define		M21_PHIPOLOSSI_02_MP3		"M21_PHIPOLOSSI_02_MP3"
+#define		M21_PHIPOLOSSI_03_MP3		"M21_PHIPOLOSSI_03_MP3"
+#define		M21_PHIPOLOSSI_04_MP3		"M21_PHIPOLOSSI_04_MP3"
+#define		M21_PHIPOLOSSI_05_MP3		"M21_PHIPOLOSSI_05_MP3"
+#define		M21_PHIPOLOSSI_06_MP3		"M21_PHIPOLOSSI_06_MP3"
+#define		M21_PLODDER_01_MP3		"M21_PLODDER_01_MP3"
+#define		M21_PLODDER_02_MP3		"M21_PLODDER_02_MP3"
+#define		M21_PLODDER_03_MP3		"M21_PLODDER_03_MP3"
+#define		M21_PLODDER_04_MP3		"M21_PLODDER_04_MP3"
+#define		M21_SARGE_01_MP3		"M21_SARGE_01_MP3"
+#define		M21_SARGE_02_MP3		"M21_SARGE_02_MP3"
+#define		M21_SARGE_03_MP3		"M21_SARGE_03_MP3"
+#define		M21_SARGE_04_MP3		"M21_SARGE_04_MP3"
+#define		M21_SARGE_05_MP3		"M21_SARGE_05_MP3"
+#define		M21_SARGE_06_MP3		"M21_SARGE_06_MP3"
+#define		M21_SARGE_07_MP3		"M21_SARGE_07_MP3"
+#define		M21_SARGE_08_MP3		"M21_SARGE_08_MP3"
+#define		M21_SATIRE_01_MP3		"M21_SATIRE_01_MP3"
+#define		M21_SATIRE_02_MP3		"M21_SATIRE_02_MP3"
+#define		M21_SHELLEY_01_MP3		"M21_SHELLEY_01_MP3"
+#define		M21_SHELLEY_02_MP3		"M21_SHELLEY_02_MP3"
+#define		M21_SHELLEY_03_MP3		"M21_SHELLEY_03_MP3"
+#define		M21_SHELLEY_04_MP3		"M21_SHELLEY_04_MP3"
+#define		M21_SHELLEY_05_MP3		"M21_SHELLEY_05_MP3"
+#define		M21_VERILITH_01_MP3		"M21_VERILITH_01_MP3"
+#define		M21_VERILITH_02_MP3		"M21_VERILITH_02_MP3"
+#define		M21_VERILITH_03_MP3		"M21_VERILITH_03_MP3"
+#define		M21_VERILITH_04_MP3		"M21_VERILITH_04_MP3"
+#define		M21_VERILITH_05_MP3		"M21_VERILITH_05_MP3"
+#define		M22_GUY_01_MP3		"M22_GUY_01_MP3"
+#define		M22_OSCURO_01_MP3		"M22_OSCURO_01_MP3"
+#define		M22_OSCURO_02_MP3		"M22_OSCURO_02_MP3"
+#define		M22_VERILITH_01_MP3		"M22_VERILITH_01_MP3"
+#define		M22_VERILITH_02_MP3		"M22_VERILITH_02_MP3"
+#define		M22_VERILITH_03_MP3		"M22_VERILITH_03_MP3"
+#define		M22_VERILITH_04_MP3		"M22_VERILITH_04_MP3"
+#define		M23_GUY_01_MP3		"M23_GUY_01_MP3"
+#define		M23_GUY_02_MP3		"M23_GUY_02_MP3"
+#define		M23_GUY_03_MP3		"M23_GUY_03_MP3"
+#define		M23_INSANITO_01_MP3		"M23_INSANITO_01_MP3"
+#define		M23_INSANITO_02_MP3		"M23_INSANITO_02_MP3"
+#define		M23_INSANITO_03_MP3		"M23_INSANITO_03_MP3"
+#define		M23_INSANITO_04_MP3		"M23_INSANITO_04_MP3"
+#define		M23_INSANITO_05_MP3		"M23_INSANITO_05_MP3"
+#define		M23_VERILITH_01_MP3		"M23_VERILITH_01_MP3"
+#define		M24_GUY_01_MP3		"M24_GUY_01_MP3"
+#define		M24_GUY_02_MP3		"M24_GUY_02_MP3"
+#define		M24_GUY_03_MP3		"M24_GUY_03_MP3"
+#define		M24_MANAGOTA_01_MP3		"M24_MANAGOTA_01_MP3"
+#define		M24_MANAGOTA_02_MP3		"M24_MANAGOTA_02_MP3"
+#define		M24_MANAGOTA_03_MP3		"M24_MANAGOTA_03_MP3"
+#define		M24_MANAGOTA_04_MP3		"M24_MANAGOTA_04_MP3"
+#define		M25_BBOW_01_MP3		"M25_BBOW_01_MP3"
+#define		M25_BBOW_02_MP3		"M25_BBOW_02_MP3"
+#define		M25_BBOW_03_MP3		"M25_BBOW_03_MP3"
+#define		M25_BBOW_04_MP3		"M25_BBOW_04_MP3"
+#define		M25_GUY_01_MP3		"M25_GUY_01_MP3"
+#define		M25_GUY_02_MP3		"M25_GUY_02_MP3"
+#define		M25_VERILITH_01_MP3		"M25_VERILITH_01_MP3"
+#define		M26_GUY_01_MP3		"M26_GUY_01_MP3"
+#define		M26_GUY_02_MP3		"M26_GUY_02_MP3"
+#define		M26_GUY_03_MP3		"M26_GUY_03_MP3"
+#define		M26_GUY_04_MP3		"M26_GUY_04_MP3"
+#define		M26_GUY_05_MP3		"M26_GUY_05_MP3"
+#define		M26_FDOE_01_MP3		"M26_FDOE_01_MP3"
+#define		M26_FDOE_02_MP3		"M26_FDOE_02_MP3"
+#define		M26_FDOE_03_MP3		"M26_FDOE_03_MP3"
+#define		M26_FDOE_04_MP3		"M26_FDOE_04_MP3"
+#define		M27_AYONN_01_MP3		"M27_AYONN_01_MP3"
+#define		M27_AYONN_02_MP3		"M27_AYONN_02_MP3"
+#define		M27_AYONN_03_MP3		"M27_AYONN_03_MP3"
+#define		M27_AYONN_04_MP3		"M27_AYONN_04_MP3"
+#define		M27_BALE_01_MP3		"M27_BALE_01_MP3"
+#define		M27_BALE_02_MP3		"M27_BALE_02_MP3"
+#define		M27_BALE_03_MP3		"M27_BALE_03_MP3"
+#define		M27_GUY_01_MP3		"M27_GUY_01_MP3"
+#define		M27_GUY_02_MP3		"M27_GUY_02_MP3"
+#define		M27_GUY_03_MP3		"M27_GUY_03_MP3"
+#define		M27_ONABILDEN_01_MP3		"M27_ONABILDEN_01_MP3"
+#define		M27_ONABILDEN_02_MP3		"M27_ONABILDEN_02_MP3"
+#define		M27_ONABILDEN_03_MP3		"M27_ONABILDEN_03_MP3"
+#define		M27_ONABILDEN_04_MP3		"M27_ONABILDEN_04_MP3"
+#define		M28_FINN_01_MP3		"M28_FINN_01_MP3"
+#define		M28_FINN_02_MP3		"M28_FINN_02_MP3"
+#define		M28_FINN_03_MP3		"M28_FINN_03_MP3"
+#define		M28_GUY_01_MP3		"M28_GUY_01_MP3"
+#define		M28_GUY_02_MP3		"M28_GUY_02_MP3"
+#define		M28_GUY_03_MP3		"M28_GUY_03_MP3"
+#define		M29_ALERE_01_MP3		"M29_ALERE_01_MP3"
+#define		M29_ALERE_02_MP3		"M29_ALERE_02_MP3"
+#define		M29_ALERE_03_MP3		"M29_ALERE_03_MP3"
+#define		M29_AOLOS_01_MP3		"M29_AOLOS_01_MP3"
+#define		M29_AOLOS_02_MP3		"M29_AOLOS_02_MP3"
+#define		M29_AOLOS_03_MP3		"M29_AOLOS_03_MP3"
+#define		M29_AOLOS_04_MP3		"M29_AOLOS_04_MP3"
+#define		M29_AOLOS_05_MP3		"M29_AOLOS_05_MP3"
+#define		M29_GUY_01_MP3		"M29_GUY_01_MP3"
+#define		M29_GUY_02_MP3		"M29_GUY_02_MP3"
+#define		M29_GUY_03_MP3		"M29_GUY_03_MP3"
+#define		M29_GUY_04_MP3		"M29_GUY_04_MP3"
+#define		M29_GUY_05_MP3		"M29_GUY_05_MP3"
+#define		M29_GUY_06_MP3		"M29_GUY_06_MP3"
+#define		M29_GUY_07_MP3		"M29_GUY_07_MP3"
+#define		M29_GUY_08_MP3		"M29_GUY_08_MP3"
+#define		M29_GUY_09_MP3		"M29_GUY_09_MP3"
+#define		M29_GUY_10_MP3		"M29_GUY_10_MP3"
+#define		M29_GUY_11_MP3		"M29_GUY_11_MP3"
+#define		M29_GUY_12_MP3		"M29_GUY_12_MP3"
+#define		M29_GUY_13_MP3		"M29_GUY_13_MP3"
+#define		M29_GUY_14_MP3		"M29_GUY_14_MP3"
+#define		M29_GUY_15_MP3		"M29_GUY_15_MP3"
+#define		M29_KORENAAR_01_MP3		"M29_KORENAAR_01_MP3"
+#define		M29_KORENAAR_02_MP3		"M29_KORENAAR_02_MP3"
+#define		M29_KORENAAR_03_MP3		"M29_KORENAAR_03_MP3"
+#define		M29_KORENAAR_04_MP3		"M29_KORENAAR_04_MP3"
+#define		M29_KORENAAR_05_MP3		"M29_KORENAAR_05_MP3"
+#define		M29_PHARIBOS_01_MP3		"M29_PHARIBOS_01_MP3"
+#define		M29_PHARIBOS_02_MP3		"M29_PHARIBOS_02_MP3"
+#define		M29_VELEGAL_01_MP3		"M29_VELEGAL_01_MP3"
+#define		M29_VELEGAL_02_MP3		"M29_VELEGAL_02_MP3"
+#define		M30_AOLOS_01_MP3		"M30_AOLOS_01_MP3"
+#define		M30_AOLOS_02_MP3		"M30_AOLOS_02_MP3"
+#define		M30_AOLOS_03_MP3		"M30_AOLOS_03_MP3"
+#define		M30_AOLOS_04_MP3		"M30_AOLOS_04_MP3"
+#define		M30_AOLOS_05_MP3		"M30_AOLOS_05_MP3"
+#define		M30_AOLOS_06_MP3		"M30_AOLOS_06_MP3"
+#define		M30_AOLOS_07_MP3		"M30_AOLOS_07_MP3"
+#define		M30_AOLOS_08_MP3		"M30_AOLOS_08_MP3"
+#define		M30_AOLOS_09_MP3		"M30_AOLOS_09_MP3"
+#define		M30_AOLOS_11_MP3		"M30_AOLOS_11_MP3"
+#define		M30_AOLOS_12_MP3		"M30_AOLOS_12_MP3"
+#define		M30_AOLOS_13_MP3		"M30_AOLOS_13_MP3"
+#define		M30_AOLOS_14_MP3		"M30_AOLOS_14_MP3"
+#define		M30_AOLOS_15_MP3		"M30_AOLOS_15_MP3"
+#define		M30_AOLOS_16_MP3		"M30_AOLOS_16_MP3"
+#define		M30_AOLOS_17_MP3		"M30_AOLOS_17_MP3"
+#define		M30_AOLOS_18_MP3		"M30_AOLOS_18_MP3"
+#define		M30_AOLOS_19_MP3		"M30_AOLOS_19_MP3"
+#define		M30_AOLOS_20_MP3		"M30_AOLOS_20_MP3"
+#define		M30_CASINOX_01_MP3		"M30_CASINOX_01_MP3"
+#define		M30_CASINOX_02_MP3		"M30_CASINOX_02_MP3"
+#define		M30_CASINOX_03_MP3		"M30_CASINOX_03_MP3"
+#define		M30_CASINOX_04_MP3		"M30_CASINOX_04_MP3"
+#define		M30_CASINOX_05_MP3		"M30_CASINOX_05_MP3"
+#define		M30_CASINOX_06_MP3		"M30_CASINOX_06_MP3"
+#define		M30_CHICKEN_EXPLOSION_01_MP3		"M30_CHICKEN_EXPLOSION_01_MP3"
+#define		M30_CHICKEN_EXPLOSION_02_MP3		"M30_CHICKEN_EXPLOSION_02_MP3"
+#define		M30_DOPEFISH_01_MP3		"M30_DOPEFISH_01_MP3"
+#define		M30_DOPEFISH_02_MP3		"M30_DOPEFISH_02_MP3"
+#define		M30_DOPEFISH_03_MP3		"M30_DOPEFISH_03_MP3"
+#define		M30_DOPEFISH_04_MP3		"M30_DOPEFISH_04_MP3"
+#define		M30_GUY_01_MP3		"M30_GUY_01_MP3"
+#define		M30_GUY_02_MP3		"M30_GUY_02_MP3"
+#define		M30_JOHN_01_MP3		"M30_JOHN_01_MP3"
+#define		M30_JOHN_02_MP3		"M30_JOHN_02_MP3"
+#define		M30_JOHN_03_MP3		"M30_JOHN_03_MP3"
+#define		M30_JOHN_04_MP3		"M30_JOHN_04_MP3"
+#define		M30_JOHN_05_MP3		"M30_JOHN_05_MP3"
+#define		M30_LUCAS_01_MP3		"M30_LUCAS_01_MP3"
+#define		M30_LUCAS_02_MP3		"M30_LUCAS_02_MP3"
+#define		M30_LUCAS_03_MP3		"M30_LUCAS_03_MP3"
+#define		M30_LUCAS_04_MP3		"M30_LUCAS_04_MP3"
+#define		M30_STEVIE_01_MP3		"M30_STEVIE_01_MP3"
+#define		M30_STEVIE_02_MP3		"M30_STEVIE_02_MP3"
+#define		M30_STEVIE_03_MP3		"M30_STEVIE_03_MP3"
+#define		M30_STEVIE_04_MP3		"M30_STEVIE_04_MP3"
+#define		M30_STEVIE_05_MP3		"M30_STEVIE_05_MP3"
+#define		M30_STEVIE_06_MP3		"M30_STEVIE_06_MP3"
+#define		M30_STEVIE_07_MP3		"M30_STEVIE_07_MP3"
+#define		M30_STEVIE_08_MP3		"M30_STEVIE_08_MP3"
+#define		M30_STEVIE_09_MP3		"M30_STEVIE_09_MP3"
+#define		M30_STEVIE_10_MP3		"M30_STEVIE_10_MP3"
+#define		M30_TOM_01_MP3		"M30_TOM_01_MP3"
+#define		M30_TOM_02_MP3		"M30_TOM_02_MP3"
+#define		M30_TOM_03_MP3		"M30_TOM_03_MP3"
+#define		M30_TOM_04_MP3		"M30_TOM_04_MP3"
+#define		M30_TOM_05_MP3		"M30_TOM_05_MP3"
+#define		M30_TOM_06_MP3		"M30_TOM_06_MP3"
+#define		M30_VERILITH_01_MP3		"M30_VERILITH_01_MP3"
+#define		M30_VERILITH_02_MP3		"M30_VERILITH_02_MP3"
+#define		M30_VERILITH_03_MP3		"M30_VERILITH_03_MP3"
+#define		M30_VERILITH_04_MP3		"M30_VERILITH_04_MP3"
+#define		M30_VERILITH_05_MP3		"M30_VERILITH_05_MP3"
+#define		M30_VERILITH_06_MP3		"M30_VERILITH_06_MP3"
+#define		M30_VERILITH_07_MP3		"M30_VERILITH_07_MP3"
+#define		OUTRO_DOLLY_01_MP3		"OUTRO_DOLLY_01_MP3"
+#define		OUTRO_DOLLY_02_MP3		"OUTRO_DOLLY_02_MP3"
+#define		OUTRO_DOLLY_03_MP3		"OUTRO_DOLLY_03_MP3"
+#define		OUTRO_DOLLY_04_MP3		"OUTRO_DOLLY_04_MP3"
+#define		OUTRO_DOLLY_05_MP3		"OUTRO_DOLLY_05_MP3"
+#define		OUTRO_DOLLY_06_MP3		"OUTRO_DOLLY_06_MP3"
+#define		OUTRO_DOLLY_07_MP3		"OUTRO_DOLLY_07_MP3"
+#define		OUTRO_DOLLY_08_MP3		"OUTRO_DOLLY_08_MP3"
+#define		OUTRO_DOLLY_09_MP3		"OUTRO_DOLLY_09_MP3"
+#define		OUTRO_DOLLY_10_MP3		"OUTRO_DOLLY_10_MP3"
+#define		OUTRO_DOLLY_11_MP3		"OUTRO_DOLLY_11_MP3"
+#define		OUTRO_DOLLY_12_MP3		"OUTRO_DOLLY_12_MP3"
+#define		OUTRO_DOLLY_13_MP3		"OUTRO_DOLLY_13_MP3"
+#define		OUTRO_DOLLY_14_MP3		"OUTRO_DOLLY_14_MP3"
+#define		OUTRO_DOLLY_15_MP3		"OUTRO_DOLLY_15_MP3"
+#define		OUTRO_DOLLY_16_MP3		"OUTRO_DOLLY_16_MP3"
+#define		OUTRO_DOLLY_17_MP3		"OUTRO_DOLLY_17_MP3"
+#define		OUTRO_DOLLY_18_MP3		"OUTRO_DOLLY_18_MP3"
+#define		OUTRO_DOREK_01_MP3		"OUTRO_DOREK_01_MP3"
+#define		OUTRO_DOREK_02_MP3		"OUTRO_DOREK_02_MP3"
+#define		OUTRO_DOREK_03_MP3		"OUTRO_DOREK_03_MP3"
+#define		OUTRO_DOREK_04_MP3		"OUTRO_DOREK_04_MP3"
+#define		OUTRO_DOREK_05_MP3		"OUTRO_DOREK_05_MP3"
+#define		OUTRO_DOREK_06_MP3		"OUTRO_DOREK_06_MP3"
+#define		OUTRO_GUY_01_MP3		"OUTRO_GUY_01_MP3"
+#define		OUTRO_GUY_02_MP3		"OUTRO_GUY_02_MP3"
+#define		OUTRO_GUY_03_MP3		"OUTRO_GUY_03_MP3"
+#define		OUTRO_GUY_04_MP3		"OUTRO_GUY_04_MP3"
+#define		OUTRO_GUY_05_MP3		"OUTRO_GUY_05_MP3"
+#define		OUTRO_GUY_06_MP3		"OUTRO_GUY_06_MP3"
+#define		OUTRO_JENKINS_01_MP3		"OUTRO_JENKINS_01_MP3"
+#define		OUTRO_JENKINS_02_MP3		"OUTRO_JENKINS_02_MP3"
+#define		OUTRO_JENKINS_03_MP3		"OUTRO_JENKINS_03_MP3"
+#define		OUTRO_JENKINS_04_MP3		"OUTRO_JENKINS_04_MP3"
+#define		OUTRO_JENKINS_05_MP3		"OUTRO_JENKINS_05_MP3"
+#define		OUTRO_SARGE_01_MP3		"OUTRO_SARGE_01_MP3"
+#define		OUTRO_SARGE_02_MP3		"OUTRO_SARGE_02_MP3"
+#define		OUTRO_SARGE_03_MP3		"OUTRO_SARGE_03_MP3"
+#define		OUTRO_SARGE_04_MP3		"OUTRO_SARGE_04_MP3"
+#define		OUTRO_SARGE_05_MP3		"OUTRO_SARGE_05_MP3"
+#define		OUTRO_SARGE_06_MP3		"OUTRO_SARGE_06_MP3"
+#define		GUY_ENERGY_CELL_MP3		"GUY_ENERGY_CELL_MP3"
+#define		GUY_GOT_A_JOB_MP3		"GUY_GOT_A_JOB_MP3"
+#define		GUY_COMPLETED_MP3		"GUY_COMPLETED_MP3"
+#define		GUY_GOT_SOMETHING_MP3		"GUY_GOT_SOMETHING_MP3"
+#define		GUY_WINS_MP3		"GUY_WINS_MP3"
+#define		HDB_INTRO_MP3		"HDB_INTRO_MP3"
 
 enum IconList {
 	ICON_GUY_DOWN,


Commit: a09ac7b1140b3b1db32b5f6cb553643744544400
    https://github.com/scummvm/scummvm/commit/a09ac7b1140b3b1db32b5f6cb553643744544400
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:28+02:00

Commit Message:
HDB: Add voice related data

Changed paths:
    engines/hdb/sound.cpp
    engines/hdb/sound.h


diff --git a/engines/hdb/sound.cpp b/engines/hdb/sound.cpp
index 5eda133..88bede7 100644
--- a/engines/hdb/sound.cpp
+++ b/engines/hdb/sound.cpp
@@ -21,10 +21,6 @@
  */
 
 #include "common/debug.h"
-#include "audio/audiostream.h"
-#include "audio/mixer.h"
-#include "audio/decoders/wave.h"
-#include "audio/decoders/mp3.h"
 
 #include "hdb/hdb.h"
 #include "hdb/file-manager.h"
@@ -1430,21 +1426,22 @@ bool Sound::init() {
 	_numSounds = index;
 
 	// voices are on by default
-	warning("STUB: Initialize voices");
+	_voicesOn = 1;
+	memset(&_voicePlayed[0], 0, sizeof(_voicePlayed));
 
 	return true;
 }
 
 void Sound::save(Common::OutSaveFile *out) {
-	warning("STUB: Sound::save()");
+	for (int i = 0; i < NUM_VOICES; i++) {
+		out->writeByte(_voicePlayed[i]);
+	}
 }
 
 void Sound::loadSaveFile(Common::InSaveFile *in) {
-	warning("STUB: Sound::loadSaveFile()");
-}
-
-void Sound::clearPersistent() {
-	warning("STUB: Sound::clearPersistent()");
+	for (int i = 0; i < NUM_VOICES; i++) {
+		_voicePlayed[i] = in->readByte();
+	}
 }
 
 bool Sound::playSound(int index) {
diff --git a/engines/hdb/sound.h b/engines/hdb/sound.h
index 67b8d10..68501a1 100644
--- a/engines/hdb/sound.h
+++ b/engines/hdb/sound.h
@@ -47,6 +47,11 @@
 #define		FIRST_VOICE		V00_AIRLOCK_01
 #define		NUM_VOICES		( LAST_SOUND - FIRST_VOICE )
 
+#include "audio/audiostream.h"
+#include "audio/mixer.h"
+#include "audio/decoders/wave.h"
+#include "audio/decoders/mp3.h"
+
 namespace HDB {
 
 enum {
@@ -1408,6 +1413,18 @@ struct SoundLookUp {
 	const char *luaName;		// name for Lua code to use
 };
 
+struct Voice {
+	bool active;
+	int32 length;
+	int index;
+	Audio::SoundHandle *handle;
+
+	Voice() : active(false), length(0), index(0), handle(new Audio::SoundHandle) {}
+	~Voice() {
+		delete handle;
+	}
+};
+
 struct SoundCache {
 	int	loaded;				// -1 = freeable; in memory, 0 = not cached, 1 = cached
 	int32 size;				// size of sound
@@ -1417,9 +1434,7 @@ struct SoundCache {
 	//void *data;				// actual file data
 	//FSOUND_SAMPLE *sample;			// used to play sound in FMOD
 
-	SoundCache() : loaded(0), size(0), name(nullptr), luaName(nullptr), ext(0) {
-
-	}
+	SoundCache() : loaded(0), size(0), name(nullptr), luaName(nullptr), ext(0) {}
 };
 
 class Sound {
@@ -1432,7 +1447,6 @@ public:
 	bool init();
 	void save(Common::OutSaveFile *out);
 	void loadSaveFile(Common::InSaveFile *in);
-	void clearPersistent();
 	void setMusicVolume(int value) {
 		//debug(9, "STUB: Add Music System Variables");
 	}
@@ -1441,18 +1455,19 @@ public:
 		return 1;
 	}
 	void setSFXVolume(int value) {
-		//debug(9, "STUB: Add Music System Variables");
+		_sfxVolume = value;
 	}
 	int getSFXVolume() {
-		//debug(9, "STUB: Add Music System Variables");
-		return 1;
+		return _sfxVolume;
 	}
 	void setVoiceStatus(int value) {
-		//debug(9, "STUB: Add Music System Variables");
+		_voicesOn = value;
 	}
 	int getVoiceStatus() {
-		//debug(9, "STUB: Add Music System Variables");
-		return 1;
+		return _voicesOn;
+	}
+	void clearPersistent() {
+		memset(&_voicePlayed[0], 0, sizeof(_voicePlayed));
 	}
 
 	bool playSound(int index);
@@ -1476,6 +1491,19 @@ public:
 
 	void markSoundCacheFreeable();
 
+	// Voice System Variables
+
+	enum {
+		GUY,
+		OTHER,
+		MAX_VOICES
+	};
+
+	Voice _voices[MAX_VOICES];
+
+	int _voicesOn;
+	byte _voicePlayed[NUM_VOICES];
+
 	// Sound Caching System Variables
 
 	SoundCache _soundCache[kMaxSounds];


Commit: 123b65931e366ee759344a54dcbdf012f030b1cf
    https://github.com/scummvm/scummvm/commit/123b65931e366ee759344a54dcbdf012f030b1cf
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:28+02:00

Commit Message:
HDB: Add playVoice()

Changed paths:
    engines/hdb/sound.cpp


diff --git a/engines/hdb/sound.cpp b/engines/hdb/sound.cpp
index 88bede7..752f80f 100644
--- a/engines/hdb/sound.cpp
+++ b/engines/hdb/sound.cpp
@@ -1455,7 +1455,36 @@ bool Sound::playSoundEx(int index, int channel, bool loop) {
 }
 
 bool Sound::playVoice(int index, int actor) {
-	warning("STUB: Play Voice");
+	if (!_voicesOn)
+		return false;
+
+	// make sure we aren't playing a line more than once this time (only on CHANNEL 0)
+	if (!actor && _voicePlayed[index - FIRST_VOICE])
+		return false;
+
+	// is voice channel already active?  if so, shut 'er down (automagically called StopVoice via callback)
+	if (_voices[actor].active) {
+		g_hdb->_mixer->stopHandle(*_voices[actor].handle);
+	}
+
+#ifdef USE_MAD
+	Common::SeekableReadStream *stream = g_hdb->_fileMan->findFirstData(soundList[index].name, TYPE_BINARY);
+	if (stream == nullptr)
+		return false;
+	Audio::AudioStream *audioStream = Audio::makeMP3Stream(stream, DisposeAfterUse::YES);
+	if (audioStream == nullptr) {
+		delete stream;
+		return false;
+	}
+
+	g_hdb->_mixer->setChannelVolume(*_voices[actor].handle, _sfxVolume);
+
+	g_hdb->_mixer->playStream(Audio::Mixer::kSpeechSoundType, _voices[actor].handle, audioStream);
+
+	_voices[actor].active = true;
+	_voicePlayed[index - FIRST_VOICE] = 1;
+
+#endif
 	return true;
 }
 


Commit: 5ba58bf03c41befe5086474170c2ea5d8a3d5d74
    https://github.com/scummvm/scummvm/commit/5ba58bf03c41befe5086474170c2ea5d8a3d5d74
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:28+02:00

Commit Message:
HDB: Simplify Voice struct

Changed paths:
    engines/hdb/sound.h


diff --git a/engines/hdb/sound.h b/engines/hdb/sound.h
index 68501a1..8d98a45 100644
--- a/engines/hdb/sound.h
+++ b/engines/hdb/sound.h
@@ -1415,11 +1415,9 @@ struct SoundLookUp {
 
 struct Voice {
 	bool active;
-	int32 length;
-	int index;
 	Audio::SoundHandle *handle;
 
-	Voice() : active(false), length(0), index(0), handle(new Audio::SoundHandle) {}
+	Voice() : active(false), handle(new Audio::SoundHandle) {}
 	~Voice() {
 		delete handle;
 	}


Commit: 174b8c31cf4355d18220d8d984df60451ff42efd
    https://github.com/scummvm/scummvm/commit/174b8c31cf4355d18220d8d984df60451ff42efd
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:28+02:00

Commit Message:
HDB: Update Music filenames

Changed paths:
    engines/hdb/sound.h


diff --git a/engines/hdb/sound.h b/engines/hdb/sound.h
index 8d98a45..af037fc 100644
--- a/engines/hdb/sound.h
+++ b/engines/hdb/sound.h
@@ -23,26 +23,26 @@
 #ifndef HDB_SOUND_H
 #define HDB_SOUND_H
 
-#define	SFNAME_TITLE		"jungle"
-#define	SFNAME_MENU			"on_a_mission"
-#define	SFNAME_ROBO			"low_techno"
-#define	SFNAME_MEXI			"ambient_mexi_howl"
-#define	SFNAME_BASSO		"amb_walkin_basso"
-#define	SFNAME_WIND			"dangerous_wind"
-#define	SFNAME_INDUSTRO		"industro_hunch"
-#define	SFNAME_JACKIN		"jaround"
-#define	SFNAME_SNEAKERS		"lost_my_sneakers"
-#define	SFNAME_QUIET		"mysterious_quiet"
-#define	SFNAME_JEEBIES		"jeebies5B"
-#define	SFNAME_VIBRACIOUS	"vibracious_(dope_delivery_mix)"
-#define	SFNAME_ROMANTIC		"romantic"
-#define	SFNAME_ARETHERE		"AreWeThereYet_(extended)"
+#define	SFNAME_TITLE		"jungle.mp3"
+#define	SFNAME_MENU			"on_a_mission.mp3"
+#define	SFNAME_ROBO			"low_techno.mp3"
+#define	SFNAME_MEXI			"ambient_mexi_howl.mp3"
+#define	SFNAME_BASSO		"amb_walkin_basso.mp3"
+#define	SFNAME_WIND			"dangerous_wind.mp3"
+#define	SFNAME_INDUSTRO		"industro_hunch.mp3"
+#define	SFNAME_JACKIN		"jaround.mp3"
+#define	SFNAME_SNEAKERS		"lost_my_sneakers.mp3"
+#define	SFNAME_QUIET		"mysterious_quiet.mp3"
+#define	SFNAME_JEEBIES		"jeebies5B.mp3"
+#define	SFNAME_VIBRACIOUS	"vibracious_(dope_delivery_mix).mp3"
+#define	SFNAME_ROMANTIC		"romantic.mp3"
+#define	SFNAME_ARETHERE		"AreWeThereYet_(extended).mp3"
 
-#define	SFNAME_CORRIDOR		"corridor(extended)"
-#define SFNAME_MOKE			"moke_a_doke_doke"
-#define	SFNAME_TILES		"tilesache(extended)"
-#define SFNAME_DARKVIB		"vibracious_(Dark_Delivery_Mix)"
-#define SFNAME_EXPER		"experimentatus_(extended)"
+#define	SFNAME_CORRIDOR		"corridor(extended).mp3"
+#define SFNAME_MOKE			"moke_a_doke_doke.mp3"
+#define	SFNAME_TILES		"tilesache(extended).mp3"
+#define SFNAME_DARKVIB		"vibracious_(Dark_Delivery_Mix).mp3"
+#define SFNAME_EXPER		"experimentatus_(extended).mp3"
 
 #define		FIRST_VOICE		V00_AIRLOCK_01
 #define		NUM_VOICES		( LAST_SOUND - FIRST_VOICE )


Commit: becfce8bfc42d53dfa72e28e29a90fabe12f43bc
    https://github.com/scummvm/scummvm/commit/becfce8bfc42d53dfa72e28e29a90fabe12f43bc
Author: Strangerke (strangerke at scummvm.org)
Date: 2019-09-03T17:17:28+02:00

Commit Message:
HDB: More cleanup in ai-bots

Changed paths:
    engines/hdb/ai-bots.cpp


diff --git a/engines/hdb/ai-bots.cpp b/engines/hdb/ai-bots.cpp
index 482ae87..cf7a799 100644
--- a/engines/hdb/ai-bots.cpp
+++ b/engines/hdb/ai-bots.cpp
@@ -78,7 +78,7 @@ void aiOmniBotAction(AIEntity *e) {
 			// Shoot player ?
 			if (onEvenTile(e->x, e->y) && g_hdb->getActionMode()) {
 				int xv = 0, yv = 0, result;
-				int shoot = 0;
+				bool shoot = false;
 
 				// FIXME: Is reloading Player required here?
 				p = g_hdb->_ai->getPlayer();
@@ -91,25 +91,25 @@ void aiOmniBotAction(AIEntity *e) {
 				switch (e->dir) {
 				case DIR_UP:
 					if (p->x == e->x && p->y < e->y) {
-						shoot = 1;
+						shoot = true;
 						yv = -1;
 					}
 					break;
 				case DIR_DOWN:
 					if (p->x == e->x && p->y > e->y) {
-						shoot = 1;
+						shoot = true;
 						yv = 1;
 					}
 					break;
 				case DIR_LEFT:
 					if (p->x < e->x && p->y == e->y) {
-						shoot = 1;
+						shoot = true;
 						xv = -1;
 					}
 					break;
 				case DIR_RIGHT:
 					if (p->x > e->x && p->y == e->y) {
-						shoot = 1;
+						shoot = true;
 						xv = 1;
 					}
 					break;
@@ -118,10 +118,10 @@ void aiOmniBotAction(AIEntity *e) {
 					break;
 				}
 
-				// If shoot = 1, take the shot
+				// If shoot = true, take the shot
 				// (1) Check we're not shooting into a solid tile
 				// (2) Check we're not shooting into an Entity unless it's the player
-				AIEntity *hit = g_hdb->_ai->legalMoveOverWater(e->tileX+xv, e->tileY + yv, e->level, &result);
+				AIEntity *hit = g_hdb->_ai->legalMoveOverWater(e->tileX + xv, e->tileY + yv, e->level, &result);
 				if (shoot && !hit && result) {
 					AIEntity *omni = g_hdb->_ai->spawn(AI_OMNIBOT_MISSILE, e->dir, e->tileX + xv, e->tileY + yv, NULL, NULL, NULL, DIR_NONE, e->level, 0, 0, 1);
 					omni->xVel = xv * kPlayerMoveSpeed * 2;
@@ -298,17 +298,16 @@ void aiShockBotAction(AIEntity *e) {
 }
 
 void aiShockBotShock(AIEntity *e, int mx, int my) {
-	int offX[8] = { -1, 0, 1, 1, 1, 0, -1, -1 };
-	int offY[8] = { -1, -1, -1, 0, 1, 1, 1, 0 };
+	static const int offX[8] = { -1, 0, 1, 1, 1, 0, -1, -1 };
+	static const int offY[8] = { -1, -1, -1, 0, 1, 1, 1, 0 };
 
 	// Only on a exact tile boundary do we change the shocked tiles
 	// Start at top left and go around
 	if (g_hdb->_map->getMapBGTileFlags(e->tileX, e->tileY) & kFlagMetal)
 		e->special1Gfx[e->animFrame]->drawMasked(e->tileX * kTileWidth - mx, e->tileY * kTileHeight - my);
 
-	uint32 flags;
 	for (int i = 0; i < 8; i++) {
-		flags = g_hdb->_map->getMapBGTileFlags(e->tileX + offX[i], e->tileY + offY[i]);
+		uint32 flags = g_hdb->_map->getMapBGTileFlags(e->tileX + offX[i], e->tileY + offY[i]);
 		if (flags & kFlagMetal) {
 			// Is the shocking tile onScreen?
 			if (g_hdb->_map->checkXYOnScreen((e->tileX + offX[i]) * kTileWidth, (e->tileY + offY[i]) * kTileHeight)) {
@@ -465,10 +464,26 @@ void aiRightBotFindGoal(AIEntity *e) {
 				}
 			} else {
 				switch (e->dir) {
-				case DIR_UP: e->dir = DIR_DOWN; yv = 1; xv = 0; break;
-				case DIR_DOWN: e->dir = DIR_UP; yv = -1; xv = 0; break;
-				case DIR_LEFT: e->dir = DIR_RIGHT; yv = 0; xv = 1; break;
-				case DIR_RIGHT: e->dir = DIR_LEFT; yv = 0; xv = -1; break;
+				case DIR_UP:
+					e->dir = DIR_DOWN;
+					yv = 1;
+					xv = 0;
+					break;
+				case DIR_DOWN:
+					e->dir = DIR_UP;
+					yv = -1;
+					xv = 0;
+					break;
+				case DIR_LEFT:
+					e->dir = DIR_RIGHT;
+					yv = 0;
+					xv = 1;
+					break;
+				case DIR_RIGHT:
+					e->dir = DIR_LEFT;
+					yv = 0;
+					xv = -1;
+					break;
 				case DIR_NONE:
 					warning("aiRightBotFindGoal: DIR_NONE found");
 				}
@@ -593,10 +608,18 @@ void aiPushBotAction(AIEntity *e) {
 				e1->moveSpeed = e->moveSpeed;
 				g_hdb->_ai->setEntityGoal(e1, nx2, ny2);
 				switch (e1->type) {
-				case AI_CRATE: g_hdb->_sound->playSound(SND_CRATE_SLIDE); break;
-				case AI_HEAVYBARREL: case AI_BOOMBARREL: g_hdb->_sound->playSound(SND_HEAVY_SLIDE); break;
-				case AI_LIGHTBARREL: g_hdb->_sound->playSound(SND_LIGHT_SLIDE); break;
-				default: break;
+				case AI_CRATE:
+					g_hdb->_sound->playSound(SND_CRATE_SLIDE);
+					break;
+				case AI_HEAVYBARREL:
+				case AI_BOOMBARREL:
+					g_hdb->_sound->playSound(SND_HEAVY_SLIDE);
+					break;
+				case AI_LIGHTBARREL:
+					g_hdb->_sound->playSound(SND_LIGHT_SLIDE);
+					break;
+				default:
+					break;
 				}
 			} else {
 				if (e->onScreen)
@@ -715,12 +738,10 @@ void aiRailRiderOnUse(AIEntity *e) {
 			g_hdb->_ai->setEntityGoal(p, p->tileX, p->tileY - 1);
 		else
 			g_hdb->_ai->setEntityGoal(p, p->tileX, p->tileY + 1);
-	} else {
-		if (p->tileX > e->tileX)
-			g_hdb->_ai->setEntityGoal(p, p->tileX - 1, p->tileY);
-		else
-			g_hdb->_ai->setEntityGoal(p, p->tileX + 1, p->tileY);
-	}
+	} else if (p->tileX > e->tileX)
+		g_hdb->_ai->setEntityGoal(p, p->tileX - 1, p->tileY);
+	else
+		g_hdb->_ai->setEntityGoal(p, p->tileX + 1, p->tileY);
 
 	e->sequence = -1;	// Waiting for player to board
 }
@@ -901,6 +922,9 @@ void aiMaintBotAction(AIEntity *e) {
 	static const int xvAhead[5]  = {9, 0, 0,-1, 1};
 	static const int yvAhead[5]  = {9,-1, 1, 0, 0};
 	static const int whistles[3] = {SND_MBOT_WHISTLE1, SND_MBOT_WHISTLE2, SND_MBOT_WHISTLE3};
+	static const AIDir lookRight[5] = {DIR_NONE, DIR_RIGHT, DIR_LEFT, DIR_UP, DIR_DOWN};
+	static const AIDir lookLeft[5] = {DIR_NONE, DIR_LEFT, DIR_RIGHT, DIR_DOWN, DIR_UP};
+	static const AIDir dirList[5] = {DIR_NONE, DIR_UP, DIR_DOWN, DIR_LEFT, DIR_RIGHT};
 
 	// Waiting at an arrow (or hit by player)?
 	if (e->sequence) {
@@ -967,9 +991,6 @@ void aiMaintBotAction(AIEntity *e) {
 			}
 		// Deciding where to go at 4-way
 		else {
-			AIDir lookRight[5] = {DIR_NONE, DIR_RIGHT, DIR_LEFT, DIR_UP, DIR_DOWN};
-			AIDir lookLeft[5] = {DIR_NONE, DIR_LEFT, DIR_RIGHT, DIR_DOWN, DIR_UP};
-			AIDir dirList[5] = {DIR_NONE, DIR_UP, DIR_DOWN, DIR_LEFT, DIR_RIGHT};
 			switch (e->sequence) {
 			// HMM
 			case 50:
@@ -1057,10 +1078,10 @@ void aiFourFirerInit2(AIEntity *e) {
 }
 
 void aiFourFirerAction(AIEntity *e) {
-	AIEntity *p = g_hdb->_ai->getPlayer();
-	AIState state[5] = {STATE_NONE, STATE_STANDUP, STATE_STANDDOWN, STATE_STANDLEFT, STATE_STANDRIGHT};
-	AIDir turn[5] = {DIR_NONE, DIR_RIGHT, DIR_LEFT, DIR_UP, DIR_DOWN};
+	static const AIState state[5] = {STATE_NONE, STATE_STANDUP, STATE_STANDDOWN, STATE_STANDLEFT, STATE_STANDRIGHT};
+	static const AIDir turn[5] = {DIR_NONE, DIR_RIGHT, DIR_LEFT, DIR_UP, DIR_DOWN};
 
+	AIEntity *p = g_hdb->_ai->getPlayer();
 	// Time to turn right?
 	if (!e->value1) {
 		e->dir = turn[e->dir];
@@ -1089,11 +1110,32 @@ void aiFourFirerAction(AIEntity *e) {
 	int yv = 0;
 
 	switch (e->dir) {
-	case DIR_UP:	if (p->x == e->x && p->y < e->y) { shoot = true; yv = -1; } break;
-	case DIR_DOWN:	if (p->x == e->x && p->y > e->y) { shoot = true; yv = 1; } break;
-	case DIR_LEFT:	if (p->y == e->y && p->x < e->x) { shoot = true; xv = -1; } break;
-	case DIR_RIGHT:	if (p->y == e->y && p->x > e->x) { shoot = true; xv = 1; } break;
-	case DIR_NONE: warning("aiFourFirerAction: DIR_NONE found"); break;
+	case DIR_UP:
+		if (p->x == e->x && p->y < e->y) {
+			shoot = true;
+			yv = -1; }
+		break;
+	case DIR_DOWN:
+		if (p->x == e->x && p->y > e->y) {
+			shoot = true;
+			yv = 1;
+		}
+		break;
+	case DIR_LEFT:
+		if (p->y == e->y && p->x < e->x) {
+			shoot = true;
+			xv = -1;
+		}
+		break;
+	case DIR_RIGHT:
+		if (p->y == e->y && p->x > e->x) {
+			shoot = true;
+			xv = 1;
+		}
+		break;
+	case DIR_NONE:
+		warning("aiFourFirerAction: DIR_NONE found");
+		break;
 	}
 
 	// Shoot if needed
@@ -1142,9 +1184,7 @@ void aiDeadEyeInit2(AIEntity *e) {
 }
 
 void aiDeadEyeWalkInPlace(AIEntity *e) {
-	AIState state[5] = {STATE_NONE, STATE_MOVEUP, STATE_MOVEDOWN, STATE_MOVELEFT, STATE_MOVERIGHT};
-	AIDir dir;
-	AIState s;
+	static const AIState state[5] = {STATE_NONE, STATE_MOVEUP, STATE_MOVEDOWN, STATE_MOVELEFT, STATE_MOVERIGHT};
 
 	e->sequence--;
 
@@ -1154,15 +1194,16 @@ void aiDeadEyeWalkInPlace(AIEntity *e) {
 	case 30:
 	case 20:
 	case 10:
-		dir = (AIDir)(g_hdb->_rnd->getRandomNumber(3) + 1);
-		s = state[dir];
-		e->dir = dir;
-		e->state = s;
-		if (e->onScreen) {
-			if (e->sequence == 50)
-				g_hdb->_sound->playSound(SND_DEADEYE_AMB01);
-			else if (e->sequence == 10)
-				g_hdb->_sound->playSound(SND_DEADEYE_AMB02);
+		{
+			int rnd = g_hdb->_rnd->getRandomNumber(3) + 1;
+			e->dir = (AIDir)rnd;
+			e->state = state[rnd];
+			if (e->onScreen) {
+				if (e->sequence == 50)
+					g_hdb->_sound->playSound(SND_DEADEYE_AMB01);
+				else if (e->sequence == 10)
+					g_hdb->_sound->playSound(SND_DEADEYE_AMB02);
+			}
 		}
 		break;
 	case 0:
@@ -1172,12 +1213,9 @@ void aiDeadEyeWalkInPlace(AIEntity *e) {
 }
 
 void aiDeadEyeAction(AIEntity *e) {
-	AIState state[5] = {STATE_NONE, STATE_MOVEUP, STATE_MOVEDOWN, STATE_MOVELEFT, STATE_MOVERIGHT};
-	int xvAhead[5] = {9, 0, 0, -1, 1}, yvAhead[5] = {9, -1, 1, 0, 0};
-	int result;
-	AIEntity *hit;
-	AIDir dir;
-	AIState s;
+	static const AIState state[5] = {STATE_NONE, STATE_MOVEUP, STATE_MOVEDOWN, STATE_MOVELEFT, STATE_MOVERIGHT};
+	static const int xvAhead[5] = {9, 0, 0, -1, 1};
+	static const int yvAhead[5] = {9, -1, 1, 0, 0};
 
 	if (e->sequence) {
 		e->sequence--;
@@ -1188,42 +1226,56 @@ void aiDeadEyeAction(AIEntity *e) {
 		// Is player visible to us?
 		AIEntity *p = g_hdb->_ai->getPlayer();
 		if (e->onScreen && p->level == e->level && !e->blinkFrames) {
-			int nuts = 0;
+			bool nuts = false;
 			switch (e->dir) {
-			case DIR_UP:	if (p->tileX == e->tileX && p->tileY < e->tileY) nuts = 1; break;
-			case DIR_DOWN:	if (p->tileX == e->tileX && p->tileY > e->tileY) nuts = 1; break;
-			case DIR_LEFT:	if (p->tileY == e->tileY && p->tileX < e->tileX) nuts = 1; break;
-			case DIR_RIGHT: if (p->tileY == e->tileY && p->tileX > e->tileX) nuts = 1; break;
-			case DIR_NONE:	warning("aiDeadEyeAction: DIR_NONE found"); break;
+			case DIR_UP:
+				if (p->tileX == e->tileX && p->tileY < e->tileY)
+					nuts = true;
+				break;
+			case DIR_DOWN:
+				if (p->tileX == e->tileX && p->tileY > e->tileY)
+					nuts = true;
+				break;
+			case DIR_LEFT:
+				if (p->tileY == e->tileY && p->tileX < e->tileX)
+					nuts = true;
+				break;
+			case DIR_RIGHT:
+				if (p->tileY == e->tileY && p->tileX > e->tileX)
+					nuts = true;
+				break;
+			case DIR_NONE:
+				warning("aiDeadEyeAction: DIR_NONE found");
+				break;
 			}
 
 			// Did we see the player (and we're done moving)?
 			if (nuts && e->aiAction != aiDeadEyeWalkInPlace) {
-				int newX, newY, xv, yv, done, okToMove;
-
 				e->sequence = 0;
 				e->blinkFrames = 20;
 
-				xv = xvAhead[e->dir];
-				yv = yvAhead[e->dir];
-				newX = e->tileX + xv;
-				newY = e->tileY + yv;
+				int xv = xvAhead[e->dir];
+				int yv = yvAhead[e->dir];
+				int newX = e->tileX + xv;
+				int newY = e->tileY + yv;
 
-				okToMove = done = 0;
+				bool okToMove = false;
+				bool done = false;
 				do {
-					hit = g_hdb->_ai->legalMove(newX, newY, e->level, &result);
+					int result;
+					AIEntity *hit = g_hdb->_ai->legalMove(newX, newY, e->level, &result);
 					if (hit && hit->type == AI_GUY)
-						hit = NULL;
+						hit = nullptr;
 					if (result && !hit) {
-						okToMove = 1;
+						okToMove = true;
 						newX += xv;
 						newY += yv;
 						if (newX == p->tileX && newY == p->tileY)
-							done = 1;
+							done = true;
 					} else {
 						newX -= xv;
 						newY -= yv;
-						done = 1;
+						done = true;
 					}
 				} while (!done);
 
@@ -1245,34 +1297,34 @@ void aiDeadEyeAction(AIEntity *e) {
 		case 30:
 		case 20:
 		case 10:
-			dir = (AIDir)(g_hdb->_rnd->getRandomNumber(3)+1);
-			s = state[dir];
-			e->dir = dir;
-			e->state = s;
-
-			if (e->onScreen) {
-				if (e->sequence == 50)
-					g_hdb->_sound->playSound(SND_DEADEYE_AMB01);
-				else if (e->sequence == 10)
-					g_hdb->_sound->playSound(SND_DEADEYE_AMB02);
+			{
+				int dir = g_hdb->_rnd->getRandomNumber(3) + 1;
+				e->dir = (AIDir)dir;
+				e->state = state[dir];
+
+				if (e->onScreen) {
+					if (e->sequence == 50)
+						g_hdb->_sound->playSound(SND_DEADEYE_AMB01);
+					else if (e->sequence == 10)
+						g_hdb->_sound->playSound(SND_DEADEYE_AMB02);
+				}
 			}
 			break;
 		case 0:
 			// Pick a random direction and random number of tiles in that direction
-			dir = (AIDir)(g_hdb->_rnd->getRandomNumber(3) + 1);
+			int dir = g_hdb->_rnd->getRandomNumber(3) + 1;
 			int walk = g_hdb->_rnd->getRandomNumber(4) + 1;
-			int xv, yv;
 
-			e->dir = dir;
+			e->dir = (AIDir)dir;
 			e->state = state[dir];
 
-			xv = xvAhead[dir] * walk;
+			int xv = xvAhead[dir] * walk;
 			if (e->tileX + xv < 1)
 				xv = 1 - e->tileX;
 			if (e->tileX + xv > g_hdb->_map->_width)
 				xv = g_hdb->_map->_width - e->tileX - 1;
 
-			yv = yvAhead[dir] * walk;
+			int yv = yvAhead[dir] * walk;
 			if (e->tileY + yv < 1)
 				yv = 1 - e->tileY;
 			if (e->tileY + yv > g_hdb->_map->_height)
@@ -1281,9 +1333,10 @@ void aiDeadEyeAction(AIEntity *e) {
 			e->value1 = xvAhead[dir];
 			e->value2 = yvAhead[dir];
 			e->moveSpeed = kPlayerMoveSpeed;
-			hit = g_hdb->_ai->legalMove(e->tileX + xvAhead[e->dir], e->tileY + yvAhead[e->dir], e->level, &result);
+			int result;
+			AIEntity *hit = g_hdb->_ai->legalMove(e->tileX + xvAhead[e->dir], e->tileY + yvAhead[e->dir], e->level, &result);
 			if (hit && hit->type == AI_GUY)
-				hit = NULL;
+				hit = nullptr;
 
 			if (!hit && result)
 				g_hdb->_ai->setEntityGoal(e, e->tileX + xv, e->tileY + yv);
@@ -1303,9 +1356,10 @@ void aiDeadEyeAction(AIEntity *e) {
 		// Did we run into a wall, entity, water, slime etc?
 		// If so, Pick new direction
 		if (onEvenTile(e->x, e->y)) {
-			hit = g_hdb->_ai->legalMove(e->tileX + e->value1, e->tileY + e->value2, e->level, &result);
+			int result;
+			AIEntity *hit = g_hdb->_ai->legalMove(e->tileX + e->value1, e->tileY + e->value2, e->level, &result);
 			if (hit && hit->type == AI_GUY)
-				hit = NULL;
+				hit = nullptr;
 			if (!result || hit) {
 				g_hdb->_ai->stopEntity(e);
 				e->state = STATE_MOVEDOWN;
@@ -1327,15 +1381,15 @@ void aiDeadEyeAction(AIEntity *e) {
 
 void aiLaserInit(AIEntity *e) {
 	e->aiDraw = aiLaserDraw;
-	e->value1 = e->value2 = 0;		// start & end of laser beam
+	// start & end of laser beam
+	e->value1 = e->value2 = 0;
 }
 
 void aiLaserInit2(AIEntity *e) {
 	e->draw = g_hdb->_ai->getStandFrameDir(e);
 	if (!g_hdb->_ai->_gfxLaserbeamUD[0]) {
 		char name[64];
-		int	i;
-		for (i = 0; i < 4; i++) {
+		for (int i = 0; i < 4; i++) {
 			sprintf(name, FORCEFIELD_UD"0%d", i + 1);
 			g_hdb->_ai->_gfxLaserbeamUD[i] = g_hdb->_gfx->loadTile(name);
 			sprintf(name, FORCESPLASH_TOP"0%d", i + 1);
@@ -1353,46 +1407,63 @@ void aiLaserInit2(AIEntity *e) {
 }
 
 void aiLaserAction(AIEntity *e) {
-	int	xva[] = {9,0,0,-1,1}, yva[] = {9,-1,1,0,0};
-	int	nx, ny, moveOK;
-	AIEntity *hit;
+	static const int xva[] = {9, 0, 0,-1, 1};
+	static const int yva[] = {9,-1, 1, 0, 0};
 
-	hit = e;
+	AIEntity *hit = e;
+	int moveOK = 0;
 	do {
+		int nx = hit->tileX;
+		int ny = hit->tileY;
+
 		if (hit->type != AI_DIVERTER) {
 			hit->int1 = xva[hit->dir];
 			hit->int2 = yva[hit->dir];
 
-			nx = hit->tileX;
-			ny = hit->tileY;
 			if (hit->dir == DIR_UP || hit->dir == DIR_DOWN)
 				hit->value1 = ny;
 			else
 				hit->value1 = nx;
 		} else {
-			nx = hit->tileX;
-			ny = hit->tileY;
 			// diverter is on y-plane?
 			if (hit->tileX == e->tileX) {
 				hit->value1 = nx;
 				hit->int2 = 0;
 				switch (hit->dir2) {
-				case DIR_UP: hit->int1 = 1; break;
-				case DIR_DOWN: hit->int1 = -1; break;
-				case DIR_LEFT: hit->int1 = -1; break;
-				case DIR_RIGHT: hit->int1 = 1; break;
-				case DIR_NONE: break;
+				case DIR_UP:
+					hit->int1 = 1;
+					break;
+				case DIR_DOWN:
+					hit->int1 = -1;
+					break;
+				case DIR_LEFT:
+					hit->int1 = -1;
+					break;
+				case DIR_RIGHT:
+					hit->int1 = 1;
+					break;
+				case DIR_NONE:
+					break;
 				}
 			} else {
 				// diverter is on x-plane
 				hit->value1 = ny;
 				hit->int1 = 0;
 				switch (hit->dir2) {
-				case DIR_UP: hit->int2 = 1; break;
-				case DIR_DOWN: hit->int2 = 1; break;
-				case DIR_LEFT: hit->int2 = -1; break;
-				case DIR_RIGHT: hit->int2 = -1; break;
-				case DIR_NONE: break;
+				case DIR_UP:
+					hit->int2 = 1;
+					break;
+				case DIR_DOWN:
+					hit->int2 = 1;
+					break;
+				case DIR_LEFT:
+					hit->int2 = -1;
+					break;
+				case DIR_RIGHT:
+					hit->int2 = -1;
+					break;
+				case DIR_NONE:
+					break;
 				}
 			}
 		}
@@ -1414,7 +1485,6 @@ void aiLaserAction(AIEntity *e) {
 					g_hdb->_ai->killPlayer(DEATH_FRIED);
 				else if (hit->type == AI_BOOMBARREL && hit->state != STATE_EXPLODING && onEvenTile(hit->x, hit->y)) {
 					// hit BOOM BARREL = explodes
-
 					aiBarrelExplode(hit);
 					aiBarrelBlowup(hit, nx, ny);
 				} else if (hit->type == AI_LIGHTBARREL || hit->type == AI_HEAVYBARREL || hit->type == AI_CRATE) {
@@ -1425,7 +1495,8 @@ void aiLaserAction(AIEntity *e) {
 					moveOK = 0;
 				} else if (onEvenTile(hit->x, hit->y) && hit != g_hdb->_ai->getPlayer()) {
 					switch (hit->type) {
-					case AI_VORTEXIAN:		// cannot kill Vortexians!
+					// cannot kill Vortexians!
+					case AI_VORTEXIAN:
 						continue;
 
 					case AI_BOOMBARREL:
@@ -1435,7 +1506,6 @@ void aiLaserAction(AIEntity *e) {
 					case AI_LASER:
 						g_hdb->_ai->_laserRescan = true;
 						break;
-
 					case ITEM_KEYCARD_WHITE:
 					case ITEM_KEYCARD_BLUE:
 					case ITEM_KEYCARD_RED:
@@ -1563,11 +1633,24 @@ void aiDiverterInit2(AIEntity *e) {
 	if (e->dir2 == DIR_NONE)
 		d = e->dir;
 	switch (d) {
-	case DIR_DOWN: e->state = STATE_DIVERTER_BL; e->draw = e->standdownGfx[0]; break;
-	case DIR_UP: e->state = STATE_DIVERTER_BR; e->draw = e->standupGfx[0]; break;
-	case DIR_LEFT: e->state = STATE_DIVERTER_TL; e->draw = e->standleftGfx[0]; break;
-	case DIR_RIGHT: e->state = STATE_DIVERTER_TR; e->draw = e->standrightGfx[0]; break;
-	case DIR_NONE: break;
+	case DIR_DOWN:
+		e->state = STATE_DIVERTER_BL;
+		e->draw = e->standdownGfx[0];
+		break;
+	case DIR_UP:
+		e->state = STATE_DIVERTER_BR;
+		e->draw = e->standupGfx[0];
+		break;
+	case DIR_LEFT:
+		e->state = STATE_DIVERTER_TL;
+		e->draw = e->standleftGfx[0];
+		break;
+	case DIR_RIGHT:
+		e->state = STATE_DIVERTER_TR;
+		e->draw = e->standrightGfx[0];
+		break;
+	case DIR_NONE:
+		break;
 	}
 
 	g_hdb->_ai->_laserRescan = true;
@@ -1580,22 +1663,35 @@ void aiDiverterAction(AIEntity *e) {
 
 		// have to reset the state because we might have been moved...
 		switch (e->dir2) {
-		case DIR_DOWN: e->state = STATE_DIVERTER_BL; e->draw = e->standdownGfx[0]; break;
-		case DIR_UP: e->state = STATE_DIVERTER_BR; e->draw = e->standupGfx[0]; break;
-		case DIR_LEFT: e->state = STATE_DIVERTER_TL; e->draw = e->standleftGfx[0]; break;
-		case DIR_RIGHT: e->state = STATE_DIVERTER_TR; e->draw = e->standrightGfx[0]; break;
-		case DIR_NONE: break;
+		case DIR_DOWN:
+			e->state = STATE_DIVERTER_BL;
+			e->draw = e->standdownGfx[0];
+			break;
+		case DIR_UP:
+			e->state = STATE_DIVERTER_BR;
+			e->draw = e->standupGfx[0];
+			break;
+		case DIR_LEFT:
+			e->state = STATE_DIVERTER_TL;
+			e->draw = e->standleftGfx[0];
+			break;
+		case DIR_RIGHT:
+			e->state = STATE_DIVERTER_TR;
+			e->draw = e->standrightGfx[0];
+			break;
+		case DIR_NONE:
+			break;
 		}
 	}
 }
 
 void aiDiverterDraw(AIEntity *e, int mx, int my) {
-	int		i;
 	if (!e->value1 && !e->value2)
 		return;
 
 	int	frame = e->movedownFrames & 3;
 	int onScreen = 0;
+	int i;
 	switch (e->dir2) {
 	case DIR_UP:
 		if (e->tileY == e->value1 && e->int2) {	// going down or right?
@@ -1721,6 +1817,9 @@ void aiMeerkatDraw(AIEntity *e, int mx, int my) {
 }
 
 void aiMeerkatAction(AIEntity *e) {
+	static const int gem_xv[] = { 0, 0,-2,-3,-4,-4,-3,-2,-2,-2,-2,-1,-1, 100};
+	static const int gem_yv[] = {-6,-5,-4,-3,-2,-1, 0, 0, 1, 2, 3, 4, 5, 100};
+
 	AIEntity *p = g_hdb->_ai->getPlayer();
 
 	switch (e->sequence) {
@@ -1787,7 +1886,7 @@ void aiMeerkatAction(AIEntity *e) {
 	case 5:
 		g_hdb->_ai->animateEntity(e);
 		if (!e->animFrame && e->animDelay == e->animCycle) {
-			e->sequence = 0;;
+			e->sequence = 0;
 			e->state = STATE_NONE;
 			e->draw = NULL;
 		}
@@ -1849,9 +1948,6 @@ void aiMeerkatAction(AIEntity *e) {
 
 	// blasting a gem outta Guy?
 	if (e->value1) {
-		int	gem_xv[] = {0, 0,-2,-3,-4,-4,-3,-2,-2,-2,-2,-1,-1, 100};
-		int gem_yv[] = {-6,-5,-4,-3,-2,-1, 0, 0, 1, 2, 3, 4, 5, 100};
-
 		if (gem_xv[e->blinkFrames] == 100) {
 			e->value1 = 0;
 			e->aiDraw = NULL;
@@ -2225,9 +2321,10 @@ void aiGoodFairyInit2(AIEntity *e) {
 }
 
 void aiGoodFairyAction(AIEntity *e) {
-	AIState state[5] = {STATE_NONE, STATE_MOVEUP, STATE_MOVEDOWN, STATE_MOVELEFT, STATE_MOVERIGHT};
-	int	xvAhead[5] = {9, 0, 0,-1, 1}, yvAhead[5] = {9,-1, 1, 0, 0};
-	int xv, yv;
+	static const AIState state[5] = {STATE_NONE, STATE_MOVEUP, STATE_MOVEDOWN, STATE_MOVELEFT, STATE_MOVERIGHT};
+	static const int xvAhead[5] = {9, 0, 0,-1, 1};
+	static const int yvAhead[5] = {9,-1, 1, 0, 0};
+
 	int	result;
 	AIEntity *hit;
 
@@ -2243,12 +2340,10 @@ void aiGoodFairyAction(AIEntity *e) {
 			{
 				// Create a GEM?
 				if (g_hdb->_rnd->getRandomNumber(99) > 98) {
-					int	spawnOK;
-
 					// spawn a gem in a random direction
 					int	d = g_hdb->_rnd->getRandomNumber(3) + 1;
-					xv = xvAhead[d];
-					yv = yvAhead[d];
+					int xv = xvAhead[d];
+					int yv = yvAhead[d];
 
 					e->sequence = 30;
 					e->state = STATE_MOVEDOWN;
@@ -2256,6 +2351,7 @@ void aiGoodFairyAction(AIEntity *e) {
 					if ((g_hdb->_ai->findEntityType(AI_CRATE, e->tileX + xv, e->tileY + yv) != NULL) ||
 						(g_hdb->_ai->findEntityType(AI_LIGHTBARREL, e->tileX + xv, e->tileY + yv) != NULL))
 						return;
+					int spawnOK;
 					hit = g_hdb->_ai->legalMove(e->tileX + xv, e->tileY + yv, e->level, &spawnOK);
 					uint32 bg_flags = g_hdb->_map->getMapBGTileFlags(e->tileX + xv, e->tileY + yv);
 					if (hit || !spawnOK || (bg_flags & kFlagSpecial))
@@ -2273,9 +2369,8 @@ void aiGoodFairyAction(AIEntity *e) {
 				int	tries = 4;
 				do {
 					// pick a random direction, then a random # of tiles in that direction
-					int	 rnd = g_hdb->_rnd->getRandomNumber(3) + 1;
-					AIDir d = (AIDir)rnd;
-					int	 walk = g_hdb->_rnd->getRandomNumber(4) + 1;
+					AIDir d = (AIDir)(g_hdb->_rnd->getRandomNumber(3) + 1);
+					int walk = g_hdb->_rnd->getRandomNumber(4) + 1;
 					AIEntity *p = g_hdb->_ai->getPlayer();
 
 					// if player is within 3 tiles, move closer
@@ -2317,14 +2412,15 @@ void aiGoodFairyAction(AIEntity *e) {
 					}
 
 					e->dir = d;
-					e->state = state[d];
-					xv = xvAhead[d] * walk;
+					int tmpDir = (int)d;
+					e->state = state[tmpDir];
+					int xv = xvAhead[tmpDir] * walk;
 					if (e->tileX + xv < 1)
 						xv = -e->tileX + 1;
 					if (e->tileX + xv > g_hdb->_map->_width)
 						xv = g_hdb->_map->_width - e->tileX - 1;
 
-					yv = yvAhead[d] * walk;
+					int yv = yvAhead[d] * walk;
 					if (e->tileY + yv < 1)
 						yv = -e->tileY + 1;
 					if (e->tileY + yv > g_hdb->_map->_height)
@@ -2425,9 +2521,10 @@ void aiBadFairyInit2(AIEntity *e) {
 }
 
 void aiBadFairyAction(AIEntity *e) {
-	AIState	state[5] = {STATE_NONE, STATE_MOVEUP, STATE_MOVEDOWN, STATE_MOVELEFT, STATE_MOVERIGHT};
-	int	xvAhead[5] = {9, 0, 0,-1, 1}, yvAhead[5] = {9,-1, 1, 0, 0};
-	int	result;
+	static const AIState state[5] = {STATE_NONE, STATE_MOVEUP, STATE_MOVEDOWN, STATE_MOVELEFT, STATE_MOVERIGHT};
+	static const AIDir opposite[5] = {DIR_NONE, DIR_DOWN, DIR_UP, DIR_RIGHT, DIR_LEFT};
+	static const int xvAhead[5] = {9, 0, 0,-1, 1};
+	static const int yvAhead[5] = {9,-1, 1, 0, 0};
 
 	if (e->sequence) {
 		e->sequence--;
@@ -2441,8 +2538,6 @@ void aiBadFairyAction(AIEntity *e) {
 			{
 				// Create a GATE PUDDLE?
 				if (e->onScreen && (g_hdb->_rnd->getRandomNumber(99) > 90) && g_hdb->getActionMode() && (g_hdb->_ai->getGatePuddles() < kMaxGatePuddles)) {
-					AIDir opposite[] = {DIR_NONE, DIR_DOWN, DIR_UP, DIR_RIGHT, DIR_LEFT};
-
 					if (e->onScreen)
 						g_hdb->_sound->playSound(SND_BADFAIRY_SPELL);
 
@@ -2457,14 +2552,14 @@ void aiBadFairyAction(AIEntity *e) {
 				}
 
 				int	tries = 4;
+				int	result;
 				do {
 					// pick a random direction, then a random # of tiles in that direction
-					int	rnd = g_hdb->_rnd->getRandomNumber(3) + 1;
-					AIDir d = (AIDir)rnd;
+					int d = g_hdb->_rnd->getRandomNumber(3) + 1;
 					int	walk = g_hdb->_rnd->getRandomNumber(4) + 1;
 					AIEntity *p = g_hdb->_ai->getPlayer();
 
-					e->dir = d;
+					e->dir = (AIDir)d;
 					e->state = state[d];
 					int xv = xvAhead[d] * walk;
 					if (e->tileX + xv < 1)
@@ -2524,6 +2619,7 @@ void aiBadFairyAction(AIEntity *e) {
 		// did we run into a wall, entity, water, slime etc?
 		// if so, pick a new direction!
 		if (onEvenTile(e->x, e->y)) {
+			int	result;
 			AIEntity *hit = g_hdb->_ai->legalMoveOverWater(e->tileX + e->value1, e->tileY + e->value2, e->level, &result);
 			uint32 bg_flags = g_hdb->_map->getMapBGTileFlags(e->tileX + e->value1, e->tileY + e->value2);
 			if (!result || (hit && hit->type != AI_GUY) || (bg_flags & kFlagSpecial)) {
@@ -2562,8 +2658,7 @@ void aiGatePuddleAction(AIEntity *e) {
 	if (e->goalX) {
 		g_hdb->_ai->animateEntity(e);
 		if (hitPlayer(e->x, e->y)) {
-			int		i;
-			for (i = 0; i < kMaxTeleporters; i++) {
+			for (int i = 0; i < kMaxTeleporters; i++) {
 				if (g_hdb->_ai->_teleporters[i].anim1 == 2) {	// PANIC ZONE?
 					p->tileX = g_hdb->_ai->_teleporters[i].x1;
 					p->tileY = g_hdb->_ai->_teleporters[i].y1;
@@ -2637,11 +2732,11 @@ void aiGatePuddleAction(AIEntity *e) {
 		}
 	} else {
 		int rnd = g_hdb->_rnd->getRandomNumber(3) + 1;
-		int move_ok = 0, nx, ny;
-
 		e->dir = (AIDir)rnd;
-		nx = e->tileX + xva[e->dir];
-		ny = e->tileY + yva[e->dir];
+		int nx = e->tileX + xva[rnd];
+		int ny = e->tileY + yva[rnd];
+
+		int move_ok;
 		AIEntity *hit = g_hdb->_ai->legalMoveOverWater(nx, ny, e->level, &move_ok);
 		if (hit == p)
 			hit = NULL;
@@ -2706,12 +2801,10 @@ void aiIcePuffSnowballInit(AIEntity *e) {
 }
 
 void aiIcePuffSnowballAction(AIEntity *e) {
-	int	result, speed;
-	AIEntity *hit = NULL;
-
 	// check for hit BEFORE moving so snowball is closer to object
 	// NOTE: Need to do logic in this draw routine just in case the ICEPUFF gets stunned!
-	hit = g_hdb->_ai->legalMoveOverWater(e->value1 / kTileWidth, e->value2 / kTileHeight, e->level, &result);
+	int result;
+	AIEntity *hit = g_hdb->_ai->legalMoveOverWater(e->value1 / kTileWidth, e->value2 / kTileHeight, e->level, &result);
 	if (hit && hit->type == AI_GUY && !g_hdb->_ai->playerDead()) {
 		g_hdb->_ai->killPlayer(DEATH_NORMAL);
 		g_hdb->_ai->addAnimateTarget(hit->x, hit->y, 0, 3, ANIM_NORMAL, false, false, GROUP_WATER_SPLASH_SIT);
@@ -2725,15 +2818,22 @@ void aiIcePuffSnowballAction(AIEntity *e) {
 		return;
 	}
 
-	speed = kPlayerMoveSpeed;
+	int speed = kPlayerMoveSpeed;
 	if (!g_hdb->getActionMode())
 		speed >>= 1;
 
 	switch (e->dir2) {
-	case DIR_DOWN:  e->value2 += speed; break;
-	case DIR_LEFT:  e->value1 -= speed; break;
-	case DIR_RIGHT: e->value1 += speed; break;
-	default: break;
+	case DIR_DOWN:
+		e->value2 += speed;
+		break;
+	case DIR_LEFT:
+		e->value1 -= speed;
+		break;
+	case DIR_RIGHT:
+		e->value1 += speed;
+		break;
+	default:
+		break;
 	}
 }
 
@@ -2826,10 +2926,20 @@ void aiIcePuffAction(AIEntity *e) {
 		if (e->animFrame == e->standupFrames) {
 			e->animFrame = 0;
 			switch (e->dir) {
-			case DIR_DOWN: e->state = STATE_ICEP_THROWDOWN; g_hdb->_sound->playSound(SND_ICEPUFF_THROW); break;
-			case DIR_LEFT: e->state = STATE_ICEP_THROWLEFT;g_hdb->_sound->playSound(SND_ICEPUFF_THROW);  break;
-			case DIR_RIGHT: e->state = STATE_ICEP_THROWRIGHT; g_hdb->_sound->playSound(SND_ICEPUFF_THROW); break;
-			default: break;
+			case DIR_DOWN:
+				e->state = STATE_ICEP_THROWDOWN;
+				g_hdb->_sound->playSound(SND_ICEPUFF_THROW);
+				break;
+			case DIR_LEFT:
+				e->state = STATE_ICEP_THROWLEFT;
+				g_hdb->_sound->playSound(SND_ICEPUFF_THROW);
+				break;
+			case DIR_RIGHT:
+				e->state = STATE_ICEP_THROWRIGHT;
+				g_hdb->_sound->playSound(SND_ICEPUFF_THROW);
+				break;
+			default:
+				break;
 			}
 		}
 		break;
@@ -2919,9 +3029,8 @@ void aiBuzzflyInit(AIEntity *e) {
 }
 
 void aiBuzzflyInit2(AIEntity *e) {
-	int		i;
 	e->draw = g_hdb->_ai->getStandFrameDir(e);
-	for (i = 0; i < e->movedownFrames; i++)
+	for (int i = 0; i < e->movedownFrames; i++)
 	{
 		e->standdownGfx[i] = e->movedownGfx[i];
 		e->standupGfx[i] = e->moveupGfx[i];
@@ -2979,8 +3088,6 @@ void aiBuzzflyAction(AIEntity *e) {
 //-------------------------------------------------------------------
 
 void aiDragonInit(AIEntity *e) {
-	AIEntity *block;
-
 	e->state = STATE_STANDDOWN;
 	e->sequence = 0;	// 0 = sleeping
 	e->aiAction = aiDragonAction;
@@ -2988,7 +3095,7 @@ void aiDragonInit(AIEntity *e) {
 	e->animCycle = 10;		// time between flaps
 
 	// need to save the dragon's coords and type in the blocking entity for gem-hit-blocking detection
-	block = spawnBlocking(e->tileX - 1, e->tileY, e->level);
+	AIEntity *block = spawnBlocking(e->tileX - 1, e->tileY, e->level);
 	block->value1 = (int)AI_DRAGON;
 	sprintf(block->luaFuncUse, "%03d%03d", e->tileX, e->tileY);
 	block = spawnBlocking(e->tileX + 1, e->tileY, e->level);


Commit: 29c7a6cc4aa2e4a1b715b6e2aa35d9450bb41887
    https://github.com/scummvm/scummvm/commit/29c7a6cc4aa2e4a1b715b6e2aa35d9450bb41887
Author: Strangerke (strangerke at scummvm.org)
Date: 2019-09-03T17:17:28+02:00

Commit Message:
HDB: More clean up in ai-bots

Changed paths:
    engines/hdb/ai-bots.cpp


diff --git a/engines/hdb/ai-bots.cpp b/engines/hdb/ai-bots.cpp
index cf7a799..3db6cd3 100644
--- a/engines/hdb/ai-bots.cpp
+++ b/engines/hdb/ai-bots.cpp
@@ -2326,7 +2326,6 @@ void aiGoodFairyAction(AIEntity *e) {
 	static const int yvAhead[5] = {9,-1, 1, 0, 0};
 
 	int	result;
-	AIEntity *hit;
 
 	if (e->sequence) {
 		e->sequence--;
@@ -2352,7 +2351,7 @@ void aiGoodFairyAction(AIEntity *e) {
 						(g_hdb->_ai->findEntityType(AI_LIGHTBARREL, e->tileX + xv, e->tileY + yv) != NULL))
 						return;
 					int spawnOK;
-					hit = g_hdb->_ai->legalMove(e->tileX + xv, e->tileY + yv, e->level, &spawnOK);
+					AIEntity *hit = g_hdb->_ai->legalMove(e->tileX + xv, e->tileY + yv, e->level, &spawnOK);
 					uint32 bg_flags = g_hdb->_map->getMapBGTileFlags(e->tileX + xv, e->tileY + yv);
 					if (hit || !spawnOK || (bg_flags & kFlagSpecial))
 						return;
@@ -2431,7 +2430,7 @@ void aiGoodFairyAction(AIEntity *e) {
 					e->moveSpeed = kPlayerMoveSpeed;
 
 					// make sure we can move over water & white gems, but not fg_hdb->_ai->y blockers and solids
-					hit = g_hdb->_ai->legalMoveOverWater(e->tileX + e->value1, e->tileY + e->value2, e->level, &result);
+					AIEntity *hit = g_hdb->_ai->legalMoveOverWater(e->tileX + e->value1, e->tileY + e->value2, e->level, &result);
 					if (hit && ((hit->type == ITEM_GEM_WHITE) || (hit->type == AI_GUY)))
 						hit = NULL;
 					uint32 bg_flags = g_hdb->_map->getMapBGTileFlags(e->tileX + e->value1, e->tileY + e->value2);
@@ -2461,14 +2460,12 @@ void aiGoodFairyAction(AIEntity *e) {
 		// did we run into a wall, entity, water, slime etc?
 		// if so, pick a new direction!
 		if (onEvenTile(e->x, e->y)) {
-
-			int	index;
 			// did we hit a Fg_hdb->_ai->YSTONE??? if so - teleport the thing at the other end to here!
-			index = g_hdb->_ai->checkFairystones(e->tileX, e->tileY);
+			int index = g_hdb->_ai->checkFairystones(e->tileX, e->tileY);
 			if (index >= 0) {
 				int	sx, sy;
 				g_hdb->_ai->getFairystonesSrc(index, &sx, &sy);
-				hit = g_hdb->_ai->findEntity(sx, sy);
+				AIEntity *hit = g_hdb->_ai->findEntity(sx, sy);
 				if (hit && (hit != g_hdb->_ai->getPlayer())) {
 					hit->tileX = e->tileX;
 					hit->tileY = e->tileY;
@@ -2488,7 +2485,7 @@ void aiGoodFairyAction(AIEntity *e) {
 			// (1) we're gonna hit a solid wall; ok to move over water/slime
 			// (2) ok to move thru white gems
 			// (3) cannot move thru SPECIAL flagged tiles (fg_hdb->_ai->y blockers)
-			hit = g_hdb->_ai->legalMoveOverWater(e->tileX + e->value1, e->tileY + e->value2, e->level, &result);
+			AIEntity *hit = g_hdb->_ai->legalMoveOverWater(e->tileX + e->value1, e->tileY + e->value2, e->level, &result);
 			uint32 bg_flags = g_hdb->_map->getMapBGTileFlags(e->tileX + e->value1, e->tileY + e->value2);
 			if (!result || (hit && hit->type != ITEM_GEM_WHITE && hit->type != AI_GUY) || (bg_flags & kFlagSpecial)) {
 				g_hdb->_ai->stopEntity(e);
@@ -2499,9 +2496,10 @@ void aiGoodFairyAction(AIEntity *e) {
 			}
 		}
 		g_hdb->_ai->animateEntity(e);
-	} else
+	} else {
 		// if not, start looking around!
 		e->sequence = 20;
+	}
 }
 
 //-------------------------------------------------------------------
@@ -2872,7 +2870,8 @@ void aiIcePuffInit(AIEntity *e) {
 }
 
 void aiIcePuffInit2(AIEntity *e) {
-	e->draw = e->blinkGfx[3];	// empty frame
+	// empty frame
+	e->draw = e->blinkGfx[3];
 }
 
 void aiIcePuffAction(AIEntity *e) {
@@ -2882,16 +2881,28 @@ void aiIcePuffAction(AIEntity *e) {
 	case STATE_ICEP_PEEK:
 		e->sequence--;
 		switch (e->sequence) {
-		case 20: e->draw = e->blinkGfx[0]; break;	// underground
-		case 16: e->draw = e->blinkGfx[1]; break;	// peek - looking
-		case 12: e->draw = e->blinkGfx[2]; break;	// peek - blinking
-		case  8: e->draw = e->blinkGfx[1]; break;	// peek - looking
-		case  4: e->draw = e->blinkGfx[0]; break;	// peek - looking
-		case  3:
+		case 20: // underground
+			e->draw = e->blinkGfx[0];
+			break;
+		case 16: // peek - looking
+			e->draw = e->blinkGfx[1];
+			break;
+		case 12: // peek - blinking
+			e->draw = e->blinkGfx[2];
+			break;
+		case 8: // peek - looking
+			e->draw = e->blinkGfx[1];
+			break;
+		case 4: // peek - looking
+			e->draw = e->blinkGfx[0];
+			break;
+		case 3:
 			if (e->onScreen && !g_hdb->_rnd->getRandomNumber(5))
 				g_hdb->_sound->playSound(SND_ICEPUFF_WARNING);
 			break;
-		case  0: e->draw = e->blinkGfx[3];			// underground
+		case 0:
+			// underground
+			e->draw = e->blinkGfx[3];
 			e->sequence = 30;
 			break;
 		}
@@ -2954,8 +2965,10 @@ void aiIcePuffAction(AIEntity *e) {
 
 		e->animFrame++;
 		if (e->animFrame == e->standdownFrames && e->state != STATE_ICEP_DISAPPEAR) {
-			e->dir2 = e->dir;				// dir2 = direction snowball is moving
-			aiIcePuffSnowballInit(e);	// throw it!
+			// dir2 = direction snowball is moving
+			e->dir2 = e->dir;
+			// throw it!
+			aiIcePuffSnowballInit(e);
 			e->animFrame = 0;
 			e->state = STATE_ICEP_DISAPPEAR;
 		} else if (e->animFrame == e->special1Frames) {
@@ -2975,8 +2988,10 @@ void aiIcePuffAction(AIEntity *e) {
 
 		e->animFrame++;
 		if (e->animFrame == e->standdownFrames && e->state != STATE_ICEP_DISAPPEAR) {
-			e->dir2 = e->dir;				// dir2 = direction snowball is moving
-			aiIcePuffSnowballInit(e);	// throw it!
+			// dir2 = direction snowball is moving
+			e->dir2 = e->dir;
+			// throw it!
+			aiIcePuffSnowballInit(e);
 			e->animFrame = 0;
 			e->state = STATE_ICEP_DISAPPEAR;
 		} else if (e->animFrame == e->special1Frames) {
@@ -2996,8 +3011,10 @@ void aiIcePuffAction(AIEntity *e) {
 
 		e->animFrame++;
 		if (e->animFrame == e->standdownFrames && e->state != STATE_ICEP_DISAPPEAR) {
-			e->dir2 = e->dir;				// dir2 = direction snowball is moving
-			aiIcePuffSnowballInit(e);	// throw it!
+			// dir2 = direction snowball is moving
+			e->dir2 = e->dir;
+			// throw it!
+			aiIcePuffSnowballInit(e);
 			e->animFrame = 0;
 			e->state = STATE_ICEP_DISAPPEAR;
 		} else if (e->animFrame == e->special1Frames) {
@@ -3030,8 +3047,7 @@ void aiBuzzflyInit(AIEntity *e) {
 
 void aiBuzzflyInit2(AIEntity *e) {
 	e->draw = g_hdb->_ai->getStandFrameDir(e);
-	for (int i = 0; i < e->movedownFrames; i++)
-	{
+	for (int i = 0; i < e->movedownFrames; i++) {
 		e->standdownGfx[i] = e->movedownGfx[i];
 		e->standupGfx[i] = e->moveupGfx[i];
 		e->standleftGfx[i] = e->moveleftGfx[i];
@@ -3092,7 +3108,7 @@ void aiDragonInit(AIEntity *e) {
 	e->sequence = 0;	// 0 = sleeping
 	e->aiAction = aiDragonAction;
 	e->aiDraw = aiDragonDraw;
-	e->animCycle = 10;		// time between flaps
+	e->animCycle = 10;	// time between flaps
 
 	// need to save the dragon's coords and type in the blocking entity for gem-hit-blocking detection
 	AIEntity *block = spawnBlocking(e->tileX - 1, e->tileY, e->level);
@@ -3128,7 +3144,8 @@ void aiDragonInit2(AIEntity *e) {
 }
 
 void aiDragonWake(AIEntity *e) {
-	e->sequence = 1;	// woke up, start flapping and breathing!
+	// woke up, start flapping and breathing!
+	e->sequence = 1;
 	e->animFrame = 0;
 	e->animDelay = e->animCycle;
 }
@@ -3141,7 +3158,7 @@ void aiDragonAction(AIEntity *e) {
 	AIEntity *p = g_hdb->_ai->getPlayer();
 
 	switch (e->sequence) {
-		// Sleeping, waiting for the player to wake him up
+	// Sleeping, waiting for the player to wake him up
 	case 0:
 		if (e->onScreen &&
 			p->tileX >= e->tileX - 1 &&
@@ -3157,7 +3174,7 @@ void aiDragonAction(AIEntity *e) {
 		}
 		break;
 
-		// Woke up - flapping wings 3 times!
+	// Woke up - flapping wings 3 times!
 	case 1:
 		e->animDelay--;
 
@@ -3174,7 +3191,7 @@ void aiDragonAction(AIEntity *e) {
 		}
 		break;
 
-		// Start breathing fire!
+	// Start breathing fire!
 	case 2:
 		e->animDelay--;
 
@@ -3192,7 +3209,7 @@ void aiDragonAction(AIEntity *e) {
 
 		break;
 
-		// Breathing fire!
+	// Breathing fire!
 	case 3:
 		{
 			if (hitPlayer(e->x, e->y + 32)) {
@@ -3260,23 +3277,23 @@ void aiDragonAction(AIEntity *e) {
 
 void aiDragonDraw(AIEntity *e, int mx, int my) {
 	switch (e->sequence) {
-		// sleeping
+	// sleeping
 	case 0:
 		g_hdb->_ai->_gfxDragonAsleep->drawMasked(e->x - 32 - mx, e->y - 96 - my);
 		break;
-		// flapping 3 times
+	// flapping 3 times
 	case 1:
 		g_hdb->_ai->_gfxDragonFlap[e->animFrame & 1]->drawMasked(e->x - 32 - mx, e->y - 96 - my);
 		break;
-		// start breathing (very short)
+	// start breathing (very short)
 	case 2:
 		g_hdb->_ai->_gfxDragonBreathe[0]->drawMasked(e->x - 32 - mx, e->y - 96 - my);
 		break;
-		// breathing
+	// breathing
 	case 3:
 		g_hdb->_ai->_gfxDragonBreathe[(e->animFrame & 1) + 1]->drawMasked(e->x - 32 - mx, e->y - 96 - my);
 		break;
-		// flapping 3 times
+	// flapping 3 times
 	case 4:
 		g_hdb->_ai->_gfxDragonBreathe[e->animFrame & 1]->drawMasked(e->x - 32 - mx, e->y - 96 - my);
 		break;


Commit: b7a89a5eddf360139444666d9c84c4058365d8bb
    https://github.com/scummvm/scummvm/commit/b7a89a5eddf360139444666d9c84c4058365d8bb
Author: Strangerke (strangerke at scummvm.org)
Date: 2019-09-03T17:17:28+02:00

Commit Message:
HDB: Clean up in ai-cinematic

Changed paths:
    engines/hdb/ai-cinematic.cpp


diff --git a/engines/hdb/ai-cinematic.cpp b/engines/hdb/ai-cinematic.cpp
index 80226be..36e7405 100644
--- a/engines/hdb/ai-cinematic.cpp
+++ b/engines/hdb/ai-cinematic.cpp
@@ -69,17 +69,8 @@ static const char *cineTypeStr[] = {
 };
 
 void AI::processCines() {
-
-	AIEntity *e;
-	Picture *p;
-	const char *title;
-	bool complete, bailOut;
-
-	if (!_cineActive) {
+	if (!_cineActive)
 		return;
-	}
-
-	bailOut = complete = false;
 
 	// Make sure Dialogs are timing out
 	g_hdb->_window->checkDialogClose(0, 0);
@@ -96,45 +87,52 @@ void AI::processCines() {
 	if (g_hdb->getPause())
 		return;
 
+	bool bailOut = false;
+	bool complete = false;
+
 	for (uint i = 0; i < _cine.size(); i++) {
 		debug(3, "processCines: [%d] %s now: %d  start: %d delay: %d", i, cineTypeStr[_cine[i]->cmdType],
 				g_system->getMillis(), _cine[i]->start, _cine[i]->delay);
 
 		switch (_cine[i]->cmdType) {
 		case C_STOPCINE:
-			char func[64];
-			memset(func, 0, 64);
+			{
+				char func[64];
+				memset(func, 0, 64);
 
-			if (_cine[i]->title)
-				strcpy(func, _cine[i]->title);
+				if (_cine[i]->title)
+					strcpy(func, _cine[i]->title);
 
-			cineCleanup();
-			if (func[0])
-				g_hdb->_lua->callFunction(func, 0);
+				cineCleanup();
+				if (func[0])
+					g_hdb->_lua->callFunction(func, 0);
+			}
 			break;
-		case C_STARTMAP:
-			title = _cine[i]->title;
-			cineFreeGfx();			// free all gfx alloc'ed during cine
-			_cineActive = false;
-			_playerLock = false;
-			_cameraLock = false;
-			g_hdb->_window->setInfobarDark(0);
-			g_hdb->_gfx->setPointerState(1);
-			_cine.resize(0);
-			_numCineFreeList = 0;
-			_numCineBlitList = 0;
-			// if cine is aborted and an abort function was specified, call it
-			if (_cineAborted && _cineAbortFunc)
-				g_hdb->_lua->callFunction(_cineAbortFunc, 0);
-			g_hdb->changeMap(title);
-			return;
+		case C_STARTMAP: 
+			{
+				const char *title = _cine[i]->title;
+				// free all gfx alloc'ed during cine
+				cineFreeGfx();
+				_cineActive = false;
+				_playerLock = false;
+				_cameraLock = false;
+				g_hdb->_window->setInfobarDark(0);
+				g_hdb->_gfx->setPointerState(1);
+				_cine.resize(0);
+				_numCineFreeList = 0;
+				_numCineBlitList = 0;
+				// if cine is aborted and an abort function was specified, call it
+				if (_cineAborted && _cineAbortFunc)
+					g_hdb->_lua->callFunction(_cineAbortFunc, 0);
+				g_hdb->changeMap(title);
+				return;
+			}
 			break;
 		case C_LOCKPLAYER:
 			_playerLock = true;
 			complete = true;
-			if (_player) {
+			if (_player)
 				stopEntity(_player);
-			}
 			clearWaypoints();
 			break;
 		case C_UNLOCKPLAYER:
@@ -149,11 +147,13 @@ void AI::processCines() {
 			complete = true;
 			break;
 		case C_RESETCAMERA:
-			int px, py;
-			_cameraLock = false;
-			g_hdb->_ai->getPlayerXY(&px, &py);
-			g_hdb->_map->centerMapXY(px + 16, py + 16);
-			complete = true;
+			{
+				_cameraLock = false;
+				int px, py;
+				g_hdb->_ai->getPlayerXY(&px, &py);
+				g_hdb->_map->centerMapXY(px + 16, py + 16);
+				complete = true;
+			}
 			break;
 		case C_MOVECAMERA:
 			_cameraLock = true;
@@ -178,20 +178,17 @@ void AI::processCines() {
 			if (!(_cine[i]->start)) {
 				_cine[i]->start = 1;
 				_cine[i]->delay = g_system->getMillis() + _cine[i]->delay * 1000;
-			} else {
-				if (_cine[i]->delay < g_system->getMillis()) {
-					complete = true;
-				} else {
-					bailOut = true;
-				}
-			}
+			} else if (_cine[i]->delay < g_system->getMillis())
+				complete = true;
+			else
+				bailOut = true;
 			break;
 		case C_WAITUNTILDONE:
-			if (!i) {
+			if (!i)
 				complete = true;
-			} else {
+			else
 				bailOut = true;
-			}
+
 			break;
 		case C_SETENTITY:
 			_cine[i]->e = locateEntity(_cine[i]->string);
@@ -202,33 +199,31 @@ void AI::processCines() {
 				_cine[i]->e->y = (int)_cine[i]->y;
 				_cine[i]->e->level = (int)_cine[i]->x2;
 				debug(2, "Found '%s' in setEntity", _cine[i]->string);
-			} else {
+			} else
 				warning("Can't locate '%s' in setEntity", _cine[i]->string);
-			}
+
 			complete = true;
 			break;
 		case C_MOVEENTITY:
 			if (!_cine[i]->start) {
-				e = locateEntity(_cine[i]->title);
+				AIEntity *e = locateEntity(_cine[i]->title);
 				if (e) {
 					_cine[i]->e = e;
 					_cine[i]->e->moveSpeed = _cine[i]->speed;
 					_cine[i]->e->level = (int)_cine[i]->x2;
 					setEntityGoal(_cine[i]->e, (int)_cine[i]->x, (int)_cine[i]->y);
 					_cine[i]->start = 1;
-				} else {
+				} else
 					warning("Can't locate '%s' in moveEntity", _cine[i]->title);
-				}
 			} else {
 				debug(3, "C_MOVEENTITY: %d, %s tileX: %d, goalX: %d tileY %d, goalY: %d", i, AIType2Str(_cine[i]->e->type), _cine[i]->e->tileX, _cine[i]->e->goalX, _cine[i]->e->tileY, _cine[i]->e->goalY);
-				if (!_cine[i]->e->goalX) {
+				if (!_cine[i]->e->goalX)
 					complete = true;
-				}
 			}
 			break;
 		case C_ANIMENTITY:
 			if (!_cine[i]->start) {
-				e = locateEntity(_cine[i]->title);
+				AIEntity *e = locateEntity(_cine[i]->title);
 				if (e) {
 					_cine[i]->e = e;
 					e->state = (AIState)_cine[i]->speed;
@@ -243,7 +238,7 @@ void AI::processCines() {
 					complete = true;
 				}
 			} else {
-				e = _cine[i]->e;
+				AIEntity *e = _cine[i]->e;
 				if (!e->animFrame && e->animDelay == e->animCycle) {
 					e->state = STATE_STANDDOWN;
 					e->animFrame = 0;
@@ -253,94 +248,94 @@ void AI::processCines() {
 			}
 			break;
 		case C_SETANIMFRAME:
-			e = locateEntity(_cine[i]->title);
-			if (e) {
-				e->state = (AIState)_cine[i]->start;
-				e->animFrame = _cine[i]->end;
-				e->animDelay = e->animCycle;
-				animEntFrames(e);
-				e->state = STATE_NONE;
-				complete = true;
+			{
+				AIEntity *e = locateEntity(_cine[i]->title);
+				if (e) {
+					e->state = (AIState)_cine[i]->start;
+					e->animFrame = _cine[i]->end;
+					e->animDelay = e->animCycle;
+					animEntFrames(e);
+					e->state = STATE_NONE;
+					complete = true;
+				}
 			}
 			break;
 		case C_ENTITYFACE:
-		{
-			e = locateEntity(_cine[i]->title);
-
-			if (e) {
-				int d = (int)_cine[i]->x;
-				e->dir = (AIDir)d;
-				switch (e->dir) {
-				case DIR_UP:
-					e->state = STATE_STANDUP;
-					break;
-				case DIR_DOWN:
-					e->state = STATE_STANDDOWN;
-					break;
-				case DIR_LEFT:
-					e->state = STATE_STANDLEFT;
-					break;
-				case DIR_RIGHT:
-					e->state = STATE_STANDRIGHT;
-					break;
-				default:
-					warning("AI-CINEMATIC: processCines: DIR_NONE");
-				}
-			} else {
-				warning("Can't find %s to ENTITYFACE", _cine[i]->title);
+			{
+				AIEntity *e = locateEntity(_cine[i]->title);
+
+				if (e) {
+					int d = (int)_cine[i]->x;
+					e->dir = (AIDir)d;
+					switch (e->dir) {
+					case DIR_UP:
+						e->state = STATE_STANDUP;
+						break;
+					case DIR_DOWN:
+						e->state = STATE_STANDDOWN;
+						break;
+					case DIR_LEFT:
+						e->state = STATE_STANDLEFT;
+						break;
+					case DIR_RIGHT:
+						e->state = STATE_STANDRIGHT;
+						break;
+					default:
+						warning("AI-CINEMATIC: processCines: DIR_NONE");
+					}
+				} else
+					warning("Can't find %s to ENTITYFACE", _cine[i]->title);
+
+				complete = true;
 			}
-			complete = true;
 			break;
-		}
 		case C_DIALOG:
 			if (_cine[i]->start) {
 				g_hdb->_window->openDialog(_cine[i]->title, -1, _cine[i]->string, 0, NULL);
 				g_hdb->_window->setDialogDelay(_cine[i]->delay);
 				_cine[i]->start = 0;
-			} else {
-				if (g_hdb->_window->getDialogDelay() < g_hdb->getTimeSlice())
-					complete = true;
-			}
+			} else if (g_hdb->_window->getDialogDelay() < g_hdb->getTimeSlice())
+				complete = true;
 			break;
 		case C_TEXTOUT:
 			if (!_cine[i]->start) {
 				g_hdb->_window->textOut(_cine[i]->title, _cine[i]->x, _cine[i]->y, _cine[i]->end);
 				_cine[i]->start = 1;
-			} else {
-				if (!g_hdb->_window->textOutActive())
-					complete = true;
-			}
+			} else if (!g_hdb->_window->textOutActive())
+				complete = true;
 			break;
 		case C_CENTERTEXTOUT:
 			if (!_cine[i]->start) {
 				g_hdb->_window->centerTextOut(_cine[i]->title, _cine[i]->y, _cine[i]->end);
 				_cine[i]->start = 1;
-			} else {
-				if (!g_hdb->_window->textOutActive())
-					complete = true;
-			}
+			} else if (!g_hdb->_window->textOutActive())
+				complete = true;
 			break;
 		case C_DRAWPIC:
-
-			if ((p = cineFindInBlitList(_cine[i]->id)) == NULL) {
-				p = g_hdb->_gfx->loadPic(_cine[i]->string);
-				cineAddToFreeList(p);
-				cineAddToBlitList(_cine[i]->id, p, (int)_cine[i]->x, (int)_cine[i]->y, false);
+			{
+				Picture *p = cineFindInBlitList(_cine[i]->id);
+				if (p == NULL) {
+					p = g_hdb->_gfx->loadPic(_cine[i]->string);
+					cineAddToFreeList(p);
+					cineAddToBlitList(_cine[i]->id, p, (int)_cine[i]->x, (int)_cine[i]->y, false);
+				}
+				_cine[i]->pic = p;
+				_cine[i]->pic->draw((int)_cine[i]->x, (int)_cine[i]->y);
+				complete = true;
 			}
-			_cine[i]->pic = p;
-			_cine[i]->pic->draw((int)_cine[i]->x, (int)_cine[i]->y);
-			complete = true;
 			break;
 		case C_DRAWMASKEDPIC:
-
-			if ((p = cineFindInBlitList(_cine[i]->id)) == NULL) {
-				p = g_hdb->_gfx->loadPic(_cine[i]->string);
-				cineAddToFreeList(p);
-				cineAddToBlitList(_cine[i]->id, p, (int)_cine[i]->x, (int)_cine[i]->y, true);
+			{
+				Picture *p = cineFindInBlitList(_cine[i]->id);
+				if (p == NULL) {
+					p = g_hdb->_gfx->loadPic(_cine[i]->string);
+					cineAddToFreeList(p);
+					cineAddToBlitList(_cine[i]->id, p, (int)_cine[i]->x, (int)_cine[i]->y, true);
+				}
+				_cine[i]->pic = p;
+				_cine[i]->pic->drawMasked((int)_cine[i]->x, (int)_cine[i]->y);
+				complete = true;
 			}
-			_cine[i]->pic = p;
-			_cine[i]->pic->drawMasked((int)_cine[i]->x, (int)_cine[i]->y);
-			complete = true;
 			break;
 
 		case C_MOVEPIC:
@@ -385,9 +380,8 @@ void AI::processCines() {
 
 		case C_USEENTITY:
 			for (Common::Array<AIEntity *>::iterator it = _ents->begin(); it != _ents->end(); ++it) {
-				if ((*it)->entityName && Common::matchString((*it)->entityName, _cine[i]->string, true)) {
+				if ((*it)->entityName && Common::matchString((*it)->entityName, _cine[i]->string, true))
 					g_hdb->useEntity((*it));
-				}
 			}
 			for (int k = 0; k < kMaxActions; k++) {
 				if (_actions[k].entityName && Common::matchString(_actions[k].entityName, _cine[i]->string, true)) {
@@ -413,34 +407,32 @@ void AI::processCines() {
 			if (!_cine[i]->start) {
 				g_hdb->_gfx->setFade(true, (bool)_cine[i]->end, _cine[i]->speed);
 				_cine[i]->start = 1;
-			} else if (!g_hdb->_gfx->isFadeActive()) {
+			} else if (!g_hdb->_gfx->isFadeActive())
 				complete = true;
-			}
 			break;
 		case C_FADEOUT:
 			if (!_cine[i]->start) {
 				g_hdb->_gfx->setFade(false, (bool)_cine[i]->end, _cine[i]->speed);
 				_cine[i]->start = 1;
-			} else if (!g_hdb->_gfx->isFadeActive()) {
+			} else if (!g_hdb->_gfx->isFadeActive())
 				complete = true;
-			}
 			break;
 		case C_SPAWNENTITY:
-		{
-			int x2, y2;
-			x2 = (int)_cine[i]->x2;
-			y2 = (int)_cine[i]->y2;
-			spawn((AIType)x2, (AIDir)y2, (int)_cine[i]->x, (int)_cine[i]->y, _cine[i]->title, _cine[i]->string,
-				_cine[i]->id, (AIDir)_cine[i]->start, (int)_cine[i]->end, (int)_cine[i]->delay, (int)_cine[i]->speed, 1);
-			complete = true;
+			{
+				int x2 = (int)_cine[i]->x2;
+				int y2 = (int)_cine[i]->y2;
+				spawn((AIType)x2, (AIDir)y2, (int)_cine[i]->x, (int)_cine[i]->y, _cine[i]->title, _cine[i]->string,
+					_cine[i]->id, (AIDir)_cine[i]->start, (int)_cine[i]->end, (int)_cine[i]->delay, (int)_cine[i]->speed, 1);
+				complete = true;
+			}
 			break;
-		}
-		break;
 		case C_REMOVEENTITY:
-			e = locateEntity(_cine[i]->string);
-			if (e)
-				removeEntity(e);
-			complete = true;
+			{
+				AIEntity *e = locateEntity(_cine[i]->string);
+				if (e)
+					removeEntity(e);
+				complete = true;
+			}
 			break;
 		case C_CLEAR_FG:
 			g_hdb->_map->setMapFGTileIndex((int)_cine[i]->x, (int)_cine[i]->y, -1);
@@ -466,16 +458,13 @@ void AI::processCines() {
 			break;
 		}
 
-		if (bailOut) {
+		if (bailOut)
 			return;
-		}
 
-		if (complete) {
-			if (_cine.size()) {
-				_cine.remove_at(i);
-				i--;
-				complete = false;
-			}
+		if (complete && _cine.size()) {
+			_cine.remove_at(i);
+			i--;
+			complete = false;
 		}
 	}
 }
@@ -553,9 +542,9 @@ void AI::cineAddToFreeList(Picture *pic) {
 }
 
 void AI::cineFreeGfx() {
-	for (int i = 0; i < _numCineFreeList; i++) {
+	for (int i = 0; i < _numCineFreeList; i++)
 		delete _cineFreeList[i];
-	}
+
 	_numCineFreeList = 0;
 }
 
@@ -843,7 +832,7 @@ void AI::cinePlayVoice(int index, int actor) {
 void AI::cineFadeIn(bool isBlack, int steps) {
 	CineCommand *cmd = new CineCommand;
 	cmd->speed = steps;
-	cmd->end = (int) isBlack;
+	cmd->end = (int)isBlack;
 	cmd->start = 0;
 	cmd->cmdType = C_FADEIN;
 	_cine.push_back(cmd);
@@ -852,7 +841,7 @@ void AI::cineFadeIn(bool isBlack, int steps) {
 void AI::cineFadeOut(bool isBlack, int steps) {
 	CineCommand *cmd = new CineCommand;
 	cmd->speed = steps;
-	cmd->end = (int) isBlack;
+	cmd->end = (int)isBlack;
 	cmd->start = 0;
 	cmd->cmdType = C_FADEOUT;
 	_cine.push_back(cmd);


Commit: e955dbb4a2bac52de1afdf4dc7bf32c9437338a0
    https://github.com/scummvm/scummvm/commit/e955dbb4a2bac52de1afdf4dc7bf32c9437338a0
Author: Strangerke (strangerke at scummvm.org)
Date: 2019-09-03T17:17:28+02:00

Commit Message:
HDB: Clean up in ai-funcs

Changed paths:
    engines/hdb/ai-funcs.cpp


diff --git a/engines/hdb/ai-funcs.cpp b/engines/hdb/ai-funcs.cpp
index aa0876f..1aee340 100644
--- a/engines/hdb/ai-funcs.cpp
+++ b/engines/hdb/ai-funcs.cpp
@@ -46,9 +46,8 @@ AIEntity *AI::spawn(AIType type, AIDir dir, int x, int y, const char *funcInit,
 	e->y = y * kTileHeight;
 	e->tileY = y;
 	e->moveSpeed = kPlayerMoveSpeed; // Default Speed
-	if (!g_hdb->getActionMode()) {
+	if (!g_hdb->getActionMode())
 		e->moveSpeed /= 2;
-	}
 
 	// Other variables
 	e->dir2 = dir2;
@@ -61,15 +60,14 @@ AIEntity *AI::spawn(AIType type, AIDir dir, int x, int y, const char *funcInit,
 	e->animDelay = e->animCycle;
 	e->animFrame = 0;
 
-	if (funcInit) {
+	if (funcInit)
 		strcpy(e->luaFuncInit, funcInit);
-	}
-	if (funcAction) {
+
+	if (funcAction)
 		strcpy(e->luaFuncAction, funcAction);
-	}
-	if (funcUse) {
+
+	if (funcUse)
 		strcpy(e->luaFuncUse, funcUse);
-	}
 
 	if (e->luaFuncInit[0] == '*')
 		e->luaFuncInit[0] = 0;
@@ -82,11 +80,10 @@ AIEntity *AI::spawn(AIType type, AIDir dir, int x, int y, const char *funcInit,
 	e->movedownFrames = e->moveupFrames = e->moveleftFrames = e->moverightFrames = 0;
 	e->blinkFrames = 0;
 
-	if (!cacheEntGfx(e, (bool)callInit)) {
+	if (!cacheEntGfx(e, (bool)callInit))
 		return NULL;
-	} else {
+	else
 		_ents->push_back(e);
-	}
 
 	return e;
 }
@@ -94,9 +91,8 @@ AIEntity *AI::spawn(AIType type, AIDir dir, int x, int y, const char *funcInit,
 bool AI::cacheEntGfx(AIEntity *e, bool init) {
 	int i = 0;
 	while (true) {
-		if (aiEntList[i].type == END_AI_TYPES) {
+		if (aiEntList[i].type == END_AI_TYPES)
 			return false;
-		}
 
 		// Load Gfx for corresponding Entity
 		if (aiEntList[i].type == e->type) {
@@ -173,13 +169,17 @@ bool AI::cacheEntGfx(AIEntity *e, bool init) {
 							_pushrightFrames++;
 							break;
 						case STATE_GRABUP:
-							_getGfx[DIR_UP] = gfx; break;
+							_getGfx[DIR_UP] = gfx;
+							break;
 						case STATE_GRABDOWN:
-							_getGfx[DIR_DOWN] = gfx; break;
+							_getGfx[DIR_DOWN] = gfx;
+							break;
 						case STATE_GRABLEFT:
-							_getGfx[DIR_LEFT] = gfx; break;
+							_getGfx[DIR_LEFT] = gfx;
+							break;
 						case STATE_GRABRIGHT:
-							_getGfx[DIR_RIGHT] = gfx; break;
+							_getGfx[DIR_RIGHT] = gfx;
+							break;
 
 						case STATE_ATK_STUN_UP:
 							_stunUpGfx[_stunUpFrames] = gfx;
@@ -427,26 +427,22 @@ bool AI::cacheEntGfx(AIEntity *e, bool init) {
 			e->aiInit2 = aiEntList[i].initFunc2;
 			if (init) {
 				e->aiInit(e);
-				if (e->aiInit2) {
+				if (e->aiInit2)
 					e->aiInit2(e);
-				}
+
 				if (e->luaFuncInit[0]) {
 					g_hdb->_lua->callFunction(e->luaFuncInit, 2);
 
 					const char *str1 = g_hdb->_lua->getStringOffStack();
 					const char *str2 = g_hdb->_lua->getStringOffStack();
-					if (str1) {
+					if (str1)
 						strcpy(e->entityName, str1);
-					}
-					if (str2) {
+
+					if (str2)
 						strcpy(e->printedName, str2);
-					}
-				}
-			} else {
-				if (e->aiInit2) {
-					e->aiInit2(e);
 				}
-			}
+			} else if (e->aiInit2)
+				e->aiInit2(e);
 
 			break; // Entity Initiated
 		}
@@ -523,24 +519,21 @@ void AI::stopEntity(AIEntity *e) {
 
 AIEntity *AI::locateEntity(const char *luaName) {
 	for (Common::Array<AIEntity *>::iterator it = _ents->begin(); it != _ents->end(); ++it) {
-		if (Common::matchString((*it)->entityName, luaName)) {
+		if (Common::matchString((*it)->entityName, luaName))
 			return *it;
-		}
 	}
 	return NULL;
 }
 
 AIEntity *AI::findEntity(int x, int y) {
 	for (Common::Array<AIEntity *>::iterator it = _ents->begin(); it != _ents->end(); ++it) {
-		if ((*it)->tileX == x && (*it)->tileY == y) {
+		if ((*it)->tileX == x && (*it)->tileY == y)
 			return *it;
-		}
 	}
 
 	for (Common::Array<AIEntity *>::iterator it = _floats->begin(); it != _floats->end(); ++it) {
-		if ((*it)->tileX == x && (*it)->tileY == y) {
+		if ((*it)->tileX == x && (*it)->tileY == y)
 			return *it;
-		}
 	}
 
 	if (g_hdb->_map->laserBeamExist(x, y))
@@ -551,15 +544,13 @@ AIEntity *AI::findEntity(int x, int y) {
 
 AIEntity *AI::findEntityIgnore(int x, int y, AIEntity *ignore) {
 	for (Common::Array<AIEntity *>::iterator it = _ents->begin(); it != _ents->end(); ++it) {
-		if ((*it)->tileX == x && (*it)->tileY == y && (*it) != ignore) {
+		if ((*it)->tileX == x && (*it)->tileY == y && (*it) != ignore)
 			return *it;
-		}
 	}
 
 	for (Common::Array<AIEntity *>::iterator it = _floats->begin(); it != _floats->end(); ++it) {
-		if ((*it)->tileX == x && (*it)->tileY == y && (*it) != ignore) {
+		if ((*it)->tileX == x && (*it)->tileY == y && (*it) != ignore)
 			return *it;
-		}
 	}
 
 	if (g_hdb->_map->laserBeamExist(x, y) && ignore->type != AI_LASERBEAM)
@@ -570,15 +561,13 @@ AIEntity *AI::findEntityIgnore(int x, int y, AIEntity *ignore) {
 
 AIEntity *AI::findEntityType(AIType type, int x, int y) {
 	for (Common::Array<AIEntity *>::iterator it = _ents->begin(); it != _ents->end(); ++it) {
-		if ((*it)->tileX == x && (*it)->tileY == y && (*it)->type == type) {
+		if ((*it)->tileX == x && (*it)->tileY == y && (*it)->type == type)
 			return *it;
-		}
 	}
 
 	for (Common::Array<AIEntity *>::iterator it = _floats->begin(); it != _floats->end(); ++it) {
-		if ((*it)->tileX == x && (*it)->tileY == y && (*it)->type == type) {
+		if ((*it)->tileX == x && (*it)->tileY == y && (*it)->type == type)
 			return *it;
-		}
 	}
 
 	if (g_hdb->_map->laserBeamExist(x, y) && type == AI_LASERBEAM)
@@ -588,11 +577,8 @@ AIEntity *AI::findEntityType(AIType type, int x, int y) {
 }
 
 void AI::getEntityXY(const char *entName, int *x, int *y) {
-	AIEntity *e;
-	HereT *h;
-
 	for (Common::Array<AIEntity *>::iterator it = _ents->begin(); it != _ents->end(); ++it) {
-		e = *it;
+		AIEntity *e = *it;
 		if (e->entityName && !scumm_stricmp(entName, e->entityName)) {
 			*x = e->tileX;
 			*y = e->tileY;
@@ -601,7 +587,7 @@ void AI::getEntityXY(const char *entName, int *x, int *y) {
 	}
 
 	for (Common::Array<AIEntity *>::iterator jt = _floats->begin(); jt != _floats->end(); ++jt) {
-		e = *jt;
+		AIEntity *e = *jt;
 		if (e->entityName && !scumm_stricmp(entName, e->entityName)) {
 			*x = e->tileX;
 			*y = e->tileY;
@@ -610,7 +596,7 @@ void AI::getEntityXY(const char *entName, int *x, int *y) {
 	}
 
 	for (Common::Array<HereT *>::iterator kt = _hereList->begin(); kt != _hereList->end(); ++kt) {
-		h = *kt;
+		HereT *h = *kt;
 		if (!scumm_stricmp(entName, h->entName)) {
 			*x = h->x;
 			*y = h->y;
@@ -684,12 +670,13 @@ int AI::checkForTouchplate(int x, int y) {
 }
 
 void AI::removeEntity(AIEntity *e) {
-	for (uint i = 0; i < _ents->size(); i++)
+	for (uint i = 0; i < _ents->size(); i++) {
 		if (_ents->operator[](i) == e) {
 			delete _ents->operator[](i);
 			_ents->remove_at(i);
 			return;
 		}
+	}
 }
 
 void AI::setEntityGoal(AIEntity *e, int x, int y) {
@@ -736,9 +723,8 @@ void AI::initAllEnts() {
 			if (g_hdb->_lua->callFunction((*it)->luaFuncInit, 2)) {
 				strcpy((*it)->entityName, g_hdb->_lua->getStringOffStack());
 				strcpy((*it)->printedName, g_hdb->_lua->getStringOffStack());
-			} else {
+			} else
 				warning("'%s' doesn't exists", (*it)->luaFuncInit);
-			}
 		}
 	}
 
@@ -836,11 +822,7 @@ void AI::killPlayer(Death method) {
 }
 
 void AI::stunEnemy(AIEntity *e, int time) {
-	int ns = 0;
-
-	if (e->stunnedWait)
-		ns = 1;
-
+	bool ns = (e->stunnedWait != 0);
 	e->stunnedWait = g_hdb->getTimeSlice() + 1000 * time;
 
 	// Already stunned? If not, play sound
@@ -897,9 +879,7 @@ void AI::animateEntity(AIEntity *e) {
 	static const int xva[5] = {9, 0, 0, -1, 1};
 	static const int yva[5] = {9, -1, 1, 0, 0};
 
-	int bgTileFlags, bgTileIndex;
-	int fgTileFlags;
-	bool result;
+	int bgTileFlags, fgTileFlags;
 
 	// Move entity if player is not dead
 	debug(9, "Before animateEntity, e->x: %d, e->y: %d", e->x, e->y);
@@ -925,7 +905,6 @@ void AI::animateEntity(AIEntity *e) {
 			standing on a Touchplate will activate
 			something WHILE standing on it
 		*/
-		int bgtile;
 		switch (e->type) {
 		case AI_CRATE:
 		case AI_BOOMBARREL:
@@ -934,16 +913,18 @@ void AI::animateEntity(AIEntity *e) {
 		case AI_MAGIC_EGG:
 		case AI_ICE_BLOCK:
 		case AI_FROGSTATUE:
-			bgtile = g_hdb->_ai->checkForTouchplate(e->tileX, e->tileY);
-			if (bgtile && !e->touchpWait && e->touchpX != e->tileX && e->touchpY != e->tileY) {
-				if (g_hdb->_ai->checkActionList(e, e->tileX, e->tileY, false)) {
-					e->touchpTile = bgtile;
-					e->touchpX = e->tileX;
-					e->touchpY = e->tileY;
-					e->touchpWait = kPlayerTouchPWait;
+			{
+				int bgtile = g_hdb->_ai->checkForTouchplate(e->tileX, e->tileY);
+				if (bgtile && !e->touchpWait && e->touchpX != e->tileX && e->touchpY != e->tileY) {
+					if (g_hdb->_ai->checkActionList(e, e->tileX, e->tileY, false)) {
+						e->touchpTile = bgtile;
+						e->touchpX = e->tileX;
+						e->touchpY = e->tileY;
+						e->touchpWait = kPlayerTouchPWait;
+					}
 				}
+				_laserRescan = true;
 			}
-			_laserRescan = true;
 			break;
 		default:
 			break;
@@ -1013,7 +994,7 @@ void AI::animateEntity(AIEntity *e) {
 			if we're on a waypoint, nevermind!
 		*/
 		if (e == _player) {
-			result = e->x == (e->goalX * kTileWidth) && e->y == (e->goalY * kTileWidth);
+			bool result = e->x == (e->goalX * kTileWidth) && e->y == (e->goalY * kTileWidth);
 			if (!result) {
 				int xv = 0, yv = 0;
 				switch (e->dir) {
@@ -1095,9 +1076,9 @@ void AI::animateEntity(AIEntity *e) {
 	}
 
 	// Check for moving up/down stair levels
-	bgTileIndex = g_hdb->_map->getMapBGTileIndex(e->tileX, e->tileY);
+	int bgTileIndex = g_hdb->_map->getMapBGTileIndex(e->tileX, e->tileY); // CHECKME: unused?
 	bgTileFlags = g_hdb->_map->getMapBGTileFlags(e->tileX, e->tileY);
-	fgTileFlags = g_hdb->_map->getMapFGTileFlags(e->tileX, e->tileY);
+	fgTileFlags = g_hdb->_map->getMapFGTileFlags(e->tileX, e->tileY); // CHECKME: unused?
 	if (bgTileFlags & kFlagStairTop)
 		e->level = 2;
 	else if (bgTileFlags & kFlagStairBot)
@@ -1105,6 +1086,7 @@ void AI::animateEntity(AIEntity *e) {
 
 	// Reached goal?
 	// Cinematic require less accuracy for NPCs
+	bool result;
 	if (_cineActive && e != _player)
 		result = (abs(e->x - (e->goalX * kTileWidth)) <= abs(e->xVel)) && (abs(e->y - (e->goalY * kTileHeight)) <= abs(e->yVel));
 	else
@@ -1125,7 +1107,6 @@ void AI::animateEntity(AIEntity *e) {
 			e->tileY = e->goalY;
 
 			uint16 buttons = g_hdb->_input->getButtons();
-
 			if (e == _player && (buttons & (kButtonUp | kButtonDown | kButtonLeft | kButtonRight))) {
 				if (e->state != STATE_PUSHRIGHT && e->state != STATE_PUSHLEFT && e->state != STATE_PUSHUP && e->state != STATE_PUSHDOWN) {
 					if (buttons & kButtonUp)
@@ -1179,9 +1160,9 @@ void AI::animateEntity(AIEntity *e) {
 
 			// Checking at the Destination
 
-			uint64 flags;
+			uint64 flags = g_hdb->_map->getMapBGTileFlags(e->tileX, e->tileY);
 			// Can this entity float and it is over-water
-			if (((flags = g_hdb->_map->getMapBGTileFlags(e->tileX, e->tileY)) & kFlagWater) && (e->type == AI_CRATE || e->type == AI_LIGHTBARREL || e->type == AI_BOOMBARREL || e->type == AI_HEAVYBARREL || e->type == AI_FROGSTATUE || e->type == AI_DIVERTER)) {
+			if ((flags & kFlagWater) && (e->type == AI_CRATE || e->type == AI_LIGHTBARREL || e->type == AI_BOOMBARREL || e->type == AI_HEAVYBARREL || e->type == AI_FROGSTATUE || e->type == AI_DIVERTER)) {
 				// On a grating and level2?
 				if ((g_hdb->_map->getMapFGTileFlags(e->tileX, e->tileY) & kFlagGrating) && e->level == 2) {
 					animEntFrames(e);
@@ -1218,17 +1199,25 @@ void AI::animateEntity(AIEntity *e) {
 					}
 				} else if (flags & kFlagSlide) {
 					int xv = 0, yv = 0;
-					AIEntity *hit;
 
 					switch (e->dir) {
-					case DIR_UP:	yv = -1; break;
-					case DIR_DOWN:	yv = 1; break;
-					case DIR_LEFT:	xv = -1; break;
-					case DIR_RIGHT: xv = 1; break;
-					case DIR_NONE:	break;
+					case DIR_UP:
+						yv = -1;
+						break;
+					case DIR_DOWN:
+						yv = 1;
+						break;
+					case DIR_LEFT:
+						xv = -1;
+						break;
+					case DIR_RIGHT:
+						xv = 1;
+						break;
+					case DIR_NONE:
+						break;
 					}
 
-					hit = findEntityIgnore(e->tileX + xv, e->tileY + yv, &_dummyLaser);
+					AIEntity *hit = findEntityIgnore(e->tileX + xv, e->tileY + yv, &_dummyLaser);
 					if (!hit) {
 						e->state = STATE_SLIDING;
 						if ((flags & kFlagAnimFast) == kFlagAnimFast)
@@ -1346,6 +1335,8 @@ void AI::animateEntity(AIEntity *e) {
 }
 
 void AI::animEntFrames(AIEntity *e) {
+	static int click = 0;
+
 	int max = 1;
 	// Set current graphic to draw
 	switch (e->state) {
@@ -1427,7 +1418,6 @@ void AI::animEntFrames(AIEntity *e) {
 		break;
 	case STATE_HORRIBLE2:
 	{
-		static int		click = 0;
 		e->draw = _horrible2Gfx[e->animFrame];
 		max = _horrible2Frames;
 		click++;
@@ -1439,7 +1429,6 @@ void AI::animEntFrames(AIEntity *e) {
 	}
 	case STATE_HORRIBLE3:
 	{
-		static int		click = 0;
 		e->draw = _horrible3Gfx[e->animFrame];
 		max = _horrible3Frames;
 		click++;
@@ -1516,7 +1505,8 @@ void AI::animEntFrames(AIEntity *e) {
 	case STATE_EXPLODING:
 		e->draw = e->special1Gfx[e->animFrame];
 		max = e->special1Frames;
-		if (e->type == AI_BOOMBARREL) {			// while exploding, call this function
+		if (e->type == AI_BOOMBARREL) {
+			// while exploding, call this function
 			aiBarrelExplodeSpread(e);
 			if (e->animFrame == max - 1) {
 				removeEntity(e);
@@ -1642,26 +1632,24 @@ void AI::animEntFrames(AIEntity *e) {
 	// Cycle animation frames
 	if (e->animDelay-- > 0)
 		return;
-	e->animDelay = e->animCycle;
 
+	e->animDelay = e->animCycle;
 	e->animFrame++;
-	if (e->animFrame == max) {
+	if (e->animFrame == max)
 		e->animFrame = 0;
-	}
 }
 
 void AI::drawEnts(int x, int y, int w, int h) {
-
-	int debugFlag = g_hdb->getDebug();
 	static int stunAnim = 0;
 	static uint32 stunTimer = g_hdb->getTimeSlice();
 
+	int debugFlag = g_hdb->getDebug();
+
 	// Draw Floating Entities
 	for (uint i = 0; i < _floats->size(); i++) {
 		AIEntity *e = _floats->operator[](i);
-		if (e->aiDraw) {
+		if (e->aiDraw)
 			e->aiDraw(e, x, y);
-		}
 
 		if ((e->x > x - kTileWidth) && (e->x < x + w) && (e->y > y - kTileHeight) && (e->y < y + h)) {
 			e->draw->drawMasked(e->x - x + e->drawXOff, e->y - y + e->drawYOff);
@@ -1736,11 +1724,10 @@ void AI::drawEnts(int x, int y, int w, int h) {
 						debugN(5, "at %d %d", e->x, e->y);
 
 						e->draw->drawMasked(e->x - x + e->drawXOff, e->y - y + e->drawYOff);
-					} else if (debugFlag) {
+					} else if (debugFlag)
 						_debugQMark->drawMasked(e->x - x, e->y - y);
-					} else {
+					else
 						debugN(5, "no draw function");
-					}
 
 					if (e->stunnedWait)
 						g_hdb->_ai->_stunnedGfx[stunAnim]->drawMasked(e->x - x, e->y - y);
@@ -1761,9 +1748,8 @@ void AI::drawEnts(int x, int y, int w, int h) {
 	}
 
 	// Draw player last
-	if (_player && _player->level < 2 && !_playerInvisible && _player->draw) {
+	if (_player && _player->level < 2 && !_playerInvisible && _player->draw)
 		_player->draw->drawMasked(_player->x - x + _player->drawXOff, _player->y - y + _player->drawYOff);
-	}
 }
 
 void AI::drawLevel2Ents() {
@@ -1779,9 +1765,8 @@ void AI::drawLevel2Ents() {
 			debug(5, "AI::drawLevel2Ents: tile '%s' at %d,%d", _entsLevel2[i].draw->getName(), _entsLevel2[i].x, _entsLevel2[i].y);
 
 			_entsLevel2[i].draw->drawMasked(_entsLevel2[i].x, _entsLevel2[i].y);
-		} else if (debugFlag) {
+		} else if (debugFlag)
 			_debugQMark->drawMasked(_entsLevel2[i].x, _entsLevel2[i].y );
-		}
 
 		if (_entsLevel2[i].stunnedWait)
 			 g_hdb->_ai->_stunnedGfx[_stunAnim]->drawMasked(_entsLevel2[i].x , _entsLevel2[i].y);
@@ -1842,18 +1827,26 @@ void AI::entityFace(const char *luaName, int dir) {
 	e->dir = (AIDir)dir;
 
 	switch (e->dir) {
-	case DIR_UP: e->state = STATE_STANDUP; break;
-	case DIR_DOWN: e->state = STATE_STANDDOWN; break;
-	case DIR_LEFT: e->state = STATE_STANDLEFT; break;
-	case DIR_RIGHT: e->state = STATE_STANDRIGHT; break;
-	case DIR_NONE: break;
+	case DIR_UP:
+		e->state = STATE_STANDUP;
+		break;
+	case DIR_DOWN:
+		e->state = STATE_STANDDOWN;
+		break;
+	case DIR_LEFT:
+		e->state = STATE_STANDLEFT;
+		break;
+	case DIR_RIGHT:
+		e->state = STATE_STANDRIGHT;
+		break;
+	case DIR_NONE:
+		break;
 	}
 }
 
 void AI::moveEnts() {
 	static int frameDelay = kAnimFrameDelay;
-	static int startLaserSound = false;
-	AIEntity *e;
+	static bool startLaserSound = false;
 
 	if (frameDelay-- > 0)
 		return;
@@ -1868,7 +1861,7 @@ void AI::moveEnts() {
 
 	// Call aiAction for all other Entities
 	for (uint i = 0; i < _ents->size(); i++) {
-		e = _ents->operator[](i);
+		AIEntity *e = _ents->operator[](i);
 		if (e->aiAction) {
 			// NPC Touchplate Counter
 			if (e != _player && e->touchpWait) {
@@ -1886,10 +1879,8 @@ void AI::moveEnts() {
 			// Stunned Entity Timer
 			if (!e->stunnedWait)
 				e->aiAction(e);
-			else {
-				if (e->stunnedWait < (int32)g_hdb->getTimeSlice())
-					e->stunnedWait = 0;
-			}
+			else if (e->stunnedWait < (int32)g_hdb->getTimeSlice())
+				e->stunnedWait = 0;
 		}
 	}
 
@@ -1903,23 +1894,21 @@ void AI::moveEnts() {
 	if (_laserOnScreen)
 		startLaserSound = true;
 	if (!_laserOnScreen && startLaserSound) {
-		startLaserSound = 0;
+		startLaserSound = false;
 		g_hdb->_sound->stopChannel(kLaserChannel);
 	}
 }
 
 bool AI::findPath(AIEntity *e) {
-	int x, y, xv = 0, yv = 0, max;
-	ArrowPath *here;
-
 	// Initial Pointing Direction to search in
-	x = e->tileX;
-	y = e->tileY;
-	here = findArrowPath(x, y);
+	int x = e->tileX;
+	int y = e->tileY;
+	ArrowPath *here = findArrowPath(x, y);
 	// Only look for GO arrows at this first location
 	if (here && here->type == 1)
 		e->dir = here->dir;
 
+	int xv = 0, yv = 0;
 	switch (e->dir) {
 	case DIR_UP:
 		yv = -1;
@@ -1938,6 +1927,7 @@ bool AI::findPath(AIEntity *e) {
 		break;
 	}
 
+	int max;
 	if (xv)
 		max = g_hdb->_map->_width;
 	else
@@ -1968,11 +1958,10 @@ AIEntity *AI::legalMove(int tileX, int tileY, int level, int *result) {
 	if (hit && hit->state != STATE_FLOATING) {
 		// If player and entity are not at the same level, are they on stairs?
 		if (hit->level != level) {
-			if (level == 1 && !(bgFlags & kFlagStairTop)) {
+			if (level == 1 && !(bgFlags & kFlagStairTop))
 				hit = NULL;
-			} else if (level == 2 && !(bgFlags & kFlagStairBot)) {
+			else if (level == 2 && !(bgFlags & kFlagStairBot))
 				hit = NULL;
-			}
 		}
 	}
 
@@ -2025,6 +2014,7 @@ AIEntity *AI::legalMoveOverWater(int tileX, int tileY, int level, int *result) {
 		*result = 0;
 	else
 		*result = 1;
+
 	return hit;
 }
 
@@ -2037,6 +2027,7 @@ AIEntity *AI::legalMoveOverWaterIgnore(int tileX, int tileY, int level, int *res
 		*result = 0;
 	else
 		*result = 1;
+
 	return hit;
 }
 
@@ -2045,6 +2036,7 @@ AIEntity *AI::playerCollision(int topBorder, int bottomBorder, int leftBorder, i
 		AIEntity *e = *it;
 		if (e == _player || !e->onScreen)
 			continue;
+
 		if (e->x > (_player->x - 32 - leftBorder) && e->x < (_player->x + 32 + rightBorder) && e->y >(_player->y - 32 - topBorder) && e->y < (_player->y + 32 + bottomBorder))
 			return e;
 	}
@@ -2179,33 +2171,29 @@ void AI::lookAtEntity(AIEntity *e) {
 
 // Change player direction to XY
 void AI::lookAtXY(int x, int y) {
-	int distX, distY;
-
-	distX = abs(_player->tileX - x);
-	distY = abs(_player->tileY - y);
+	int distX = abs(_player->tileX - x);
+	int distY = abs(_player->tileY - y);
 
 	if (distX > distY) {
 		// X takes precedence
-		if (x < _player->tileX) {
+		if (x < _player->tileX)
 			_player->dir = DIR_LEFT;
-		} else if (x > _player->tileX) {
+		else if (x > _player->tileX)
 			_player->dir = DIR_RIGHT;
-		} else if (y < _player->tileY) {
+		else if (y < _player->tileY)
 			_player->dir = DIR_UP;
-		} else {
+		else
 			_player->dir = DIR_DOWN;
-		}
 	} else {
 		// Y takes precedence
-		if (y < _player->tileY) {
+		if (y < _player->tileY)
 			_player->dir = DIR_UP;
-		} else if (y > _player->tileY) {
+		else if (y > _player->tileY)
 			_player->dir = DIR_DOWN;
-		} else if (x < _player->tileX) {
+		else if (x < _player->tileX)
 			_player->dir = DIR_LEFT;
-		} else {
+		else
 			_player->dir = DIR_RIGHT;
-		}
 	}
 
 	switch (_player->dir) {
@@ -2231,15 +2219,16 @@ void AI::lookAtXY(int x, int y) {
 }
 
 void AI::movePlayer(uint16 buttons) {
-	AIState stateList[] = {STATE_ATK_CLUB_UP,	STATE_ATK_CLUB_DOWN, STATE_ATK_CLUB_LEFT, STATE_ATK_CLUB_RIGHT,
-							STATE_ATK_STUN_UP,	STATE_ATK_STUN_DOWN, STATE_ATK_STUN_LEFT, STATE_ATK_STUN_RIGHT,
-							STATE_ATK_SLUG_UP,	STATE_ATK_SLUG_DOWN, STATE_ATK_SLUG_LEFT, STATE_ATK_SLUG_RIGHT,
-							STATE_PUSHUP,		STATE_PUSHDOWN,		 STATE_PUSHLEFT,	  STATE_PUSHRIGHT,
-							STATE_GRABUP,		STATE_GRABDOWN,		 STATE_GRABLEFT,	  STATE_GRABRIGHT};
-	int	xva[5] = {9, 0, 0,-1, 1};
-	int	yva[5] = {9,-1, 1, 0, 0};
-	AIEntity *hit;
-	int	xv = 0, yv = 0, nx, ny;
+	static const AIState stateList[] = {
+		STATE_ATK_CLUB_UP,	STATE_ATK_CLUB_DOWN, STATE_ATK_CLUB_LEFT, STATE_ATK_CLUB_RIGHT,
+		STATE_ATK_STUN_UP,	STATE_ATK_STUN_DOWN, STATE_ATK_STUN_LEFT, STATE_ATK_STUN_RIGHT,
+		STATE_ATK_SLUG_UP,	STATE_ATK_SLUG_DOWN, STATE_ATK_SLUG_LEFT, STATE_ATK_SLUG_RIGHT,
+		STATE_PUSHUP,		STATE_PUSHDOWN,		 STATE_PUSHLEFT,	  STATE_PUSHRIGHT,
+		STATE_GRABUP,		STATE_GRABDOWN,		 STATE_GRABLEFT,	  STATE_GRABRIGHT
+	};
+
+	static const int xva[5] = {9, 0, 0,-1, 1};
+	static const int yva[5] = {9,-1, 1, 0, 0};
 
 	if (!_player)
 		return;
@@ -2267,9 +2256,9 @@ void AI::movePlayer(uint16 buttons) {
 			return;
 
 		// Are we trying to use something? An ACTION, AUTO, LUA?
-		nx = _player->tileX + xva[_player->dir];
-		ny = _player->tileY + yva[_player->dir];
-		hit = findEntity(nx, ny);
+		int nx = _player->tileX + xva[_player->dir];
+		int ny = _player->tileY + yva[_player->dir];
+		AIEntity *hit = findEntity(nx, ny);
 
 		// the reason to check for no entity or an AI_NONE is because
 		// there's a possibility that an actual entity and a LUA entity
@@ -2283,7 +2272,7 @@ void AI::movePlayer(uint16 buttons) {
 			case STATE_STANDRIGHT:
 				if (checkForTouchplate(nx, ny))
 					break;
-
+				// TODO: CHECKME - Uselessly redundant call - nx and ny are not modified by the call
 				if (checkForTouchplate(nx, ny))
 					break;
 				if (checkActionList(_player, nx, ny, true))
@@ -2299,7 +2288,7 @@ void AI::movePlayer(uint16 buttons) {
 
 		// Attackable Entity? (we're right up on it)
 		int amt = getGemAmount();
-		int	attackable = 0;
+		bool attackable = false;
 		if (hit)
 			switch (hit->type) {
 			case AI_OMNIBOT:
@@ -2318,7 +2307,7 @@ void AI::movePlayer(uint16 buttons) {
 			case AI_BUZZFLY:
 			case AI_DRAGON:
 			case AI_NONE:
-				attackable = 1;
+				attackable = true;
 				break;
 			default:
 				break;
@@ -2385,8 +2374,8 @@ void AI::movePlayer(uint16 buttons) {
 		// If this is the last gem, throw it and signal that it should come back
 
 		if (amt && (attackable || !hit)) {
-			xv = xva[_player->dir];
-			yv = yva[_player->dir];
+			int xv = xva[_player->dir];
+			int yv = yva[_player->dir];
 			nx = _player->tileX + xv;
 			ny = _player->tileY + yv;
 
@@ -2415,9 +2404,10 @@ void AI::movePlayer(uint16 buttons) {
 		return;
 
 	// Is a dialog active?
-	if (g_hdb->_window->dialogActive())
+	if (g_hdb->_window->dialogActive()) {
 		if (!cinematicsActive())
 			return;
+	}
 
 	// is a choice dialog active?
 	if (g_hdb->_window->dialogChoiceActive()) {
@@ -2429,6 +2419,7 @@ void AI::movePlayer(uint16 buttons) {
 	if (_playerLock || _numWaypoints)
 		return;
 
+	int	xv = 0, yv = 0;
 	if (buttons & kButtonUp)
 		yv = -1;
 	else if (buttons & kButtonDown)
@@ -2443,13 +2434,13 @@ void AI::movePlayer(uint16 buttons) {
 	}
 
 	// Check if we can move there
-	nx = _player->tileX + xv;
-	if (!nx)	// Don't allow moving to X-cooridinate 0
+	int nx = _player->tileX + xv;
+	if (!nx)	// Don't allow moving to X-coordinate 0
 		return;
-	ny = _player->tileY + yv;
+	int ny = _player->tileY + yv;
 
 	int moveOK;
-	hit = legalMove(nx, ny, _player->level, &moveOK);
+	AIEntity *hit = legalMove(nx, ny, _player->level, &moveOK);
 	if (hit && walkThroughEnt(hit->type))
 		hit = NULL;
 
@@ -2474,8 +2465,8 @@ void AI::movePlayer(uint16 buttons) {
 }
 
 void AI::playerUse() {
-	int	xv[5] = {9, 0, 0,-1, 1};
-	int	yv[5] = {9,-1, 1, 0, 0};
+	static const int xv[5] = {9, 0, 0,-1, 1};
+	static const int yv[5] = {9,-1, 1, 0, 0};
 
 	g_hdb->setTargetXY(kTileWidth * (_player->tileX + xv[_player->dir]), kTileWidth * (_player->tileY + yv[_player->dir]));
 }


Commit: 3aa373ab2baaeb96d0113bf3d4ff5923f645f8d1
    https://github.com/scummvm/scummvm/commit/3aa373ab2baaeb96d0113bf3d4ff5923f645f8d1
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:28+02:00

Commit Message:
HDB: Fix misplaced Enum value

Changed paths:
    engines/hdb/sound.cpp
    engines/hdb/sound.h


diff --git a/engines/hdb/sound.cpp b/engines/hdb/sound.cpp
index 752f80f..ce515ae 100644
--- a/engines/hdb/sound.cpp
+++ b/engines/hdb/sound.cpp
@@ -1413,8 +1413,7 @@ bool Sound::init() {
 		_soundCache[index2].loaded = false;
 		_soundCache[index2].name = soundList[index].name;
 		_soundCache[index2].luaName = soundList[index].luaName;
-		// FIXME: Create an intuitive way to include #166
-		if (index2 < SND_UNLOCKED_ITEM || index == 166)
+		if (index2 <= SND_UNLOCKED_ITEM || index == SND_BEEPBEEPBEEP)
 			_soundCache[index2].ext = -1;	// WAV
 		else
 			_soundCache[index2].ext = 1;		// MP3
diff --git a/engines/hdb/sound.h b/engines/hdb/sound.h
index af037fc..464663a 100644
--- a/engines/hdb/sound.h
+++ b/engines/hdb/sound.h
@@ -167,7 +167,6 @@ enum SoundType {
 	SND_GET_SLUG,
 	SND_GUY_DROWN,
 	SND_GUY_GRABBED,
-	SND_BEEPBEEPBEEP,
 	SND_PANIC,
 	SND_PANIC_COUNT,
 	SND_PANIC_DEATH,
@@ -234,6 +233,8 @@ enum SoundType {
 	SONG_DARKVIB,
 	SONG_EXPER,
 
+	SND_BEEPBEEPBEEP,
+
 	V00_AIRLOCK_01,
 	V00_ARNIE_01,
 


Commit: 2bb60c69cd2a0bde98e3039e5b788fc2bced07b2
    https://github.com/scummvm/scummvm/commit/2bb60c69cd2a0bde98e3039e5b788fc2bced07b2
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:29+02:00

Commit Message:
HDB: Add Music/Song data and functions

Changed paths:
    engines/hdb/hdb.cpp
    engines/hdb/hdb.h
    engines/hdb/menu.h
    engines/hdb/sound.cpp
    engines/hdb/sound.h


diff --git a/engines/hdb/hdb.cpp b/engines/hdb/hdb.cpp
index 11c10cc..e58cae1 100644
--- a/engines/hdb/hdb.cpp
+++ b/engines/hdb/hdb.cpp
@@ -32,8 +32,8 @@
 #include "hdb/input.h"
 #include "hdb/lua-script.h"
 #include "hdb/map.h"
-#include "hdb/sound.h"
 #include "hdb/menu.h"
+#include "hdb/sound.h"
 #include "hdb/mpc.h"
 #include "hdb/window.h"
 
@@ -152,6 +152,11 @@ bool HDBGame::init() {
 	return true;
 }
 
+void HDBGame::initializePath(const Common::FSNode &gamePath) {
+	Engine::initializePath(gamePath);
+	SearchMan.addDirectory("music", gamePath.getChild("music"));
+}
+
 void HDBGame::changeGameState() {
 
 	switch (_gameState) {
@@ -856,8 +861,6 @@ Common::Error HDBGame::run() {
 	// Initializes Graphics
 	initGraphics(kScreenWidth, kScreenHeight, &_format);
 
-	_sound->test();
-
 	start();
 
 #if 0
diff --git a/engines/hdb/hdb.h b/engines/hdb/hdb.h
index 6d23bde..d55f8b3 100644
--- a/engines/hdb/hdb.h
+++ b/engines/hdb/hdb.h
@@ -26,6 +26,7 @@
 #include "common/scummsys.h"
 #include "common/system.h"
 #include "common/savefile.h"
+#include "common/fs.h"
 
 #include "engines/engine.h"
 
@@ -145,6 +146,7 @@ public:
 	~HDBGame();
 
 	virtual bool hasFeature(Engine::EngineFeature f) const;
+	virtual void initializePath(const Common::FSNode &gamePath);
 
 	virtual Common::Error run();
 
diff --git a/engines/hdb/menu.h b/engines/hdb/menu.h
index 5f846b0..b9d5aeb 100644
--- a/engines/hdb/menu.h
+++ b/engines/hdb/menu.h
@@ -24,6 +24,8 @@
 #define HDB_MENU_H
 
 #include "common/events.h"
+#include "hdb/ai.h"
+#include "hdb/sound.h"
 
 namespace HDB {
 
diff --git a/engines/hdb/sound.cpp b/engines/hdb/sound.cpp
index ce515ae..c4ff836 100644
--- a/engines/hdb/sound.cpp
+++ b/engines/hdb/sound.cpp
@@ -21,10 +21,13 @@
  */
 
 #include "common/debug.h"
+#include "common/file.h"
+#include "common/fs.h"
 
 #include "hdb/hdb.h"
 #include "hdb/file-manager.h"
 #include "hdb/mpc.h"
+#include "hdb/menu.h"
 #include "hdb/sound.h"
 
 namespace HDB {
@@ -1390,6 +1393,7 @@ const SoundLookUp soundList[] =  {
 
 Sound::Sound() {
 	_sfxVolume = 255;
+	_musicVolume = 255;
 }
 
 void Sound::test() {
@@ -1402,7 +1406,7 @@ void Sound::test() {
 }
 
 bool Sound::init() {
-	warning("STUB: Initialize songs");
+	_song1.playing = _song2.playing = false;
 
 	//
 	// init sound caching system
@@ -1443,6 +1447,22 @@ void Sound::loadSaveFile(Common::InSaveFile *in) {
 	}
 }
 
+void Sound::setMusicVolume(int volume) {
+	_musicVolume = volume;
+	if (_song1.playing) {
+		if (_song1.fadingIn)
+			_song1.fadeInVol = volume;
+		if (!_song1.fadingOut)
+			g_hdb->_mixer->setChannelVolume(*_song1.handle, volume);
+	}
+	if (_song2.playing) {
+		if (_song2.fadingIn)
+			_song1.fadeInVol = volume;
+		if (!_song2.fadingOut)
+			g_hdb->_mixer->setChannelVolume(*_song2.handle, volume);
+	}
+}
+
 bool Sound::playSound(int index) {
 	debug(9, "STUB: Play Sound");
 	return true;
@@ -1488,32 +1508,154 @@ bool Sound::playVoice(int index, int actor) {
 }
 
 bool Sound::startMusic(SoundType song) {
-	warning("STUB: Start Music");
-	return true;
+	g_hdb->_menu->saveSong(song);
+
+	if (!_musicVolume)
+		return false;
+
+	return beginMusic(song, false, 0);
 }
 
 bool Sound::fadeInMusic(SoundType song, int ramp) {
-	warning("STUB: Fade In Music");
-	return true;
+	g_hdb->_menu->saveSong(song);
+
+	if (!_musicVolume)
+		return false;
+
+	stopMusic();
+	return beginMusic(song, false, ramp);
 }
 
 void Sound::fadeOutMusic(int ramp) {
-	warning("STUB: Fade Out Music");
-	return;
+	if (_song1.playing) {
+		_song1.fadeOutRamp = ramp;
+		_song1.fadingOut = true;
+		_song1.fadeOutVol = _musicVolume;
+	} else if (_song2.playing) {
+		_song2.fadeOutRamp = ramp;
+		_song2.fadingOut = true;
+		_song2.fadeOutVol = _musicVolume;
+	}
 }
 
 bool Sound::songPlaying(SoundType song) {
-	warning("STUB: Check if Song is playing");
-	return true;
+	if (_song1.playing && _song1.song == song)
+		return true;
+
+	if (_song2.playing && _song2.song == song)
+		return true;
+
+	return false;
 }
 
 bool Sound::stopChannel(int channel) {
 	debug(9, "STUB: Stop Channel");
+
 	return true;
 }
 
 void Sound::stopMusic() {
-	debug(9, "STUB: Stop Music");
+	if (_song1.playing) {
+		_song1.playing = false;
+		g_hdb->_mixer->stopHandle(*_song1.handle);
+	}
+	if (_song2.playing) {
+		_song2.playing = false;
+		g_hdb->_mixer->stopHandle(*_song2.handle);
+	}
+}
+
+bool Sound::beginMusic(SoundType song, bool fadeIn, int ramp) {
+	if (!_song1.playing) {
+		// Start fading out SONG2 if its playing
+		if (_song2.playing) {
+			_song2.fadeOutRamp = ramp;
+			_song2.fadingOut = true;
+			_song2.fadeOutVol = _musicVolume;
+		}
+
+		// Load up the song
+#ifdef USE_MAD
+		Common::SeekableReadStream *stream = SearchMan.createReadStreamForMember(soundList[song].name);
+		if (stream == nullptr)
+			return false;
+
+		Audio::SeekableAudioStream *audioStream = Audio::makeMP3Stream(stream, DisposeAfterUse::YES);
+		Audio::AudioStream *loopingStream = new Audio::LoopingAudioStream(audioStream, 0, DisposeAfterUse::YES);
+
+		g_hdb->_mixer->setChannelVolume(*_song1.handle, _musicVolume);
+
+		// do we need to fade-in this song?
+		if (fadeIn) {
+			_song1.fadeInRamp = ramp;
+			_song1.fadingIn = true;
+			_song1.fadeInVol = 0;
+			g_hdb->_mixer->setChannelVolume(*_song1.handle, 0);
+		}
+
+		g_hdb->_mixer->playStream(Audio::Mixer::kMusicSoundType, _song1.handle, loopingStream);
+		_song1.playing = true;
+#endif
+	} else if (!_song2.playing) {
+		// Start fading out SONG1 if its playing
+		if (_song1.playing) {
+			_song1.fadeOutRamp = ramp;
+			_song1.fadingOut = true;
+			_song1.fadeOutVol = _musicVolume;
+		}
+
+		// Load up the song
+#ifdef USE_MAD
+		Common::SeekableReadStream *stream = SearchMan.createReadStreamForMember(soundList[song].name);
+		if (stream == nullptr)
+			return false;
+
+		Audio::SeekableAudioStream *audioStream = Audio::makeMP3Stream(stream, DisposeAfterUse::YES);
+		Audio::AudioStream *loopingStream = new Audio::LoopingAudioStream(audioStream, 0, DisposeAfterUse::YES);
+
+		g_hdb->_mixer->setChannelVolume(*_song2.handle, _musicVolume);
+
+		// do we need to fade-in this song?
+		if (fadeIn) {
+			_song2.fadeInRamp = ramp;
+			_song2.fadingIn = true;
+			_song2.fadeInVol = 0;
+			g_hdb->_mixer->setChannelVolume(*_song2.handle, 0);
+		}
+
+		g_hdb->_mixer->playStream(Audio::Mixer::kMusicSoundType, _song2.handle, loopingStream);
+		_song2.playing = true;
+#endif
+	} else
+		return false;
+
+	return true;
+}
+
+void Sound::updateMusic() {
+
+	if (_song1.playing) {
+		if (_song1.fadingOut) {
+			_song1.fadeOutVol = 0;
+			_song1.playing = false;
+			g_hdb->_mixer->stopHandle(*_song1.handle);
+		} else if (_song1.fadingIn) {
+			_song1.fadeInVol = _musicVolume;
+			_song1.fadingIn = false;
+		}
+	}
+
+	if (_song2.playing) {
+		if (_song2.fadingOut) {
+			_song2.fadeOutVol = 0;
+			_song2.playing = false;
+			g_hdb->_mixer->stopHandle(*_song2.handle);
+		} else if (_song2.fadingIn) {
+			_song2.fadeInVol = _musicVolume;
+			_song2.fadingIn = false;
+		}
+	}
+
 }
 
 int Sound::registerSound(const char *name) {
@@ -1560,7 +1702,12 @@ int Sound::getSNDIndex(const char *name) {
 }
 
 SoundType Sound::whatSongIsPlaying() {
-	debug(9, "STUB: whatSongIsPlaying");
+	if (_song1.playing)
+		return _song1.song;
+
+	if (_song2.playing)
+		return _song2.song;
+
 	return SONG_NONE;
 }
 
diff --git a/engines/hdb/sound.h b/engines/hdb/sound.h
index 464663a..1ed279d 100644
--- a/engines/hdb/sound.h
+++ b/engines/hdb/sound.h
@@ -1436,6 +1436,28 @@ struct SoundCache {
 	SoundCache() : loaded(0), size(0), name(nullptr), luaName(nullptr), ext(0) {}
 };
 
+struct Song {
+	bool playing;
+	SoundType song;
+	const char *sndMusic;
+	Audio::SoundHandle *handle;
+
+	bool fadingOut;
+	int fadeOutVol;
+	int	fadeOutRamp;
+
+	bool fadingIn;
+	int	fadeInVol;
+	int	fadeInRamp;
+
+	Song() : playing(false), song(SONG_NONE), sndMusic(nullptr), handle(new Audio::SoundHandle()),
+		fadingOut(false), fadeOutVol(0), fadeOutRamp(0),
+		fadingIn(false), fadeInVol(0), fadeInRamp(0) {}
+	~Song() {
+		delete handle;
+	}
+};
+
 class Sound {
 public:
 
@@ -1446,12 +1468,9 @@ public:
 	bool init();
 	void save(Common::OutSaveFile *out);
 	void loadSaveFile(Common::InSaveFile *in);
-	void setMusicVolume(int value) {
-		//debug(9, "STUB: Add Music System Variables");
-	}
+	void setMusicVolume(int value);
 	int getMusicVolume() {
-		//debug(9, "STUB: Add Music System Variables");
-		return 1;
+		return _musicVolume;
 	}
 	void setSFXVolume(int value) {
 		_sfxVolume = value;
@@ -1476,6 +1495,8 @@ public:
 	bool fadeInMusic(SoundType song, int ramp);
 	void fadeOutMusic(int ramp);
 	void stopMusic();
+	bool beginMusic(SoundType song, bool fadeIn, int ramp);
+	void updateMusic();
 	bool songPlaying(SoundType song);
 	bool stopChannel(int channel);
 	int registerSound(const char *name);
@@ -1503,6 +1524,11 @@ public:
 	int _voicesOn;
 	byte _voicePlayed[NUM_VOICES];
 
+	// Music System Variables
+
+	Song _song1, _song2;
+	int _musicVolume;
+
 	// Sound Caching System Variables
 
 	SoundCache _soundCache[kMaxSounds];


Commit: 1edab20e026c63d986aedc59e0baa7a860b94df6
    https://github.com/scummvm/scummvm/commit/1edab20e026c63d986aedc59e0baa7a860b94df6
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:29+02:00

Commit Message:
HDB: Add additional debug output

Changed paths:
    engines/hdb/gfx.cpp


diff --git a/engines/hdb/gfx.cpp b/engines/hdb/gfx.cpp
index 7c83bf1..87da345 100644
--- a/engines/hdb/gfx.cpp
+++ b/engines/hdb/gfx.cpp
@@ -1055,6 +1055,14 @@ void Gfx::drawDebugInfo(Tile *_debugLogo, int fps) {
 		sprintf(buff, "Player height level: %d", p->level);
 		drawText(buff);
 	}
+
+	setCursor(0, 48);
+	sprintf(buff, "Map Name: %s", g_hdb->getInMapName());
+	drawText(buff);
+
+	setCursor(0, 64);
+	g_hdb->getActionMode() ? sprintf(buff, "Action Mode") : sprintf(buff, "Puzzle Mode");
+	drawText(buff);
 }
 
 Picture::Picture() : _width(0), _height(0) {


Commit: 85b922895aee317631e07c5ece5ed908ee17952e
    https://github.com/scummvm/scummvm/commit/85b922895aee317631e07c5ece5ed908ee17952e
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:29+02:00

Commit Message:
HDB: Fix Deliveries with no GFX

Changed paths:
    engines/hdb/window.cpp


diff --git a/engines/hdb/window.cpp b/engines/hdb/window.cpp
index 5a1e673..6c2dcc8 100644
--- a/engines/hdb/window.cpp
+++ b/engines/hdb/window.cpp
@@ -1161,7 +1161,8 @@ void Window::drawDeliveries() {
 				if (_dlvsInfo.delay1 < g_hdb->getTimeSlice()) {
 					// Draw Item
 					_gfxIndent->draw(drawX, drawY);
-					d->itemGfx->drawMasked(drawX, drawY);
+					if (d->itemGfx)
+						d->itemGfx->drawMasked(drawX, drawY);
 
 					g_hdb->_gfx->setCursor(centerX - g_hdb->_gfx->stringLength(d->itemTextName) / 2, kDlvItemTextY);
 					g_hdb->_gfx->drawText(d->itemTextName);
@@ -1190,7 +1191,8 @@ void Window::drawDeliveries() {
 				if (_dlvsInfo.delay3 < g_hdb->getTimeSlice()) {
 					// Draw Delivery
 					_gfxIndent->draw(drawX, drawY + kTileHeight + 16);
-					d->destGfx->drawMasked(drawX, drawY + kTileHeight + 16);
+					if (d->destGfx)
+						d->destGfx->drawMasked(drawX, drawY + kTileHeight + 16);
 
 					g_hdb->_gfx->setCursor(centerX - (g_hdb->_gfx->stringLength(d->destTextName) + g_hdb->_gfx->stringLength("to")) / 2, kDlvItemTextY + 12);
 					g_hdb->_gfx->drawText("to ");
@@ -1204,10 +1206,12 @@ void Window::drawDeliveries() {
 		} else {
 			// Draw Item
 			_gfxIndent->draw(drawX, drawY);
-			d->itemGfx->drawMasked(drawX, drawY);
+			if (d->itemGfx)
+				d->itemGfx->drawMasked(drawX, drawY);
 			// Draw Delivery
 			_gfxIndent->draw(drawX, drawY + kTileHeight + 16);
-			d->destGfx->drawMasked(drawX, drawY + kTileHeight + 16);
+			if (d->destGfx)
+				d->destGfx->drawMasked(drawX, drawY + kTileHeight + 16);
 
 			if (!_dlvsInfo.animate && inv == _dlvsInfo.selected) {
 				g_hdb->_gfx->setCursor(centerX - g_hdb->_gfx->stringLength(d->itemTextName)/2, kDlvItemTextY);


Commit: d3eacb7e0fefbd9cde5b17fcfc5727eaf0143ad5
    https://github.com/scummvm/scummvm/commit/d3eacb7e0fefbd9cde5b17fcfc5727eaf0143ad5
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:29+02:00

Commit Message:
HDB: Add playSound(), playSoundEx(), stopChannel()

Changed paths:
    engines/hdb/mpc.h
    engines/hdb/sound.cpp
    engines/hdb/sound.h


diff --git a/engines/hdb/mpc.h b/engines/hdb/mpc.h
index b90deb8..71481e2 100644
--- a/engines/hdb/mpc.h
+++ b/engines/hdb/mpc.h
@@ -696,161 +696,161 @@ namespace HDB {
 #define		PIC_SNOWFLAKE		"pic_snowflake"
 #define		PIC_INFOBAR		"pic_infobar"
 #define		PIC_LOADSCREEN		"pic_loadscreen"
-#define		BUZZFLY_AMBIENT_WAV		"buzzfly_ambient.wav"
-#define		CHICKEN_AMBIENT_WAV		"chicken_ambient.wav"
-#define		CHICKEN_BAGAWK_WAV		"chicken_bagawk.wav"
-#define		CHICKEN_DEATH_WAV		"chicken_death.wav"
-#define		FERRET_SQUEAK_WAV		"ferret_squeak.wav"
-#define		MBOT_HMMM_WAV		"mbot_hmmm.wav"
-#define		MBOT_HMMM2_WAV		"mbot_hmmm2.wav"
-#define		MBOT_HYEAH_WAV		"mbot_hyeah.wav"
-#define		MBOT_YEAH_WAV		"mbot_yeah.wav"
-#define		MBOT_DEATH_WAV		"mbot_death.wav"
-#define		MBOT_WHISTLE1_WAV		"mbot_whistle1.wav"
-#define		MBOT_WHISTLE2_WAV		"mbot_whistle2.wav"
-#define		MBOT_WHISTLE3_WAV		"mbot_whistle3.wav"
-#define		DEADEYE_AMBIENT01_WAV		"deadeye_ambient01.wav"
-#define		DEADEYE_AMBIENT02_WAV		"deadeye_ambient02.wav"
-#define		DEADEYE_GROWL01_WAV		"deadeye_growl01.wav"
-#define		DEADEYE_GROWL02_WAV		"deadeye_growl02.wav"
-#define		FROG_LICK_WAV		"frog_lick.wav"
-#define		FROG_RIBBIT1_WAV		"frog_ribbit1.wav"
-#define		FROG_RIBBIT2_WAV		"frog_ribbit2.wav"
-#define		FATFROG_STUNNED_WAV		"fatfrog_stunned.wav"
-#define		RIGHTBOT_TURN_WAV		"rightbot_turn.wav"
-#define		RIGHTBOT_STUNNED_WAV		"rightbot_stunned.wav"
-#define		OMNIBOT_AMBIENT_WAV		"omnibot_ambient.wav"
-#define		OMNIBOT_FIRE_WAV		"omnibot_fire.wav"
-#define		OMNIBOT_STUNNED_WAV		"omnibot_stunned.wav"
-#define		FOURFIRE_TURN_WAV		"fourfire_turn.wav"
-#define		FOUR_FIRE_WAV		"four_fire.wav"
-#define		SHOCKBOT_AMBIENT_WAV		"shockbot_ambient.wav"
-#define		SHOCKBOT_SHOCK_WAV		"shockbot_shock.wav"
-#define		RAILRIDER_ONTRACK_WAV		"railrider_ontrack.wav"
-#define		RAILRIDER_EXIT_WAV		"railrider_exit.wav"
-#define		RAILRIDER_TASTE_WAV		"railrider_taste.wav"
-#define		BUZZFLY_STUNNED_WAV		"buzzfly_stunned.wav"
-#define		BUZZFLY_STING_WAV		"buzzfly_sting.wav"
-#define		ROBOT_STUNNED_WAV		"robot_stunned.wav"
-#define		FART_WAV		"fart.wav"
-#define		FART2_WAV		"fart2.wav"
-#define		PUSHBOT_STRAIN_WAV		"pushbot_strain.wav"
-#define		PUSHBOT_STUNNED_WAV		"pushbot_stunned.wav"
-#define		MEERKAT_BITE_WAV		"meerkat_bite.wav"
-#define		MEERKAT_WARNING_WAV		"meerkat_warning.wav"
-#define		MEERKAT_APPEAR_WAV		"meerkat_appear.wav"
-#define		MEERKAT_STUNNED_WAV		"meerkat_stunned.wav"
-#define		TURNBOT_TURN_WAV		"turnbot_turn.wav"
-#define		TURNBOT_STUNNED_WAV		"turnbot_stunned.wav"
-#define		DRAGON_WAKE_WAV		"dragon_wake.wav"
-#define		DRAGON_FALL_ASLEEP_WAV		"dragon_fall_asleep.wav"
-#define		DRAGON_BREATHE_FIRE_WAV		"dragon_breathe_fire.wav"
-#define		GOOD_FAERIE_AMBIENT_WAV		"good_faerie_ambient.wav"
-#define		GOOD_FAERIE_SPELL_WAV		"good_faerie_spell.wav"
-#define		GOOD_FAERIE_STUNNED_WAV		"good_faerie_stunned.wav"
-#define		BAD_FAERIE_AMBIENT_WAV		"bad_faerie_ambient.wav"
-#define		BAD_FAERIE_SPELL_WAV		"bad_faerie_spell.wav"
-#define		BAD_FAERIE_STUNNED_WAV		"bad_faerie_stunned.wav"
-#define		ICEPUFF_APPEAR_WAV		"icepuff_appear.wav"
-#define		ICEPUFF_WARNING_WAV		"icepuff_warning.wav"
-#define		ICEPUFF_THROW_WAV		"icepuff_throw.wav"
-#define		ICEPUFF_STUNNED_WAV		"icepuff_stunned.wav"
-#define		DEMIGOD_AMBIENT_WAV		"demigod_ambient.wav"
-#define		DEMIGOD_HOLYSPEECH_WAV		"demigod_holyspeech.wav"
-#define		DEMIGOD_UNHAPPY_WAV		"demigod_unhappy.wav"
-#define		GATEPUDDLE_AMBIENT_WAV		"gatepuddle_ambient.wav"
-#define		GATEPUDDLE_DISSIPATE_WAV		"gatepuddle_dissipate.wav"
-#define		GATEPUDDLE_SPAWN_WAV		"gatepuddle_spawn.wav"
-#define		MANNY_CRASH_WAV		"manny_crash.wav"
-#define		FOOTSTEPS_WAV		"footsteps.wav"
-#define		STEPS_ICE_WAV		"steps_ice.wav"
-#define		GUY_DROWN_WAV		"guy_drown.wav"
-#define		GUY_FRIED_WAV		"guy_fried.wav"
-#define		GUY_GRABBED_WAV		"guy_grabbed.wav"
-#define		GUY_DYING_WAV		"guy_dying.wav"
-#define		GUY_UHUH_WAV		"guy_uhuh.wav"
-#define		GUY_PLUMMET_WAV		"guy_plummet.wav"
-#define		GET_STUNNER_WAV		"get_stunner.wav"
-#define		GET_THING_WAV		"get_thing.wav"
-#define		GET_CLUB_WAV		"get_club.wav"
-#define		GET_SLUG_WAV		"get_slug.wav"
-#define		GET_MONKEYSTONE_WAV		"get_monkeystone.wav"
-#define		GET_GEM_WAV		"get_gem.wav"
-#define		GET_GOO_WAV		"get_goo.wav"
-#define		CLUB_MISS_WAV		"club_miss.wav"
-#define		CLUB_HIT_METAL_WAV		"club_hit_metal.wav"
-#define		CLUB_HIT_FLESH_WAV		"club_hit_flesh.wav"
-#define		STUNNER_BUZZ_WAV		"stunner_buzz.wav"
-#define		STUNNER_ZAP_WAV		"stunner_zap.wav"
-#define		SLUG_FIRE_WAV		"slug_fire.wav"
-#define		SLUG_HIT_WAV		"slug_hit.wav"
-#define		GEM_THROW_WAV		"gem_throw.wav"
-#define		MONKEYSTONE_SECRET_STAR_WAV		"monkeystone_secret_star.wav"
-#define		CRATE_SLIDE_WAV		"crate_slide.wav"
-#define		HEAVY_SLIDE_WAV		"heavy_slide.wav"
-#define		LIGHT_SLIDE_WAV		"light_slide.wav"
-#define		BARREL_EXPLODE_WAV		"barrel_explode.wav"
-#define		BARREL_MELTING_WAV		"barrel_melting.wav"
-#define		GUY_NOPUSH_SIZZLE_WAV		"guy_nopush_sizzle.wav"
-#define		SPLASH_WAV		"splash.wav"
-#define		TELEPORT3_WAV		"teleport3.wav"
-#define		FALL_DOWN_HOLE_WAV		"fall_down_hole.wav"
-#define		SLIME_BURN_WAV		"slime_burn.wav"
-#define		PLASMAFLOOR_SLIDE_WAV		"plasmafloor_slide.wav"
-#define		LASERD_PUSH_WAV		"laserd_push.wav"
-#define		MENU_ACCEPT_WAV		"menu_accept.wav"
-#define		MENU_BACKOUT_WAV		"menu_backout.wav"
-#define		MENU_SLIDER_WAV		"menu_slider.wav"
-#define		POP_WAV		"pop.wav"
-#define		BURP_WAV		"burp.wav"
-#define		TELEPORT3_WAV		"teleport3.wav"
-#define		DIALOG_OPEN_WAV		"dialog_open.wav"
-#define		DIALOG_CLOSE_WAV		"dialog_close.wav"
-#define		FUTUREBEEP2_WAV		"futurebeep2.wav"
-#define		INV_SELECT_WAV		"inv_select.wav"
-#define		MOVE_SELECTION_WAV		"move_selection.wav"
-#define		CELLHOLDER_USE_REJECT_WAV		"cellholder_use_reject.wav"
-#define		DOOR_OPEN_CLOSE_WAV		"door_open_close.wav"
-#define		SWITCH_USE_WAV		"switch_use.wav"
-#define		AIRLOCK_CLOSE_WAV		"airlock_close.wav"
-#define		TOUCHPLATE_CLICK_WAV		"touchplate_click.wav"
-#define		INSERT_CELL_WAV		"insert_cell.wav"
-#define		CABINET_OPEN_WAV		"cabinet_open.wav"
-#define		CABINET_CLOSE_WAV		"cabinet_close.wav"
-#define		BRIDGE_EXTEND_WAV		"bridge_extend.wav"
-#define		BRIDGE_START_WAV		"bridge_start.wav"
-#define		BRIDGE_END_WAV		"bridge_end.wav"
-#define		COMPUTERPROCESS_WAV		"computerprocess.wav"
-#define		MAILSORTER_HAPPY_WAV		"mailsorter_happy.wav"
-#define		MAILSORTER_UNHAPPY_WAV		"mailsorter_unhappy.wav"
-#define		NOTICE_WAV		"notice.wav"
-#define		MAINTBOT_WHOOSH1_WAV		"maintbot_whoosh1.wav"
-#define		MAINTBOT_WHOOSH2_WAV		"maintbot_whoosh2.wav"
-#define		SHIP_MOVING_INTRO_WAV		"ship_moving_intro.wav"
-#define		LASER_LOOP_WAV		"laser_loop.wav"
-#define		INFOCOMP_WAV		"infocomp.wav"
-#define		SLOT_SPIN_WAV		"slot_spin.wav"
-#define		SLOT_STOP_WAV		"slot_stop.wav"
-#define		SLOT_WIN_WAV		"slot_win.wav"
-#define		CLOCK_BONK_WAV		"clock_bonk.wav"
-#define		PASSCODE_CORRECT_WAV		"passcode_correct.wav"
-#define		SLOTMACHINE_SPINS_WAV		"slotmachine_spins.wav"
-#define		SLOTMACHINE_STOP_WAV		"slotmachine_stop.wav"
-#define		SLOTMACHINE_WIN_WAV		"slotmachine_win.wav"
-#define		PANIC_WAV		"panic.wav"
-#define		PANIC_TIMER_WAV		"panic_timer.wav"
-#define		PANIC_DEATH_WAV		"panic_death.wav"
-#define		QUEST_COMPLETE_WAV		"quest_complete.wav"
-#define		QUEST_FAILED_WAV		"quest_failed.wav"
-#define		TRY_AGAIN_WAV		"try_again.wav"
-#define		MONKEY_OOHOOH_WAV		"monkey_oohooh.wav"
-#define		MONKEY_WIN_WAV		"monkey_win.wav"
-#define		BYE_WAV		"bye.wav"
-#define		HDB_WAV		"hdb.wav"
-#define		VORTEXIAN_SAVE_WAV		"VORTEXIAN_SAVE.WAV"
-#define		UNLOCKED_ITEM_WAV		"UNLOCKED_ITEM.WAV"
-#define		BEEPBEEPBEEP_WAV		"BEEPBEEPBEEP.WAV"
-#define		MACHINE_AMBIENT1_WAV		"MACHINE_AMBIENT1.WAV"
+#define		BUZZFLY_AMBIENT_WAV		"BUZZFLY_AMBIENT_WAV"
+#define		CHICKEN_AMBIENT_WAV		"CHICKEN_AMBIENT_WAV"
+#define		CHICKEN_BAGAWK_WAV		"CHICKEN_BAGAWK_WAV"
+#define		CHICKEN_DEATH_WAV		"CHICKEN_DEATH_WAV"
+#define		FERRET_SQUEAK_WAV		"FERRET_SQUEAK_WAV"
+#define		MBOT_HMMM_WAV		"MBOT_HMMM_WAV"
+#define		MBOT_HMMM2_WAV		"MBOT_HMMM2_WAV"
+#define		MBOT_HYEAH_WAV		"MBOT_HYEAH_WAV"
+#define		MBOT_YEAH_WAV		"MBOT_YEAH_WAV"
+#define		MBOT_DEATH_WAV		"MBOT_DEATH_WAV"
+#define		MBOT_WHISTLE1_WAV		"MBOT_WHISTLE1_WAV"
+#define		MBOT_WHISTLE2_WAV		"MBOT_WHISTLE2_WAV"
+#define		MBOT_WHISTLE3_WAV		"MBOT_WHISTLE3_WAV"
+#define		DEADEYE_AMBIENT01_WAV		"DEADEYE_AMBIENT01_WAV"
+#define		DEADEYE_AMBIENT02_WAV		"DEADEYE_AMBIENT02_WAV"
+#define		DEADEYE_GROWL01_WAV		"DEADEYE_GROWL01_WAV"
+#define		DEADEYE_GROWL02_WAV		"DEADEYE_GROWL02_WAV"
+#define		FROG_LICK_WAV		"FROG_LICK_WAV"
+#define		FROG_RIBBIT1_WAV		"FROG_RIBBIT1_WAV"
+#define		FROG_RIBBIT2_WAV		"FROG_RIBBIT2_WAV"
+#define		FATFROG_STUNNED_WAV		"FATFROG_STUNNED_WAV"
+#define		RIGHTBOT_TURN_WAV		"RIGHTBOT_TURN_WAV"
+#define		RIGHTBOT_STUNNED_WAV		"RIGHTBOT_STUNNED_WAV"
+#define		OMNIBOT_AMBIENT_WAV		"OMNIBOT_AMBIENT_WAV"
+#define		OMNIBOT_FIRE_WAV		"OMNIBOT_FIRE_WAV"
+#define		OMNIBOT_STUNNED_WAV		"OMNIBOT_STUNNED_WAV"
+#define		FOURFIRE_TURN_WAV		"FOURFIRE_TURN_WAV"
+#define		FOUR_FIRE_WAV		"FOUR_FIRE_WAV"
+#define		SHOCKBOT_AMBIENT_WAV		"SHOCKBOT_AMBIENT_WAV"
+#define		SHOCKBOT_SHOCK_WAV		"SHOCKBOT_SHOCK_WAV"
+#define		RAILRIDER_ONTRACK_WAV		"RAILRIDER_ONTRACK_WAV"
+#define		RAILRIDER_EXIT_WAV		"RAILRIDER_EXIT_WAV"
+#define		RAILRIDER_TASTE_WAV		"RAILRIDER_TASTE_WAV"
+#define		BUZZFLY_STUNNED_WAV		"BUZZFLY_STUNNED_WAV"
+#define		BUZZFLY_STING_WAV		"BUZZFLY_STING_WAV"
+#define		ROBOT_STUNNED_WAV		"ROBOT_STUNNED_WAV"
+#define		FART_WAV		"FART_WAV"
+#define		FART2_WAV		"FART2_WAV"
+#define		PUSHBOT_STRAIN_WAV		"PUSHBOT_STRAIN_WAV"
+#define		PUSHBOT_STUNNED_WAV		"PUSHBOT_STUNNED_WAV"
+#define		MEERKAT_BITE_WAV		"MEERKAT_BITE_WAV"
+#define		MEERKAT_WARNING_WAV		"MEERKAT_WARNING_WAV"
+#define		MEERKAT_APPEAR_WAV		"MEERKAT_APPEAR_WAV"
+#define		MEERKAT_STUNNED_WAV		"MEERKAT_STUNNED_WAV"
+#define		TURNBOT_TURN_WAV		"TURNBOT_TURN_WAV"
+#define		TURNBOT_STUNNED_WAV		"TURNBOT_STUNNED_WAV"
+#define		DRAGON_WAKE_WAV		"DRAGON_WAKE_WAV"
+#define		DRAGON_FALL_ASLEEP_WAV		"DRAGON_FALL_ASLEEP_WAV"
+#define		DRAGON_BREATHE_FIRE_WAV		"DRAGON_BREATHE_FIRE_WAV"
+#define		GOOD_FAERIE_AMBIENT_WAV		"GOOD_FAERIE_AMBIENT_WAV"
+#define		GOOD_FAERIE_SPELL_WAV		"GOOD_FAERIE_SPELL_WAV"
+#define		GOOD_FAERIE_STUNNED_WAV		"GOOD_FAERIE_STUNNED_WAV"
+#define		BAD_FAERIE_AMBIENT_WAV		"BAD_FAERIE_AMBIENT_WAV"
+#define		BAD_FAERIE_SPELL_WAV		"BAD_FAERIE_SPELL_WAV"
+#define		BAD_FAERIE_STUNNED_WAV		"BAD_FAERIE_STUNNED_WAV"
+#define		ICEPUFF_APPEAR_WAV		"ICEPUFF_APPEAR_WAV"
+#define		ICEPUFF_WARNING_WAV		"ICEPUFF_WARNING_WAV"
+#define		ICEPUFF_THROW_WAV		"ICEPUFF_THROW_WAV"
+#define		ICEPUFF_STUNNED_WAV		"ICEPUFF_STUNNED_WAV"
+#define		DEMIGOD_AMBIENT_WAV		"DEMIGOD_AMBIENT_WAV"
+#define		DEMIGOD_HOLYSPEECH_WAV		"DEMIGOD_HOLYSPEECH_WAV"
+#define		DEMIGOD_UNHAPPY_WAV		"DEMIGOD_UNHAPPY_WAV"
+#define		GATEPUDDLE_AMBIENT_WAV		"GATEPUDDLE_AMBIENT_WAV"
+#define		GATEPUDDLE_DISSIPATE_WAV		"GATEPUDDLE_DISSIPATE_WAV"
+#define		GATEPUDDLE_SPAWN_WAV		"GATEPUDDLE_SPAWN_WAV"
+#define		MANNY_CRASH_WAV		"MANNY_CRASH_WAV"
+#define		FOOTSTEPS_WAV		"FOOTSTEPS_WAV"
+#define		STEPS_ICE_WAV		"STEPS_ICE_WAV"
+#define		GUY_DROWN_WAV		"GUY_DROWN_WAV"
+#define		GUY_FRIED_WAV		"GUY_FRIED_WAV"
+#define		GUY_GRABBED_WAV		"GUY_GRABBED_WAV"
+#define		GUY_DYING_WAV		"GUY_DYING_WAV"
+#define		GUY_UHUH_WAV		"GUY_UHUH_WAV"
+#define		GUY_PLUMMET_WAV		"GUY_PLUMMET_WAV"
+#define		GET_STUNNER_WAV		"GET_STUNNER_WAV"
+#define		GET_THING_WAV		"GET_THING_WAV"
+#define		GET_CLUB_WAV		"GET_CLUB_WAV"
+#define		GET_SLUG_WAV		"GET_SLUG_WAV"
+#define		GET_MONKEYSTONE_WAV		"GET_MONKEYSTONE_WAV"
+#define		GET_GEM_WAV		"GET_GEM_WAV"
+#define		GET_GOO_WAV		"GET_GOO_WAV"
+#define		CLUB_MISS_WAV		"CLUB_MISS_WAV"
+#define		CLUB_HIT_METAL_WAV		"CLUB_HIT_METAL_WAV"
+#define		CLUB_HIT_FLESH_WAV		"CLUB_HIT_FLESH_WAV"
+#define		STUNNER_BUZZ_WAV		"STUNNER_BUZZ_WAV"
+#define		STUNNER_ZAP_WAV		"STUNNER_ZAP_WAV"
+#define		SLUG_FIRE_WAV		"SLUG_FIRE_WAV"
+#define		SLUG_HIT_WAV		"SLUG_HIT_WAV"
+#define		GEM_THROW_WAV		"GEM_THROW_WAV"
+#define		MONKEYSTONE_SECRET_STAR_WAV		"MONKEYSTONE_SECRET_STAR_WAV"
+#define		CRATE_SLIDE_WAV		"CRATE_SLIDE_WAV"
+#define		HEAVY_SLIDE_WAV		"HEAVY_SLIDE_WAV"
+#define		LIGHT_SLIDE_WAV		"LIGHT_SLIDE_WAV"
+#define		BARREL_EXPLODE_WAV		"BARREL_EXPLODE_WAV"
+#define		BARREL_MELTING_WAV		"BARREL_MELTING_WAV"
+#define		GUY_NOPUSH_SIZZLE_WAV		"GUY_NOPUSH_SIZZLE_WAV"
+#define		SPLASH_WAV		"SPLASH_WAV"
+#define		TELEPORT3_WAV		"TELEPORT3_WAV"
+#define		FALL_DOWN_HOLE_WAV		"FALL_DOWN_HOLE_WAV"
+#define		SLIME_BURN_WAV		"SLIME_BURN_WAV"
+#define		PLASMAFLOOR_SLIDE_WAV		"PLASMAFLOOR_SLIDE_WAV"
+#define		LASERD_PUSH_WAV		"LASERD_PUSH_WAV"
+#define		MENU_ACCEPT_WAV		"MENU_ACCEPT_WAV"
+#define		MENU_BACKOUT_WAV		"MENU_BACKOUT_WAV"
+#define		MENU_SLIDER_WAV		"MENU_SLIDER_WAV"
+#define		POP_WAV		"POP_WAV"
+#define		BURP_WAV		"BURP_WAV"
+#define		TELEPORT3_WAV		"TELEPORT3_WAV"
+#define		DIALOG_OPEN_WAV		"DIALOG_OPEN_WAV"
+#define		DIALOG_CLOSE_WAV		"DIALOG_CLOSE_WAV"
+#define		FUTUREBEEP2_WAV		"FUTUREBEEP2_WAV"
+#define		INV_SELECT_WAV		"INV_SELECT_WAV"
+#define		MOVE_SELECTION_WAV		"MOVE_SELECTION_WAV"
+#define		CELLHOLDER_USE_REJECT_WAV		"CELLHOLDER_USE_REJECT_WAV"
+#define		DOOR_OPEN_CLOSE_WAV		"DOOR_OPEN_CLOSE_WAV"
+#define		SWITCH_USE_WAV		"SWITCH_USE_WAV"
+#define		AIRLOCK_CLOSE_WAV		"AIRLOCK_CLOSE_WAV"
+#define		TOUCHPLATE_CLICK_WAV		"TOUCHPLATE_CLICK_WAV"
+#define		INSERT_CELL_WAV		"INSERT_CELL_WAV"
+#define		CABINET_OPEN_WAV		"CABINET_OPEN_WAV"
+#define		CABINET_CLOSE_WAV		"CABINET_CLOSE_WAV"
+#define		BRIDGE_EXTEND_WAV		"BRIDGE_EXTEND_WAV"
+#define		BRIDGE_START_WAV		"BRIDGE_START_WAV"
+#define		BRIDGE_END_WAV		"BRIDGE_END_WAV"
+#define		COMPUTERPROCESS_WAV		"COMPUTERPROCESS_WAV"
+#define		MAILSORTER_HAPPY_WAV		"MAILSORTER_HAPPY_WAV"
+#define		MAILSORTER_UNHAPPY_WAV		"MAILSORTER_UNHAPPY_WAV"
+#define		NOTICE_WAV		"NOTICE_WAV"
+#define		MAINTBOT_WHOOSH1_WAV		"MAINTBOT_WHOOSH1_WAV"
+#define		MAINTBOT_WHOOSH2_WAV		"MAINTBOT_WHOOSH2_WAV"
+#define		SHIP_MOVING_INTRO_WAV		"SHIP_MOVING_INTRO_WAV"
+#define		LASER_LOOP_WAV		"LASER_LOOP_WAV"
+#define		INFOCOMP_WAV		"INFOCOMP_WAV"
+#define		SLOT_SPIN_WAV		"SLOT_SPIN_WAV"
+#define		SLOT_STOP_WAV		"SLOT_STOP_WAV"
+#define		SLOT_WIN_WAV		"SLOT_WIN_WAV"
+#define		CLOCK_BONK_WAV		"CLOCK_BONK_WAV"
+#define		PASSCODE_CORRECT_WAV		"PASSCODE_CORRECT_WAV"
+#define		SLOTMACHINE_SPINS_WAV		"SLOTMACHINE_SPINS_WAV"
+#define		SLOTMACHINE_STOP_WAV		"SLOTMACHINE_STOP_WAV"
+#define		SLOTMACHINE_WIN_WAV		"SLOTMACHINE_WIN_WAV"
+#define		PANIC_WAV		"PANIC_WAV"
+#define		PANIC_TIMER_WAV		"PANIC_TIMER_WAV"
+#define		PANIC_DEATH_WAV		"PANIC_DEATH_WAV"
+#define		QUEST_COMPLETE_WAV		"QUEST_COMPLETE_WAV"
+#define		QUEST_FAILED_WAV		"QUEST_FAILED_WAV"
+#define		TRY_AGAIN_WAV		"TRY_AGAIN_WAV"
+#define		MONKEY_OOHOOH_WAV		"MONKEY_OOHOOH_WAV"
+#define		MONKEY_WIN_WAV		"MONKEY_WIN_WAV"
+#define		BYE_WAV		"BYE_WAV"
+#define		HDB_WAV		"HDB_WAV"
+#define		VORTEXIAN_SAVE_WAV		"VORTEXIAN_SAVE_WAV"
+#define		UNLOCKED_ITEM_WAV		"UNLOCKED_ITEM_WAV"
+#define		BEEPBEEPBEEP_WAV		"BEEPBEEPBEEP_WAV"
+#define		MACHINE_AMBIENT1_WAV		"MACHINE_AMBIENT1_WAV"
 #define		M00_AIRLOCK_01_MP3		"M00_AIRLOCK_01_MP3"
 #define		M00_ARNIE_01_MP3		"M00_ARNIE_01_MP3"
 #define		M00_BRAD_01_MP3		"M00_BRAD_01_MP3"
diff --git a/engines/hdb/sound.cpp b/engines/hdb/sound.cpp
index c4ff836..4fa5e2b 100644
--- a/engines/hdb/sound.cpp
+++ b/engines/hdb/sound.cpp
@@ -1464,12 +1464,91 @@ void Sound::setMusicVolume(int volume) {
 }
 
 bool Sound::playSound(int index) {
-	debug(9, "STUB: Play Sound");
+
+	if (index > _numSounds || !_sfxVolume)
+		return false;
+
+	// is sound in memory at least?
+	if (_soundCache[index].loaded == -1)
+		_soundCache[index].loaded = 1;
+
+	// is sound marked as cached?
+	if (!_soundCache[index].loaded) {
+
+		Common::SeekableReadStream *stream = g_hdb->_fileMan->findFirstData(_soundCache[index].name, TYPE_BINARY);
+		if (stream == nullptr)
+			return false;
+
+		if (_soundCache[index].ext) {
+#ifdef USE_MAD
+			_soundCache[index].audioStream = Audio::makeMP3Stream(stream, DisposeAfterUse::YES);
+			_soundCache[index].loaded = 1;
+#endif // USE_MAD
+		} else {
+			_soundCache[index].audioStream = Audio::makeWAVStream(stream, DisposeAfterUse::YES);
+			_soundCache[index].loaded = 1;
+		}
+	}
+
+	int soundChannel = 0;
+
+	// Select Free Audio Handle
+	for (int i = 0; i < kLaserChannel; i++) {
+		if (!g_hdb->_mixer->isSoundHandleActive(_handles[i])) {
+			soundChannel = i;
+			break;
+		}
+	}
+
+	// If no free handles found
+	if (soundChannel == kLaserChannel)
+		return false;
+
+	g_hdb->_mixer->setChannelVolume(_handles[soundChannel], _sfxVolume);
+
+	g_hdb->_mixer->playStream(Audio::Mixer::kSFXSoundType, &_handles[soundChannel], _soundCache[index].audioStream);
+
 	return true;
 }
 
 bool Sound::playSoundEx(int index, int channel, bool loop) {
-	debug(9, "STUB: Play SoundEx");
+	if (g_hdb->_mixer->isSoundHandleActive(_handles[channel]))
+		return false;
+
+	if (index > _numSounds || !_sfxVolume)
+		return false;
+
+	// is sound in memory at least?
+	if (_soundCache[index].loaded == -1)
+		_soundCache[index].loaded = 1;
+
+	// is sound marked as cached?
+	if (!_soundCache[index].loaded) {
+
+		Common::SeekableReadStream *stream = g_hdb->_fileMan->findFirstData(_soundCache[index].name, TYPE_BINARY);
+		if (stream == nullptr)
+			return false;
+
+		if (_soundCache[index].ext) {
+#ifdef USE_MAD
+			_soundCache[index].audioStream = Audio::makeMP3Stream(stream, DisposeAfterUse::YES);
+			_soundCache[index].loaded = 1;
+#endif // USE_MAD
+		} else {
+			_soundCache[index].audioStream = Audio::makeWAVStream(stream, DisposeAfterUse::YES);
+			_soundCache[index].loaded = 1;
+		}
+	}
+
+	g_hdb->_mixer->setChannelVolume(_handles[channel], _sfxVolume);
+
+	if (loop) {
+		Audio::AudioStream *loopingStream = new Audio::LoopingAudioStream(_soundCache[index].audioStream, 0, DisposeAfterUse::YES);
+		g_hdb->_mixer->playStream(Audio::Mixer::kSFXSoundType, &_handles[channel], loopingStream);
+	} else {
+		g_hdb->_mixer->playStream(Audio::Mixer::kSFXSoundType, &_handles[channel], _soundCache[index].audioStream);
+	}
+
 	return true;
 }
 
@@ -1549,7 +1628,7 @@ bool Sound::songPlaying(SoundType song) {
 }
 
 bool Sound::stopChannel(int channel) {
-	debug(9, "STUB: Stop Channel");
+	g_hdb->_mixer->stopHandle(_handles[channel]);
 
 	return true;
 }
@@ -1674,7 +1753,7 @@ int Sound::registerSound(const char *name) {
 
 bool Sound::freeSound(int index) {
 	if (_soundCache[index].loaded == 1) {
-		warning("STUB: Free the audio stream in cache");
+		delete _soundCache[index].audioStream;
 		_soundCache[index].loaded = 0;
 		_soundCache[index].ext = 0;
 		return true;
diff --git a/engines/hdb/sound.h b/engines/hdb/sound.h
index 1ed279d..7984ab1 100644
--- a/engines/hdb/sound.h
+++ b/engines/hdb/sound.h
@@ -58,8 +58,6 @@ enum {
 	kMaxSNDChannels = 32,
 	kMaxSounds = 5000,
 	kLaserChannel = kMaxSNDChannels - 1,
-	kMusicChannel = kMaxSNDChannels - 2,
-	kVoiceChannel = kMaxSNDChannels - 5
 };
 
 enum SoundType {
@@ -1429,11 +1427,10 @@ struct SoundCache {
 	int32 size;				// size of sound
 	const char *name;				// filename / MSD name
 	const char *luaName;			// name used by Lua for i.d.
-	int ext;					// 0 = Uninitialized, -1 = WAV, 1 = MP3
-	//void *data;				// actual file data
-	//FSOUND_SAMPLE *sample;			// used to play sound in FMOD
+	int ext;				// 0 = Uninitialized, -1 = WAV, 1 = MP3
+	Audio::SeekableAudioStream *audioStream;
 
-	SoundCache() : loaded(0), size(0), name(nullptr), luaName(nullptr), ext(0) {}
+	SoundCache() : loaded(0), size(0), name(nullptr), luaName(nullptr), ext(0), audioStream(nullptr) {}
 };
 
 struct Song {
@@ -1534,6 +1531,7 @@ public:
 	SoundCache _soundCache[kMaxSounds];
 	int _numSounds;
 	int _sfxVolume;
+	Audio::SoundHandle _handles[kMaxSNDChannels];
 
 };
 


Commit: 5ba5a335a14ba79c9aa0671f1825dad0807fee0b
    https://github.com/scummvm/scummvm/commit/5ba5a335a14ba79c9aa0671f1825dad0807fee0b
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:29+02:00

Commit Message:
HDB: Unstub Sound related stubs

Changed paths:
    engines/hdb/ai-funcs.cpp
    engines/hdb/ai-player.cpp
    engines/hdb/ai.h


diff --git a/engines/hdb/ai-funcs.cpp b/engines/hdb/ai-funcs.cpp
index 1aee340..7258fa0 100644
--- a/engines/hdb/ai-funcs.cpp
+++ b/engines/hdb/ai-funcs.cpp
@@ -864,11 +864,33 @@ void AI::stunEnemy(AIEntity *e, int time) {
 			g_hdb->_sound->playSound(SND_CHICKEN_DEATH);
 			// fallthrough
 		default:
-			warning("STUB: stunEnemy: MetalOrFleshSnd");
+			g_hdb->_sound->playSound(g_hdb->_ai->metalOrFleshSND(e));
 			break;
 		}
 }
 
+int AI::metalOrFleshSND(AIEntity *e) {
+	switch (e->type) {
+	case AI_OMNIBOT:
+	case AI_TURNBOT:
+	case AI_SHOCKBOT:
+	case AI_RIGHTBOT:
+	case AI_PUSHBOT:
+	case AI_LISTENBOT:
+	case AI_MAINTBOT:
+		return SND_CLUB_HIT_METAL;
+	case AI_DEADEYE:
+	case AI_MEERKAT:
+	case AI_FATFROG:
+	case AI_GOODFAIRY:
+	case AI_BADFAIRY:
+	case AI_ICEPUFF:
+	case AI_BUZZFLY:
+	default:
+		return SND_CLUB_HIT_FLESH;
+	}
+}
+
 /*
 	Note from original:
 	Moves the entity along toward its goal, sets current frame to draw
@@ -2162,7 +2184,54 @@ bool AI::walkThroughEnt(AIType type) {
 
 // Play special sound for every item you get
 void AI::getItemSound(AIType type) {
-	warning("STUB: AI: getItemSound required");
+	switch (type) {
+	case ITEM_GOO_CUP: g_hdb->_sound->playSound(SND_GET_GOO);
+		break;
+	case ITEM_GEM_WHITE:
+	case ITEM_GEM_BLUE:
+	case ITEM_GEM_RED:
+	case ITEM_GEM_GREEN:
+		g_hdb->_sound->playSound(SND_GET_GEM);
+		break;
+	case ITEM_CLUB:
+		g_hdb->_sound->playSound(SND_GET_CLUB);
+		break;
+	case ITEM_SLUGSLINGER:
+		g_hdb->_sound->playSound(SND_GET_SLUG);
+		break;
+	case ITEM_ROBOSTUNNER:
+		g_hdb->_sound->playSound(SND_GET_STUNNER);
+		break;
+	case ITEM_CELL:
+	case ITEM_TRANSCEIVER:
+	case ITEM_TEACUP:
+	case ITEM_COOKIE:
+	case ITEM_BURGER:
+	case ITEM_PDA:
+	case ITEM_BOOK:
+	case ITEM_CLIPBOARD:
+	case ITEM_NOTE:
+	case ITEM_CABKEY:
+	case ITEM_DOLLYTOOL1:
+	case ITEM_DOLLYTOOL2:
+	case ITEM_DOLLYTOOL3:
+	case ITEM_DOLLYTOOL4:
+	case ITEM_SEED:
+	case ITEM_SODA:
+	case ITEM_ROUTER:
+	case ITEM_SLICER:
+	case ITEM_CHICKEN:
+	case ITEM_PACKAGE:
+	case ITEM_ENV_RED:
+	case ITEM_ENV_BLUE:
+	case ITEM_ENV_GREEN:
+		if (g_hdb->_sound->getVoiceStatus())
+			g_hdb->_sound->playVoice(GUY_GOT_SOMETHING, 1);
+		else
+			g_hdb->_sound->playSound(SND_GET_THING);
+		break;
+	default: g_hdb->_sound->playSound(SND_GET_THING);
+	}
 }
 
 void AI::lookAtEntity(AIEntity *e) {
diff --git a/engines/hdb/ai-player.cpp b/engines/hdb/ai-player.cpp
index aef00e1..4e70436 100644
--- a/engines/hdb/ai-player.cpp
+++ b/engines/hdb/ai-player.cpp
@@ -156,7 +156,6 @@ void aiPlayerAction(AIEntity *e) {
 				g_hdb->_ai->stunEnemy(hit, 8);
 				break;
 			default:
-				debug(9, "STUB: stunEnemy: Play sound");
 				break;
 			}
 
@@ -188,7 +187,6 @@ void aiPlayerAction(AIEntity *e) {
 				g_hdb->_ai->stunEnemy(hit, 8);
 				break;
 			default:
-				debug(9, "STUB: stunEnemy: Play sound");
 				break;
 			}
 	}
@@ -209,7 +207,6 @@ void aiPlayerAction(AIEntity *e) {
 			case STATE_GRABLEFT:	e->draw = e->standleftGfx[0];	e->state = STATE_STANDLEFT; break;
 			case STATE_GRABRIGHT:	e->draw = e->standrightGfx[0];	e->state = STATE_STANDRIGHT; break;
 			default:
-				debug(9, "STUB: stunEnemy: Play sound");
 				break;
 			}
 			e->animDelay = 1;
@@ -230,7 +227,6 @@ void aiPlayerAction(AIEntity *e) {
 		case STATE_ATK_CLUB_LEFT:	cycleFrames(e, g_hdb->_ai->_clubLeftFrames); break;
 		case STATE_ATK_CLUB_RIGHT:	cycleFrames(e, g_hdb->_ai->_clubRightFrames); break;
 		default:
-			debug(9, "STUB: stunEnemy: Play sound");
 			break;
 		}
 		// Whack!
@@ -241,7 +237,6 @@ void aiPlayerAction(AIEntity *e) {
 			case DIR_LEFT:	hit = g_hdb->_ai->playerCollision(16, 16, 32, 0); break;
 			case DIR_RIGHT:	hit = g_hdb->_ai->playerCollision(16, 16, 0, 32); break;
 			default:
-				warning("aiPlayerAction: DIR_NONE found");
 				break;
 			}
 
@@ -275,7 +270,7 @@ void aiPlayerAction(AIEntity *e) {
 				case AI_SHOCKBOT:
 				case AI_GATEPUDDLE:
 					g_hdb->_ai->stunEnemy(hit, 2);
-					warning("STUB: Play MetalorFlesh SND");
+					g_hdb->_sound->playSound(g_hdb->_ai->metalOrFleshSND(hit));
 					break;
 				default:
 					break;
@@ -291,7 +286,6 @@ void aiPlayerAction(AIEntity *e) {
 			case STATE_ATK_CLUB_LEFT:	e->draw = e->standleftGfx[0]; break;
 			case STATE_ATK_CLUB_RIGHT:	e->draw = e->standrightGfx[0]; break;
 			default:
-				debug(9, "STUB: stunEnemy: Play sound");
 				break;
 			}
 			g_hdb->_ai->setPlayerInvisible(false);
@@ -367,7 +361,6 @@ void aiPlayerAction(AIEntity *e) {
 		}
 		return;
 	default:
-		debug(9, "STUB: stunEnemy: Play sound");
 		break;
 	}
 
@@ -956,7 +949,7 @@ void aiSlugAttackAction(AIEntity *e) {
 	result = (e->level == 1 ? (bg_flags & (kFlagSolid)) : !(fg_flags & kFlagGrating) && (bg_flags & (kFlagSolid)));
 	if (hit) {
 		g_hdb->_sound->playSound(SND_SLUG_HIT);
-		warning("STUB: Play MetalOrFleshSnd");
+		g_hdb->_sound->playSound(g_hdb->_ai->metalOrFleshSND(hit));
 		switch (hit->type) {
 		case AI_MEERKAT:
 			if (hit->sequence > 2) {		// out of the ground?
diff --git a/engines/hdb/ai.h b/engines/hdb/ai.h
index dfa22bb..6bf3af8 100644
--- a/engines/hdb/ai.h
+++ b/engines/hdb/ai.h
@@ -832,6 +832,7 @@ public:
 	void initAllEnts();
 	void killPlayer(Death method);
 	void stunEnemy(AIEntity *e, int time);
+	int metalOrFleshSND(AIEntity *e);
 	int tileDistance(AIEntity *e1, AIEntity *e2) {
 		return abs(e1->tileX - e2->tileX) + abs(e1->tileY - e2->tileY);
 	}


Commit: 12f46b3f9d246e4610ed309254f6850f31d478d5
    https://github.com/scummvm/scummvm/commit/12f46b3f9d246e4610ed309254f6850f31d478d5
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:29+02:00

Commit Message:
HDB: Remove redundant stubs

Changed paths:
    engines/hdb/ai-cinematic.cpp
    engines/hdb/gfx.cpp


diff --git a/engines/hdb/ai-cinematic.cpp b/engines/hdb/ai-cinematic.cpp
index 36e7405..572f059 100644
--- a/engines/hdb/ai-cinematic.cpp
+++ b/engines/hdb/ai-cinematic.cpp
@@ -454,7 +454,6 @@ void AI::processCines() {
 			complete = true;
 			break;
 		default:
-			warning("STUB: AI::PROCESSCINES incomplete for %d", _cine[i]->cmdType);
 			break;
 		}
 
diff --git a/engines/hdb/gfx.cpp b/engines/hdb/gfx.cpp
index 87da345..3aa37e9 100644
--- a/engines/hdb/gfx.cpp
+++ b/engines/hdb/gfx.cpp
@@ -153,11 +153,6 @@ bool Gfx::init() {
 	_tileSkyClouds = getTileIndex(TILE_SKY_CLOUDS); // Not completely sure about this filename.
 	_skyClouds = NULL;
 
-	/*
-		TODO: Setup Gamma Table
-	*/
-	warning("STUB: Gfx::init() gamma missing");
-
 	// Load Mouse Pointer and Display Cursor
 	_mousePointer[0] = loadPic(PIC_MOUSE_CURSOR1);
 	_mousePointer[1] = loadPic(PIC_MOUSE_CURSOR2);


Commit: 588d0235ae954120bdad38415a648f59a3b0b35f
    https://github.com/scummvm/scummvm/commit/588d0235ae954120bdad38415a648f59a3b0b35f
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:29+02:00

Commit Message:
HDB: Comment out SND code until data is found

Changed paths:
    engines/hdb/sound.cpp


diff --git a/engines/hdb/sound.cpp b/engines/hdb/sound.cpp
index 4fa5e2b..a1c220c 100644
--- a/engines/hdb/sound.cpp
+++ b/engines/hdb/sound.cpp
@@ -1464,7 +1464,7 @@ void Sound::setMusicVolume(int volume) {
 }
 
 bool Sound::playSound(int index) {
-
+#if 0
 	if (index > _numSounds || !_sfxVolume)
 		return false;
 
@@ -1507,11 +1507,12 @@ bool Sound::playSound(int index) {
 	g_hdb->_mixer->setChannelVolume(_handles[soundChannel], _sfxVolume);
 
 	g_hdb->_mixer->playStream(Audio::Mixer::kSFXSoundType, &_handles[soundChannel], _soundCache[index].audioStream);
-
+#endif
 	return true;
 }
 
 bool Sound::playSoundEx(int index, int channel, bool loop) {
+#if 0
 	if (g_hdb->_mixer->isSoundHandleActive(_handles[channel]))
 		return false;
 
@@ -1548,7 +1549,7 @@ bool Sound::playSoundEx(int index, int channel, bool loop) {
 	} else {
 		g_hdb->_mixer->playStream(Audio::Mixer::kSFXSoundType, &_handles[channel], _soundCache[index].audioStream);
 	}
-
+#endif
 	return true;
 }
 


Commit: c6af142ce703db1205b77c08f9148037c94a235e
    https://github.com/scummvm/scummvm/commit/c6af142ce703db1205b77c08f9148037c94a235e
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:29+02:00

Commit Message:
HDB: Fix warning

Changed paths:
    engines/hdb/sound.h


diff --git a/engines/hdb/sound.h b/engines/hdb/sound.h
index 7984ab1..0190d12 100644
--- a/engines/hdb/sound.h
+++ b/engines/hdb/sound.h
@@ -57,7 +57,7 @@ namespace HDB {
 enum {
 	kMaxSNDChannels = 32,
 	kMaxSounds = 5000,
-	kLaserChannel = kMaxSNDChannels - 1,
+	kLaserChannel = kMaxSNDChannels - 1
 };
 
 enum SoundType {


Commit: ac90e5541e04f624e32301c8e8747c31385253ad
    https://github.com/scummvm/scummvm/commit/ac90e5541e04f624e32301c8e8747c31385253ad
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:29+02:00

Commit Message:
HDB: Added more detection entries

Changed paths:
    engines/hdb/detection.cpp


diff --git a/engines/hdb/detection.cpp b/engines/hdb/detection.cpp
index 3a4a45e..63563ba 100644
--- a/engines/hdb/detection.cpp
+++ b/engines/hdb/detection.cpp
@@ -64,9 +64,30 @@ static const ADGameDescription gameDescriptions[] = {
 	{
 		"hdb",
 		"",
+		AD_ENTRY1s("hyperspace.mpc", "39d3c9dbc9614f370ad9430307c043f9", 45645305),
+		Common::EN_ANY,
+		Common::kPlatformLinux,
+		ADGF_NO_FLAGS,
+		GUIO1(GUIO_NONE)
+	},
+	// PocketPC Arm
+	{
+		"hdb",
+		"",
+		AD_ENTRY1s("hyperspace.msd", "a62468904beb3efe16d4d64f3955a32e", 6825555),
+		Common::EN_ANY,
+		Common::kPlatformUnknown, // PPC
+		ADGF_NO_FLAGS,
+		GUIO1(GUIO_NONE)
+	},
+
+	// Demos
+	{
+		"hdb",
+		"",
 		AD_ENTRY1s("hyperdemo.mpc", "d8743b3b8be56486bcfb1398b2f2aad4", 13816461),
 		Common::EN_ANY,
-		Common::kPlatformUnknown,
+		Common::kPlatformLinux,
 		ADGF_DEMO,
 		GUIO1(GUIO_NONE)
 	},
@@ -75,7 +96,7 @@ static const ADGameDescription gameDescriptions[] = {
 		"",
 		AD_ENTRY1s("hyperdemo.mpc", "f3bc878e179f00b8666a9846f3d9f9f5", 5236568),
 		Common::EN_ANY,
-		Common::kPlatformUnknown,
+		Common::kPlatformUnknown, // FIXME
 		ADGF_DEMO,
 		GUIO1(GUIO_NONE)
 	},
@@ -89,6 +110,24 @@ static const ADGameDescription gameDescriptions[] = {
 		ADGF_DEMO,
 		GUIO1(GUIO_NONE)
 	},
+	{
+		"hdb",
+		"",
+		AD_ENTRY1s("hyperdemo.msd", "312525298ca9f5ac904883d1ce19dc0f", 3088651),
+		Common::EN_ANY,
+		Common::kPlatformUnknown, // PPC
+		ADGF_DEMO,
+		GUIO1(GUIO_NONE)
+	},
+	{
+		"hdb",
+		"alt",
+		AD_ENTRY1s("hyperdemo.msd", "2d4457b284a940b7058b36e5706b9951", 3094241),
+		Common::EN_ANY,
+		Common::kPlatformUnknown, // PPC
+		ADGF_DEMO,
+		GUIO1(GUIO_NONE)
+	},
 	AD_TABLE_END_MARKER
 };
 } // End of namespace HDB


Commit: da5f1fa26544d35e3342f5c622db3a457adbc36c
    https://github.com/scummvm/scummvm/commit/da5f1fa26544d35e3342f5c622db3a457adbc36c
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:29+02:00

Commit Message:
HDB: Added demo-specific start code

Changed paths:
    engines/hdb/hdb.cpp


diff --git a/engines/hdb/hdb.cpp b/engines/hdb/hdb.cpp
index e58cae1..900709f 100644
--- a/engines/hdb/hdb.cpp
+++ b/engines/hdb/hdb.cpp
@@ -171,8 +171,14 @@ void HDBGame::changeGameState() {
 		_ai->clearPersistent();
 		_timePlayed = 0;
 		_timeSeconds = 0;
-		if (!startMap("CINE_INTRO"))
-			error("Can't load CINE_INTRO");
+
+		if (!isDemo()) {
+			if (!startMap("CINE_INTRO"))
+				error("Can't load CINE_INTRO");
+		} else {
+			if (!startMap("CINE_INTRO_DEMO"))
+				error("Can't load CINE_INTRO_DEMO");
+		}
 		_gameState = GAME_PLAY;
 		break;
 	case GAME_PLAY:


Commit: 7f7de57ba4a860d5918e4e69e6fa90c9cb691312
    https://github.com/scummvm/scummvm/commit/7f7de57ba4a860d5918e4e69e6fa90c9cb691312
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:29+02:00

Commit Message:
HDB: Modified the patching engine so it works for the demo

Changed paths:
    engines/hdb/lua-script.cpp


diff --git a/engines/hdb/lua-script.cpp b/engines/hdb/lua-script.cpp
index d0dc52f..5d963da 100644
--- a/engines/hdb/lua-script.cpp
+++ b/engines/hdb/lua-script.cpp
@@ -42,57 +42,57 @@ struct ScriptPatch {
 	const char *search;
 	const char *replace;
 } scriptPatches[] = {
-	{"GLOBAL.LUA", "return gsub( s, \"\\n\", \"\\\\\\n\" )", "return string.gsub( s, \"\\n\", \"\\\\\\n\" )"}, // line 10
-	{"GLOBAL.LUA", "strsub(", "string.sub("}, // line 15
-	{"GLOBAL.LUA", "if type(v) == 'userdata' or type(v) == 'function' then return end", "if type(v) == 'userdata' or type(v) == 'function' or i == 'package' or i == 'os' or i == 'io' or i == 'string' or i == 'table' or i == 'debug' or i == 'math' or i == 'coroutine' then return end" }, // Line 16
-	{"GLOBAL.LUA", "for i,v in t do", "for i,v in pairs(t) do"},  // line 43
-	{"GLOBAL.LUA", "for i,v in globals() do", "for i,v in pairs(_G) do"}, // line 52
-	{"GLOBAL.LUA", "for npcname,npcdata in npcs do", "for npcname,npcdata in pairs(npcs) do"}, // Line 66
-	{"GLOBAL.LUA", "for dlgname,dlgdata in npcdata.dialog do", "for dlgname,dlgdata in pairs(npcdata.dialog) do"}, // Line 67
-	{"GLOBAL.LUA", "s = format( \"npcs.%s.dialog.%s.counter", "s = string.format( \"npcs.%s.dialog.%s.counter"}, // Line 68
-	{"GLOBAL.LUA", "s = format( \"npcs.%s.dialog.%s.finished = ", "s = string.format( \"npcs.%s.dialog.%s.finished = "}, // line 70
-	{"GLOBAL.LUA", "if( getglobal( \"map\"..tostring(v1)..\"_complete\" ) ) then", "if( _G[\"map\"..tostring(v1)..\"_complete\"] ) then"}, // line 219
-	{"GLOBAL.LUA", "local mapname = format( \"MAP", "local mapname = string.format( \"MAP"}, // line 225
-	{"GLOBAL.LUA", "if( dtable.counter < getn(dtable) ) then", "if( dtable.counter < #dtable ) then"}, // line 254
-	{"GLOBAL.LUA", "closefunc = getglobal( npcdef.codename..\"_use\" )", "closefunc = _G[npcdef.codename..\"_use\"]"}, // line 272
-	{"GLOBAL.LUA", "setglobal( npcdef.codename..\"_init\", function() return NPC_Init( %npcdef ) end )", "_G[npcdef.codename .. \"_init\"] = function() return NPC_Init( npcdef ) end"}, // line 317
-	{"GLOBAL.LUA", "setglobal( npcdef.codename..\"_use\", function(x, y, v1, v2) return NPC_Use( %npcdef, x, y, v1, v2 ) end )", "_G[npcdef.codename .. \"_use\"] = function(x, y, v1, v2) return NPC_Use( npcdef, x, y, v1, v2 ) end"}, // line 318
-	{"GLOBAL.LUA", "for i,npc in npcs do", "for i,npc in pairs(npcs) do"}, // 323
-
-	{"MAP00.LUA", "if( getn( beds ) == 0 ) then", "if( #beds == 0 ) then"}, // line 924
-	{"MAP00.LUA", "tempfunc = function() emptybed_use( %x, %y, %v1, %v2 ) end", "tempfunc = function() emptybed_use(x, y, v1, v2) end"}, // line 926
-
-	{"MAP01.LUA", "strsub(", "string.sub("}, // line 23
-	{"MAP01.LUA", "if( covert_index < getn(covert_dialog) ) then", "if( covert_index < #covert_dialog ) then"}, // line 766
-	{"MAP01.LUA", "if( chiste_index < getn( chiste_dialog ) )then", "if( covert_index < #covert_dialog ) then"}, // 845
-
-	{"MAP10.LUA", "if( getn( beds ) == 0 ) then", "if( #beds == 0 ) then"}, // line 119
-	{"MAP10.LUA", "emptybed_use( %x, %y, %v1, %v2 )", "emptybed_use( x, y, v1, v2 )"}, // line 121
-
-	{"MAP15.LUA", "function cop5_5b()", "function cop5_4b()"}, // line 112
-	{"MAP15.LUA", "function cop5_5c()", "function cop5_4c()"}, // line 115
-	{"MAP15.LUA", "function cop5_5d()", "function cop5_4d()"}, // line 118
-	{"MAP15.LUA", "function cop5_5e()", "function cop5_4e()"}, // line 121
-	{"MAP15.LUA", "function cop5_5f()", "function cop5_4f()"}, // line 124
-
-	{"MAP19.LUA", "func = getglobal( \"frustrato_nice\"..tostring(frustrato_stage) )", "func = _G[ \"frustrato_nice\"..tostring(frustrato_stage) ]"}, // line 296
-	{"MAP19.LUA", "func = getglobal( \"frustrato_choice\"..tostring(frustrato_stage + 1) )", "func = _G[ \"frustrato_choice\"..tostring(frustrato_stage + 1) ]"}, // line 298
-
-	{"MAP11.LUA", "mapstring = strsub( LASTMAP, 1, 5 )", "mapstring = string.sub( LASTMAP, 1, 5 )"}, // line 51
-
-	{"MAP21.LUA", "mapstring = strsub( LASTMAP, 1, 5 )", "mapstring = string.sub( LASTMAP, 1, 5 )"}, // line 105
-
-	{"MAP29.LUA", "Message( format( \"", "Message( string.format( \""}, // line 195
-
-	{"MAP30.LUA", "rots = 19 + random( 6 )", "rots = 19 + math.random( 6 )"}, // line 208
-	{"MAP30.LUA", "if i1 > getn(tiles)", "if i1 > #tiles"}, // line 211
-	{"MAP30.LUA", "if i2 > getn(tiles)", "if i2 > #tiles"}, // line 212
-	{"MAP30.LUA", "if i3 > getn(tiles)", "if i3 > #tiles"}, // line 213
-	{"MAP30.LUA", "rots = 13 + random( 4 )", "rots = 13 + math.random( 4 )"}, // line 234
-	{"MAP30.LUA", "if i2 > getn(tiles)", "if i2 > #tiles"}, // line 237
-	{"MAP30.LUA", "if i3 > getn(tiles)", "if i3 > #tiles"}, // line 238
-	{"MAP30.LUA", "rots = 13 + random( 4 )", "rots = 13 + math.random( 4 )"}, // line 258
-	{"MAP30.LUA", "if i3 > getn(tiles)", "if i3 > #tiles"}, // line 261
+	{"GLOBAL", "return gsub( s, \"\\n\", \"\\\\\\n\" )", "return string.gsub( s, \"\\n\", \"\\\\\\n\" )"}, // line 10
+	{"GLOBAL", "strsub(", "string.sub("}, // line 15
+	{"GLOBAL", "if type(v) == 'userdata' or type(v) == 'function' then return end", "if type(v) == 'userdata' or type(v) == 'function' or i == 'package' or i == 'os' or i == 'io' or i == 'string' or i == 'table' or i == 'debug' or i == 'math' or i == 'coroutine' then return end" }, // Line 16
+	{"GLOBAL", "for i,v in t do", "for i,v in pairs(t) do"},  // line 43
+	{"GLOBAL", "for i,v in globals() do", "for i,v in pairs(_G) do"}, // line 52
+	{"GLOBAL", "for npcname,npcdata in npcs do", "for npcname,npcdata in pairs(npcs) do"}, // Line 66
+	{"GLOBAL", "for dlgname,dlgdata in npcdata.dialog do", "for dlgname,dlgdata in pairs(npcdata.dialog) do"}, // Line 67
+	{"GLOBAL", "s = format( \"npcs.%s.dialog.%s.counter", "s = string.format( \"npcs.%s.dialog.%s.counter"}, // Line 68
+	{"GLOBAL", "s = format( \"npcs.%s.dialog.%s.finished = ", "s = string.format( \"npcs.%s.dialog.%s.finished = "}, // line 70
+	{"GLOBAL", "if( getglobal( \"map\"..tostring(v1)..\"_complete\" ) ) then", "if( _G[\"map\"..tostring(v1)..\"_complete\"] ) then"}, // line 219
+	{"GLOBAL", "local mapname = format( \"MAP", "local mapname = string.format( \"MAP"}, // line 225
+	{"GLOBAL", "if( dtable.counter < getn(dtable) ) then", "if( dtable.counter < #dtable ) then"}, // line 254
+	{"GLOBAL", "closefunc = getglobal( npcdef.codename..\"_use\" )", "closefunc = _G[npcdef.codename..\"_use\"]"}, // line 272
+	{"GLOBAL", "setglobal( npcdef.codename..\"_init\", function() return NPC_Init( %npcdef ) end )", "_G[npcdef.codename .. \"_init\"] = function() return NPC_Init( npcdef ) end"}, // line 317
+	{"GLOBA", "setglobal( npcdef.codename..\"_use\", function(x, y, v1, v2) return NPC_Use( %npcdef, x, y, v1, v2 ) end )", "_G[npcdef.codename .. \"_use\"] = function(x, y, v1, v2) return NPC_Use( npcdef, x, y, v1, v2 ) end"}, // line 318
+	{"GLOBAL", "for i,npc in npcs do", "for i,npc in pairs(npcs) do"}, // 323
+
+	{"MAP00", "if( getn( beds ) == 0 ) then", "if( #beds == 0 ) then"}, // line 924
+	{"MAP00", "tempfunc = function() emptybed_use( %x, %y, %v1, %v2 ) end", "tempfunc = function() emptybed_use(x, y, v1, v2) end"}, // line 926
+
+	{"MAP01", "strsub(", "string.sub("}, // line 23
+	{"MAP01", "if( covert_index < getn(covert_dialog) ) then", "if( covert_index < #covert_dialog ) then"}, // line 766
+	{"MAP01", "if( chiste_index < getn( chiste_dialog ) )then", "if( covert_index < #covert_dialog ) then"}, // 845
+
+	{"MAP10", "if( getn( beds ) == 0 ) then", "if( #beds == 0 ) then"}, // line 119
+	{"MAP10", "emptybed_use( %x, %y, %v1, %v2 )", "emptybed_use( x, y, v1, v2 )"}, // line 121
+
+	{"MAP15", "function cop5_5b()", "function cop5_4b()"}, // line 112
+	{"MAP15", "function cop5_5c()", "function cop5_4c()"}, // line 115
+	{"MAP15", "function cop5_5d()", "function cop5_4d()"}, // line 118
+	{"MAP15", "function cop5_5e()", "function cop5_4e()"}, // line 121
+	{"MAP15", "function cop5_5f()", "function cop5_4f()"}, // line 124
+
+	{"MAP19", "func = getglobal( \"frustrato_nice\"..tostring(frustrato_stage) )", "func = _G[ \"frustrato_nice\"..tostring(frustrato_stage) ]"}, // line 296
+	{"MAP19", "func = getglobal( \"frustrato_choice\"..tostring(frustrato_stage + 1) )", "func = _G[ \"frustrato_choice\"..tostring(frustrato_stage + 1) ]"}, // line 298
+
+	{"MAP11", "mapstring = strsub( LASTMAP, 1, 5 )", "mapstring = string.sub( LASTMAP, 1, 5 )"}, // line 51
+
+	{"MAP21", "mapstring = strsub( LASTMAP, 1, 5 )", "mapstring = string.sub( LASTMAP, 1, 5 )"}, // line 105
+
+	{"MAP29", "Message( format( \"", "Message( string.format( \""}, // line 195
+
+	{"MAP30", "rots = 19 + random( 6 )", "rots = 19 + math.random( 6 )"}, // line 208
+	{"MAP30", "if i1 > getn(tiles)", "if i1 > #tiles"}, // line 211
+	{"MAP30", "if i2 > getn(tiles)", "if i2 > #tiles"}, // line 212
+	{"MAP30", "if i3 > getn(tiles)", "if i3 > #tiles"}, // line 213
+	{"MAP30", "rots = 13 + random( 4 )", "rots = 13 + math.random( 4 )"}, // line 234
+	{"MAP30", "if i2 > getn(tiles)", "if i2 > #tiles"}, // line 237
+	{"MAP30", "if i3 > getn(tiles)", "if i3 > #tiles"}, // line 238
+	{"MAP30", "rots = 13 + random( 4 )", "rots = 13 + math.random( 4 )"}, // line 258
+	{"MAP30", "if i3 > getn(tiles)", "if i3 > #tiles"}, // line 261
 
 	{NULL, NULL, NULL}
 };
@@ -2032,7 +2032,7 @@ void LuaScript::addPatches(Common::String &chunk, const char *scriptName) {
 	int applied = 0;
 
 	while (patch->scriptName) {
-		if (!strcmp(scriptName, patch->scriptName)) {
+		if (!scumm_strnicmp(scriptName, patch->scriptName, strlen(patch->scriptName))) {
 			Common::String searchString(patch->search);
 			Common::String replaceString(patch->replace);
 			Common::replace(chunk, searchString, replaceString);


Commit: fc0dd1fb1a522e496501ee41f2e0f3c24059455c
    https://github.com/scummvm/scummvm/commit/fc0dd1fb1a522e496501ee41f2e0f3c24059455c
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:29+02:00

Commit Message:
HDB: Added demo sound constants

Changed paths:
    engines/hdb/mpc.h
    engines/hdb/sound.cpp
    engines/hdb/sound.h


diff --git a/engines/hdb/mpc.h b/engines/hdb/mpc.h
index 71481e2..137a5b3 100644
--- a/engines/hdb/mpc.h
+++ b/engines/hdb/mpc.h
@@ -1995,6 +1995,17 @@ namespace HDB {
 #define		GUY_WINS_MP3		"GUY_WINS_MP3"
 #define		HDB_INTRO_MP3		"HDB_INTRO_MP3"
 
+#define		DEMO_SARGE01_MP3		"DEMO_SARGE01_MP3"
+#define		DEMO_SARGE02_MP3		"DEMO_SARGE_02_MP3"
+#define		DEMO_SARGE03_MP3		"DEMO_SARGE_03_MP3"
+#define		DEMO_SARGE04_MP3		"DEMO_SARGE_04_MP3"
+#define		DEMO_SARGE05_MP3		"DEMO_SARGE_05_MP3"
+#define		DEMO_SARGE06_MP3		"DEMO_SARGE_06_MP3"
+#define		DEMO_GUY_01_MP3			"DEMO_GUY_01_MP3"
+#define		DEMO_PILOT_01_MP3		"DEMO_PILOT_01_MP3"
+#define		DEMO_SCIENTIST_01_MP3	"DEMO_SCIENTIST_01_MP3"
+#define		DEMO_SCIENTIST_02_MP3	"DEMO_SCIENTIST_02_MP3"
+
 enum IconList {
 	ICON_GUY_DOWN,
 	ICON_GUY_UP,
diff --git a/engines/hdb/sound.cpp b/engines/hdb/sound.cpp
index a1c220c..394745f 100644
--- a/engines/hdb/sound.cpp
+++ b/engines/hdb/sound.cpp
@@ -1388,6 +1388,19 @@ const SoundLookUp soundList[] =  {
 	{GUY_GOT_SOMETHING,		GUY_GOT_SOMETHING_MP3,		"GUY_GOT_SOMETHING"},
 	{HDB_INTRO,				HDB_INTRO_MP3,				"HDB_INTRO"},
 
+	// Demo files
+	{DEMO_SARGE_01,			DEMO_SARGE01_MP3,			"DEMO_SARGE_01"},
+	{DEMO_SARGE_02,			DEMO_SARGE02_MP3,			"DEMO_SARGE_02"},
+	{DEMO_SARGE_03,			DEMO_SARGE03_MP3,			"DEMO_SARGE_03"},
+	{DEMO_SARGE_04,			DEMO_SARGE04_MP3,			"DEMO_SARGE_04"},
+	{DEMO_SARGE_05,			DEMO_SARGE05_MP3,			"DEMO_SARGE_05"},
+	{DEMO_SARGE_06,			DEMO_SARGE06_MP3,			"DEMO_SARGE_06"},
+
+	{DEMO_GUY_01,			DEMO_GUY_01_MP3,			"DEMO_GUY_01"},
+	{DEMO_PILOT_01,			DEMO_PILOT_01_MP3,			"DEMO_PILOT_01"},
+	{DEMO_SCIENTIST_01,		DEMO_SCIENTIST_01_MP3,		"DEMO_SCIENTIST_01"},
+	{DEMO_SCIENTIST_02,		DEMO_SCIENTIST_02_MP3,		"DEMO_SCIENTIST_02"},
+
 	{LAST_SOUND,			NULL,						NULL}
 };
 
diff --git a/engines/hdb/sound.h b/engines/hdb/sound.h
index 0190d12..9e04dad 100644
--- a/engines/hdb/sound.h
+++ b/engines/hdb/sound.h
@@ -1403,6 +1403,18 @@ enum SoundType {
 	GUY_GOT_SOMETHING,
 	HDB_INTRO,
 
+	// Demo files
+	DEMO_SARGE_01,
+	DEMO_SARGE_02,
+	DEMO_SARGE_03,
+	DEMO_SARGE_04,
+	DEMO_SARGE_05,
+	DEMO_SARGE_06,
+	DEMO_GUY_01,
+	DEMO_PILOT_01,
+	DEMO_SCIENTIST_01,
+	DEMO_SCIENTIST_02,
+
 	LAST_SOUND
 };
 


Commit: 421ae7165e0b6341a179a508bb1719e2fdde4ae2
    https://github.com/scummvm/scummvm/commit/421ae7165e0b6341a179a508bb1719e2fdde4ae2
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:29+02:00

Commit Message:
HDB: Added heuristic to determing sound file type

Changed paths:
    engines/hdb/sound.cpp


diff --git a/engines/hdb/sound.cpp b/engines/hdb/sound.cpp
index 394745f..9d3b80c 100644
--- a/engines/hdb/sound.cpp
+++ b/engines/hdb/sound.cpp
@@ -1430,7 +1430,7 @@ bool Sound::init() {
 		_soundCache[index2].loaded = false;
 		_soundCache[index2].name = soundList[index].name;
 		_soundCache[index2].luaName = soundList[index].luaName;
-		if (index2 <= SND_UNLOCKED_ITEM || index == SND_BEEPBEEPBEEP)
+		if (!scumm_stricmp(_soundCache[index2].name, ".wav"))
 			_soundCache[index2].ext = -1;	// WAV
 		else
 			_soundCache[index2].ext = 1;		// MP3


Commit: 74f3917db79f191c23510d5a90732251c5fab75d
    https://github.com/scummvm/scummvm/commit/74f3917db79f191c23510d5a90732251c5fab75d
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:29+02:00

Commit Message:
HDB: Made file manager case-insensitive.

Demo uses lowercase everywhere

Changed paths:
    engines/hdb/file-manager.cpp


diff --git a/engines/hdb/file-manager.cpp b/engines/hdb/file-manager.cpp
index 575e66a..c205a4b 100644
--- a/engines/hdb/file-manager.cpp
+++ b/engines/hdb/file-manager.cpp
@@ -70,7 +70,7 @@ bool FileMan::openMPC(const Common::String &filename) {
 			MPCEntry *dirEntry = new MPCEntry();
 
 			for (int i = 0; i < 64; i++) {
-				dirEntry->filename[i] = _mpcFile->readByte();
+				dirEntry->filename[i] = tolower(_mpcFile->readByte());
 			}
 
 			dirEntry->offset = _mpcFile->readUint32LE();
@@ -111,21 +111,24 @@ Common::SeekableReadStream *FileMan::findFirstData(const char *string, DataType
 
 	debug(8, "Looking for Data: '%s' <- '%s'", fname, string);
 
+	Common::String fnameS(fname);
+	fnameS.toLowercase();
+
 	// Find MPC Entry
 	for (MPCIterator it = _dir.begin(); it != _dir.end(); it++) {
 		fileString = (*it)->filename;
-		if (fileString.equals(fname)) {
+		if (fileString.equals(fnameS)) {
 			if ((*it)->type == type) {
 				file = *it;
 				break;
 			} else {
-				debug(4, "Found Data but type mismatch: '%s', target: %d, found: %d", fname, type, (*it)->type);
+				debug(4, "Found Data but type mismatch: '%s', target: %d, found: %d", fnameS.c_str(), type, (*it)->type);
 			}
 		}
 	}
 
 	if (file == NULL) {
-		debug(4, "Couldn't find Data: '%s'", fname);
+		debug(4, "Couldn't find Data: '%s'", fnameS.c_str());
 		return NULL;
 	}
 
@@ -149,10 +152,13 @@ int32 FileMan::getLength(const char *string, DataType type) {
 	if (pDest)
 		*pDest = '_';
 
+	Common::String fnameS(fname);
+	fnameS.toLowercase();
+
 	// Find MPC Entry
 	for (MPCIterator it = _dir.begin(); it != _dir.end(); it++) {
 		fileString = (*it)->filename;
-		if (fileString.contains(fname)) {
+		if (fileString.contains(fnameS)) {
 			if ((*it)->type == type) {
 				file = *it;
 				break;
@@ -171,9 +177,12 @@ int FileMan::getCount(const char *subString, DataType type) {
 	int count = 0;
 	Common::String fileString;
 
+	Common::String fnameS(subString);
+	fnameS.toLowercase();
+
 	for (MPCIterator it = _dir.begin(); it != _dir.end(); it++) {
 		fileString = (*it)->filename;
-		if (fileString.contains(subString)) {
+		if (fileString.contains(fnameS)) {
 			if ((*it)->type == type) {
 				count++;
 			}
@@ -187,10 +196,13 @@ Common::Array<const char *> *FileMan::findFiles(const char *string, DataType typ
 	Common::Array<const char *> *result = new Common::Array<const char *>;
 	Common::String fileString;
 
+	Common::String fnameS(string);
+	fnameS.toLowercase();
+
 	// Find MPC Entry
 	for (MPCIterator it = _dir.begin(); it != _dir.end(); it++) {
 		fileString = (*it)->filename;
-		if (fileString.contains(string)) {
+		if (fileString.contains(fnameS)) {
 			if ((*it)->type == type) {
 				result->push_back((*it)->filename);
 			}


Commit: 2e3a36acbac4ffed5660567068e68be332b58b3b
    https://github.com/scummvm/scummvm/commit/2e3a36acbac4ffed5660567068e68be332b58b3b
Author: Strangerke (strangerke at scummvm.org)
Date: 2019-09-03T17:17:29+02:00

Commit Message:
HDB: Simplify animateEntity by removing a useless call to getMapBGTileFlags()

Changed paths:
    engines/hdb/ai-funcs.cpp


diff --git a/engines/hdb/ai-funcs.cpp b/engines/hdb/ai-funcs.cpp
index 7258fa0..d3d98d7 100644
--- a/engines/hdb/ai-funcs.cpp
+++ b/engines/hdb/ai-funcs.cpp
@@ -1331,7 +1331,7 @@ void AI::animateEntity(AIEntity *e) {
 						e->state = state;
 					}
 				}
-			} else if (((flags = g_hdb->_map->getMapBGTileFlags(e->tileX, e->tileY)) & kFlagWater) && (e->type == AI_MAGIC_EGG || e->type == AI_ICE_BLOCK)) {
+			} else if ((flags & kFlagWater) && (e->type == AI_MAGIC_EGG || e->type == AI_ICE_BLOCK)) {
 				// And no foreground tile is there
 				if (g_hdb->_map->getMapFGTileIndex(e->tileX, e->tileY) < 0 && !checkFloating(e->tileX, e->tileY)) {
 					if ((flags & kFlagSlime) == kFlagSlime) {


Commit: cfa90aa7bfc5a5b30b5e26210596dc251f62e353
    https://github.com/scummvm/scummvm/commit/cfa90aa7bfc5a5b30b5e26210596dc251f62e353
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:29+02:00

Commit Message:
HDB: Added more demo Lua constants

Changed paths:
    engines/hdb/lua-script.cpp
    engines/hdb/mpc.h


diff --git a/engines/hdb/lua-script.cpp b/engines/hdb/lua-script.cpp
index 5d963da..082fa04 100644
--- a/engines/hdb/lua-script.cpp
+++ b/engines/hdb/lua-script.cpp
@@ -1513,6 +1513,8 @@ struct VarInit {
 	{ MONKEYLOGOSCREEN,					"PIC_MONKEYLOGOSCREEN"	},
 	{ MONKEYLOGO_OOHOOH,				"PIC_MONKEYLOGO_OOHOOH" },
 	{ MONKEYLOGO_SMILE,					"PIC_MONKEYLOGO_SMILE"	},
+	{ PIC_DEMOSCREEN,					"PIC_DEMOSCREEN" },
+	{ PIC_DEMOSCREEN2,					"PIC_DEMOSCREEN2" },
 	{ PIC_ENV_WHITE,					"PIC_ENV_WHITE" },
 	{ PIC_TEAM_BRIAN,					"PIC_TEAM_BRIAN" },
 	{ PIC_TEAM_STEVIE,					"PIC_TEAM_STEVIE" },
diff --git a/engines/hdb/mpc.h b/engines/hdb/mpc.h
index 137a5b3..6f2b734 100644
--- a/engines/hdb/mpc.h
+++ b/engines/hdb/mpc.h
@@ -565,6 +565,8 @@ namespace HDB {
 #define		MONKEYLOGOSCREEN				"monkeylogoscreen"
 #define		MONKEYLOGO_OOHOOH				"monkeylogo_oohooh"
 #define		MONKEYLOGO_SMILE				"monkeylogo_smile"
+#define		PIC_DEMOSCREEN					"pic_demoscreen"
+#define		PIC_DEMOSCREEN2					"pic_demoscreen2"
 #define		BACKSCROLL_PLANET1				"backscroll_planet1"
 #define		BACKSCROLL_PLANET2				"backscroll_planet2"
 #define		BACKSCROLL_PLANET3				"backscroll_planet3"


Commit: 0a6cd0a99aa27a5ad8b2450c980e30d20262094e
    https://github.com/scummvm/scummvm/commit/0a6cd0a99aa27a5ad8b2450c980e30d20262094e
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:29+02:00

Commit Message:
JANITORIAL: Beautify table formatting

Changed paths:
    engines/hdb/sound.cpp


diff --git a/engines/hdb/sound.cpp b/engines/hdb/sound.cpp
index 9d3b80c..fef2945 100644
--- a/engines/hdb/sound.cpp
+++ b/engines/hdb/sound.cpp
@@ -42,337 +42,337 @@ const SoundLookUp soundList[] =  {
 	//
 	//	enum value			hyperspace_msd.h			lua global name
 	//---------------------------------------------------------------
-	{SONG_NONE,			POP_WAV,					"SND_POP" },
-	{SND_GUI_INPUT,		FUTUREBEEP2_WAV,			"SND_GUI_INPUT"},
-	{SND_MAIL_PROCESS,	COMPUTERPROCESS_WAV,		"SND_MAIL_PROCESS"},
-	{SND_MONKEY_OOHOOH,	MONKEY_OOHOOH_WAV,			"SND_MONKEY_OOHOOH"},
-	{SND_GET_GEM,		GET_GEM_WAV,				"SND_GET_GEM"},
-	{SND_MENU_ACCEPT,	MENU_ACCEPT_WAV,			"SND_MENU_ACCEPT"},
-	{SND_MENU_BACKOUT,	MENU_BACKOUT_WAV,			"SND_MENU_BACKOUT"},
-	{SND_MENU_SLIDER,	MENU_SLIDER_WAV,			"SND_MENU_SLIDER"},
-	{SND_DIALOG_CLOSE,	DIALOG_CLOSE_WAV,			"SND_DIALOG_CLOSE"},
-	{SND_CRATE_SLIDE,	CRATE_SLIDE_WAV,			"SND_CRATE_SLIDE"},
-	{SND_LIGHT_SLIDE,	LIGHT_SLIDE_WAV,			"SND_LIGHT_SLIDE"},
-	{SND_HEAVY_SLIDE,	HEAVY_SLIDE_WAV,			"SND_HEAVY_SLIDE"},
-	{SND_POP,			POP_WAV,					"SND_POP"},
-	{SND_TELEPORT,		TELEPORT3_WAV,				"SND_TELEPORT"},
-	{SND_FOOTSTEPS,		FOOTSTEPS_WAV,				"SND_FOOTSTEPS"},
+	{SONG_NONE,				POP_WAV,					"SND_POP" },
+	{SND_GUI_INPUT,			FUTUREBEEP2_WAV,			"SND_GUI_INPUT"},
+	{SND_MAIL_PROCESS,		COMPUTERPROCESS_WAV,		"SND_MAIL_PROCESS"},
+	{SND_MONKEY_OOHOOH,		MONKEY_OOHOOH_WAV,			"SND_MONKEY_OOHOOH"},
+	{SND_GET_GEM,			GET_GEM_WAV,				"SND_GET_GEM"},
+	{SND_MENU_ACCEPT,		MENU_ACCEPT_WAV,			"SND_MENU_ACCEPT"},
+	{SND_MENU_BACKOUT,		MENU_BACKOUT_WAV,			"SND_MENU_BACKOUT"},
+	{SND_MENU_SLIDER,		MENU_SLIDER_WAV,			"SND_MENU_SLIDER"},
+	{SND_DIALOG_CLOSE,		DIALOG_CLOSE_WAV,			"SND_DIALOG_CLOSE"},
+	{SND_CRATE_SLIDE,		CRATE_SLIDE_WAV,			"SND_CRATE_SLIDE"},
+	{SND_LIGHT_SLIDE,		LIGHT_SLIDE_WAV,			"SND_LIGHT_SLIDE"},
+	{SND_HEAVY_SLIDE,		HEAVY_SLIDE_WAV,			"SND_HEAVY_SLIDE"},
+	{SND_POP,				POP_WAV,					"SND_POP"},
+	{SND_TELEPORT,			TELEPORT3_WAV,				"SND_TELEPORT"},
+	{SND_FOOTSTEPS,			FOOTSTEPS_WAV,				"SND_FOOTSTEPS"},
 	{SND_SPLASH,			SPLASH_WAV,					"SND_SPLASH"},
 	{SND_CELLHOLDER_USE_REJECT, CELLHOLDER_USE_REJECT_WAV, "SND_CELLHOLDER_USE_REJECT"},
-	{SND_CHICKEN_AMBIENT, CHICKEN_AMBIENT_WAV,		"SND_CHICKEN_AMBIENT"},
-	{SND_FERRET_SQUEAK,	FERRET_SQUEAK_WAV,			"SND_FERRET_SQUEAK"},
+	{SND_CHICKEN_AMBIENT,	CHICKEN_AMBIENT_WAV,		"SND_CHICKEN_AMBIENT"},
+	{SND_FERRET_SQUEAK,		FERRET_SQUEAK_WAV,			"SND_FERRET_SQUEAK"},
 	{SND_SWITCH_USE,		SWITCH_USE_WAV,				"SND_SWITCH_USE"},
 	{SND_MOVE_SELECTION,	MOVE_SELECTION_WAV,			"SND_MOVE_SELECTION"},
 	{SND_NOTICE,			NOTICE_WAV,					"SND_NOTICE"},
-	{SND_MAINTBOT_WHOOSH1,	MAINTBOT_WHOOSH1_WAV,	"SND_MAINTBOT_WHOOSH1"},
-	{SND_MAINTBOT_WHOOSH2,	MAINTBOT_WHOOSH2_WAV,	"SND_MAINTBOT_WHOOSH2"},
-	{SND_SHIPMOVING_INTRO,	SHIP_MOVING_INTRO_WAV,	"SND_SHIPMOVING_INTRO"},
-	{SND_DIALOG_OPEN,	DIALOG_OPEN_WAV,			"SND_DIALOG_OPEN"},
-	{SND_TOUCHPLATE_CLICK,	TOUCHPLATE_CLICK_WAV,	"SND_TOUCHPLATE_CLICK"},
-	{SND_DOOR_OPEN_CLOSE, DOOR_OPEN_CLOSE_WAV,		"SND_DOOR_OPEN_CLOSE"},
+	{SND_MAINTBOT_WHOOSH1,	MAINTBOT_WHOOSH1_WAV,		"SND_MAINTBOT_WHOOSH1"},
+	{SND_MAINTBOT_WHOOSH2,	MAINTBOT_WHOOSH2_WAV,		"SND_MAINTBOT_WHOOSH2"},
+	{SND_SHIPMOVING_INTRO,	SHIP_MOVING_INTRO_WAV,		"SND_SHIPMOVING_INTRO"},
+	{SND_DIALOG_OPEN,		DIALOG_OPEN_WAV,			"SND_DIALOG_OPEN"},
+	{SND_TOUCHPLATE_CLICK,	TOUCHPLATE_CLICK_WAV,		"SND_TOUCHPLATE_CLICK"},
+	{SND_DOOR_OPEN_CLOSE, 	DOOR_OPEN_CLOSE_WAV,		"SND_DOOR_OPEN_CLOSE"},
 	{SND_MBOT_HYEAH,		MBOT_HYEAH_WAV,				"SND_MBOT_HYEAH"},
-	{SND_MBOT_YEAH,		MBOT_YEAH_WAV,				"SND_MBOT_YEAH"},
-	{SND_MBOT_WHISTLE1,	MBOT_WHISTLE1_WAV,			"SND_MBOT_WHISTLE1"},
-	{SND_CLUB_MISS,		CLUB_MISS_WAV,				"SND_CLUB_MISS"},
+	{SND_MBOT_YEAH,			MBOT_YEAH_WAV,				"SND_MBOT_YEAH"},
+	{SND_MBOT_WHISTLE1,		MBOT_WHISTLE1_WAV,			"SND_MBOT_WHISTLE1"},
+	{SND_CLUB_MISS,			CLUB_MISS_WAV,				"SND_CLUB_MISS"},
 	{SND_CLUB_HIT_METAL,	CLUB_HIT_METAL_WAV,			"SND_CLUB_HIT_METAL"},
 	{SND_CLUB_HIT_FLESH,	CLUB_HIT_FLESH_WAV,			"SND_CLUB_HIT_FLESH"},
-	{SND_FROG_LICK,		FROG_LICK_WAV,				"SND_FROG_LICK"},
-	{SND_ROBOT_STUNNED,	ROBOT_STUNNED_WAV,			"SND_ROBOT_STUNNED"},
-	{SND_QUEST_FAILED,	QUEST_FAILED_WAV,			"SND_QUEST_FAILED"},
-	{SND_GET_MONKEYSTONE,GET_MONKEYSTONE_WAV,		"SND_GET_MONKEYSTONE"},
-	{SND_INSERT_CELL,	INSERT_CELL_WAV,			"SND_INSERT_CELL"},
-	{SND_CABINET_OPEN,	CABINET_OPEN_WAV,			"SND_CABINET_OPEN"},
-	{SND_CABINET_CLOSE,	CABINET_CLOSE_WAV,			"SND_CABINET_CLOSE"},
-	{SND_MAILSORTER_HAPPY,MAILSORTER_HAPPY_WAV,		"SND_MAILSORTER_HAPPY"},
+	{SND_FROG_LICK,			FROG_LICK_WAV,				"SND_FROG_LICK"},
+	{SND_ROBOT_STUNNED,		ROBOT_STUNNED_WAV,			"SND_ROBOT_STUNNED"},
+	{SND_QUEST_FAILED,		QUEST_FAILED_WAV,			"SND_QUEST_FAILED"},
+	{SND_GET_MONKEYSTONE,	GET_MONKEYSTONE_WAV,		"SND_GET_MONKEYSTONE"},
+	{SND_INSERT_CELL,		INSERT_CELL_WAV,			"SND_INSERT_CELL"},
+	{SND_CABINET_OPEN,		CABINET_OPEN_WAV,			"SND_CABINET_OPEN"},
+	{SND_CABINET_CLOSE,		CABINET_CLOSE_WAV,			"SND_CABINET_CLOSE"},
+	{SND_MAILSORTER_HAPPY,	MAILSORTER_HAPPY_WAV,		"SND_MAILSORTER_HAPPY"},
 	{SND_QUEST_COMPLETE,	QUEST_COMPLETE_WAV,			"SND_QUEST_COMPLETE"},
-	{SND_TRY_AGAIN,		TRY_AGAIN_WAV,				"SND_TRY_AGAIN"},
-	{SND_AIRLOCK_CLOSE,	AIRLOCK_CLOSE_WAV,			"SND_AIRLOCK_CLOSE"},
-	{SND_BYE,			BYE_WAV,					"SND_BYE"},
-	{SND_FART,			FART_WAV,					"SND_FART"},
-	{SND_FART2,			FART2_WAV,					"SND_FART2"},
-	{SND_GUY_UHUH,		GUY_UHUH_WAV,				"SND_GUY_UHUH"},
-	{SND_GUY_DYING,		GUY_DYING_WAV,				"SND_GUY_DYING"},
-	{SND_GEM_THROW,		GEM_THROW_WAV,				"SND_GEM_THROW"},
+	{SND_TRY_AGAIN,			TRY_AGAIN_WAV,				"SND_TRY_AGAIN"},
+	{SND_AIRLOCK_CLOSE,		AIRLOCK_CLOSE_WAV,			"SND_AIRLOCK_CLOSE"},
+	{SND_BYE,				BYE_WAV,					"SND_BYE"},
+	{SND_FART,				FART_WAV,					"SND_FART"},
+	{SND_FART2,				FART2_WAV,					"SND_FART2"},
+	{SND_GUY_UHUH,			GUY_UHUH_WAV,				"SND_GUY_UHUH"},
+	{SND_GUY_DYING,			GUY_DYING_WAV,				"SND_GUY_DYING"},
+	{SND_GEM_THROW,			GEM_THROW_WAV,				"SND_GEM_THROW"},
 	{SND_INV_SELECT,		INV_SELECT_WAV,				"SND_INV_SELECT"},
-	{SND_INFOCOMP,		INFOCOMP_WAV,				"SND_INFOCOMP"},
+	{SND_INFOCOMP,			INFOCOMP_WAV,				"SND_INFOCOMP"},
 	{SND_CLOCK_BONK,		CLOCK_BONK_WAV,				"SND_CLOCK_BONK"},
-	{SND_HDB,			HDB_WAV,					"SND_HDB"},
-	{SND_VORTEX_SAVE,	VORTEXIAN_SAVE_WAV,			"SND_VORTEX_SAVE"},
-	{SND_GET_GOO,		GET_GOO_WAV,				"SND_GET_GOO"},
-	{SND_MANNY_CRASH,	MANNY_CRASH_WAV,			"SND_MANNY_CRASH"},
+	{SND_HDB,				HDB_WAV,					"SND_HDB"},
+	{SND_VORTEX_SAVE,		VORTEXIAN_SAVE_WAV,			"SND_VORTEX_SAVE"},
+	{SND_GET_GOO,			GET_GOO_WAV,				"SND_GET_GOO"},
+	{SND_MANNY_CRASH,		MANNY_CRASH_WAV,			"SND_MANNY_CRASH"},
 	{SND_BARREL_EXPLODE,	BARREL_EXPLODE_WAV,			"SND_BARREL_EXPLODE"},
 	{SND_BARREL_MELTING,	BARREL_MELTING_WAV,			"SND_BARREL_MELTING"},
 	{SND_CHICKEN_BAGAWK,	CHICKEN_BAGAWK_WAV,			"SND_CHICKEN_BAGAWK"},
-	{SND_CHICKEN_DEATH,	CHICKEN_DEATH_WAV,			"SND_CHICKEN_DEATH"},
-	{SND_GET_THING,		GET_THING_WAV,				"SND_GET_THING"},
-	{SND_STEPS_ICE,		STEPS_ICE_WAV,				"SND_STEPS_ICE"},
-	{SND_FOURFIRE_TURN,	FOURFIRE_TURN_WAV,			"SND_FOURFIRE_TURN"},
-	{SND_FOUR_FIRE,		FOUR_FIRE_WAV,				"SND_FOUR_FIRE"},
-	{SND_SHOCKBOT_AMBIENT,SHOCKBOT_AMBIENT_WAV,		"SND_SHOCKBOT_AMBIENT"},
+	{SND_CHICKEN_DEATH,		CHICKEN_DEATH_WAV,			"SND_CHICKEN_DEATH"},
+	{SND_GET_THING,			GET_THING_WAV,				"SND_GET_THING"},
+	{SND_STEPS_ICE,			STEPS_ICE_WAV,				"SND_STEPS_ICE"},
+	{SND_FOURFIRE_TURN,		FOURFIRE_TURN_WAV,			"SND_FOURFIRE_TURN"},
+	{SND_FOUR_FIRE,			FOUR_FIRE_WAV,				"SND_FOUR_FIRE"},
+	{SND_SHOCKBOT_AMBIENT,	SHOCKBOT_AMBIENT_WAV,		"SND_SHOCKBOT_AMBIENT"},
 	{SND_SHOCKBOT_SHOCK,	SHOCKBOT_SHOCK_WAV,			"SND_SHOCKBOT_SHOCK"},
-	{SND_RAILRIDER_ONTRACK,RAILRIDER_ONTRACK_WAV,	"SND_RAILRIDER_ONTRACK"},
-	{SND_RAILRIDER_TASTE, RAILRIDER_TASTE_WAV,		"SND_RAILRIDER_TASTE"},
+	{SND_RAILRIDER_ONTRACK,	RAILRIDER_ONTRACK_WAV,		"SND_RAILRIDER_ONTRACK"},
+	{SND_RAILRIDER_TASTE, 	RAILRIDER_TASTE_WAV,		"SND_RAILRIDER_TASTE"},
 	{SND_RAILRIDER_EXIT,	RAILRIDER_EXIT_WAV,			"SND_RAILRIDER_EXIT"},
-	{SND_GUY_FRIED,		GUY_FRIED_WAV,				"SND_GUY_FRIED"},
-	{SND_MAILSORTER_UNHAPPY,	MAILSORTER_UNHAPPY_WAV,	"SND_MAILSORTER_UNHAPPY"},
-	{SND_GET_CLUB,		GET_CLUB_WAV,				"SND_GET_CLUB"},
-	{SND_GUY_GRABBED,	GUY_GRABBED_WAV,			"SND_GUY_GRABBED"},
-	{SND_GUY_DROWN,		GUY_DROWN_WAV,				"SND_GUY_DROWN"},
-	{SND_BUZZFLY_FLY,	BUZZFLY_AMBIENT_WAV,		"SND_BUZZFLY_FLY"},
-	{SND_BUZZFLY_STUNNED, BUZZFLY_STUNNED_WAV,		"SND_BUZZFLY_STUNNED"},
-	{SND_BUZZFLY_STING,	BUZZFLY_STING_WAV,			"SND_BUZZFLY_STING"},
-	{SND_FATFROG_STUNNED, FATFROG_STUNNED_WAV,		"SND_FATFROG_STUNNED"},
-	{SND_NOPUSH_SIZZLE,	GUY_NOPUSH_SIZZLE_WAV,		"SND_NOPUSH_SIZZLE"},
-	{SND_OMNIBOT_FIRE,	OMNIBOT_FIRE_WAV,			"SND_OMNIBOT_FIRE"},
-	{SND_RIGHTBOT_TURN,	RIGHTBOT_TURN_WAV,			"SND_RIGHTBOT_TURN"},
-	{SND_RIGHTBOT_STUNNED, RIGHTBOT_STUNNED_WAV,		"SND_RIGHTBOT_STUNNED"},
+	{SND_GUY_FRIED,			GUY_FRIED_WAV,				"SND_GUY_FRIED"},
+	{SND_MAILSORTER_UNHAPPY,MAILSORTER_UNHAPPY_WAV,		"SND_MAILSORTER_UNHAPPY"},
+	{SND_GET_CLUB,			GET_CLUB_WAV,				"SND_GET_CLUB"},
+	{SND_GUY_GRABBED,		GUY_GRABBED_WAV,			"SND_GUY_GRABBED"},
+	{SND_GUY_DROWN,			GUY_DROWN_WAV,				"SND_GUY_DROWN"},
+	{SND_BUZZFLY_FLY,		BUZZFLY_AMBIENT_WAV,		"SND_BUZZFLY_FLY"},
+	{SND_BUZZFLY_STUNNED,	BUZZFLY_STUNNED_WAV,		"SND_BUZZFLY_STUNNED"},
+	{SND_BUZZFLY_STING,		BUZZFLY_STING_WAV,			"SND_BUZZFLY_STING"},
+	{SND_FATFROG_STUNNED, 	FATFROG_STUNNED_WAV,		"SND_FATFROG_STUNNED"},
+	{SND_NOPUSH_SIZZLE,		GUY_NOPUSH_SIZZLE_WAV,		"SND_NOPUSH_SIZZLE"},
+	{SND_OMNIBOT_FIRE,		OMNIBOT_FIRE_WAV,			"SND_OMNIBOT_FIRE"},
+	{SND_RIGHTBOT_TURN,		RIGHTBOT_TURN_WAV,			"SND_RIGHTBOT_TURN"},
+	{SND_RIGHTBOT_STUNNED,	RIGHTBOT_STUNNED_WAV,		"SND_RIGHTBOT_STUNNED"},
 	{SND_MONKEY_WIN,		MONKEY_WIN_WAV,				"SND_MONKEY_WIN"},
 	{SND_FALL_DOWN_HOLE,	FALL_DOWN_HOLE_WAV,			"SND_FALL_DOWN_HOLE"},
-	{SND_MBOT_HMMM,		MBOT_HMMM_WAV,				"SND_MBOT_HMMM"},
+	{SND_MBOT_HMMM,			MBOT_HMMM_WAV,				"SND_MBOT_HMMM"},
 	{SND_MBOT_HMMM2,		MBOT_HMMM2_WAV,				"SND_MBOT_HMMM2"},
 	{SND_MBOT_DEATH,		MBOT_DEATH_WAV,				"SND_MBOT_DEATH"},
-	{SND_MBOT_WHISTLE2,	MBOT_WHISTLE2_WAV,			"SND_MBOT_WHISTLE2"},
-	{SND_MBOT_WHISTLE3,	MBOT_WHISTLE3_WAV,			"SND_MBOT_WHISTLE3"},
-	{SND_DEADEYE_AMB01,	DEADEYE_AMBIENT01_WAV,		"SND_DEADEYE_AMB01"},
-	{SND_DEADEYE_AMB02,	DEADEYE_AMBIENT02_WAV,		"SND_DEADEYE_AMB02"},
-	{SND_DEADEYE_ATTACK01,DEADEYE_GROWL01_WAV,		"SND_DEADEYE_ATTACK01"},
-	{SND_DEADEYE_ATTACK02,DEADEYE_GROWL02_WAV,		"SND_DEADEYE_ATTACK02"},
-	{SND_FROG_RIBBIT1,	FROG_RIBBIT1_WAV,			"SND_FROG_RIBBIT1"},
-	{SND_FROG_RIBBIT2,	FROG_RIBBIT2_WAV,			"SND_FROG_RIBBIT2"},
-	{SND_MEERKAT_BITE,	MEERKAT_BITE_WAV,			"SND_MEERKAT_BITE"},
-	{SND_BRIDGE_EXTEND,	BRIDGE_EXTEND_WAV,			"SND_BRIDGE_EXTEND"},
-	{SND_BRIDGE_START,	BRIDGE_START_WAV,			"SND_BRIDGE_START"},
+	{SND_MBOT_WHISTLE2,		MBOT_WHISTLE2_WAV,			"SND_MBOT_WHISTLE2"},
+	{SND_MBOT_WHISTLE3,		MBOT_WHISTLE3_WAV,			"SND_MBOT_WHISTLE3"},
+	{SND_DEADEYE_AMB01,		DEADEYE_AMBIENT01_WAV,		"SND_DEADEYE_AMB01"},
+	{SND_DEADEYE_AMB02,		DEADEYE_AMBIENT02_WAV,		"SND_DEADEYE_AMB02"},
+	{SND_DEADEYE_ATTACK01,	DEADEYE_GROWL01_WAV,		"SND_DEADEYE_ATTACK01"},
+	{SND_DEADEYE_ATTACK02,	DEADEYE_GROWL02_WAV,		"SND_DEADEYE_ATTACK02"},
+	{SND_FROG_RIBBIT1,		FROG_RIBBIT1_WAV,			"SND_FROG_RIBBIT1"},
+	{SND_FROG_RIBBIT2,		FROG_RIBBIT2_WAV,			"SND_FROG_RIBBIT2"},
+	{SND_MEERKAT_BITE,		MEERKAT_BITE_WAV,			"SND_MEERKAT_BITE"},
+	{SND_BRIDGE_EXTEND,		BRIDGE_EXTEND_WAV,			"SND_BRIDGE_EXTEND"},
+	{SND_BRIDGE_START,		BRIDGE_START_WAV,			"SND_BRIDGE_START"},
 	{SND_BRIDGE_END,		BRIDGE_END_WAV,				"SND_BRIDGE_END"},
-	{SND_MACHINE_AMBIENT1,MACHINE_AMBIENT1_WAV,		"SND_MACHINE_AMBIENT1"},
-	{SND_GET_STUNNER,	GET_STUNNER_WAV,			"SND_GET_STUNNER"},
-	{SND_GET_SLUG,		GET_SLUG_WAV,				"SND_GET_SLUG"},
-	{SND_PANIC,			PANIC_WAV,					"SND_PANIC"},
-	{SND_PANIC_COUNT,	PANIC_TIMER_WAV,			"SND_PANIC_COUNT"},
-	{SND_PANIC_DEATH,	PANIC_DEATH_WAV,			"SND_PANIC_DEATH"},
+	{SND_MACHINE_AMBIENT1,	MACHINE_AMBIENT1_WAV,		"SND_MACHINE_AMBIENT1"},
+	{SND_GET_STUNNER,		GET_STUNNER_WAV,			"SND_GET_STUNNER"},
+	{SND_GET_SLUG,			GET_SLUG_WAV,				"SND_GET_SLUG"},
+	{SND_PANIC,				PANIC_WAV,					"SND_PANIC"},
+	{SND_PANIC_COUNT,		PANIC_TIMER_WAV,			"SND_PANIC_COUNT"},
+	{SND_PANIC_DEATH,		PANIC_DEATH_WAV,			"SND_PANIC_DEATH"},
 	{SND_LASER_LOOP,		LASER_LOOP_WAV,				"SND_LASER_LOOP"},
-	{SND_SLOT_WIN,		SLOT_WIN_WAV,				"SND_SLOT_WIN"},
-	{SND_SLOT_SPIN,		SLOT_SPIN_WAV,				"SND_SLOT_SPIN"},
-	{SND_SLOT_STOP,		SLOT_STOP_WAV,				"SND_SLOT_STOP"},
-	{SND_GOOD_FAERIE_AMBIENT,	GOOD_FAERIE_AMBIENT_WAV, "SND_GOOD_FAERIE_AMBIENT"},
+	{SND_SLOT_WIN,			SLOT_WIN_WAV,				"SND_SLOT_WIN"},
+	{SND_SLOT_SPIN,			SLOT_SPIN_WAV,				"SND_SLOT_SPIN"},
+	{SND_SLOT_STOP,			SLOT_STOP_WAV,				"SND_SLOT_STOP"},
+	{SND_GOOD_FAERIE_AMBIENT,	GOOD_FAERIE_AMBIENT_WAV,"SND_GOOD_FAERIE_AMBIENT"},
 	{SND_GOOD_FAERIE_SPELL,		GOOD_FAERIE_SPELL_WAV,	"SND_GOOD_FAERIE_SPELL"},
-	{SND_GOOD_FAERIE_STUNNED,	GOOD_FAERIE_STUNNED_WAV,	"SND_GOOD_FAERIE_STUNNED"},
-	{SND_ICEPUFF_WARNING,	ICEPUFF_WARNING_WAV,	"SND_ICEPUFF_WARNING"},
-	{SND_ICEPUFF_THROW,		ICEPUFF_THROW_WAV,		"SND_ICEPUFF_THROW"},
-	{SND_ICEPUFF_STUNNED,	ICEPUFF_STUNNED_WAV,	"SND_ICEPUFF_STUNNED"},
-	{SND_ICEPUFF_APPEAR,		ICEPUFF_APPEAR_WAV,		"SND_ICEPUFF_APPEAR"},
-	{SND_GUY_PLUMMET,	GUY_PLUMMET_WAV,			"SND_GUY_PLUMMET"},
-	{SND_PUSH_DIVERTER,	LASERD_PUSH_WAV,			"SND_PUSH_DIVERTER"},
-	{SND_TURNBOT_TURN,		TURNBOT_TURN_WAV,		"SND_TURNBOT_TURN"},
+	{SND_GOOD_FAERIE_STUNNED,	GOOD_FAERIE_STUNNED_WAV,"SND_GOOD_FAERIE_STUNNED"},
+	{SND_ICEPUFF_WARNING,	ICEPUFF_WARNING_WAV,		"SND_ICEPUFF_WARNING"},
+	{SND_ICEPUFF_THROW,		ICEPUFF_THROW_WAV,			"SND_ICEPUFF_THROW"},
+	{SND_ICEPUFF_STUNNED,	ICEPUFF_STUNNED_WAV,		"SND_ICEPUFF_STUNNED"},
+	{SND_ICEPUFF_APPEAR,	ICEPUFF_APPEAR_WAV,			"SND_ICEPUFF_APPEAR"},
+	{SND_GUY_PLUMMET,		GUY_PLUMMET_WAV,			"SND_GUY_PLUMMET"},
+	{SND_PUSH_DIVERTER,		LASERD_PUSH_WAV,			"SND_PUSH_DIVERTER"},
+	{SND_TURNBOT_TURN,		TURNBOT_TURN_WAV,			"SND_TURNBOT_TURN"},
 	{SND_PUSHBOT_STRAIN,	PUSHBOT_STRAIN_WAV,			"SND_PUSHBOT_STRAIN"},
 	{SND_MONKEYSTONE_SECRET_STAR, MONKEYSTONE_SECRET_STAR_WAV, "SND_MONKEYSTONE_SECRET_STAR"},
-	{SND_OMNIBOT_AMBIENT, OMNIBOT_AMBIENT_WAV,		"SND_OMNIBOT_AMBIENT"},
-	{SND_PUSHBOT_STUNNED,	PUSHBOT_STUNNED_WAV,	"SND_PUSHBOT_STUNNED"},
-	{SND_MEERKAT_WARNING,	MEERKAT_WARNING_WAV,	"SND_MEERKAT_WARNING"},
-	{SND_MEERKAT_APPEAR,		MEERKAT_APPEAR_WAV,		"SND_MEERKAT_APPEAR"},
-	{SND_MEERKAT_STUNNED,	MEERKAT_STUNNED_WAV,	"SND_MEERKAT_STUNNED"},
-	{SND_TURNBOT_STUNNED,	TURNBOT_STUNNED_WAV,	"SND_TURNBOT_STUNNED"},
-	{SND_DRAGON_WAKE,		DRAGON_WAKE_WAV,		"SND_DRAGON_WAKE"},
-	{SND_DRAGON_FALLASLEEP,	DRAGON_FALL_ASLEEP_WAV,	"SND_DRAGON_FALLASLEEP"},
-	{SND_DRAGON_BREATHEFIRE,	DRAGON_BREATHE_FIRE_WAV,	"SND_DRAGON_BREATHEFIRE"},
+	{SND_OMNIBOT_AMBIENT, 	OMNIBOT_AMBIENT_WAV,		"SND_OMNIBOT_AMBIENT"},
+	{SND_PUSHBOT_STUNNED,	PUSHBOT_STUNNED_WAV,		"SND_PUSHBOT_STUNNED"},
+	{SND_MEERKAT_WARNING,	MEERKAT_WARNING_WAV,		"SND_MEERKAT_WARNING"},
+	{SND_MEERKAT_APPEAR,	MEERKAT_APPEAR_WAV,			"SND_MEERKAT_APPEAR"},
+	{SND_MEERKAT_STUNNED,	MEERKAT_STUNNED_WAV,		"SND_MEERKAT_STUNNED"},
+	{SND_TURNBOT_STUNNED,	TURNBOT_STUNNED_WAV,		"SND_TURNBOT_STUNNED"},
+	{SND_DRAGON_WAKE,		DRAGON_WAKE_WAV,			"SND_DRAGON_WAKE"},
+	{SND_DRAGON_FALLASLEEP,	DRAGON_FALL_ASLEEP_WAV,		"SND_DRAGON_FALLASLEEP"},
+	{SND_DRAGON_BREATHEFIRE,DRAGON_BREATHE_FIRE_WAV,	"SND_DRAGON_BREATHEFIRE"},
 	{SND_BADFAIRY_AMBIENT,	BAD_FAERIE_AMBIENT_WAV,		"SND_BADFAIRY_AMBIENT"},
-	{SND_BADFAIRY_SPELL,		BAD_FAERIE_SPELL_WAV,		"SND_BADFAIRY_SPELL"},
+	{SND_BADFAIRY_SPELL,	BAD_FAERIE_SPELL_WAV,		"SND_BADFAIRY_SPELL"},
 	{SND_BADFAIRY_STUNNED,	BAD_FAERIE_STUNNED_WAV,		"SND_BADFAIRY_STUNNED"},
-	{SND_DEMIGOD_AMBIENT,	DEMIGOD_AMBIENT_WAV,	"SND_DEMIGOD_AMBIENT"},
-	{SND_DEMIGOD_HOLYSPEECH,	DEMIGOD_HOLYSPEECH_WAV,	"SND_DEMIGOD_HOLYSPEECH"},
-	{SND_DEMIGOD_UNHAPPY,	DEMIGOD_UNHAPPY_WAV,	"SND_DEMIGOD_UNHAPPY"},
-	{SND_GATEPUDDLE_AMBIENT,	GATEPUDDLE_AMBIENT_WAV,	"SND_GATEPUDDLE_AMBIENT"},
+	{SND_DEMIGOD_AMBIENT,	DEMIGOD_AMBIENT_WAV,		"SND_DEMIGOD_AMBIENT"},
+	{SND_DEMIGOD_HOLYSPEECH,DEMIGOD_HOLYSPEECH_WAV,		"SND_DEMIGOD_HOLYSPEECH"},
+	{SND_DEMIGOD_UNHAPPY,	DEMIGOD_UNHAPPY_WAV,		"SND_DEMIGOD_UNHAPPY"},
+	{SND_GATEPUDDLE_AMBIENT,GATEPUDDLE_AMBIENT_WAV,		"SND_GATEPUDDLE_AMBIENT"},
 	{SND_GATEPUDDLE_DISSIPATE, GATEPUDDLE_DISSIPATE_WAV, "SND_GATEPUDDLE_DISSIPATE"},
-	{SND_GATEPUDDLE_SPAWN,	GATEPUDDLE_SPAWN_WAV,	"SND_GATEPUDDLE_SPAWN"},
-	{SND_REALSLOT_SPIN,		SLOTMACHINE_SPINS_WAV,	"SND_REALSLOT_SPIN"},
-	{SND_REALSLOT_STOP,		SLOTMACHINE_STOP_WAV,	"SND_REALSLOT_STOP"},
-	{SND_REALSLOT_WIN,		SLOTMACHINE_WIN_WAV,	"SND_REALSLOT_WIN"},
-	{SND_SLUG_FIRE,			SLUG_FIRE_WAV,			"SND_SLUG_FIRE"},
-	{SND_SLUG_HIT,			SLUG_HIT_WAV,			"SND_SLUG_HIT"},
-	{SND_STUNNER_FIRE,		STUNNER_ZAP_WAV,		"SND_STUNNER_FIRE"},
-	{SND_UNLOCKED_ITEM,		UNLOCKED_ITEM_WAV,		"SND_UNLOCKED_ITEM"},
+	{SND_GATEPUDDLE_SPAWN,	GATEPUDDLE_SPAWN_WAV,		"SND_GATEPUDDLE_SPAWN"},
+	{SND_REALSLOT_SPIN,		SLOTMACHINE_SPINS_WAV,		"SND_REALSLOT_SPIN"},
+	{SND_REALSLOT_STOP,		SLOTMACHINE_STOP_WAV,		"SND_REALSLOT_STOP"},
+	{SND_REALSLOT_WIN,		SLOTMACHINE_WIN_WAV,		"SND_REALSLOT_WIN"},
+	{SND_SLUG_FIRE,			SLUG_FIRE_WAV,				"SND_SLUG_FIRE"},
+	{SND_SLUG_HIT,			SLUG_HIT_WAV,				"SND_SLUG_HIT"},
+	{SND_STUNNER_FIRE,		STUNNER_ZAP_WAV,			"SND_STUNNER_FIRE"},
+	{SND_UNLOCKED_ITEM,		UNLOCKED_ITEM_WAV,			"SND_UNLOCKED_ITEM"},
 
 		//
 		// MP1/2 music - external to .MPC file; they're in a MUSIC subdir
 		//
 	{SONG_TITLE,			SFNAME_TITLE,				"SONG_TITLE"},
-	{SONG_MENU,			SFNAME_MENU,				"SONG_MENU"},
-	{SONG_ROBO,			SFNAME_ROBO,				"SONG_ROBO"},
-	{SONG_MEXI,			SFNAME_MEXI,				"SONG_MEXI"},
+	{SONG_MENU,				SFNAME_MENU,				"SONG_MENU"},
+	{SONG_ROBO,				SFNAME_ROBO,				"SONG_ROBO"},
+	{SONG_MEXI,				SFNAME_MEXI,				"SONG_MEXI"},
 	{SONG_BASSO,			SFNAME_BASSO,				"SONG_BASSO"},
-	{SONG_WIND,			SFNAME_WIND,				"SONG_WIND"},
-	{SONG_INDUSTRO,		SFNAME_INDUSTRO,			"SONG_INDUSTRO"},
-	{SONG_JACKIN,		SFNAME_JACKIN,				"SONG_JACKIN"},
-	{SONG_SNEAKERS,		SFNAME_SNEAKERS,			"SONG_SNEAKERS"},
+	{SONG_WIND,				SFNAME_WIND,				"SONG_WIND"},
+	{SONG_INDUSTRO,			SFNAME_INDUSTRO,			"SONG_INDUSTRO"},
+	{SONG_JACKIN,			SFNAME_JACKIN,				"SONG_JACKIN"},
+	{SONG_SNEAKERS,			SFNAME_SNEAKERS,			"SONG_SNEAKERS"},
 	{SONG_QUIET,			SFNAME_QUIET,				"SONG_QUIET"},
-	{SONG_JEEBIES,		SFNAME_JEEBIES,				"SONG_JEEBIES"},
-	{SONG_VIBRACIOUS,	SFNAME_VIBRACIOUS,			"SONG_VIBRACIOUS"},
-	{SONG_ROMANTIC,		SFNAME_ROMANTIC,			"SONG_ROMANTIC"},
-	{SONG_ARETHERE,		SFNAME_ARETHERE,			"SONG_ARETHERE"},
+	{SONG_JEEBIES,			SFNAME_JEEBIES,				"SONG_JEEBIES"},
+	{SONG_VIBRACIOUS,		SFNAME_VIBRACIOUS,			"SONG_VIBRACIOUS"},
+	{SONG_ROMANTIC,			SFNAME_ROMANTIC,			"SONG_ROMANTIC"},
+	{SONG_ARETHERE,			SFNAME_ARETHERE,			"SONG_ARETHERE"},
 
-	{SONG_CORRIDOR,		SFNAME_CORRIDOR,			"SONG_CORRIDOR"},
-	{SONG_MOKE,			SFNAME_MOKE,				"SONG_MOKE"},
+	{SONG_CORRIDOR,			SFNAME_CORRIDOR,			"SONG_CORRIDOR"},
+	{SONG_MOKE,				SFNAME_MOKE,				"SONG_MOKE"},
 	{SONG_TILES,			SFNAME_TILES,				"SONG_TILES"},
-	{SONG_DARKVIB,		SFNAME_DARKVIB,				"SONG_DARKVIB"},
+	{SONG_DARKVIB,			SFNAME_DARKVIB,				"SONG_DARKVIB"},
 	{SONG_EXPER,			SFNAME_EXPER,				"SONG_EXPER"},
 
-	{SND_BEEPBEEPBEEP,		BEEPBEEPBEEP_WAV,		"SND_BEEPBEEPBEEP"},
+	{SND_BEEPBEEPBEEP,		BEEPBEEPBEEP_WAV,			"SND_BEEPBEEPBEEP"},
 
 		//
 		// Voice files - in the .MPC file
 		//
 	{V00_AIRLOCK_01,		M00_AIRLOCK_01_MP3,			"V00_AIRLOCK_01"},
-	{V00_ARNIE_01,		M00_ARNIE_01_MP3,			"V00_ARNIE_01"},
-
-	{V00_BRAD_01,		M00_BRAD_01_MP3,			"V00_BRAD_01"},
-	{V00_BRAD_02,		M00_BRAD_02_MP3,			"V00_BRAD_02"},
-	{V00_BRAD_03,		M00_BRAD_03_MP3,			"V00_BRAD_03"},
-
-	{V00_BUSTER_01,		M00_BUSTER_01_MP3,			"V00_BUSTER_01"},
-	{V00_BUSTER_02,		M00_BUSTER_02_MP3,			"V00_BUSTER_02"},
-	{V00_BUSTER_03,		M00_BUSTER_03_MP3,			"V00_BUSTER_03"},
-	{V00_BUSTER_04,		M00_BUSTER_04_MP3,			"V00_BUSTER_04"},
-	{V00_BUSTER_05,		M00_BUSTER_05_MP3,			"V00_BUSTER_05"},
-	{V00_BUSTER_06,		M00_BUSTER_06_MP3,			"V00_BUSTER_06"},
-	{V00_BUSTER_07,		M00_BUSTER_07_MP3,			"V00_BUSTER_07"},
-	{V00_BUSTER_08,		M00_BUSTER_08_MP3,			"V00_BUSTER_08"},
-	{V00_BUSTER_09,		M00_BUSTER_09_MP3,			"V00_BUSTER_09"},
-	{V00_BUSTER_10,		M00_BUSTER_10_MP3,			"V00_BUSTER_10"},
-	{V00_BUSTER_11,		M00_BUSTER_11_MP3,			"V00_BUSTER_11"},
-	{V00_BUSTER_12,		M00_BUSTER_12_MP3,			"V00_BUSTER_12"},
+	{V00_ARNIE_01,			M00_ARNIE_01_MP3,			"V00_ARNIE_01"},
+
+	{V00_BRAD_01,			M00_BRAD_01_MP3,			"V00_BRAD_01"},
+	{V00_BRAD_02,			M00_BRAD_02_MP3,			"V00_BRAD_02"},
+	{V00_BRAD_03,			M00_BRAD_03_MP3,			"V00_BRAD_03"},
+
+	{V00_BUSTER_01,			M00_BUSTER_01_MP3,			"V00_BUSTER_01"},
+	{V00_BUSTER_02,			M00_BUSTER_02_MP3,			"V00_BUSTER_02"},
+	{V00_BUSTER_03,			M00_BUSTER_03_MP3,			"V00_BUSTER_03"},
+	{V00_BUSTER_04,			M00_BUSTER_04_MP3,			"V00_BUSTER_04"},
+	{V00_BUSTER_05,			M00_BUSTER_05_MP3,			"V00_BUSTER_05"},
+	{V00_BUSTER_06,			M00_BUSTER_06_MP3,			"V00_BUSTER_06"},
+	{V00_BUSTER_07,			M00_BUSTER_07_MP3,			"V00_BUSTER_07"},
+	{V00_BUSTER_08,			M00_BUSTER_08_MP3,			"V00_BUSTER_08"},
+	{V00_BUSTER_09,			M00_BUSTER_09_MP3,			"V00_BUSTER_09"},
+	{V00_BUSTER_10,			M00_BUSTER_10_MP3,			"V00_BUSTER_10"},
+	{V00_BUSTER_11,			M00_BUSTER_11_MP3,			"V00_BUSTER_11"},
+	{V00_BUSTER_12,			M00_BUSTER_12_MP3,			"V00_BUSTER_12"},
 	{V00_BUSTER_13A,		M00_BUSTER_13A_MP3,			"V00_BUSTER_13A"},
 	{V00_BUSTER_13B,		M00_BUSTER_13B_MP3,			"V00_BUSTER_13B"},
-	{V00_BUSTER_14,		M00_BUSTER_14_MP3,			"V00_BUSTER_14"},
-	{V00_BUSTER_15,		M00_BUSTER_15_MP3,			"V00_BUSTER_15"},
-	{V00_BUSTER_16,		M00_BUSTER_16_MP3,			"V00_BUSTER_16"},
-	{V00_BUSTER_17,		M00_BUSTER_17_MP3,			"V00_BUSTER_17"},
-	{V00_BUSTER_18,		M00_BUSTER_18_MP3,			"V00_BUSTER_18"},
-	{V00_BUSTER_19,		M00_BUSTER_19_MP3,			"V00_BUSTER_19"},
+	{V00_BUSTER_14,			M00_BUSTER_14_MP3,			"V00_BUSTER_14"},
+	{V00_BUSTER_15,			M00_BUSTER_15_MP3,			"V00_BUSTER_15"},
+	{V00_BUSTER_16,			M00_BUSTER_16_MP3,			"V00_BUSTER_16"},
+	{V00_BUSTER_17,			M00_BUSTER_17_MP3,			"V00_BUSTER_17"},
+	{V00_BUSTER_18,			M00_BUSTER_18_MP3,			"V00_BUSTER_18"},
+	{V00_BUSTER_19,			M00_BUSTER_19_MP3,			"V00_BUSTER_19"},
 
 	{V00_CHICKEN_01,		M00_CHICKEN_01_MP3,			"V00_CHICKEN_01"},
 
-	{V00_CHUTEGUARD_01,		M00_CHUTEGUARD_01_MP3,			"V00_CHUTEGUARD_01"},
-	{V00_CHUTEGUARD_02,		M00_CHUTEGUARD_02_MP3,			"V00_CHUTEGUARD_02"},
-	{V00_CHUTEGUARD_03,		M00_CHUTEGUARD_03_MP3,			"V00_CHUTEGUARD_03"},
-	{V00_CHUTEGUARD_04,		M00_CHUTEGUARD_04_MP3,			"V00_CHUTEGUARD_04"},
-	{V00_CHUTEGUARD_05,		M00_CHUTEGUARD_05_MP3,			"V00_CHUTEGUARD_05"},
-
-	{V00_COOPER_01,		M00_COOPER_01_MP3,			"V00_COOPER_01"},
-	{V00_COOPER_02,		M00_COOPER_02_MP3,			"V00_COOPER_02"},
-	{V00_COOPER_03,		M00_COOPER_03_MP3,			"V00_COOPER_03"},
-	{V00_COOPER_04,		M00_COOPER_04_MP3,			"V00_COOPER_04"},
-	{V00_COOPER_05,		M00_COOPER_05_MP3,			"V00_COOPER_05"},
-
-	{V00_DINERS_01,		M00_DINERS_01_MP3,			"V00_DINERS_01"},
-	{V00_DINERS_02,		M00_DINERS_02_MP3,			"V00_DINERS_02"},
-	{V00_DINERS_03,		M00_DINERS_03_MP3,			"V00_DINERS_03"},
-	{V00_DINERS_04,		M00_DINERS_04_MP3,			"V00_DINERS_04"},
-	{V00_DINERS_05,		M00_DINERS_05_MP3,			"V00_DINERS_05"},
-	{V00_DINERS_06,		M00_DINERS_06_MP3,			"V00_DINERS_06"},
-
-	{V00_DOLLY_01,		M00_DOLLY_01_MP3,			"V00_DOLLY_01"},
-	{V00_DOLLY_02,		M00_DOLLY_02_MP3,			"V00_DOLLY_02"},
-	{V00_DOLLY_03,		M00_DOLLY_03_MP3,			"V00_DOLLY_03"},
-	{V00_DOLLY_04,		M00_DOLLY_04_MP3,			"V00_DOLLY_04"},
-	{V00_DOLLY_05,		M00_DOLLY_05_MP3,			"V00_DOLLY_05"},
-	{V00_DOLLY_06,		M00_DOLLY_06_MP3,			"V00_DOLLY_06"},
-	{V00_DOLLY_07,		M00_DOLLY_07_MP3,			"V00_DOLLY_07"},
-	{V00_DOLLY_08,		M00_DOLLY_08_MP3,			"V00_DOLLY_08"},
-	{V00_DOLLY_09,		M00_DOLLY_09_MP3,			"V00_DOLLY_09"},
-
-	{V00_DOREK_01,		M00_DOREK_01_MP3,			"V00_DOREK_01"},
-	{V00_DOREK_02,		M00_DOREK_02_MP3,			"V00_DOREK_02"},
-	{V00_DOREK_03,		M00_DOREK_03_MP3,			"V00_DOREK_03"},
-	{V00_DOREK_04,		M00_DOREK_04_MP3,			"V00_DOREK_04"},
+	{V00_CHUTEGUARD_01,		M00_CHUTEGUARD_01_MP3,		"V00_CHUTEGUARD_01"},
+	{V00_CHUTEGUARD_02,		M00_CHUTEGUARD_02_MP3,		"V00_CHUTEGUARD_02"},
+	{V00_CHUTEGUARD_03,		M00_CHUTEGUARD_03_MP3,		"V00_CHUTEGUARD_03"},
+	{V00_CHUTEGUARD_04,		M00_CHUTEGUARD_04_MP3,		"V00_CHUTEGUARD_04"},
+	{V00_CHUTEGUARD_05,		M00_CHUTEGUARD_05_MP3,		"V00_CHUTEGUARD_05"},
+
+	{V00_COOPER_01,			M00_COOPER_01_MP3,			"V00_COOPER_01"},
+	{V00_COOPER_02,			M00_COOPER_02_MP3,			"V00_COOPER_02"},
+	{V00_COOPER_03,			M00_COOPER_03_MP3,			"V00_COOPER_03"},
+	{V00_COOPER_04,			M00_COOPER_04_MP3,			"V00_COOPER_04"},
+	{V00_COOPER_05,			M00_COOPER_05_MP3,			"V00_COOPER_05"},
+
+	{V00_DINERS_01,			M00_DINERS_01_MP3,			"V00_DINERS_01"},
+	{V00_DINERS_02,			M00_DINERS_02_MP3,			"V00_DINERS_02"},
+	{V00_DINERS_03,			M00_DINERS_03_MP3,			"V00_DINERS_03"},
+	{V00_DINERS_04,			M00_DINERS_04_MP3,			"V00_DINERS_04"},
+	{V00_DINERS_05,			M00_DINERS_05_MP3,			"V00_DINERS_05"},
+	{V00_DINERS_06,			M00_DINERS_06_MP3,			"V00_DINERS_06"},
+
+	{V00_DOLLY_01,			M00_DOLLY_01_MP3,			"V00_DOLLY_01"},
+	{V00_DOLLY_02,			M00_DOLLY_02_MP3,			"V00_DOLLY_02"},
+	{V00_DOLLY_03,			M00_DOLLY_03_MP3,			"V00_DOLLY_03"},
+	{V00_DOLLY_04,			M00_DOLLY_04_MP3,			"V00_DOLLY_04"},
+	{V00_DOLLY_05,			M00_DOLLY_05_MP3,			"V00_DOLLY_05"},
+	{V00_DOLLY_06,			M00_DOLLY_06_MP3,			"V00_DOLLY_06"},
+	{V00_DOLLY_07,			M00_DOLLY_07_MP3,			"V00_DOLLY_07"},
+	{V00_DOLLY_08,			M00_DOLLY_08_MP3,			"V00_DOLLY_08"},
+	{V00_DOLLY_09,			M00_DOLLY_09_MP3,			"V00_DOLLY_09"},
+
+	{V00_DOREK_01,			M00_DOREK_01_MP3,			"V00_DOREK_01"},
+	{V00_DOREK_02,			M00_DOREK_02_MP3,			"V00_DOREK_02"},
+	{V00_DOREK_03,			M00_DOREK_03_MP3,			"V00_DOREK_03"},
+	{V00_DOREK_04,			M00_DOREK_04_MP3,			"V00_DOREK_04"},
 
 	{V00_ENGCOMPUTER_01,	M00_ENGCOMPUTER_01_MP3,		"V00_ENGCOMPUTER_01"},
 	{V00_ENGCOMPUTER_02,	M00_ENGCOMPUTER_02_MP3,		"V00_ENGCOMPUTER_02"},
 
-	{V00_FARBLE_01,		M00_FARBLE_01_MP3,			"V00_FARBLE_01"},
-	{V00_FARBLE_02,		M00_FARBLE_02_MP3,			"V00_FARBLE_02"},
-	{V00_FARBLE_03,		M00_FARBLE_03_MP3,			"V00_FARBLE_03"},
-	{V00_FARBLE_04,		M00_FARBLE_04_MP3,			"V00_FARBLE_04"},
-	{V00_FARBLE_05,		M00_FARBLE_05_MP3,			"V00_FARBLE_05"},
-	{V00_FARBLE_06,		M00_FARBLE_06_MP3,			"V00_FARBLE_06"},
-	{V00_FARBLE_07,		M00_FARBLE_07_MP3,			"V00_FARBLE_07"},
-	{V00_FARBLE_08,		M00_FARBLE_08_MP3,			"V00_FARBLE_08"},
+	{V00_FARBLE_01,			M00_FARBLE_01_MP3,			"V00_FARBLE_01"},
+	{V00_FARBLE_02,			M00_FARBLE_02_MP3,			"V00_FARBLE_02"},
+	{V00_FARBLE_03,			M00_FARBLE_03_MP3,			"V00_FARBLE_03"},
+	{V00_FARBLE_04,			M00_FARBLE_04_MP3,			"V00_FARBLE_04"},
+	{V00_FARBLE_05,			M00_FARBLE_05_MP3,			"V00_FARBLE_05"},
+	{V00_FARBLE_06,			M00_FARBLE_06_MP3,			"V00_FARBLE_06"},
+	{V00_FARBLE_07,			M00_FARBLE_07_MP3,			"V00_FARBLE_07"},
+	{V00_FARBLE_08,			M00_FARBLE_08_MP3,			"V00_FARBLE_08"},
 
 	{V00_GRUNETT_01,		M00_GRUNETT_01_MP3,			"V00_GRUNETT_01"},
 	{V00_GRUNETT_02,		M00_GRUNETT_02_MP3,			"V00_GRUNETT_02"},
 	{V00_GRUNETT_03,		M00_GRUNETT_03_MP3,			"V00_GRUNETT_03"},
 	{V00_GRUNETT_04,		M00_GRUNETT_04_MP3,			"V00_GRUNETT_04"},
 
-	{V00_GUY_01,		M00_GUY_01_MP3,			"V00_GUY_01"},
-	{V00_GUY_02,		M00_GUY_02_MP3,			"V00_GUY_02"},
-	{V00_GUY_03,		M00_GUY_03_MP3,			"V00_GUY_03"},
-	{V00_GUY_04,		M00_GUY_04_MP3,			"V00_GUY_04"},
-	{V00_GUY_05,		M00_GUY_05_MP3,			"V00_GUY_05"},
-	{V00_GUY_06,		M00_GUY_06_MP3,			"V00_GUY_06"},
-	{V00_GUY_07,		M00_GUY_07_MP3,			"V00_GUY_07"},
-	{V00_GUY_08,		M00_GUY_08_MP3,			"V00_GUY_08"},
-	{V00_GUY_09,		M00_GUY_09_MP3,			"V00_GUY_09"},
-	{V00_GUY_10A,	M00_GUY_10A_MP3,		"V00_GUY_10A"},
-	{V00_GUY_10B,	M00_GUY_10B_MP3,		"V00_GUY_10B"},
-	{V00_GUY_11,		M00_GUY_11_MP3,			"V00_GUY_11"},
-	{V00_GUY_12,		M00_GUY_12_MP3,			"V00_GUY_12"},
-	{V00_GUY_13,		M00_GUY_13_MP3,			"V00_GUY_13"},
-	{V00_GUY_14,		M00_GUY_14_MP3,			"V00_GUY_14"},
-	{V00_GUY_15,		M00_GUY_15_MP3,			"V00_GUY_15"},
-	{V00_GUY_16,		M00_GUY_16_MP3,			"V00_GUY_16"},
-	{V00_GUY_17,		M00_GUY_17_MP3,			"V00_GUY_17"},
-	{V00_GUY_18,		M00_GUY_18_MP3,			"V00_GUY_18"},
+	{V00_GUY_01,			M00_GUY_01_MP3,				"V00_GUY_01"},
+	{V00_GUY_02,			M00_GUY_02_MP3,				"V00_GUY_02"},
+	{V00_GUY_03,			M00_GUY_03_MP3,				"V00_GUY_03"},
+	{V00_GUY_04,			M00_GUY_04_MP3,				"V00_GUY_04"},
+	{V00_GUY_05,			M00_GUY_05_MP3,				"V00_GUY_05"},
+	{V00_GUY_06,			M00_GUY_06_MP3,				"V00_GUY_06"},
+	{V00_GUY_07,			M00_GUY_07_MP3,				"V00_GUY_07"},
+	{V00_GUY_08,			M00_GUY_08_MP3,				"V00_GUY_08"},
+	{V00_GUY_09,			M00_GUY_09_MP3,				"V00_GUY_09"},
+	{V00_GUY_10A,			M00_GUY_10A_MP3,			"V00_GUY_10A"},
+	{V00_GUY_10B,			M00_GUY_10B_MP3,			"V00_GUY_10B"},
+	{V00_GUY_11,			M00_GUY_11_MP3,				"V00_GUY_11"},
+	{V00_GUY_12,			M00_GUY_12_MP3,				"V00_GUY_12"},
+	{V00_GUY_13,			M00_GUY_13_MP3,				"V00_GUY_13"},
+	{V00_GUY_14,			M00_GUY_14_MP3,				"V00_GUY_14"},
+	{V00_GUY_15,			M00_GUY_15_MP3,				"V00_GUY_15"},
+	{V00_GUY_16,			M00_GUY_16_MP3,				"V00_GUY_16"},
+	{V00_GUY_17,			M00_GUY_17_MP3,				"V00_GUY_17"},
+	{V00_GUY_18,			M00_GUY_18_MP3,				"V00_GUY_18"},
 
 	{V00_HUMBERT_01,		M00_HUMBERT_01_MP3,			"V00_HUMBERT_01"},
 	{V00_HUMBERT_02,		M00_HUMBERT_02_MP3,			"V00_HUMBERT_02"},
 
-	{V00_ILLIAC_01,		M00_ILLIAC_01_MP3,			"V00_ILLIAC_01"},
-	{V00_INFOCOMP_01,	M00_INFOCOMP_01_MP3,		"V00_INFOCOMP_01"},
-
-	{V00_JAQUES_01,		M00_JAQUES_01_MP3,			"V00_JAQUES_01"},
-	{V00_JAQUES_03,		M00_JAQUES_03_MP3,			"V00_JAQUES_03"},
-	{V00_JAQUES_04,		M00_JAQUES_04_MP3,			"V00_JAQUES_04"},
-	{V00_JAQUES_05,		M00_JAQUES_05_MP3,			"V00_JAQUES_05"},
-
-	{V00_LUMBAR_01,		M00_LUMBAR_01_MP3,			"V00_LUMBAR_01"},
-
-	{V00_MAILSORTER_01,		M00_MAILSORTER_01_MP3,			"V00_MAILSORTER_01"},
-	{V00_MAILSORTER_02,		M00_MAILSORTER_02_MP3,			"V00_MAILSORTER_02"},
-	{V00_MAILSORTER_03,		M00_MAILSORTER_03_MP3,			"V00_MAILSORTER_03"},
-	{V00_MAILSORTER_04,		M00_MAILSORTER_04_MP3,			"V00_MAILSORTER_04"},
-	{V00_MAILSORTER_05,		M00_MAILSORTER_05_MP3,			"V00_MAILSORTER_05"},
-	{V00_MAILSORTER_06,		M00_MAILSORTER_06_MP3,			"V00_MAILSORTER_06"},
-	{V00_MAILSORTER_07,		M00_MAILSORTER_07_MP3,			"V00_MAILSORTER_07"},
-	{V00_MAILSORTER_08,		M00_MAILSORTER_08_MP3,			"V00_MAILSORTER_08"},
-	{V00_MAILSORTER_09,		M00_MAILSORTER_09_MP3,			"V00_MAILSORTER_09"},
-	{V00_MAILSORTER_10,		M00_MAILSORTER_10_MP3,			"V00_MAILSORTER_10"},
-	{V00_MAILSORTER_11,		M00_MAILSORTER_11_MP3,			"V00_MAILSORTER_11"},
-	{V00_MAILSORTER_12,		M00_MAILSORTER_12_MP3,			"V00_MAILSORTER_12"},
-	{V00_MAILSORTER_13,		M00_MAILSORTER_13_MP3,			"V00_MAILSORTER_13"},
-	{V00_MAILSORTER_14,		M00_MAILSORTER_14_MP3,			"V00_MAILSORTER_14"},
-	{V00_MAILSORTER_15,		M00_MAILSORTER_15_MP3,			"V00_MAILSORTER_15"},
-
-	{V00_MANNY_01,		M00_MANNY_01_MP3,			"V00_MANNY_01"},
-	{V00_MANNY_02,		M00_MANNY_02_MP3,			"V00_MANNY_02"},
-	{V00_MANNY_03,		M00_MANNY_03_MP3,			"V00_MANNY_03"},
-	{V00_MANNY_04,		M00_MANNY_04_MP3,			"V00_MANNY_04"},
-	{V00_MANNY_05,		M00_MANNY_05_MP3,			"V00_MANNY_05"},
-	{V00_MANNY_06,		M00_MANNY_06_MP3,			"V00_MANNY_06"},
-	{V00_MANNY_07,		M00_MANNY_07_MP3,			"V00_MANNY_07"},
-	{V00_MANNY_08,		M00_MANNY_08_MP3,			"V00_MANNY_08"},
-	{V00_MANNY_09,		M00_MANNY_09_MP3,			"V00_MANNY_09"},
-	{V00_MANNY_10,		M00_MANNY_10_MP3,			"V00_MANNY_10"},
-	{V00_MANNY_11,		M00_MANNY_11_MP3,			"V00_MANNY_11"},
-	{V00_MANNY_12,		M00_MANNY_12_MP3,			"V00_MANNY_12"},
-	{V00_MANNY_13,		M00_MANNY_13_MP3,			"V00_MANNY_13"},
-	{V00_MANNY_14,		M00_MANNY_14_MP3,			"V00_MANNY_14"},
-	{V00_MANNY_15,		M00_MANNY_15_MP3,			"V00_MANNY_15"},
-	{V00_MANNY_16,		M00_MANNY_16_MP3,			"V00_MANNY_16"},
-	{V00_MANNY_17,		M00_MANNY_17_MP3,			"V00_MANNY_17"},
-	{V00_MANNY_18,		M00_MANNY_18_MP3,			"V00_MANNY_18"},
-
-	{V00_NOTEBRICK_01,	M00_NOTEBRICK_01_MP3,		"V00_NOTEBRICK_01"},
-
-	{V00_PILOTS_01,		M00_PILOTS_01_MP3,			"V00_PILOTS_01"},
-	{V00_PILOTS_02,		M00_PILOTS_02_MP3,			"V00_PILOTS_02"},
+	{V00_ILLIAC_01,			M00_ILLIAC_01_MP3,			"V00_ILLIAC_01"},
+	{V00_INFOCOMP_01,		M00_INFOCOMP_01_MP3,		"V00_INFOCOMP_01"},
+
+	{V00_JAQUES_01,			M00_JAQUES_01_MP3,			"V00_JAQUES_01"},
+	{V00_JAQUES_03,			M00_JAQUES_03_MP3,			"V00_JAQUES_03"},
+	{V00_JAQUES_04,			M00_JAQUES_04_MP3,			"V00_JAQUES_04"},
+	{V00_JAQUES_05,			M00_JAQUES_05_MP3,			"V00_JAQUES_05"},
+
+	{V00_LUMBAR_01,			M00_LUMBAR_01_MP3,			"V00_LUMBAR_01"},
+
+	{V00_MAILSORTER_01,		M00_MAILSORTER_01_MP3,		"V00_MAILSORTER_01"},
+	{V00_MAILSORTER_02,		M00_MAILSORTER_02_MP3,		"V00_MAILSORTER_02"},
+	{V00_MAILSORTER_03,		M00_MAILSORTER_03_MP3,		"V00_MAILSORTER_03"},
+	{V00_MAILSORTER_04,		M00_MAILSORTER_04_MP3,		"V00_MAILSORTER_04"},
+	{V00_MAILSORTER_05,		M00_MAILSORTER_05_MP3,		"V00_MAILSORTER_05"},
+	{V00_MAILSORTER_06,		M00_MAILSORTER_06_MP3,		"V00_MAILSORTER_06"},
+	{V00_MAILSORTER_07,		M00_MAILSORTER_07_MP3,		"V00_MAILSORTER_07"},
+	{V00_MAILSORTER_08,		M00_MAILSORTER_08_MP3,		"V00_MAILSORTER_08"},
+	{V00_MAILSORTER_09,		M00_MAILSORTER_09_MP3,		"V00_MAILSORTER_09"},
+	{V00_MAILSORTER_10,		M00_MAILSORTER_10_MP3,		"V00_MAILSORTER_10"},
+	{V00_MAILSORTER_11,		M00_MAILSORTER_11_MP3,		"V00_MAILSORTER_11"},
+	{V00_MAILSORTER_12,		M00_MAILSORTER_12_MP3,		"V00_MAILSORTER_12"},
+	{V00_MAILSORTER_13,		M00_MAILSORTER_13_MP3,		"V00_MAILSORTER_13"},
+	{V00_MAILSORTER_14,		M00_MAILSORTER_14_MP3,		"V00_MAILSORTER_14"},
+	{V00_MAILSORTER_15,		M00_MAILSORTER_15_MP3,		"V00_MAILSORTER_15"},
+
+	{V00_MANNY_01,			M00_MANNY_01_MP3,			"V00_MANNY_01"},
+	{V00_MANNY_02,			M00_MANNY_02_MP3,			"V00_MANNY_02"},
+	{V00_MANNY_03,			M00_MANNY_03_MP3,			"V00_MANNY_03"},
+	{V00_MANNY_04,			M00_MANNY_04_MP3,			"V00_MANNY_04"},
+	{V00_MANNY_05,			M00_MANNY_05_MP3,			"V00_MANNY_05"},
+	{V00_MANNY_06,			M00_MANNY_06_MP3,			"V00_MANNY_06"},
+	{V00_MANNY_07,			M00_MANNY_07_MP3,			"V00_MANNY_07"},
+	{V00_MANNY_08,			M00_MANNY_08_MP3,			"V00_MANNY_08"},
+	{V00_MANNY_09,			M00_MANNY_09_MP3,			"V00_MANNY_09"},
+	{V00_MANNY_10,			M00_MANNY_10_MP3,			"V00_MANNY_10"},
+	{V00_MANNY_11,			M00_MANNY_11_MP3,			"V00_MANNY_11"},
+	{V00_MANNY_12,			M00_MANNY_12_MP3,			"V00_MANNY_12"},
+	{V00_MANNY_13,			M00_MANNY_13_MP3,			"V00_MANNY_13"},
+	{V00_MANNY_14,			M00_MANNY_14_MP3,			"V00_MANNY_14"},
+	{V00_MANNY_15,			M00_MANNY_15_MP3,			"V00_MANNY_15"},
+	{V00_MANNY_16,			M00_MANNY_16_MP3,			"V00_MANNY_16"},
+	{V00_MANNY_17,			M00_MANNY_17_MP3,			"V00_MANNY_17"},
+	{V00_MANNY_18,			M00_MANNY_18_MP3,			"V00_MANNY_18"},
+
+	{V00_NOTEBRICK_01,		M00_NOTEBRICK_01_MP3,		"V00_NOTEBRICK_01"},
+
+	{V00_PILOTS_01,			M00_PILOTS_01_MP3,			"V00_PILOTS_01"},
+	{V00_PILOTS_02,			M00_PILOTS_02_MP3,			"V00_PILOTS_02"},
 
 	{V00_POLONEY_01,		M00_POLONEY_01_MP3,			"V00_POLONEY_01"},
 	{V00_POLONEY_02,		M00_POLONEY_02_MP3,			"V00_POLONEY_02"},
@@ -381,180 +381,180 @@ const SoundLookUp soundList[] =  {
 	{V00_POLONEY_05,		M00_POLONEY_05_MP3,			"V00_POLONEY_05"},
 	{V00_POLONEY_06,		M00_POLONEY_06_MP3,			"V00_POLONEY_06"},
 
-	{V00_SARGE_01,		M00_SARGE_01_MP3,			"V00_SARGE_01"},
-	{V00_SARGE_02,		M00_SARGE_02_MP3,			"V00_SARGE_02"},
-	{V00_SARGE_03,		M00_SARGE_03_MP3,			"V00_SARGE_03"},
-	{V00_SARGE_04,		M00_SARGE_04_MP3,			"V00_SARGE_04"},
-	{V00_SARGE_05,		M00_SARGE_05_MP3,			"V00_SARGE_05"},
-	{V00_SARGE_06,		M00_SARGE_06_MP3,			"V00_SARGE_06"},
-	{V00_SARGE_07,		M00_SARGE_07_MP3,			"V00_SARGE_07"},
-	{V00_SARGE_08,		M00_SARGE_08_MP3,			"V00_SARGE_08"},
-	{V00_SARGE_09,		M00_SARGE_09_MP3,			"V00_SARGE_09"},
-	{V00_SARGE_10,		M00_SARGE_10_MP3,			"V00_SARGE_10"},
-	{V00_SARGE_11,		M00_SARGE_11_MP3,			"V00_SARGE_11"},
-	{V00_SARGE_12,		M00_SARGE_12_MP3,			"V00_SARGE_12"},
-	{V00_SARGE_13,		M00_SARGE_13_MP3,			"V00_SARGE_13"},
-	{V00_SARGE_14,		M00_SARGE_14_MP3,			"V00_SARGE_14"},
-	{V00_SARGE_15,		M00_SARGE_15_MP3,			"V00_SARGE_15"},
-	{V00_SARGE_16,		M00_SARGE_16_MP3,			"V00_SARGE_16"},
-
-	{V01_ALABASTER_01,	M01_ALABASTER_01_MP3,	"V01_ALABASTER_01"},
-	{V01_ALABASTER_02,	M01_ALABASTER_02_MP3,	"V01_ALABASTER_02"},
-	{V01_ALABASTER_03,	M01_ALABASTER_03_MP3,	"V01_ALABASTER_03"},
-	{V01_ALABASTER_04,	M01_ALABASTER_04_MP3,	"V01_ALABASTER_04"},
-	{V01_ALABASTER_05,	M01_ALABASTER_05_MP3,	"V01_ALABASTER_05"},
-	{V01_ALABASTER_06,	M01_ALABASTER_06_MP3,	"V01_ALABASTER_06"},
-	{V01_BRAKER_01,		M01_BRAKER_01_MP3,		"V01_BRAKER_01"},
-	{V01_BRAKER_02,		M01_BRAKER_02_MP3,		"V01_BRAKER_02"},
-	{V01_BRAKER_03,		M01_BRAKER_03_MP3,		"V01_BRAKER_03"},
-	{V01_BRAKER_04,		M01_BRAKER_04_MP3,		"V01_BRAKER_04"},
-	{V01_CHISTE_01,		M01_CHISTE_01_MP3,		"V01_CHISTE_01"},
-	{V01_CHISTE_02,		M01_CHISTE_02_MP3,		"V01_CHISTE_02"},
-	{V01_CHISTE_03,		M01_CHISTE_03_MP3,		"V01_CHISTE_03"},
-	{V01_CHISTE_04,		M01_CHISTE_04_MP3,		"V01_CHISTE_04"},
-	{V01_CHISTE_05,		M01_CHISTE_05_MP3,		"V01_CHISTE_05"},
-	{V01_CHISTE_06,		M01_CHISTE_06_MP3,		"V01_CHISTE_06"},
-	{V01_CHISTE_07,		M01_CHISTE_07_MP3,		"V01_CHISTE_07"},
-	{V01_CHISTE_08,		M01_CHISTE_08_MP3,		"V01_CHISTE_08"},
-	{V01_CHISTE_09,		M01_CHISTE_09_MP3,		"V01_CHISTE_09"},
-	{V01_CHISTE_10,		M01_CHISTE_10_MP3,		"V01_CHISTE_10"},
-	{V01_CHISTE_11,		M01_CHISTE_11_MP3,		"V01_CHISTE_11"},
-	{V01_CHISTE_12,		M01_CHISTE_12_MP3,		"V01_CHISTE_12"},
-	{V01_CHISTE_13,		M01_CHISTE_13_MP3,		"V01_CHISTE_13"},
-	{V01_CHISTE_14,		M01_CHISTE_14_MP3,		"V01_CHISTE_14"},
-	{V01_COVERT_01,		M01_COVERT_01_MP3,		"V01_COVERT_01"},
-	{V01_COVERT_02,		M01_COVERT_02_MP3,		"V01_COVERT_02"},
-	{V01_COVERT_03,		M01_COVERT_03_MP3,		"V01_COVERT_03"},
-	{V01_COVERT_04,		M01_COVERT_04_MP3,		"V01_COVERT_04"},
-	{V01_COVERT_05,		M01_COVERT_05_MP3,		"V01_COVERT_05"},
-	{V01_COVERT_06,		M01_COVERT_06_MP3,		"V01_COVERT_06"},
-	{V01_COVERT_07,		M01_COVERT_07_MP3,		"V01_COVERT_07"},
-	{V01_COVERT_08,		M01_COVERT_08_MP3,		"V01_COVERT_08"},
-	{V01_COVERT_09,		M01_COVERT_09_MP3,		"V01_COVERT_09"},
-	{V01_COVERT_10,		M01_COVERT_10_MP3,		"V01_COVERT_10"},
-	{V01_COVERT_11,		M01_COVERT_11_MP3,		"V01_COVERT_11"},
-	{V01_COVERT_12,		M01_COVERT_12_MP3,		"V01_COVERT_12"},
-	{V01_COVERT_13,		M01_COVERT_13_MP3,		"V01_COVERT_13"},
-	{V01_DAGEAUBE_01,	M01_DAGEAUBE_01_MP3,	"V01_DAGEAUBE_01"},
-	{V01_DAGEAUBE_02,	M01_DAGEAUBE_02_MP3,	"V01_DAGEAUBE_02"},
-	{V01_DAGEAUBE_03,	M01_DAGEAUBE_03_MP3,	"V01_DAGEAUBE_03"},
-	{V01_DAGEAUBE_04,	M01_DAGEAUBE_04_MP3,	"V01_DAGEAUBE_04"},
-	{V01_DAGEAUBE_05,	M01_DAGEAUBE_05_MP3,	"V01_DAGEAUBE_05"},
-	{V01_EMC2_01,		M01_EMC2_01_MP3,		"V01_EMC2_01"},
-	{V01_EMC2_02,		M01_EMC2_02_MP3,		"V01_EMC2_02"},
-	{V01_GIZZARD_01,		M01_GIZZARD_01_MP3,		"V01_GIZZARD_01"},
-	{V01_GIZZARD_02,		M01_GIZZARD_02_MP3,		"V01_GIZZARD_02"},
-	{V01_GUY_01,			M01_GUY_01_MP3,			"V01_GUY_01"},
-	{V01_GUY_02,			M01_GUY_02_MP3,			"V01_GUY_02"},
-	{V01_GUY_03,			M01_GUY_03_MP3,			"V01_GUY_03"},
-	{V01_GUY_04,			M01_GUY_04_MP3,			"V01_GUY_04"},
-	{V01_GUY_05,			M01_GUY_05_MP3,			"V01_GUY_05"},
-	{V01_HIDROW_01,		M01_HIDROW_01_MP3,		"V01_HIDROW_01"},
-	{V01_HIDROW_02,		M01_HIDROW_02_MP3,		"V01_HIDROW_02"},
-	{V01_HIDROW_03,		M01_HIDROW_03_MP3,		"V01_HIDROW_03"},
-	{V01_KEBOTTLE_01,	M01_KEBOTTLE_01_MP3,	"V01_KEBOTTLE_01"},
-	{V01_KEBOTTLE_02,	M01_KEBOTTLE_02_MP3,	"V01_KEBOTTLE_02"},
-	{V01_KEBOTTLE_03,	M01_KEBOTTLE_03_MP3,	"V01_KEBOTTLE_03"},
-	{V01_KEBOTTLE_04,	M01_KEBOTTLE_04_MP3,	"V01_KEBOTTLE_04"},
-	{V01_KEBOTTLE_05,	M01_KEBOTTLE_05_MP3,	"V01_KEBOTTLE_05"},
-	{V01_KEBOTTLE_06,	M01_KEBOTTLE_06_MP3,	"V01_KEBOTTLE_06"},
-	{V01_KEBOTTLE_07,	M01_KEBOTTLE_07_MP3,	"V01_KEBOTTLE_07"},
-	{V01_PONTE_01,		M01_PONTE_01_MP3,		"V01_PONTE_01"},
-	{V01_PONTE_02,		M01_PONTE_02_MP3,		"V01_PONTE_02"},
-	{V01_PONTE_03,		M01_PONTE_03_MP3,		"V01_PONTE_03"},
-	{V01_PONTE_04,		M01_PONTE_04_MP3,		"V01_PONTE_04"},
-	{V01_PONTE_05,		M01_PONTE_05_MP3,		"V01_PONTE_05"},
-	{V01_PONTE_06,		M01_PONTE_06_MP3,		"V01_PONTE_06"},
-	{V01_PONTE_07,		M01_PONTE_07_MP3,		"V01_PONTE_07"},
-	{V01_PONTE_08,		M01_PONTE_08_MP3,		"V01_PONTE_08"},
-	{V01_PONTE_09,		M01_PONTE_09_MP3,		"V01_PONTE_09"},
-	{V01_PONTE_10,		M01_PONTE_10_MP3,		"V01_PONTE_10"},
-	{V01_POPOPOLIS_01,	M01_POPOPOLIS_01_MP3,	"V01_POPOPOLIS_01"},
-	{V01_POPOPOLIS_02,	M01_POPOPOLIS_02_MP3,	"V01_POPOPOLIS_02"},
-	{V01_POPOPOLIS_03,	M01_POPOPOLIS_03_MP3,	"V01_POPOPOLIS_03"},
-	{V01_POPOPOLIS_04,	M01_POPOPOLIS_04_MP3,	"V01_POPOPOLIS_04"},
-	{V01_POPOPOLIS_05,	M01_POPOPOLIS_05_MP3,	"V01_POPOPOLIS_05"},
-	{V01_POPOPOLIS_06,	M01_POPOPOLIS_06_MP3,	"V01_POPOPOLIS_06"},
-	{V01_POPOPOLIS_07,	M01_POPOPOLIS_07_MP3,	"V01_POPOPOLIS_07"},
-	{V01_POPOPOLIS_08,	M01_POPOPOLIS_08_MP3,	"V01_POPOPOLIS_08"},
-	{V01_POPOPOLIS_09,	M01_POPOPOLIS_09_MP3,	"V01_POPOPOLIS_09"},
-	{V01_POPOPOLIS_10,	M01_POPOPOLIS_10_MP3,	"V01_POPOPOLIS_10"},
-	{V01_POPOPOLIS_11,	M01_POPOPOLIS_11_MP3,	"V01_POPOPOLIS_11"},
-	{V01_POPOPOLIS_12,	M01_POPOPOLIS_12_MP3,	"V01_POPOPOLIS_12"},
-	{V01_POPOPOLIS_13,	M01_POPOPOLIS_13_MP3,	"V01_POPOPOLIS_13"},
-	{V01_POPOPOLIS_14,	M01_POPOPOLIS_14_MP3,	"V01_POPOPOLIS_14"},
-	{V01_POPOPOLIS_15,	M01_POPOPOLIS_15_MP3,	"V01_POPOPOLIS_15"},
-	{V01_POPOPOLIS_16,	M01_POPOPOLIS_16_MP3,	"V01_POPOPOLIS_16"},
-	{V01_POPOPOLIS_17,	M01_POPOPOLIS_17_MP3,	"V01_POPOPOLIS_17"},
-	{V01_POPOPOLIS_18,	M01_POPOPOLIS_18_MP3,	"V01_POPOPOLIS_18"},
-	{V01_POPOPOLIS_19,	M01_POPOPOLIS_19_MP3,	"V01_POPOPOLIS_19"},
-	{V01_POPOPOLIS_20,	M01_POPOPOLIS_20_MP3,	"V01_POPOPOLIS_20"},
-	{V01_POPOPOLIS_21,	M01_POPOPOLIS_21_MP3,	"V01_POPOPOLIS_21"},
-	{V01_POPOPOLIS_22,	M01_POPOPOLIS_22_MP3,	"V01_POPOPOLIS_22"},
-	{V01_POPOPOLIS_23,	M01_POPOPOLIS_23_MP3,	"V01_POPOPOLIS_23"},
-	{V01_POPOPOLIS_24,	M01_POPOPOLIS_24_MP3,	"V01_POPOPOLIS_24"},
-	{V01_POPOPOLIS_25,	M01_POPOPOLIS_25_MP3,	"V01_POPOPOLIS_25"},
-	{V01_POPOPOLIS_26,	M01_POPOPOLIS_26_MP3,	"V01_POPOPOLIS_26"},
-	{V01_POPOPOLIS_27,	M01_POPOPOLIS_27_MP3,	"V01_POPOPOLIS_27"},
-	{V01_POPOPOLIS_28,	M01_POPOPOLIS_28_MP3,	"V01_POPOPOLIS_28"},
-	{V01_POPOPOLIS_29,	M01_POPOPOLIS_29_MP3,	"V01_POPOPOLIS_29"},
-	{V01_POPOPOLIS_30,	M01_POPOPOLIS_30_MP3,	"V01_POPOPOLIS_30"},
-	{V01_POPOPOLIS_31,	M01_POPOPOLIS_31_MP3,	"V01_POPOPOLIS_31"},
-	{V01_POPOPOLIS_32,	M01_POPOPOLIS_32_MP3,	"V01_POPOPOLIS_32"},
-	{V01_POPOPOLIS_33,	M01_POPOPOLIS_33_MP3,	"V01_POPOPOLIS_33"},
-	{V01_POPOPOLIS_34,	M01_POPOPOLIS_34_MP3,	"V01_POPOPOLIS_34"},
-	{V01_POPOPOLIS_35,	M01_POPOPOLIS_35_MP3,	"V01_POPOPOLIS_35"},
-	{V01_POPOPOLIS_36,	M01_POPOPOLIS_36_MP3,	"V01_POPOPOLIS_36"},
-	{V01_POPOPOLIS_37,	M01_POPOPOLIS_37_MP3,	"V01_POPOPOLIS_37"},
-	{V01_SARGE_01,		M01_SARGE_01_MP3,		"V01_SARGE_01"},
-	{V01_SARGE_02,		M01_SARGE_02_MP3,		"V01_SARGE_02"},
-	{V01_SARGE_03,		M01_SARGE_03_MP3,		"V01_SARGE_03"},
-	{V01_SARGE_04,		M01_SARGE_04_MP3,		"V01_SARGE_04"},
-	{V01_SOBREDELLE_01,	M01_SOBREDELLE_01_MP3,	"V01_SOBREDELLE_01"},
-	{V01_SOBREDELLE_02,	M01_SOBREDELLE_02_MP3,	"V01_SOBREDELLE_02"},
-	{V01_SOBREDELLE_03,	M01_SOBREDELLE_03_MP3,	"V01_SOBREDELLE_03"},
-	{V01_WAYNE_01,		M01_WAYNE_01_MP3,		"V01_WAYNE_01"},
-	{V01_WAYNE_02,		M01_WAYNE_02_MP3,		"V01_WAYNE_02"},
-	{V01_ZIQUOZ_01,		M01_ZIQUOZ_01_MP3,		"V01_ZIQUOZ_01"},
-	{V01_ZIQUOZ_02,		M01_ZIQUOZ_02_MP3,		"V01_ZIQUOZ_02"},
-	{V01_ZIQUOZ_03,		M01_ZIQUOZ_03_MP3,		"V01_ZIQUOZ_03"},
-
-	{V02_AGUSTO_01,		M02_AGUSTO_01_MP3,		"V02_AGUSTO_01"},
-	{V02_AGUSTO_02,		M02_AGUSTO_02_MP3,		"V02_AGUSTO_02"},
+	{V00_SARGE_01,			M00_SARGE_01_MP3,			"V00_SARGE_01"},
+	{V00_SARGE_02,			M00_SARGE_02_MP3,			"V00_SARGE_02"},
+	{V00_SARGE_03,			M00_SARGE_03_MP3,			"V00_SARGE_03"},
+	{V00_SARGE_04,			M00_SARGE_04_MP3,			"V00_SARGE_04"},
+	{V00_SARGE_05,			M00_SARGE_05_MP3,			"V00_SARGE_05"},
+	{V00_SARGE_06,			M00_SARGE_06_MP3,			"V00_SARGE_06"},
+	{V00_SARGE_07,			M00_SARGE_07_MP3,			"V00_SARGE_07"},
+	{V00_SARGE_08,			M00_SARGE_08_MP3,			"V00_SARGE_08"},
+	{V00_SARGE_09,			M00_SARGE_09_MP3,			"V00_SARGE_09"},
+	{V00_SARGE_10,			M00_SARGE_10_MP3,			"V00_SARGE_10"},
+	{V00_SARGE_11,			M00_SARGE_11_MP3,			"V00_SARGE_11"},
+	{V00_SARGE_12,			M00_SARGE_12_MP3,			"V00_SARGE_12"},
+	{V00_SARGE_13,			M00_SARGE_13_MP3,			"V00_SARGE_13"},
+	{V00_SARGE_14,			M00_SARGE_14_MP3,			"V00_SARGE_14"},
+	{V00_SARGE_15,			M00_SARGE_15_MP3,			"V00_SARGE_15"},
+	{V00_SARGE_16,			M00_SARGE_16_MP3,			"V00_SARGE_16"},
+
+	{V01_ALABASTER_01,		M01_ALABASTER_01_MP3,		"V01_ALABASTER_01"},
+	{V01_ALABASTER_02,		M01_ALABASTER_02_MP3,		"V01_ALABASTER_02"},
+	{V01_ALABASTER_03,		M01_ALABASTER_03_MP3,		"V01_ALABASTER_03"},
+	{V01_ALABASTER_04,		M01_ALABASTER_04_MP3,		"V01_ALABASTER_04"},
+	{V01_ALABASTER_05,		M01_ALABASTER_05_MP3,		"V01_ALABASTER_05"},
+	{V01_ALABASTER_06,		M01_ALABASTER_06_MP3,		"V01_ALABASTER_06"},
+	{V01_BRAKER_01,			M01_BRAKER_01_MP3,			"V01_BRAKER_01"},
+	{V01_BRAKER_02,			M01_BRAKER_02_MP3,			"V01_BRAKER_02"},
+	{V01_BRAKER_03,			M01_BRAKER_03_MP3,			"V01_BRAKER_03"},
+	{V01_BRAKER_04,			M01_BRAKER_04_MP3,			"V01_BRAKER_04"},
+	{V01_CHISTE_01,			M01_CHISTE_01_MP3,			"V01_CHISTE_01"},
+	{V01_CHISTE_02,			M01_CHISTE_02_MP3,			"V01_CHISTE_02"},
+	{V01_CHISTE_03,			M01_CHISTE_03_MP3,			"V01_CHISTE_03"},
+	{V01_CHISTE_04,			M01_CHISTE_04_MP3,			"V01_CHISTE_04"},
+	{V01_CHISTE_05,			M01_CHISTE_05_MP3,			"V01_CHISTE_05"},
+	{V01_CHISTE_06,			M01_CHISTE_06_MP3,			"V01_CHISTE_06"},
+	{V01_CHISTE_07,			M01_CHISTE_07_MP3,			"V01_CHISTE_07"},
+	{V01_CHISTE_08,			M01_CHISTE_08_MP3,			"V01_CHISTE_08"},
+	{V01_CHISTE_09,			M01_CHISTE_09_MP3,			"V01_CHISTE_09"},
+	{V01_CHISTE_10,			M01_CHISTE_10_MP3,			"V01_CHISTE_10"},
+	{V01_CHISTE_11,			M01_CHISTE_11_MP3,			"V01_CHISTE_11"},
+	{V01_CHISTE_12,			M01_CHISTE_12_MP3,			"V01_CHISTE_12"},
+	{V01_CHISTE_13,			M01_CHISTE_13_MP3,			"V01_CHISTE_13"},
+	{V01_CHISTE_14,			M01_CHISTE_14_MP3,			"V01_CHISTE_14"},
+	{V01_COVERT_01,			M01_COVERT_01_MP3,			"V01_COVERT_01"},
+	{V01_COVERT_02,			M01_COVERT_02_MP3,			"V01_COVERT_02"},
+	{V01_COVERT_03,			M01_COVERT_03_MP3,			"V01_COVERT_03"},
+	{V01_COVERT_04,			M01_COVERT_04_MP3,			"V01_COVERT_04"},
+	{V01_COVERT_05,			M01_COVERT_05_MP3,			"V01_COVERT_05"},
+	{V01_COVERT_06,			M01_COVERT_06_MP3,			"V01_COVERT_06"},
+	{V01_COVERT_07,			M01_COVERT_07_MP3,			"V01_COVERT_07"},
+	{V01_COVERT_08,			M01_COVERT_08_MP3,			"V01_COVERT_08"},
+	{V01_COVERT_09,			M01_COVERT_09_MP3,			"V01_COVERT_09"},
+	{V01_COVERT_10,			M01_COVERT_10_MP3,			"V01_COVERT_10"},
+	{V01_COVERT_11,			M01_COVERT_11_MP3,			"V01_COVERT_11"},
+	{V01_COVERT_12,			M01_COVERT_12_MP3,			"V01_COVERT_12"},
+	{V01_COVERT_13,			M01_COVERT_13_MP3,			"V01_COVERT_13"},
+	{V01_DAGEAUBE_01,		M01_DAGEAUBE_01_MP3,		"V01_DAGEAUBE_01"},
+	{V01_DAGEAUBE_02,		M01_DAGEAUBE_02_MP3,		"V01_DAGEAUBE_02"},
+	{V01_DAGEAUBE_03,		M01_DAGEAUBE_03_MP3,		"V01_DAGEAUBE_03"},
+	{V01_DAGEAUBE_04,		M01_DAGEAUBE_04_MP3,		"V01_DAGEAUBE_04"},
+	{V01_DAGEAUBE_05,		M01_DAGEAUBE_05_MP3,		"V01_DAGEAUBE_05"},
+	{V01_EMC2_01,			M01_EMC2_01_MP3,			"V01_EMC2_01"},
+	{V01_EMC2_02,			M01_EMC2_02_MP3,			"V01_EMC2_02"},
+	{V01_GIZZARD_01,		M01_GIZZARD_01_MP3,			"V01_GIZZARD_01"},
+	{V01_GIZZARD_02,		M01_GIZZARD_02_MP3,			"V01_GIZZARD_02"},
+	{V01_GUY_01,			M01_GUY_01_MP3,				"V01_GUY_01"},
+	{V01_GUY_02,			M01_GUY_02_MP3,				"V01_GUY_02"},
+	{V01_GUY_03,			M01_GUY_03_MP3,				"V01_GUY_03"},
+	{V01_GUY_04,			M01_GUY_04_MP3,				"V01_GUY_04"},
+	{V01_GUY_05,			M01_GUY_05_MP3,				"V01_GUY_05"},
+	{V01_HIDROW_01,			M01_HIDROW_01_MP3,			"V01_HIDROW_01"},
+	{V01_HIDROW_02,			M01_HIDROW_02_MP3,			"V01_HIDROW_02"},
+	{V01_HIDROW_03,			M01_HIDROW_03_MP3,			"V01_HIDROW_03"},
+	{V01_KEBOTTLE_01,		M01_KEBOTTLE_01_MP3,		"V01_KEBOTTLE_01"},
+	{V01_KEBOTTLE_02,		M01_KEBOTTLE_02_MP3,		"V01_KEBOTTLE_02"},
+	{V01_KEBOTTLE_03,		M01_KEBOTTLE_03_MP3,		"V01_KEBOTTLE_03"},
+	{V01_KEBOTTLE_04,		M01_KEBOTTLE_04_MP3,		"V01_KEBOTTLE_04"},
+	{V01_KEBOTTLE_05,		M01_KEBOTTLE_05_MP3,		"V01_KEBOTTLE_05"},
+	{V01_KEBOTTLE_06,		M01_KEBOTTLE_06_MP3,		"V01_KEBOTTLE_06"},
+	{V01_KEBOTTLE_07,		M01_KEBOTTLE_07_MP3,		"V01_KEBOTTLE_07"},
+	{V01_PONTE_01,			M01_PONTE_01_MP3,			"V01_PONTE_01"},
+	{V01_PONTE_02,			M01_PONTE_02_MP3,			"V01_PONTE_02"},
+	{V01_PONTE_03,			M01_PONTE_03_MP3,			"V01_PONTE_03"},
+	{V01_PONTE_04,			M01_PONTE_04_MP3,			"V01_PONTE_04"},
+	{V01_PONTE_05,			M01_PONTE_05_MP3,			"V01_PONTE_05"},
+	{V01_PONTE_06,			M01_PONTE_06_MP3,			"V01_PONTE_06"},
+	{V01_PONTE_07,			M01_PONTE_07_MP3,			"V01_PONTE_07"},
+	{V01_PONTE_08,			M01_PONTE_08_MP3,			"V01_PONTE_08"},
+	{V01_PONTE_09,			M01_PONTE_09_MP3,			"V01_PONTE_09"},
+	{V01_PONTE_10,			M01_PONTE_10_MP3,			"V01_PONTE_10"},
+	{V01_POPOPOLIS_01,		M01_POPOPOLIS_01_MP3,		"V01_POPOPOLIS_01"},
+	{V01_POPOPOLIS_02,		M01_POPOPOLIS_02_MP3,		"V01_POPOPOLIS_02"},
+	{V01_POPOPOLIS_03,		M01_POPOPOLIS_03_MP3,		"V01_POPOPOLIS_03"},
+	{V01_POPOPOLIS_04,		M01_POPOPOLIS_04_MP3,		"V01_POPOPOLIS_04"},
+	{V01_POPOPOLIS_05,		M01_POPOPOLIS_05_MP3,		"V01_POPOPOLIS_05"},
+	{V01_POPOPOLIS_06,		M01_POPOPOLIS_06_MP3,		"V01_POPOPOLIS_06"},
+	{V01_POPOPOLIS_07,		M01_POPOPOLIS_07_MP3,		"V01_POPOPOLIS_07"},
+	{V01_POPOPOLIS_08,		M01_POPOPOLIS_08_MP3,		"V01_POPOPOLIS_08"},
+	{V01_POPOPOLIS_09,		M01_POPOPOLIS_09_MP3,		"V01_POPOPOLIS_09"},
+	{V01_POPOPOLIS_10,		M01_POPOPOLIS_10_MP3,		"V01_POPOPOLIS_10"},
+	{V01_POPOPOLIS_11,		M01_POPOPOLIS_11_MP3,		"V01_POPOPOLIS_11"},
+	{V01_POPOPOLIS_12,		M01_POPOPOLIS_12_MP3,		"V01_POPOPOLIS_12"},
+	{V01_POPOPOLIS_13,		M01_POPOPOLIS_13_MP3,		"V01_POPOPOLIS_13"},
+	{V01_POPOPOLIS_14,		M01_POPOPOLIS_14_MP3,		"V01_POPOPOLIS_14"},
+	{V01_POPOPOLIS_15,		M01_POPOPOLIS_15_MP3,		"V01_POPOPOLIS_15"},
+	{V01_POPOPOLIS_16,		M01_POPOPOLIS_16_MP3,		"V01_POPOPOLIS_16"},
+	{V01_POPOPOLIS_17,		M01_POPOPOLIS_17_MP3,		"V01_POPOPOLIS_17"},
+	{V01_POPOPOLIS_18,		M01_POPOPOLIS_18_MP3,		"V01_POPOPOLIS_18"},
+	{V01_POPOPOLIS_19,		M01_POPOPOLIS_19_MP3,		"V01_POPOPOLIS_19"},
+	{V01_POPOPOLIS_20,		M01_POPOPOLIS_20_MP3,		"V01_POPOPOLIS_20"},
+	{V01_POPOPOLIS_21,		M01_POPOPOLIS_21_MP3,		"V01_POPOPOLIS_21"},
+	{V01_POPOPOLIS_22,		M01_POPOPOLIS_22_MP3,		"V01_POPOPOLIS_22"},
+	{V01_POPOPOLIS_23,		M01_POPOPOLIS_23_MP3,		"V01_POPOPOLIS_23"},
+	{V01_POPOPOLIS_24,		M01_POPOPOLIS_24_MP3,		"V01_POPOPOLIS_24"},
+	{V01_POPOPOLIS_25,		M01_POPOPOLIS_25_MP3,		"V01_POPOPOLIS_25"},
+	{V01_POPOPOLIS_26,		M01_POPOPOLIS_26_MP3,		"V01_POPOPOLIS_26"},
+	{V01_POPOPOLIS_27,		M01_POPOPOLIS_27_MP3,		"V01_POPOPOLIS_27"},
+	{V01_POPOPOLIS_28,		M01_POPOPOLIS_28_MP3,		"V01_POPOPOLIS_28"},
+	{V01_POPOPOLIS_29,		M01_POPOPOLIS_29_MP3,		"V01_POPOPOLIS_29"},
+	{V01_POPOPOLIS_30,		M01_POPOPOLIS_30_MP3,		"V01_POPOPOLIS_30"},
+	{V01_POPOPOLIS_31,		M01_POPOPOLIS_31_MP3,		"V01_POPOPOLIS_31"},
+	{V01_POPOPOLIS_32,		M01_POPOPOLIS_32_MP3,		"V01_POPOPOLIS_32"},
+	{V01_POPOPOLIS_33,		M01_POPOPOLIS_33_MP3,		"V01_POPOPOLIS_33"},
+	{V01_POPOPOLIS_34,		M01_POPOPOLIS_34_MP3,		"V01_POPOPOLIS_34"},
+	{V01_POPOPOLIS_35,		M01_POPOPOLIS_35_MP3,		"V01_POPOPOLIS_35"},
+	{V01_POPOPOLIS_36,		M01_POPOPOLIS_36_MP3,		"V01_POPOPOLIS_36"},
+	{V01_POPOPOLIS_37,		M01_POPOPOLIS_37_MP3,		"V01_POPOPOLIS_37"},
+	{V01_SARGE_01,			M01_SARGE_01_MP3,			"V01_SARGE_01"},
+	{V01_SARGE_02,			M01_SARGE_02_MP3,			"V01_SARGE_02"},
+	{V01_SARGE_03,			M01_SARGE_03_MP3,			"V01_SARGE_03"},
+	{V01_SARGE_04,			M01_SARGE_04_MP3,			"V01_SARGE_04"},
+	{V01_SOBREDELLE_01,		M01_SOBREDELLE_01_MP3,		"V01_SOBREDELLE_01"},
+	{V01_SOBREDELLE_02,		M01_SOBREDELLE_02_MP3,		"V01_SOBREDELLE_02"},
+	{V01_SOBREDELLE_03,		M01_SOBREDELLE_03_MP3,		"V01_SOBREDELLE_03"},
+	{V01_WAYNE_01,			M01_WAYNE_01_MP3,			"V01_WAYNE_01"},
+	{V01_WAYNE_02,			M01_WAYNE_02_MP3,			"V01_WAYNE_02"},
+	{V01_ZIQUOZ_01,			M01_ZIQUOZ_01_MP3,			"V01_ZIQUOZ_01"},
+	{V01_ZIQUOZ_02,			M01_ZIQUOZ_02_MP3,			"V01_ZIQUOZ_02"},
+	{V01_ZIQUOZ_03,			M01_ZIQUOZ_03_MP3,			"V01_ZIQUOZ_03"},
+
+	{V02_AGUSTO_01,			M02_AGUSTO_01_MP3,			"V02_AGUSTO_01"},
+	{V02_AGUSTO_02,			M02_AGUSTO_02_MP3,			"V02_AGUSTO_02"},
 	{V02_ALBONDIGAS_01,		M02_ALBONDIGAS_01_MP3,		"V02_ALBONDIGAS_01"},
 	{V02_ALBONDIGAS_02,		M02_ALBONDIGAS_02_MP3,		"V02_ALBONDIGAS_02"},
-	{V02_BUMPER_01,		M02_BUMPER_01_MP3,		"V02_BUMPER_01"},
-	{V02_BUMPER_02,		M02_BUMPER_02_MP3,		"V02_BUMPER_02"},
-	{V02_BUMPER_03,		M02_BUMPER_03_MP3,		"V02_BUMPER_03"},
-	{V02_BUMPER_04,		M02_BUMPER_04_MP3,		"V02_BUMPER_04"},
-	{V02_BUMPER_05,		M02_BUMPER_05_MP3,		"V02_BUMPER_05"},
-	{V02_BUMPER_06,		M02_BUMPER_06_MP3,		"V02_BUMPER_06"},
-	{V02_BUMPER_07,		M02_BUMPER_07_MP3,		"V02_BUMPER_07"},
-	{V02_DELGADO_01,		M02_DELGADO_01_MP3,		"V02_DELGADO_01"},
-	{V02_FEBRARO_01,		M02_FEBRARO_01_MP3,		"V02_FEBRARO_01"},
-	{V02_GUY_01,		M02_GUY_01_MP3,		"V02_GUY_01"},
-	{V02_GUY_02,		M02_GUY_02_MP3,		"V02_GUY_02"},
-	{V03_ACROPHO_01,		M03_ACROPHO_01_MP3,		"V03_ACROPHO_01"},
-	{V03_ACROPHO_02,		M03_ACROPHO_02_MP3,		"V03_ACROPHO_02"},
-	{V03_ACROPHO_03,		M03_ACROPHO_03_MP3,		"V03_ACROPHO_03"},
-	{V03_ACROPHO_04,		M03_ACROPHO_04_MP3,		"V03_ACROPHO_04"},
-	{V03_ENERO_01,		M03_ENERO_01_MP3,		"V03_ENERO_01"},
-	{V03_ENERO_02,		M03_ENERO_02_MP3,		"V03_ENERO_02"},
-	{V03_ENERO_03,		M03_ENERO_03_MP3,		"V03_ENERO_03"},
-	{V03_ENERO_04,		M03_ENERO_04_MP3,		"V03_ENERO_04"},
-	{V03_ENERO_05,		M03_ENERO_05_MP3,		"V03_ENERO_05"},
-	{V03_GAIA_01,		M03_GAIA_01_MP3,		"V03_GAIA_01"},
-	{V03_GAIA_02,		M03_GAIA_02_MP3,		"V03_GAIA_02"},
-	{V03_GAIA_03,		M03_GAIA_03_MP3,		"V03_GAIA_03"},
-	{V03_GAIA_04,		M03_GAIA_04_MP3,		"V03_GAIA_04"},
-	{V03_GAIA_05,		M03_GAIA_05_MP3,		"V03_GAIA_05"},
-	{V03_GAIA_06,		M03_GAIA_06_MP3,		"V03_GAIA_06"},
-	{V03_LAGO_01,		M03_LAGO_01_MP3,		"V03_LAGO_01"},
-	{V03_LAGO_02,		M03_LAGO_02_MP3,		"V03_LAGO_02"},
-	{V03_LAGO_04,		M03_LAGO_04_MP3,		"V03_LAGO_04"},
-	{V03_LAGO_05,		M03_LAGO_05_MP3,		"V03_LAGO_05"},
-	{V03_LAGO_06,		M03_LAGO_06_MP3,		"V03_LAGO_06"},
-	{V03_LAGO_07,		M03_LAGO_07_MP3,		"V03_LAGO_07"},
+	{V02_BUMPER_01,			M02_BUMPER_01_MP3,			"V02_BUMPER_01"},
+	{V02_BUMPER_02,			M02_BUMPER_02_MP3,			"V02_BUMPER_02"},
+	{V02_BUMPER_03,			M02_BUMPER_03_MP3,			"V02_BUMPER_03"},
+	{V02_BUMPER_04,			M02_BUMPER_04_MP3,			"V02_BUMPER_04"},
+	{V02_BUMPER_05,			M02_BUMPER_05_MP3,			"V02_BUMPER_05"},
+	{V02_BUMPER_06,			M02_BUMPER_06_MP3,			"V02_BUMPER_06"},
+	{V02_BUMPER_07,			M02_BUMPER_07_MP3,			"V02_BUMPER_07"},
+	{V02_DELGADO_01,		M02_DELGADO_01_MP3,			"V02_DELGADO_01"},
+	{V02_FEBRARO_01,		M02_FEBRARO_01_MP3,			"V02_FEBRARO_01"},
+	{V02_GUY_01,			M02_GUY_01_MP3,				"V02_GUY_01"},
+	{V02_GUY_02,			M02_GUY_02_MP3,				"V02_GUY_02"},
+	{V03_ACROPHO_01,		M03_ACROPHO_01_MP3,			"V03_ACROPHO_01"},
+	{V03_ACROPHO_02,		M03_ACROPHO_02_MP3,			"V03_ACROPHO_02"},
+	{V03_ACROPHO_03,		M03_ACROPHO_03_MP3,			"V03_ACROPHO_03"},
+	{V03_ACROPHO_04,		M03_ACROPHO_04_MP3,			"V03_ACROPHO_04"},
+	{V03_ENERO_01,			M03_ENERO_01_MP3,			"V03_ENERO_01"},
+	{V03_ENERO_02,			M03_ENERO_02_MP3,			"V03_ENERO_02"},
+	{V03_ENERO_03,			M03_ENERO_03_MP3,			"V03_ENERO_03"},
+	{V03_ENERO_04,			M03_ENERO_04_MP3,			"V03_ENERO_04"},
+	{V03_ENERO_05,			M03_ENERO_05_MP3,			"V03_ENERO_05"},
+	{V03_GAIA_01,			M03_GAIA_01_MP3,			"V03_GAIA_01"},
+	{V03_GAIA_02,			M03_GAIA_02_MP3,			"V03_GAIA_02"},
+	{V03_GAIA_03,			M03_GAIA_03_MP3,			"V03_GAIA_03"},
+	{V03_GAIA_04,			M03_GAIA_04_MP3,			"V03_GAIA_04"},
+	{V03_GAIA_05,			M03_GAIA_05_MP3,			"V03_GAIA_05"},
+	{V03_GAIA_06,			M03_GAIA_06_MP3,			"V03_GAIA_06"},
+	{V03_LAGO_01,			M03_LAGO_01_MP3,			"V03_LAGO_01"},
+	{V03_LAGO_02,			M03_LAGO_02_MP3,			"V03_LAGO_02"},
+	{V03_LAGO_04,			M03_LAGO_04_MP3,			"V03_LAGO_04"},
+	{V03_LAGO_05,			M03_LAGO_05_MP3,			"V03_LAGO_05"},
+	{V03_LAGO_06,			M03_LAGO_06_MP3,			"V03_LAGO_06"},
+	{V03_LAGO_07,			M03_LAGO_07_MP3,			"V03_LAGO_07"},
 	{V04_BONIFACE_01,		M04_BONIFACE_01_MP3,		"V04_BONIFACE_01"},
 	{V04_BONIFACE_02,		M04_BONIFACE_02_MP3,		"V04_BONIFACE_02"},
 	{V04_BONIFACE_03,		M04_BONIFACE_03_MP3,		"V04_BONIFACE_03"},
@@ -562,65 +562,65 @@ const SoundLookUp soundList[] =  {
 	{V04_BONIFACE_05,		M04_BONIFACE_05_MP3,		"V04_BONIFACE_05"},
 	{V04_BONIFACE_06,		M04_BONIFACE_06_MP3,		"V04_BONIFACE_06"},
 	{V04_BONIFACE_07,		M04_BONIFACE_07_MP3,		"V04_BONIFACE_07"},
-	{V04_JULIO_01,		M04_JULIO_01_MP3,		"V04_JULIO_01"},
-	{V04_JULIO_02,		M04_JULIO_02_MP3,		"V04_JULIO_02"},
-	{V04_JULIO_04,		M04_JULIO_04_MP3,		"V04_JULIO_04"},
-	{V04_MARZO_01,		M04_MARZO_01_MP3,		"V04_MARZO_01"},
-	{V04_OCTUBRE_01,		M04_OCTUBRE_01_MP3,		"V04_OCTUBRE_01"},
-	{V04_OCTUBRE_02,		M04_OCTUBRE_02_MP3,		"V04_OCTUBRE_02"},
-	{V04_OCTUBRE_03,		M04_OCTUBRE_03_MP3,		"V04_OCTUBRE_03"},
-	{V05_ABRIL_01,		M05_ABRIL_01_MP3,		"V05_ABRIL_01"},
-	{V05_ABRIL_02,		M05_ABRIL_02_MP3,		"V05_ABRIL_02"},
-	{V05_ABRIL_03,		M05_ABRIL_03_MP3,		"V05_ABRIL_03"},
-	{V05_ABRIL_04,		M05_ABRIL_04_MP3,		"V05_ABRIL_04"},
-	{V05_ABRIL_05,		M05_ABRIL_05_MP3,		"V05_ABRIL_05"},
+	{V04_JULIO_01,			M04_JULIO_01_MP3,			"V04_JULIO_01"},
+	{V04_JULIO_02,			M04_JULIO_02_MP3,			"V04_JULIO_02"},
+	{V04_JULIO_04,			M04_JULIO_04_MP3,			"V04_JULIO_04"},
+	{V04_MARZO_01,			M04_MARZO_01_MP3,			"V04_MARZO_01"},
+	{V04_OCTUBRE_01,		M04_OCTUBRE_01_MP3,			"V04_OCTUBRE_01"},
+	{V04_OCTUBRE_02,		M04_OCTUBRE_02_MP3,			"V04_OCTUBRE_02"},
+	{V04_OCTUBRE_03,		M04_OCTUBRE_03_MP3,			"V04_OCTUBRE_03"},
+	{V05_ABRIL_01,			M05_ABRIL_01_MP3,			"V05_ABRIL_01"},
+	{V05_ABRIL_02,			M05_ABRIL_02_MP3,			"V05_ABRIL_02"},
+	{V05_ABRIL_03,			M05_ABRIL_03_MP3,			"V05_ABRIL_03"},
+	{V05_ABRIL_04,			M05_ABRIL_04_MP3,			"V05_ABRIL_04"},
+	{V05_ABRIL_05,			M05_ABRIL_05_MP3,			"V05_ABRIL_05"},
 	{V05_GELIGELLA_01,		M05_GELIGELLA_01_MP3,		"V05_GELIGELLA_01"},
 	{V05_GELIGELLA_02,		M05_GELIGELLA_02_MP3,		"V05_GELIGELLA_02"},
 	{V05_RAILRIDER_01,		M05_RAILRIDER_01_MP3,		"V05_RAILRIDER_01"},
 	{V05_RAILRIDER_02,		M05_RAILRIDER_02_MP3,		"V05_RAILRIDER_02"},
 	{V05_RAILRIDER_03,		M05_RAILRIDER_03_MP3,		"V05_RAILRIDER_03"},
 	{V05_RAILRIDER_04,		M05_RAILRIDER_04_MP3,		"V05_RAILRIDER_04"},
-	{V05_EVERLOO_01,		M05_EVERLOO_01_MP3,		"V05_EVERLOO_01"},
-	{V05_EVERLOO_02,		M05_EVERLOO_02_MP3,		"V05_EVERLOO_02"},
-	{V05_EVERLOO_03,		M05_EVERLOO_03_MP3,		"V05_EVERLOO_03"},
-	{V05_EVERLOO_04,		M05_EVERLOO_04_MP3,		"V05_EVERLOO_04"},
-	{V06_AZUL_01,		M06_AZUL_01_MP3,		"V06_AZUL_01"},
-	{V06_AZUL_02,		M06_AZUL_02_MP3,		"V06_AZUL_02"},
-	{V06_AZUL_03,		M06_AZUL_03_MP3,		"V06_AZUL_03"},
-	{V06_AZUL_04,		M06_AZUL_04_MP3,		"V06_AZUL_04"},
-	{V06_AZUL_05,		M06_AZUL_05_MP3,		"V06_AZUL_05"},
-	{V06_AZUL_06,		M06_AZUL_06_MP3,		"V06_AZUL_06"},
-	{V06_AZUL_07,		M06_AZUL_07_MP3,		"V06_AZUL_07"},
-	{V06_AZUL_08,		M06_AZUL_08_MP3,		"V06_AZUL_08"},
-	{V06_GUY_01,		M06_GUY_01_MP3,		"V06_GUY_01"},
-	{V06_GUY_02,		M06_GUY_02_MP3,		"V06_GUY_02"},
-	{V06_GUY_03,		M06_GUY_03_MP3,		"V06_GUY_03"},
-	{V06_GUY_04,		M06_GUY_04_MP3,		"V06_GUY_04"},
-	{V06_HANSON_01,		M06_HANSON_01_MP3,		"V06_HANSON_01"},
-	{V06_HANSON_03,		M06_HANSON_03_MP3,		"V06_HANSON_03"},
-	{V06_HANSON_04,		M06_HANSON_04_MP3,		"V06_HANSON_04"},
-	{V06_HANSON_05,		M06_HANSON_05_MP3,		"V06_HANSON_05"},
-	{V06_HANSON_06,		M06_HANSON_06_MP3,		"V06_HANSON_06"},
-	{V06_HANSON_07,		M06_HANSON_07_MP3,		"V06_HANSON_07"},
-	{V06_HANSON_08,		M06_HANSON_08_MP3,		"V06_HANSON_08"},
-	{V06_HANSON_09,		M06_HANSON_09_MP3,		"V06_HANSON_09"},
-	{V06_HANSON_10,		M06_HANSON_10_MP3,		"V06_HANSON_10"},
-	{V06_HANSON_11,		M06_HANSON_11_MP3,		"V06_HANSON_11"},
-	{V06_HANSON_12,		M06_HANSON_12_MP3,		"V06_HANSON_12"},
-	{V06_JUNIO_01,		M06_JUNIO_01_MP3,		"V06_JUNIO_01"},
-	{V06_JUNIO_02,		M06_JUNIO_02_MP3,		"V06_JUNIO_02"},
-	{V06_JUNIO_03,		M06_JUNIO_03_MP3,		"V06_JUNIO_03"},
-	{V06_JUNIO_04,		M06_JUNIO_04_MP3,		"V06_JUNIO_04"},
-	{V06_JUNIO_05,		M06_JUNIO_05_MP3,		"V06_JUNIO_05"},
-	{V06_JUNIO_06,		M06_JUNIO_06_MP3,		"V06_JUNIO_06"},
-	{V06_JUNIO_07,		M06_JUNIO_07_MP3,		"V06_JUNIO_07"},
-	{V06_JUNIO_08,		M06_JUNIO_08_MP3,		"V06_JUNIO_08"},
-	{V06_JUNIO_09,		M06_JUNIO_09_MP3,		"V06_JUNIO_09"},
-	{V06_NARANJA_01,		M06_NARANJA_01_MP3,		"V06_NARANJA_01"},
-	{V06_NARANJA_02,		M06_NARANJA_02_MP3,		"V06_NARANJA_02"},
-	{V06_NARANJA_03,		M06_NARANJA_03_MP3,		"V06_NARANJA_03"},
-	{V06_NARANJA_04,		M06_NARANJA_04_MP3,		"V06_NARANJA_04"},
-	{V06_NARANJA_05,		M06_NARANJA_05_MP3,		"V06_NARANJA_05"},
+	{V05_EVERLOO_01,		M05_EVERLOO_01_MP3,			"V05_EVERLOO_01"},
+	{V05_EVERLOO_02,		M05_EVERLOO_02_MP3,			"V05_EVERLOO_02"},
+	{V05_EVERLOO_03,		M05_EVERLOO_03_MP3,			"V05_EVERLOO_03"},
+	{V05_EVERLOO_04,		M05_EVERLOO_04_MP3,			"V05_EVERLOO_04"},
+	{V06_AZUL_01,			M06_AZUL_01_MP3,			"V06_AZUL_01"},
+	{V06_AZUL_02,			M06_AZUL_02_MP3,			"V06_AZUL_02"},
+	{V06_AZUL_03,			M06_AZUL_03_MP3,			"V06_AZUL_03"},
+	{V06_AZUL_04,			M06_AZUL_04_MP3,			"V06_AZUL_04"},
+	{V06_AZUL_05,			M06_AZUL_05_MP3,			"V06_AZUL_05"},
+	{V06_AZUL_06,			M06_AZUL_06_MP3,			"V06_AZUL_06"},
+	{V06_AZUL_07,			M06_AZUL_07_MP3,			"V06_AZUL_07"},
+	{V06_AZUL_08,			M06_AZUL_08_MP3,			"V06_AZUL_08"},
+	{V06_GUY_01,			M06_GUY_01_MP3,				"V06_GUY_01"},
+	{V06_GUY_02,			M06_GUY_02_MP3,				"V06_GUY_02"},
+	{V06_GUY_03,			M06_GUY_03_MP3,				"V06_GUY_03"},
+	{V06_GUY_04,			M06_GUY_04_MP3,				"V06_GUY_04"},
+	{V06_HANSON_01,			M06_HANSON_01_MP3,			"V06_HANSON_01"},
+	{V06_HANSON_03,			M06_HANSON_03_MP3,			"V06_HANSON_03"},
+	{V06_HANSON_04,			M06_HANSON_04_MP3,			"V06_HANSON_04"},
+	{V06_HANSON_05,			M06_HANSON_05_MP3,			"V06_HANSON_05"},
+	{V06_HANSON_06,			M06_HANSON_06_MP3,			"V06_HANSON_06"},
+	{V06_HANSON_07,			M06_HANSON_07_MP3,			"V06_HANSON_07"},
+	{V06_HANSON_08,			M06_HANSON_08_MP3,			"V06_HANSON_08"},
+	{V06_HANSON_09,			M06_HANSON_09_MP3,			"V06_HANSON_09"},
+	{V06_HANSON_10,			M06_HANSON_10_MP3,			"V06_HANSON_10"},
+	{V06_HANSON_11,			M06_HANSON_11_MP3,			"V06_HANSON_11"},
+	{V06_HANSON_12,			M06_HANSON_12_MP3,			"V06_HANSON_12"},
+	{V06_JUNIO_01,			M06_JUNIO_01_MP3,			"V06_JUNIO_01"},
+	{V06_JUNIO_02,			M06_JUNIO_02_MP3,			"V06_JUNIO_02"},
+	{V06_JUNIO_03,			M06_JUNIO_03_MP3,			"V06_JUNIO_03"},
+	{V06_JUNIO_04,			M06_JUNIO_04_MP3,			"V06_JUNIO_04"},
+	{V06_JUNIO_05,			M06_JUNIO_05_MP3,			"V06_JUNIO_05"},
+	{V06_JUNIO_06,			M06_JUNIO_06_MP3,			"V06_JUNIO_06"},
+	{V06_JUNIO_07,			M06_JUNIO_07_MP3,			"V06_JUNIO_07"},
+	{V06_JUNIO_08,			M06_JUNIO_08_MP3,			"V06_JUNIO_08"},
+	{V06_JUNIO_09,			M06_JUNIO_09_MP3,			"V06_JUNIO_09"},
+	{V06_NARANJA_01,		M06_NARANJA_01_MP3,			"V06_NARANJA_01"},
+	{V06_NARANJA_02,		M06_NARANJA_02_MP3,			"V06_NARANJA_02"},
+	{V06_NARANJA_03,		M06_NARANJA_03_MP3,			"V06_NARANJA_03"},
+	{V06_NARANJA_04,		M06_NARANJA_04_MP3,			"V06_NARANJA_04"},
+	{V06_NARANJA_05,		M06_NARANJA_05_MP3,			"V06_NARANJA_05"},
 	{V06_SEPTEMBRE_01,		M06_SEPTEMBRE_01_MP3,		"V06_SEPTEMBRE_01"},
 	{V06_SEPTEMBRE_02,		M06_SEPTEMBRE_02_MP3,		"V06_SEPTEMBRE_02"},
 	{V06_SEPTEMBRE_03,		M06_SEPTEMBRE_03_MP3,		"V06_SEPTEMBRE_03"},
@@ -630,107 +630,107 @@ const SoundLookUp soundList[] =  {
 	{V06_SEPTEMBRE_07,		M06_SEPTEMBRE_07_MP3,		"V06_SEPTEMBRE_07"},
 	{V06_SEPTEMBRE_08,		M06_SEPTEMBRE_08_MP3,		"V06_SEPTEMBRE_08"},
 	{V06_SEPTEMBRE_09,		M06_SEPTEMBRE_09_MP3,		"V06_SEPTEMBRE_09"},
-	{V06_WORKER_01,		M06_WORKER_01_MP3,		"V06_WORKER_01"},
-	{V06_WORKER_02,		M06_WORKER_02_MP3,		"V06_WORKER_02"},
-	{V06_WORKER_03,		M06_WORKER_03_MP3,		"V06_WORKER_03"},
-	{V06_WORKER_04,		M06_WORKER_04_MP3,		"V06_WORKER_04"},
-	{V07_CERCO_01,		M07_CERCO_01_MP3,		"V07_CERCO_01"},
-	{V07_CERCO_02,		M07_CERCO_02_MP3,		"V07_CERCO_02"},
+	{V06_WORKER_01,			M06_WORKER_01_MP3,			"V06_WORKER_01"},
+	{V06_WORKER_02,			M06_WORKER_02_MP3,			"V06_WORKER_02"},
+	{V06_WORKER_03,			M06_WORKER_03_MP3,			"V06_WORKER_03"},
+	{V06_WORKER_04,			M06_WORKER_04_MP3,			"V06_WORKER_04"},
+	{V07_CERCO_01,			M07_CERCO_01_MP3,			"V07_CERCO_01"},
+	{V07_CERCO_02,			M07_CERCO_02_MP3,			"V07_CERCO_02"},
 	{V07_COMPUTER_01,		M07_COMPUTER_01_MP3,		"V07_COMPUTER_01"},
-	{V07_MAYO_01,		M07_MAYO_01_MP3,		"V07_MAYO_01"},
-	{V07_MAYO_02,		M07_MAYO_02_MP3,		"V07_MAYO_02"},
+	{V07_MAYO_01,			M07_MAYO_01_MP3,			"V07_MAYO_01"},
+	{V07_MAYO_02,			M07_MAYO_02_MP3,			"V07_MAYO_02"},
 	{V07_NOVIEMBRE_01,		M07_NOVIEMBRE_01_MP3,		"V07_NOVIEMBRE_01"},
 	{V07_NOVIEMBRE_02,		M07_NOVIEMBRE_02_MP3,		"V07_NOVIEMBRE_02"},
 	{V07_NOVIEMBRE_03,		M07_NOVIEMBRE_03_MP3,		"V07_NOVIEMBRE_03"},
-	{V07_PANITO_01,		M07_PANITO_01_MP3,		"V07_PANITO_01"},
-	{V07_PANITO_02,		M07_PANITO_02_MP3,		"V07_PANITO_02"},
-	{V07_PANITO_03,		M07_PANITO_03_MP3,		"V07_PANITO_03"},
-	{V07_PANITO_04,		M07_PANITO_04_MP3,		"V07_PANITO_04"},
-	{V07_PANITO_05,		M07_PANITO_05_MP3,		"V07_PANITO_05"},
-	{V08_COOKIE_01,		M08_COOKIE_01_MP3,		"V08_COOKIE_01"},
-	{V08_COOKIE_02,		M08_COOKIE_02_MP3,		"V08_COOKIE_02"},
+	{V07_PANITO_01,			M07_PANITO_01_MP3,			"V07_PANITO_01"},
+	{V07_PANITO_02,			M07_PANITO_02_MP3,			"V07_PANITO_02"},
+	{V07_PANITO_03,			M07_PANITO_03_MP3,			"V07_PANITO_03"},
+	{V07_PANITO_04,			M07_PANITO_04_MP3,			"V07_PANITO_04"},
+	{V07_PANITO_05,			M07_PANITO_05_MP3,			"V07_PANITO_05"},
+	{V08_COOKIE_01,			M08_COOKIE_01_MP3,			"V08_COOKIE_01"},
+	{V08_COOKIE_02,			M08_COOKIE_02_MP3,			"V08_COOKIE_02"},
 	{V08_DICIEMBRE_01,		M08_DICIEMBRE_01_MP3,		"V08_DICIEMBRE_01"},
-	{V08_GUY_01,		M08_GUY_01_MP3,		"V08_GUY_01"},
-	{V08_GUY_02,		M08_GUY_02_MP3,		"V08_GUY_02"},
-	{V08_GUY_03,		M08_GUY_03_MP3,		"V08_GUY_03"},
-	{V08_MACHINA_01,		M08_MACHINA_01_MP3,		"V08_MACHINA_01"},
-	{V08_MACHINA_02,		M08_MACHINA_02_MP3,		"V08_MACHINA_02"},
-	{V08_MACHINA_03,		M08_MACHINA_03_MP3,		"V08_MACHINA_03"},
-	{V08_MACHINA_04,		M08_MACHINA_04_MP3,		"V08_MACHINA_04"},
-	{V08_MACHINA_05,		M08_MACHINA_05_MP3,		"V08_MACHINA_05"},
-	{V08_MACHINA_06,		M08_MACHINA_06_MP3,		"V08_MACHINA_06"},
-	{V08_MACHINA_07,		M08_MACHINA_07_MP3,		"V08_MACHINA_07"},
-	{V08_MACHINA_08,		M08_MACHINA_08_MP3,		"V08_MACHINA_08"},
-	{V08_MACHINA_09,		M08_MACHINA_09_MP3,		"V08_MACHINA_09"},
-	{V08_MESA_01,		M08_MESA_01_MP3,		"V08_MESA_01"},
-	{V08_MESA_02,		M08_MESA_02_MP3,		"V08_MESA_02"},
-	{V08_MESA_03,		M08_MESA_03_MP3,		"V08_MESA_03"},
-	{V08_MESA_04,		M08_MESA_04_MP3,		"V08_MESA_04"},
-	{V08_SHAKIR_01,		M08_SHAKIR_01_MP3,		"V08_SHAKIR_01"},
-	{V08_SHAKIR_02,		M08_SHAKIR_02_MP3,		"V08_SHAKIR_02"},
-	{V08_SHAKIR_03,		M08_SHAKIR_03_MP3,		"V08_SHAKIR_03"},
-	{V09_VIOLETA_01,		M09_VIOLETA_01_MP3,		"V09_VIOLETA_01"},
-	{V09_VIOLETA_02,		M09_VIOLETA_02_MP3,		"V09_VIOLETA_02"},
-	{V09_VIOLETA_03,		M09_VIOLETA_03_MP3,		"V09_VIOLETA_03"},
-	{V09_VIOLETA_04,		M09_VIOLETA_04_MP3,		"V09_VIOLETA_04"},
-	{V10_CHICKEN_01,		M10_CHICKEN_01_MP3,		"V10_CHICKEN_01"},
-	{V10_COOPER_01,		M10_COOPER_01_MP3,		"V10_COOPER_01"},
-	{V10_COOPER_02,		M10_COOPER_02_MP3,		"V10_COOPER_02"},
-	{V10_COOPER_03,		M10_COOPER_03_MP3,		"V10_COOPER_03"},
-	{V10_COOPER_04,		M10_COOPER_04_MP3,		"V10_COOPER_04"},
-	{V10_COOPER_05,		M10_COOPER_05_MP3,		"V10_COOPER_05"},
-	{V10_COOPER_06,		M10_COOPER_06_MP3,		"V10_COOPER_06"},
-	{V10_COOPER_07,		M10_COOPER_07_MP3,		"V10_COOPER_07"},
-	{V10_COOPER_08,		M10_COOPER_08_MP3,		"V10_COOPER_08"},
-	{V10_COOPER_09,		M10_COOPER_09_MP3,		"V10_COOPER_09"},
-	{V10_DOLLY_01,		M10_DOLLY_01_MP3,		"V10_DOLLY_01"},
-	{V10_DOLLY_02,		M10_DOLLY_02_MP3,		"V10_DOLLY_02"},
-	{V10_DOLLY_03,		M10_DOLLY_03_MP3,		"V10_DOLLY_03"},
-	{V10_DOLLY_04,		M10_DOLLY_04_MP3,		"V10_DOLLY_04"},
-	{V10_DOLLY_05,		M10_DOLLY_05_MP3,		"V10_DOLLY_05"},
-	{V10_DOLLY_06,		M10_DOLLY_06_MP3,		"V10_DOLLY_06"},
-	{V10_DOLLY_07,		M10_DOLLY_07_MP3,		"V10_DOLLY_07"},
-	{V10_DOLLY_08,		M10_DOLLY_08_MP3,		"V10_DOLLY_08"},
-	{V10_DOLLY_09,		M10_DOLLY_09_MP3,		"V10_DOLLY_09"},
-	{V10_DOLLY_10,		M10_DOLLY_10_MP3,		"V10_DOLLY_10"},
-	{V10_ENGCOMPUTER_01,		M10_ENGCOMPUTER_01_MP3,		"V10_ENGCOMPUTER_01"},
-	{V10_FARBLE_01,		M10_FARBLE_01_MP3,		"V10_FARBLE_01"},
-	{V10_FARBLE_02,		M10_FARBLE_02_MP3,		"V10_FARBLE_02"},
-	{V10_FARBLE_03,		M10_FARBLE_03_MP3,		"V10_FARBLE_03"},
-	{V10_FARBLE_04,		M10_FARBLE_04_MP3,		"V10_FARBLE_04"},
-	{V10_FARBLE_05,		M10_FARBLE_05_MP3,		"V10_FARBLE_05"},
-	{V10_FARBLE_06,		M10_FARBLE_06_MP3,		"V10_FARBLE_06"},
-	{V10_GRUNETT_01,		M10_GRUNETT_01_MP3,		"V10_GRUNETT_01"},
-	{V10_GRUNETT_02,		M10_GRUNETT_02_MP3,		"V10_GRUNETT_02"},
-	{V10_GRUNETT_03,		M10_GRUNETT_03_MP3,		"V10_GRUNETT_03"},
-	{V10_GRUNETT_04,		M10_GRUNETT_04_MP3,		"V10_GRUNETT_04"},
-	{V10_GRUNETT_05,		M10_GRUNETT_05_MP3,		"V10_GRUNETT_05"},
-	{V10_GRUNETT_06,		M10_GRUNETT_06_MP3,		"V10_GRUNETT_06"},
-	{V10_GUY_01,		M10_GUY_01_MP3,		"V10_GUY_01"},
-	{V10_GUY_02,		M10_GUY_02_MP3,		"V10_GUY_02"},
-	{V10_GUY_03,		M10_GUY_03_MP3,		"V10_GUY_03"},
-	{V10_GUY_04,		M10_GUY_04_MP3,		"V10_GUY_04"},
-	{V10_GUY_05,		M10_GUY_05_MP3,		"V10_GUY_05"},
-	{V10_GUY_06,		M10_GUY_06_MP3,		"V10_GUY_06"},
-	{V10_GUY_07,		M10_GUY_07_MP3,		"V10_GUY_07"},
-	{V10_GUY_08,		M10_GUY_08_MP3,		"V10_GUY_08"},
+	{V08_GUY_01,			M08_GUY_01_MP3,				"V08_GUY_01"},
+	{V08_GUY_02,			M08_GUY_02_MP3,				"V08_GUY_02"},
+	{V08_GUY_03,			M08_GUY_03_MP3,				"V08_GUY_03"},
+	{V08_MACHINA_01,		M08_MACHINA_01_MP3,			"V08_MACHINA_01"},
+	{V08_MACHINA_02,		M08_MACHINA_02_MP3,			"V08_MACHINA_02"},
+	{V08_MACHINA_03,		M08_MACHINA_03_MP3,			"V08_MACHINA_03"},
+	{V08_MACHINA_04,		M08_MACHINA_04_MP3,			"V08_MACHINA_04"},
+	{V08_MACHINA_05,		M08_MACHINA_05_MP3,			"V08_MACHINA_05"},
+	{V08_MACHINA_06,		M08_MACHINA_06_MP3,			"V08_MACHINA_06"},
+	{V08_MACHINA_07,		M08_MACHINA_07_MP3,			"V08_MACHINA_07"},
+	{V08_MACHINA_08,		M08_MACHINA_08_MP3,			"V08_MACHINA_08"},
+	{V08_MACHINA_09,		M08_MACHINA_09_MP3,			"V08_MACHINA_09"},
+	{V08_MESA_01,			M08_MESA_01_MP3,			"V08_MESA_01"},
+	{V08_MESA_02,			M08_MESA_02_MP3,			"V08_MESA_02"},
+	{V08_MESA_03,			M08_MESA_03_MP3,			"V08_MESA_03"},
+	{V08_MESA_04,			M08_MESA_04_MP3,			"V08_MESA_04"},
+	{V08_SHAKIR_01,			M08_SHAKIR_01_MP3,			"V08_SHAKIR_01"},
+	{V08_SHAKIR_02,			M08_SHAKIR_02_MP3,			"V08_SHAKIR_02"},
+	{V08_SHAKIR_03,			M08_SHAKIR_03_MP3,			"V08_SHAKIR_03"},
+	{V09_VIOLETA_01,		M09_VIOLETA_01_MP3,			"V09_VIOLETA_01"},
+	{V09_VIOLETA_02,		M09_VIOLETA_02_MP3,			"V09_VIOLETA_02"},
+	{V09_VIOLETA_03,		M09_VIOLETA_03_MP3,			"V09_VIOLETA_03"},
+	{V09_VIOLETA_04,		M09_VIOLETA_04_MP3,			"V09_VIOLETA_04"},
+	{V10_CHICKEN_01,		M10_CHICKEN_01_MP3,			"V10_CHICKEN_01"},
+	{V10_COOPER_01,			M10_COOPER_01_MP3,			"V10_COOPER_01"},
+	{V10_COOPER_02,			M10_COOPER_02_MP3,			"V10_COOPER_02"},
+	{V10_COOPER_03,			M10_COOPER_03_MP3,			"V10_COOPER_03"},
+	{V10_COOPER_04,			M10_COOPER_04_MP3,			"V10_COOPER_04"},
+	{V10_COOPER_05,			M10_COOPER_05_MP3,			"V10_COOPER_05"},
+	{V10_COOPER_06,			M10_COOPER_06_MP3,			"V10_COOPER_06"},
+	{V10_COOPER_07,			M10_COOPER_07_MP3,			"V10_COOPER_07"},
+	{V10_COOPER_08,			M10_COOPER_08_MP3,			"V10_COOPER_08"},
+	{V10_COOPER_09,			M10_COOPER_09_MP3,			"V10_COOPER_09"},
+	{V10_DOLLY_01,			M10_DOLLY_01_MP3,			"V10_DOLLY_01"},
+	{V10_DOLLY_02,			M10_DOLLY_02_MP3,			"V10_DOLLY_02"},
+	{V10_DOLLY_03,			M10_DOLLY_03_MP3,			"V10_DOLLY_03"},
+	{V10_DOLLY_04,			M10_DOLLY_04_MP3,			"V10_DOLLY_04"},
+	{V10_DOLLY_05,			M10_DOLLY_05_MP3,			"V10_DOLLY_05"},
+	{V10_DOLLY_06,			M10_DOLLY_06_MP3,			"V10_DOLLY_06"},
+	{V10_DOLLY_07,			M10_DOLLY_07_MP3,			"V10_DOLLY_07"},
+	{V10_DOLLY_08,			M10_DOLLY_08_MP3,			"V10_DOLLY_08"},
+	{V10_DOLLY_09,			M10_DOLLY_09_MP3,			"V10_DOLLY_09"},
+	{V10_DOLLY_10,			M10_DOLLY_10_MP3,			"V10_DOLLY_10"},
+	{V10_ENGCOMPUTER_01,	M10_ENGCOMPUTER_01_MP3,		"V10_ENGCOMPUTER_01"},
+	{V10_FARBLE_01,			M10_FARBLE_01_MP3,			"V10_FARBLE_01"},
+	{V10_FARBLE_02,			M10_FARBLE_02_MP3,			"V10_FARBLE_02"},
+	{V10_FARBLE_03,			M10_FARBLE_03_MP3,			"V10_FARBLE_03"},
+	{V10_FARBLE_04,			M10_FARBLE_04_MP3,			"V10_FARBLE_04"},
+	{V10_FARBLE_05,			M10_FARBLE_05_MP3,			"V10_FARBLE_05"},
+	{V10_FARBLE_06,			M10_FARBLE_06_MP3,			"V10_FARBLE_06"},
+	{V10_GRUNETT_01,		M10_GRUNETT_01_MP3,			"V10_GRUNETT_01"},
+	{V10_GRUNETT_02,		M10_GRUNETT_02_MP3,			"V10_GRUNETT_02"},
+	{V10_GRUNETT_03,		M10_GRUNETT_03_MP3,			"V10_GRUNETT_03"},
+	{V10_GRUNETT_04,		M10_GRUNETT_04_MP3,			"V10_GRUNETT_04"},
+	{V10_GRUNETT_05,		M10_GRUNETT_05_MP3,			"V10_GRUNETT_05"},
+	{V10_GRUNETT_06,		M10_GRUNETT_06_MP3,			"V10_GRUNETT_06"},
+	{V10_GUY_01,			M10_GUY_01_MP3,				"V10_GUY_01"},
+	{V10_GUY_02,			M10_GUY_02_MP3,				"V10_GUY_02"},
+	{V10_GUY_03,			M10_GUY_03_MP3,				"V10_GUY_03"},
+	{V10_GUY_04,			M10_GUY_04_MP3,				"V10_GUY_04"},
+	{V10_GUY_05,			M10_GUY_05_MP3,				"V10_GUY_05"},
+	{V10_GUY_06,			M10_GUY_06_MP3,				"V10_GUY_06"},
+	{V10_GUY_07,			M10_GUY_07_MP3,				"V10_GUY_07"},
+	{V10_GUY_08,			M10_GUY_08_MP3,				"V10_GUY_08"},
 	{V10_INFOCOMP_01,		M10_INFOCOMP_01_MP3,		"V10_INFOCOMP_01"},
 	{V10_NOTEBRICK_01,		M10_NOTEBRICK_01_MP3,		"V10_NOTEBRICK_01"},
-	{V10_PILOTS_01,		M10_PILOTS_01_MP3,		"V10_PILOTS_01"},
-	{V10_PILOTS_02,		M10_PILOTS_02_MP3,		"V10_PILOTS_02"},
-	{V10_PILOTS_03,		M10_PILOTS_03_MP3,		"V10_PILOTS_03"},
-	{V10_PILOTS_04,		M10_PILOTS_04_MP3,		"V10_PILOTS_04"},
-	{V10_PILOTS_05,		M10_PILOTS_05_MP3,		"V10_PILOTS_05"},
-	{V10_SARGE_01,		M10_SARGE_01_MP3,		"V10_SARGE_01"},
-	{V10_SARGE_02,		M10_SARGE_02_MP3,		"V10_SARGE_02"},
-	{V10_SARGE_03,		M10_SARGE_03_MP3,		"V10_SARGE_03"},
-	{V10_SARGE_04,		M10_SARGE_04_MP3,		"V10_SARGE_04"},
-	{V10_SARGE_05,		M10_SARGE_05_MP3,		"V10_SARGE_05"},
-	{V11_ANCHOVY_01,		M11_ANCHOVY_01_MP3,		"V11_ANCHOVY_01"},
-	{V11_ANCHOVY_02,		M11_ANCHOVY_02_MP3,		"V11_ANCHOVY_02"},
-	{V11_ANCHOVY_03,		M11_ANCHOVY_03_MP3,		"V11_ANCHOVY_03"},
-	{V11_ANCHOVY_04,		M11_ANCHOVY_04_MP3,		"V11_ANCHOVY_04"},
-	{V11_ANCHOVY_05,		M11_ANCHOVY_05_MP3,		"V11_ANCHOVY_05"},
+	{V10_PILOTS_01,			M10_PILOTS_01_MP3,			"V10_PILOTS_01"},
+	{V10_PILOTS_02,			M10_PILOTS_02_MP3,			"V10_PILOTS_02"},
+	{V10_PILOTS_03,			M10_PILOTS_03_MP3,			"V10_PILOTS_03"},
+	{V10_PILOTS_04,			M10_PILOTS_04_MP3,			"V10_PILOTS_04"},
+	{V10_PILOTS_05,			M10_PILOTS_05_MP3,			"V10_PILOTS_05"},
+	{V10_SARGE_01,			M10_SARGE_01_MP3,			"V10_SARGE_01"},
+	{V10_SARGE_02,			M10_SARGE_02_MP3,			"V10_SARGE_02"},
+	{V10_SARGE_03,			M10_SARGE_03_MP3,			"V10_SARGE_03"},
+	{V10_SARGE_04,			M10_SARGE_04_MP3,			"V10_SARGE_04"},
+	{V10_SARGE_05,			M10_SARGE_05_MP3,			"V10_SARGE_05"},
+	{V11_ANCHOVY_01,		M11_ANCHOVY_01_MP3,			"V11_ANCHOVY_01"},
+	{V11_ANCHOVY_02,		M11_ANCHOVY_02_MP3,			"V11_ANCHOVY_02"},
+	{V11_ANCHOVY_03,		M11_ANCHOVY_03_MP3,			"V11_ANCHOVY_03"},
+	{V11_ANCHOVY_04,		M11_ANCHOVY_04_MP3,			"V11_ANCHOVY_04"},
+	{V11_ANCHOVY_05,		M11_ANCHOVY_05_MP3,			"V11_ANCHOVY_05"},
 	{V11_ARBIVALL_01,		M11_ARBIVALL_01_MP3,		"V11_ARBIVALL_01"},
 	{V11_ARBIVALL_02,		M11_ARBIVALL_02_MP3,		"V11_ARBIVALL_02"},
 	{V11_ARBIVALL_03,		M11_ARBIVALL_03_MP3,		"V11_ARBIVALL_03"},
@@ -738,99 +738,99 @@ const SoundLookUp soundList[] =  {
 	{V11_ARBIVALL_05,		M11_ARBIVALL_05_MP3,		"V11_ARBIVALL_05"},
 	{V11_ARBIVALL_06,		M11_ARBIVALL_06_MP3,		"V11_ARBIVALL_06"},
 	{V11_ARBIVALL_07,		M11_ARBIVALL_07_MP3,		"V11_ARBIVALL_07"},
-	{V11_ARNIE_01,		M11_ARNIE_01_MP3,		"V11_ARNIE_01"},
-	{V11_BELINDA_01,		M11_BELINDA_01_MP3,		"V11_BELINDA_01"},
-	{V11_BLOCK_01,		M11_BLOCK_01_MP3,		"V11_BLOCK_01"},
-	{V11_BLOCK_02,		M11_BLOCK_02_MP3,		"V11_BLOCK_02"},
-	{V11_BLOCK_03,		M11_BLOCK_03_MP3,		"V11_BLOCK_03"},
-	{V11_BRAD_01,		M11_BRAD_01_MP3,		"V11_BRAD_01"},
-	{V11_BRAD_02,		M11_BRAD_02_MP3,		"V11_BRAD_02"},
-	{V11_BRAD_03,		M11_BRAD_03_MP3,		"V11_BRAD_03"},
-	{V11_BUSTER_01,		M11_BUSTER_01_MP3,		"V11_BUSTER_01"},
-	{V11_BUSTER_02,		M11_BUSTER_02_MP3,		"V11_BUSTER_02"},
-	{V11_BUSTER_03,		M11_BUSTER_03_MP3,		"V11_BUSTER_03"},
-	{V11_DINERS_01,		M11_DINERS_01_MP3,		"V11_DINERS_01"},
-	{V11_DINERS_02,		M11_DINERS_02_MP3,		"V11_DINERS_02"},
-	{V11_DOPPLER_01,		M11_DOPPLER_01_MP3,		"V11_DOPPLER_01"},
-	{V11_DOPPLER_02,		M11_DOPPLER_02_MP3,		"V11_DOPPLER_02"},
-	{V11_DOPPLER_03,		M11_DOPPLER_03_MP3,		"V11_DOPPLER_03"},
-	{V11_DOPPLER_04,		M11_DOPPLER_04_MP3,		"V11_DOPPLER_04"},
-	{V11_DOPPLER_05,		M11_DOPPLER_05_MP3,		"V11_DOPPLER_05"},
-	{V11_DOREK_01,		M11_DOREK_01_MP3,		"V11_DOREK_01"},
-	{V11_DOREK_02,		M11_DOREK_02_MP3,		"V11_DOREK_02"},
-	{V11_DOREK_03,		M11_DOREK_03_MP3,		"V11_DOREK_03"},
-	{V11_DOZER_01,		M11_DOZER_01_MP3,		"V11_DOZER_01"},
-	{V11_DOZER_02,		M11_DOZER_02_MP3,		"V11_DOZER_02"},
-	{V11_DOZER_03,		M11_DOZER_03_MP3,		"V11_DOZER_03"},
-	{V11_DOZER_04,		M11_DOZER_04_MP3,		"V11_DOZER_04"},
-	{V11_GNAPPE_01,		M11_GNAPPE_01_MP3,		"V11_GNAPPE_01"},
-	{V11_GNAPPE_02,		M11_GNAPPE_02_MP3,		"V11_GNAPPE_02"},
-	{V11_GNAPPE_03,		M11_GNAPPE_03_MP3,		"V11_GNAPPE_03"},
-	{V11_GNAPPE_04,		M11_GNAPPE_04_MP3,		"V11_GNAPPE_04"},
-	{V11_GNAPPE_05,		M11_GNAPPE_05_MP3,		"V11_GNAPPE_05"},
-	{V11_GNODIMY_01,		M11_GNODIMY_01_MP3,		"V11_GNODIMY_01"},
-	{V11_GNODIMY_02,		M11_GNODIMY_02_MP3,		"V11_GNODIMY_02"},
-	{V11_GNODIMY_03,		M11_GNODIMY_03_MP3,		"V11_GNODIMY_03"},
-	{V11_GNODIMY_04,		M11_GNODIMY_04_MP3,		"V11_GNODIMY_04"},
-	{V11_GUY_01,		M11_GUY_01_MP3,		"V11_GUY_01"},
-	{V11_GUY_02,		M11_GUY_02_MP3,		"V11_GUY_02"},
-	{V11_GUY_03,		M11_GUY_03_MP3,		"V11_GUY_03"},
-	{V11_GUY_04,		M11_GUY_04_MP3,		"V11_GUY_04"},
-	{V11_GUY_05,		M11_GUY_05_MP3,		"V11_GUY_05"},
-	{V11_GUY_06,		M11_GUY_06_MP3,		"V11_GUY_06"},
-	{V11_GUY_07,		M11_GUY_07_MP3,		"V11_GUY_07"},
-	{V11_GUY_08,		M11_GUY_08_MP3,		"V11_GUY_08"},
-	{V11_GUY_09,		M11_GUY_09_MP3,		"V11_GUY_09"},
-	{V11_GUY_10,		M11_GUY_10_MP3,		"V11_GUY_10"},
-	{V11_GUY_11,		M11_GUY_11_MP3,		"V11_GUY_11"},
-	{V11_GUY_12,		M11_GUY_12_MP3,		"V11_GUY_12"},
-	{V11_GUY_13,		M11_GUY_13_MP3,		"V11_GUY_13"},
-	{V11_GUY_15,		M11_GUY_15_MP3,		"V11_GUY_15"},
-	{V11_GUY_16,		M11_GUY_16_MP3,		"V11_GUY_16"},
-	{V11_GUY_17,		M11_GUY_17_MP3,		"V11_GUY_17"},
-	{V11_HAMBRE_01,		M11_HAMBRE_01_MP3,		"V11_HAMBRE_01"},
-	{V11_HAMBRE_02,		M11_HAMBRE_02_MP3,		"V11_HAMBRE_02"},
-	{V11_HAMBRE_03,		M11_HAMBRE_03_MP3,		"V11_HAMBRE_03"},
-	{V11_HAMBRE_04,		M11_HAMBRE_04_MP3,		"V11_HAMBRE_04"},
-	{V11_HAMBRE_05,		M11_HAMBRE_05_MP3,		"V11_HAMBRE_05"},
-	{V11_HUMBERT_01,		M11_HUMBERT_01_MP3,		"V11_HUMBERT_01"},
-	{V11_ILLIAC_01,		M11_ILLIAC_01_MP3,		"V11_ILLIAC_01"},
-	{V11_JAQUES_01,		M11_JAQUES_01_MP3,		"V11_JAQUES_01"},
-	{V11_JAQUES_02,		M11_JAQUES_02_MP3,		"V11_JAQUES_02"},
-	{V11_JAQUES_03,		M11_JAQUES_03_MP3,		"V11_JAQUES_03"},
-	{V11_JAQUES_04,		M11_JAQUES_04_MP3,		"V11_JAQUES_04"},
-	{V11_LUMBAR_01,		M11_LUMBAR_01_MP3,		"V11_LUMBAR_01"},
-	{V11_MAN_IN_STALL_01,		M11_MAN_IN_STALL_01_MP3,		"V11_MAN_IN_STALL_01"},
-	{V11_MAN_IN_STALL_02,		M11_MAN_IN_STALL_02_MP3,		"V11_MAN_IN_STALL_02"},
-	{V11_MAN_IN_STALL_03,		M11_MAN_IN_STALL_03_MP3,		"V11_MAN_IN_STALL_03"},
-	{V11_MAN_IN_STALL_04,		M11_MAN_IN_STALL_04_MP3,		"V11_MAN_IN_STALL_04"},
-	{V11_MAN_IN_STALL_05,		M11_MAN_IN_STALL_05_MP3,		"V11_MAN_IN_STALL_05"},
-	{V11_MANNY_01,		M11_MANNY_01_MP3,		"V11_MANNY_01"},
-	{V11_MUMPS_01,		M11_MUMPS_01_MP3,		"V11_MUMPS_01"},
-	{V11_MUMPS_02,		M11_MUMPS_02_MP3,		"V11_MUMPS_02"},
-	{V11_MUMPS_03,		M11_MUMPS_03_MP3,		"V11_MUMPS_03"},
-	{V11_MUMPS_04,		M11_MUMPS_04_MP3,		"V11_MUMPS_04"},
-	{V11_MUMPS_05,		M11_MUMPS_05_MP3,		"V11_MUMPS_05"},
-	{V11_MUMPS_06,		M11_MUMPS_06_MP3,		"V11_MUMPS_06"},
-	{V11_MUMPS_07,		M11_MUMPS_07_MP3,		"V11_MUMPS_07"},
-	{V11_MUMPS_08,		M11_MUMPS_08_MP3,		"V11_MUMPS_08"},
-	{V11_MUMPS_09,		M11_MUMPS_09_MP3,		"V11_MUMPS_09"},
-	{V11_MUMPS_10,		M11_MUMPS_10_MP3,		"V11_MUMPS_10"},
-	{V11_MUMPS_11,		M11_MUMPS_11_MP3,		"V11_MUMPS_11"},
-	{V11_MUMPS_12,		M11_MUMPS_12_MP3,		"V11_MUMPS_12"},
-	{V11_MUMPS_13,		M11_MUMPS_13_MP3,		"V11_MUMPS_13"},
-	{V11_MUMPS_14,		M11_MUMPS_14_MP3,		"V11_MUMPS_14"},
-	{V11_MUMPS_15,		M11_MUMPS_15_MP3,		"V11_MUMPS_15"},
-	{V11_MUMPS_16,		M11_MUMPS_16_MP3,		"V11_MUMPS_16"},
-	{V11_MUMPS_17,		M11_MUMPS_17_MP3,		"V11_MUMPS_17"},
-	{V11_MUMPS_18,		M11_MUMPS_18_MP3,		"V11_MUMPS_18"},
-	{V11_MUMPS_19,		M11_MUMPS_19_MP3,		"V11_MUMPS_19"},
-	{V11_MUMPS_20,		M11_MUMPS_20_MP3,		"V11_MUMPS_20"},
-	{V11_MUMPS_22,		M11_MUMPS_22_MP3,		"V11_MUMPS_22"},
-	{V11_MUMPS_23,		M11_MUMPS_23_MP3,		"V11_MUMPS_23"},
-	{V11_MUMPS_24,		M11_MUMPS_24_MP3,		"V11_MUMPS_24"},
-	{V11_MUMPS_25,		M11_MUMPS_25_MP3,		"V11_MUMPS_25"},
-	{V11_MUMPS_26,		M11_MUMPS_26_MP3,		"V11_MUMPS_26"},
+	{V11_ARNIE_01,			M11_ARNIE_01_MP3,			"V11_ARNIE_01"},
+	{V11_BELINDA_01,		M11_BELINDA_01_MP3,			"V11_BELINDA_01"},
+	{V11_BLOCK_01,			M11_BLOCK_01_MP3,			"V11_BLOCK_01"},
+	{V11_BLOCK_02,			M11_BLOCK_02_MP3,			"V11_BLOCK_02"},
+	{V11_BLOCK_03,			M11_BLOCK_03_MP3,			"V11_BLOCK_03"},
+	{V11_BRAD_01,			M11_BRAD_01_MP3,			"V11_BRAD_01"},
+	{V11_BRAD_02,			M11_BRAD_02_MP3,			"V11_BRAD_02"},
+	{V11_BRAD_03,			M11_BRAD_03_MP3,			"V11_BRAD_03"},
+	{V11_BUSTER_01,			M11_BUSTER_01_MP3,			"V11_BUSTER_01"},
+	{V11_BUSTER_02,			M11_BUSTER_02_MP3,			"V11_BUSTER_02"},
+	{V11_BUSTER_03,			M11_BUSTER_03_MP3,			"V11_BUSTER_03"},
+	{V11_DINERS_01,			M11_DINERS_01_MP3,			"V11_DINERS_01"},
+	{V11_DINERS_02,			M11_DINERS_02_MP3,			"V11_DINERS_02"},
+	{V11_DOPPLER_01,		M11_DOPPLER_01_MP3,			"V11_DOPPLER_01"},
+	{V11_DOPPLER_02,		M11_DOPPLER_02_MP3,			"V11_DOPPLER_02"},
+	{V11_DOPPLER_03,		M11_DOPPLER_03_MP3,			"V11_DOPPLER_03"},
+	{V11_DOPPLER_04,		M11_DOPPLER_04_MP3,			"V11_DOPPLER_04"},
+	{V11_DOPPLER_05,		M11_DOPPLER_05_MP3,			"V11_DOPPLER_05"},
+	{V11_DOREK_01,			M11_DOREK_01_MP3,			"V11_DOREK_01"},
+	{V11_DOREK_02,			M11_DOREK_02_MP3,			"V11_DOREK_02"},
+	{V11_DOREK_03,			M11_DOREK_03_MP3,			"V11_DOREK_03"},
+	{V11_DOZER_01,			M11_DOZER_01_MP3,			"V11_DOZER_01"},
+	{V11_DOZER_02,			M11_DOZER_02_MP3,			"V11_DOZER_02"},
+	{V11_DOZER_03,			M11_DOZER_03_MP3,			"V11_DOZER_03"},
+	{V11_DOZER_04,			M11_DOZER_04_MP3,			"V11_DOZER_04"},
+	{V11_GNAPPE_01,			M11_GNAPPE_01_MP3,			"V11_GNAPPE_01"},
+	{V11_GNAPPE_02,			M11_GNAPPE_02_MP3,			"V11_GNAPPE_02"},
+	{V11_GNAPPE_03,			M11_GNAPPE_03_MP3,			"V11_GNAPPE_03"},
+	{V11_GNAPPE_04,			M11_GNAPPE_04_MP3,			"V11_GNAPPE_04"},
+	{V11_GNAPPE_05,			M11_GNAPPE_05_MP3,			"V11_GNAPPE_05"},
+	{V11_GNODIMY_01,		M11_GNODIMY_01_MP3,			"V11_GNODIMY_01"},
+	{V11_GNODIMY_02,		M11_GNODIMY_02_MP3,			"V11_GNODIMY_02"},
+	{V11_GNODIMY_03,		M11_GNODIMY_03_MP3,			"V11_GNODIMY_03"},
+	{V11_GNODIMY_04,		M11_GNODIMY_04_MP3,			"V11_GNODIMY_04"},
+	{V11_GUY_01,			M11_GUY_01_MP3,				"V11_GUY_01"},
+	{V11_GUY_02,			M11_GUY_02_MP3,				"V11_GUY_02"},
+	{V11_GUY_03,			M11_GUY_03_MP3,				"V11_GUY_03"},
+	{V11_GUY_04,			M11_GUY_04_MP3,				"V11_GUY_04"},
+	{V11_GUY_05,			M11_GUY_05_MP3,				"V11_GUY_05"},
+	{V11_GUY_06,			M11_GUY_06_MP3,				"V11_GUY_06"},
+	{V11_GUY_07,			M11_GUY_07_MP3,				"V11_GUY_07"},
+	{V11_GUY_08,			M11_GUY_08_MP3,				"V11_GUY_08"},
+	{V11_GUY_09,			M11_GUY_09_MP3,				"V11_GUY_09"},
+	{V11_GUY_10,			M11_GUY_10_MP3,				"V11_GUY_10"},
+	{V11_GUY_11,			M11_GUY_11_MP3,				"V11_GUY_11"},
+	{V11_GUY_12,			M11_GUY_12_MP3,				"V11_GUY_12"},
+	{V11_GUY_13,			M11_GUY_13_MP3,				"V11_GUY_13"},
+	{V11_GUY_15,			M11_GUY_15_MP3,				"V11_GUY_15"},
+	{V11_GUY_16,			M11_GUY_16_MP3,				"V11_GUY_16"},
+	{V11_GUY_17,			M11_GUY_17_MP3,				"V11_GUY_17"},
+	{V11_HAMBRE_01,			M11_HAMBRE_01_MP3,			"V11_HAMBRE_01"},
+	{V11_HAMBRE_02,			M11_HAMBRE_02_MP3,			"V11_HAMBRE_02"},
+	{V11_HAMBRE_03,			M11_HAMBRE_03_MP3,			"V11_HAMBRE_03"},
+	{V11_HAMBRE_04,			M11_HAMBRE_04_MP3,			"V11_HAMBRE_04"},
+	{V11_HAMBRE_05,			M11_HAMBRE_05_MP3,			"V11_HAMBRE_05"},
+	{V11_HUMBERT_01,		M11_HUMBERT_01_MP3,			"V11_HUMBERT_01"},
+	{V11_ILLIAC_01,			M11_ILLIAC_01_MP3,			"V11_ILLIAC_01"},
+	{V11_JAQUES_01,			M11_JAQUES_01_MP3,			"V11_JAQUES_01"},
+	{V11_JAQUES_02,			M11_JAQUES_02_MP3,			"V11_JAQUES_02"},
+	{V11_JAQUES_03,			M11_JAQUES_03_MP3,			"V11_JAQUES_03"},
+	{V11_JAQUES_04,			M11_JAQUES_04_MP3,			"V11_JAQUES_04"},
+	{V11_LUMBAR_01,			M11_LUMBAR_01_MP3,			"V11_LUMBAR_01"},
+	{V11_MAN_IN_STALL_01,	M11_MAN_IN_STALL_01_MP3,	"V11_MAN_IN_STALL_01"},
+	{V11_MAN_IN_STALL_02,	M11_MAN_IN_STALL_02_MP3,	"V11_MAN_IN_STALL_02"},
+	{V11_MAN_IN_STALL_03,	M11_MAN_IN_STALL_03_MP3,	"V11_MAN_IN_STALL_03"},
+	{V11_MAN_IN_STALL_04,	M11_MAN_IN_STALL_04_MP3,	"V11_MAN_IN_STALL_04"},
+	{V11_MAN_IN_STALL_05,	M11_MAN_IN_STALL_05_MP3,	"V11_MAN_IN_STALL_05"},
+	{V11_MANNY_01,			M11_MANNY_01_MP3,			"V11_MANNY_01"},
+	{V11_MUMPS_01,			M11_MUMPS_01_MP3,			"V11_MUMPS_01"},
+	{V11_MUMPS_02,			M11_MUMPS_02_MP3,			"V11_MUMPS_02"},
+	{V11_MUMPS_03,			M11_MUMPS_03_MP3,			"V11_MUMPS_03"},
+	{V11_MUMPS_04,			M11_MUMPS_04_MP3,			"V11_MUMPS_04"},
+	{V11_MUMPS_05,			M11_MUMPS_05_MP3,			"V11_MUMPS_05"},
+	{V11_MUMPS_06,			M11_MUMPS_06_MP3,			"V11_MUMPS_06"},
+	{V11_MUMPS_07,			M11_MUMPS_07_MP3,			"V11_MUMPS_07"},
+	{V11_MUMPS_08,			M11_MUMPS_08_MP3,			"V11_MUMPS_08"},
+	{V11_MUMPS_09,			M11_MUMPS_09_MP3,			"V11_MUMPS_09"},
+	{V11_MUMPS_10,			M11_MUMPS_10_MP3,			"V11_MUMPS_10"},
+	{V11_MUMPS_11,			M11_MUMPS_11_MP3,			"V11_MUMPS_11"},
+	{V11_MUMPS_12,			M11_MUMPS_12_MP3,			"V11_MUMPS_12"},
+	{V11_MUMPS_13,			M11_MUMPS_13_MP3,			"V11_MUMPS_13"},
+	{V11_MUMPS_14,			M11_MUMPS_14_MP3,			"V11_MUMPS_14"},
+	{V11_MUMPS_15,			M11_MUMPS_15_MP3,			"V11_MUMPS_15"},
+	{V11_MUMPS_16,			M11_MUMPS_16_MP3,			"V11_MUMPS_16"},
+	{V11_MUMPS_17,			M11_MUMPS_17_MP3,			"V11_MUMPS_17"},
+	{V11_MUMPS_18,			M11_MUMPS_18_MP3,			"V11_MUMPS_18"},
+	{V11_MUMPS_19,			M11_MUMPS_19_MP3,			"V11_MUMPS_19"},
+	{V11_MUMPS_20,			M11_MUMPS_20_MP3,			"V11_MUMPS_20"},
+	{V11_MUMPS_22,			M11_MUMPS_22_MP3,			"V11_MUMPS_22"},
+	{V11_MUMPS_23,			M11_MUMPS_23_MP3,			"V11_MUMPS_23"},
+	{V11_MUMPS_24,			M11_MUMPS_24_MP3,			"V11_MUMPS_24"},
+	{V11_MUMPS_25,			M11_MUMPS_25_MP3,			"V11_MUMPS_25"},
+	{V11_MUMPS_26,			M11_MUMPS_26_MP3,			"V11_MUMPS_26"},
 	{V11_PEDIMENT_01,		M11_PEDIMENT_01_MP3,		"V11_PEDIMENT_01"},
 	{V11_PEDIMENT_02,		M11_PEDIMENT_02_MP3,		"V11_PEDIMENT_02"},
 	{V11_PEDIMENT_03,		M11_PEDIMENT_03_MP3,		"V11_PEDIMENT_03"},
@@ -839,71 +839,71 @@ const SoundLookUp soundList[] =  {
 	{V11_PEDIMENT_06,		M11_PEDIMENT_06_MP3,		"V11_PEDIMENT_06"},
 	{V11_PEDIMENT_07,		M11_PEDIMENT_07_MP3,		"V11_PEDIMENT_07"},
 	{V11_PEDIMENT_08,		M11_PEDIMENT_08_MP3,		"V11_PEDIMENT_08"},
-	{V11_POLONEY_01,		M11_POLONEY_01_MP3,		"V11_POLONEY_01"},
-	{V11_POLONEY_02,		M11_POLONEY_02_MP3,		"V11_POLONEY_02"},
-	{V11_POLONEY_03,		M11_POLONEY_03_MP3,		"V11_POLONEY_03"},
-	{V11_SAUSAGE_01,		M11_SAUSAGE_01_MP3,		"V11_SAUSAGE_01"},
-	{V11_SAUSAGE_02,		M11_SAUSAGE_02_MP3,		"V11_SAUSAGE_02"},
-	{V11_SAUSAGE_03,		M11_SAUSAGE_03_MP3,		"V11_SAUSAGE_03"},
-	{V11_SAUSAGE_04,		M11_SAUSAGE_04_MP3,		"V11_SAUSAGE_04"},
-	{V11_SAUSAGE_05,		M11_SAUSAGE_05_MP3,		"V11_SAUSAGE_05"},
-	{V11_SAUSAGE_06,		M11_SAUSAGE_06_MP3,		"V11_SAUSAGE_06"},
-	{V11_SAUSAGE_07,		M11_SAUSAGE_07_MP3,		"V11_SAUSAGE_07"},
-	{V11_SAUSAGE_08,		M11_SAUSAGE_08_MP3,		"V11_SAUSAGE_08"},
-	{V11_SAUSAGE_09,		M11_SAUSAGE_09_MP3,		"V11_SAUSAGE_09"},
-	{V11_SAUSAGE_10,		M11_SAUSAGE_10_MP3,		"V11_SAUSAGE_10"},
-	{V12_ABLE_01,		M12_ABLE_01_MP3,		"V12_ABLE_01"},
-	{V12_ABLE_02,		M12_ABLE_02_MP3,		"V12_ABLE_02"},
-	{V12_ABLE_03,		M12_ABLE_03_MP3,		"V12_ABLE_03"},
-	{V12_BUSY_01,		M12_BUSY_01_MP3,		"V12_BUSY_01"},
-	{V12_BUSY_02,		M12_BUSY_02_MP3,		"V12_BUSY_02"},
-	{V12_BUSY_03,		M12_BUSY_03_MP3,		"V12_BUSY_03"},
-	{V12_BUSY_04,		M12_BUSY_04_MP3,		"V12_BUSY_04"},
-	{V12_BUSY_05,		M12_BUSY_05_MP3,		"V12_BUSY_05"},
-	{V12_BUSY_06,		M12_BUSY_06_MP3,		"V12_BUSY_06"},
-	{V12_BUSY_07,		M12_BUSY_07_MP3,		"V12_BUSY_07"},
-	{V12_BUSY_08,		M12_BUSY_08_MP3,		"V12_BUSY_08"},
-	{V12_CHARLIE_01,		M12_CHARLIE_01_MP3,		"V12_CHARLIE_01"},
-	{V12_CHARLIE_02,		M12_CHARLIE_02_MP3,		"V12_CHARLIE_02"},
+	{V11_POLONEY_01,		M11_POLONEY_01_MP3,			"V11_POLONEY_01"},
+	{V11_POLONEY_02,		M11_POLONEY_02_MP3,			"V11_POLONEY_02"},
+	{V11_POLONEY_03,		M11_POLONEY_03_MP3,			"V11_POLONEY_03"},
+	{V11_SAUSAGE_01,		M11_SAUSAGE_01_MP3,			"V11_SAUSAGE_01"},
+	{V11_SAUSAGE_02,		M11_SAUSAGE_02_MP3,			"V11_SAUSAGE_02"},
+	{V11_SAUSAGE_03,		M11_SAUSAGE_03_MP3,			"V11_SAUSAGE_03"},
+	{V11_SAUSAGE_04,		M11_SAUSAGE_04_MP3,			"V11_SAUSAGE_04"},
+	{V11_SAUSAGE_05,		M11_SAUSAGE_05_MP3,			"V11_SAUSAGE_05"},
+	{V11_SAUSAGE_06,		M11_SAUSAGE_06_MP3,			"V11_SAUSAGE_06"},
+	{V11_SAUSAGE_07,		M11_SAUSAGE_07_MP3,			"V11_SAUSAGE_07"},
+	{V11_SAUSAGE_08,		M11_SAUSAGE_08_MP3,			"V11_SAUSAGE_08"},
+	{V11_SAUSAGE_09,		M11_SAUSAGE_09_MP3,			"V11_SAUSAGE_09"},
+	{V11_SAUSAGE_10,		M11_SAUSAGE_10_MP3,			"V11_SAUSAGE_10"},
+	{V12_ABLE_01,			M12_ABLE_01_MP3,			"V12_ABLE_01"},
+	{V12_ABLE_02,			M12_ABLE_02_MP3,			"V12_ABLE_02"},
+	{V12_ABLE_03,			M12_ABLE_03_MP3,			"V12_ABLE_03"},
+	{V12_BUSY_01,			M12_BUSY_01_MP3,			"V12_BUSY_01"},
+	{V12_BUSY_02,			M12_BUSY_02_MP3,			"V12_BUSY_02"},
+	{V12_BUSY_03,			M12_BUSY_03_MP3,			"V12_BUSY_03"},
+	{V12_BUSY_04,			M12_BUSY_04_MP3,			"V12_BUSY_04"},
+	{V12_BUSY_05,			M12_BUSY_05_MP3,			"V12_BUSY_05"},
+	{V12_BUSY_06,			M12_BUSY_06_MP3,			"V12_BUSY_06"},
+	{V12_BUSY_07,			M12_BUSY_07_MP3,			"V12_BUSY_07"},
+	{V12_BUSY_08,			M12_BUSY_08_MP3,			"V12_BUSY_08"},
+	{V12_CHARLIE_01,		M12_CHARLIE_01_MP3,			"V12_CHARLIE_01"},
+	{V12_CHARLIE_02,		M12_CHARLIE_02_MP3,			"V12_CHARLIE_02"},
 	{V12_CONUNDRUM_01,		M12_CONUNDRUM_01_MP3,		"V12_CONUNDRUM_01"},
 	{V12_CONUNDRUM_02,		M12_CONUNDRUM_02_MP3,		"V12_CONUNDRUM_02"},
 	{V12_CONUNDRUM_03,		M12_CONUNDRUM_03_MP3,		"V12_CONUNDRUM_03"},
 	{V12_CONUNDRUM_04,		M12_CONUNDRUM_04_MP3,		"V12_CONUNDRUM_04"},
 	{V12_CONUNDRUM_05,		M12_CONUNDRUM_05_MP3,		"V12_CONUNDRUM_05"},
-	{V12_FOXTROT_01,		M12_FOXTROT_01_MP3,		"V12_FOXTROT_01"},
-	{V12_FOXTROT_02,		M12_FOXTROT_02_MP3,		"V12_FOXTROT_02"},
-	{V12_GUY_01,			M12_GUY_01_MP3,			"V12_GUY_01"},
-	{V12_GUY_02,			M12_GUY_02_MP3,			"V12_GUY_02"},
-	{V12_GUY_03,			M12_GUY_03_MP3,			"V12_GUY_03"},
-	{V12_HAUTE_01,		M12_HAUTE_01_MP3,		"V12_HAUTE_01"},
-	{V12_HAUTE_02,		M12_HAUTE_02_MP3,		"V12_HAUTE_02"},
-	{V12_HAUTE_03,		M12_HAUTE_03_MP3,		"V12_HAUTE_03"},
-	{V12_HAUTE_04,		M12_HAUTE_04_MP3,		"V12_HAUTE_04"},
-	{V12_HAUTE_05,		M12_HAUTE_05_MP3,		"V12_HAUTE_05"},
-	{V12_HAUTE_06,		M12_HAUTE_06_MP3,		"V12_HAUTE_06"},
-	{V12_HOVER_01,		M12_HOVER_01_MP3,		"V12_HOVER_01"},
-	{V12_HOVER_02,		M12_HOVER_02_MP3,		"V12_HOVER_02"},
-	{V12_RUBE_01,		M12_RUBE_01_MP3,		"V12_RUBE_01"},
-	{V12_RUBE_02,		M12_RUBE_02_MP3,		"V12_RUBE_02"},
-	{V12_RUBE_03,		M12_RUBE_03_MP3,		"V12_RUBE_03"},
-	{V12_RUBE_04,		M12_RUBE_04_MP3,		"V12_RUBE_04"},
-	{V12_RUBE_05,		M12_RUBE_05_MP3,		"V12_RUBE_05"},
-	{V12_RUBE_06,		M12_RUBE_06_MP3,		"V12_RUBE_06"},
-	{V12_RUBE_07,		M12_RUBE_07_MP3,		"V12_RUBE_07"},
-	{V12_RUBE_08,		M12_RUBE_08_MP3,		"V12_RUBE_08"},
-	{V12_RUBE_09,		M12_RUBE_09_MP3,		"V12_RUBE_09"},
-	{V12_RUBE_10,		M12_RUBE_10_MP3,		"V12_RUBE_10"},
-	{V12_TEKT_01,		M12_TEKT_01_MP3,		"V12_TEKT_01"},
-	{V12_TEKT_02,		M12_TEKT_02_MP3,		"V12_TEKT_02"},
-	{V12_TEKT_03,		M12_TEKT_03_MP3,		"V12_TEKT_03"},
-	{V12_TEKT_04,		M12_TEKT_04_MP3,		"V12_TEKT_04"},
-	{V12_TEKT_05,		M12_TEKT_05_MP3,		"V12_TEKT_05"},
-	{V12_TEKT_06,		M12_TEKT_06_MP3,		"V12_TEKT_06"},
-	{V12_TEKT_07,		M12_TEKT_07_MP3,		"V12_TEKT_07"},
-	{V13_ANIBLE_01,		M13_ANIBLE_01_MP3,		"V13_ANIBLE_01"},
-	{V13_ANIBLE_02,		M13_ANIBLE_02_MP3,		"V13_ANIBLE_02"},
-	{V13_FLOWER_01,		M13_FLOWER_01_MP3,		"V13_FLOWER_01"},
-	{V13_FLOWER_02,		M13_FLOWER_02_MP3,		"V13_FLOWER_02"},
+	{V12_FOXTROT_01,		M12_FOXTROT_01_MP3,			"V12_FOXTROT_01"},
+	{V12_FOXTROT_02,		M12_FOXTROT_02_MP3,			"V12_FOXTROT_02"},
+	{V12_GUY_01,			M12_GUY_01_MP3,				"V12_GUY_01"},
+	{V12_GUY_02,			M12_GUY_02_MP3,				"V12_GUY_02"},
+	{V12_GUY_03,			M12_GUY_03_MP3,				"V12_GUY_03"},
+	{V12_HAUTE_01,			M12_HAUTE_01_MP3,			"V12_HAUTE_01"},
+	{V12_HAUTE_02,			M12_HAUTE_02_MP3,			"V12_HAUTE_02"},
+	{V12_HAUTE_03,			M12_HAUTE_03_MP3,			"V12_HAUTE_03"},
+	{V12_HAUTE_04,			M12_HAUTE_04_MP3,			"V12_HAUTE_04"},
+	{V12_HAUTE_05,			M12_HAUTE_05_MP3,			"V12_HAUTE_05"},
+	{V12_HAUTE_06,			M12_HAUTE_06_MP3,			"V12_HAUTE_06"},
+	{V12_HOVER_01,			M12_HOVER_01_MP3,			"V12_HOVER_01"},
+	{V12_HOVER_02,			M12_HOVER_02_MP3,			"V12_HOVER_02"},
+	{V12_RUBE_01,			M12_RUBE_01_MP3,			"V12_RUBE_01"},
+	{V12_RUBE_02,			M12_RUBE_02_MP3,			"V12_RUBE_02"},
+	{V12_RUBE_03,			M12_RUBE_03_MP3,			"V12_RUBE_03"},
+	{V12_RUBE_04,			M12_RUBE_04_MP3,			"V12_RUBE_04"},
+	{V12_RUBE_05,			M12_RUBE_05_MP3,			"V12_RUBE_05"},
+	{V12_RUBE_06,			M12_RUBE_06_MP3,			"V12_RUBE_06"},
+	{V12_RUBE_07,			M12_RUBE_07_MP3,			"V12_RUBE_07"},
+	{V12_RUBE_08,			M12_RUBE_08_MP3,			"V12_RUBE_08"},
+	{V12_RUBE_09,			M12_RUBE_09_MP3,			"V12_RUBE_09"},
+	{V12_RUBE_10,			M12_RUBE_10_MP3,			"V12_RUBE_10"},
+	{V12_TEKT_01,			M12_TEKT_01_MP3,			"V12_TEKT_01"},
+	{V12_TEKT_02,			M12_TEKT_02_MP3,			"V12_TEKT_02"},
+	{V12_TEKT_03,			M12_TEKT_03_MP3,			"V12_TEKT_03"},
+	{V12_TEKT_04,			M12_TEKT_04_MP3,			"V12_TEKT_04"},
+	{V12_TEKT_05,			M12_TEKT_05_MP3,			"V12_TEKT_05"},
+	{V12_TEKT_06,			M12_TEKT_06_MP3,			"V12_TEKT_06"},
+	{V12_TEKT_07,			M12_TEKT_07_MP3,			"V12_TEKT_07"},
+	{V13_ANIBLE_01,			M13_ANIBLE_01_MP3,			"V13_ANIBLE_01"},
+	{V13_ANIBLE_02,			M13_ANIBLE_02_MP3,			"V13_ANIBLE_02"},
+	{V13_FLOWER_01,			M13_FLOWER_01_MP3,			"V13_FLOWER_01"},
+	{V13_FLOWER_02,			M13_FLOWER_02_MP3,			"V13_FLOWER_02"},
 	{V13_FOOCHANE_01,		M13_FOOCHANE_01_MP3,		"V13_FOOCHANE_01"},
 	{V13_FOOCHANE_02,		M13_FOOCHANE_02_MP3,		"V13_FOOCHANE_02"},
 	{V13_FOOCHANE_03,		M13_FOOCHANE_03_MP3,		"V13_FOOCHANE_03"},
@@ -915,27 +915,27 @@ const SoundLookUp soundList[] =  {
 	{V13_GHULABUL_05,		M13_GHULABUL_05_MP3,		"V13_GHULABUL_05"},
 	{V13_GHULABUL_06,		M13_GHULABUL_06_MP3,		"V13_GHULABUL_06"},
 	{V13_GHULABUL_07,		M13_GHULABUL_07_MP3,		"V13_GHULABUL_07"},
-	{V13_GUY_01,		M13_GUY_01_MP3,		"V13_GUY_01"},
-	{V13_GUY_02,		M13_GUY_02_MP3,		"V13_GUY_02"},
+	{V13_GUY_01,			M13_GUY_01_MP3,				"V13_GUY_01"},
+	{V13_GUY_02,			M13_GUY_02_MP3,				"V13_GUY_02"},
 	{V13_HAVENGIN_01,		M13_HAVENGIN_01_MP3,		"V13_HAVENGIN_01"},
-	{V13_MELO_01,		M13_MELO_01_MP3,		"V13_MELO_01"},
-	{V13_MELO_02,		M13_MELO_02_MP3,		"V13_MELO_02"},
-	{V13_MELO_03,		M13_MELO_03_MP3,		"V13_MELO_03"},
-	{V13_MITAKO_01,		M13_MITAKO_01_MP3,		"V13_MITAKO_01"},
-	{V13_MITAKO_02,		M13_MITAKO_02_MP3,		"V13_MITAKO_02"},
-	{V13_MITAKO_03,		M13_MITAKO_03_MP3,		"V13_MITAKO_03"},
-	{V13_SPOONIE_01,		M13_SPOONIE_01_MP3,		"V13_SPOONIE_01"},
-	{V13_SPOONIE_02,		M13_SPOONIE_02_MP3,		"V13_SPOONIE_02"},
-	{V13_SPOONIE_03,		M13_SPOONIE_03_MP3,		"V13_SPOONIE_03"},
-	{V13_SPOONIE_04,		M13_SPOONIE_04_MP3,		"V13_SPOONIE_04"},
-	{V13_SPOONIE_05,		M13_SPOONIE_05_MP3,		"V13_SPOONIE_05"},
-	{V13_ZYGOTE_01,		M13_ZYGOTE_01_MP3,		"V13_ZYGOTE_01"},
-	{V13_ZYGOTE_02,		M13_ZYGOTE_02_MP3,		"V13_ZYGOTE_02"},
-	{V13_ZYGOTE_03,		M13_ZYGOTE_03_MP3,		"V13_ZYGOTE_03"},
-	{V13_ZYGOTE_04,		M13_ZYGOTE_04_MP3,		"V13_ZYGOTE_04"},
-	{V13_ZYGOTE_05,		M13_ZYGOTE_05_MP3,		"V13_ZYGOTE_05"},
-	{V14_LAMORTE_01,		M14_LAMORTE_01_MP3,		"V14_LAMORTE_01"},
-	{V14_LAMORTE_02,		M14_LAMORTE_02_MP3,		"V14_LAMORTE_02"},
+	{V13_MELO_01,			M13_MELO_01_MP3,			"V13_MELO_01"},
+	{V13_MELO_02,			M13_MELO_02_MP3,			"V13_MELO_02"},
+	{V13_MELO_03,			M13_MELO_03_MP3,			"V13_MELO_03"},
+	{V13_MITAKO_01,			M13_MITAKO_01_MP3,			"V13_MITAKO_01"},
+	{V13_MITAKO_02,			M13_MITAKO_02_MP3,			"V13_MITAKO_02"},
+	{V13_MITAKO_03,			M13_MITAKO_03_MP3,			"V13_MITAKO_03"},
+	{V13_SPOONIE_01,		M13_SPOONIE_01_MP3,			"V13_SPOONIE_01"},
+	{V13_SPOONIE_02,		M13_SPOONIE_02_MP3,			"V13_SPOONIE_02"},
+	{V13_SPOONIE_03,		M13_SPOONIE_03_MP3,			"V13_SPOONIE_03"},
+	{V13_SPOONIE_04,		M13_SPOONIE_04_MP3,			"V13_SPOONIE_04"},
+	{V13_SPOONIE_05,		M13_SPOONIE_05_MP3,			"V13_SPOONIE_05"},
+	{V13_ZYGOTE_01,			M13_ZYGOTE_01_MP3,			"V13_ZYGOTE_01"},
+	{V13_ZYGOTE_02,			M13_ZYGOTE_02_MP3,			"V13_ZYGOTE_02"},
+	{V13_ZYGOTE_03,			M13_ZYGOTE_03_MP3,			"V13_ZYGOTE_03"},
+	{V13_ZYGOTE_04,			M13_ZYGOTE_04_MP3,			"V13_ZYGOTE_04"},
+	{V13_ZYGOTE_05,			M13_ZYGOTE_05_MP3,			"V13_ZYGOTE_05"},
+	{V14_LAMORTE_01,		M14_LAMORTE_01_MP3,			"V14_LAMORTE_01"},
+	{V14_LAMORTE_02,		M14_LAMORTE_02_MP3,			"V14_LAMORTE_02"},
 	{V15_COPROLITE_01,		M15_COPROITE_01_MP3,		"V15_COPROLITE_01"},
 	{V15_COPROLITE_02,		M15_COPROITE_02_MP3,		"V15_COPROLITE_02"},
 	{V15_COPROLITE_03,		M15_COPROITE_03_MP3,		"V15_COPROLITE_03"},
@@ -954,56 +954,56 @@ const SoundLookUp soundList[] =  {
 	{V15_COPROLITE_16,		M15_COPROITE_16_MP3,		"V15_COPROLITE_16"},
 	{V15_COPROLITE_17,		M15_COPROITE_17_MP3,		"V15_COPROLITE_17"},
 	{V15_COPROLITE_18,		M15_COPROITE_18_MP3,		"V15_COPROLITE_18"},
-	{V15_GUY_01,		M15_GUY_01_MP3,		"V15_GUY_01"},
-	{V15_GUY_02,		M15_GUY_02_MP3,		"V15_GUY_02"},
-	{V15_REED_01,		M15_REED_01_MP3,		"V15_REED_01"},
-	{V15_REED_02,		M15_REED_02_MP3,		"V15_REED_02"},
-	{V15_REED_03,		M15_REED_03_MP3,		"V15_REED_03"},
-	{V16_DYING_01,		M16_DYING_01_MP3,		"V16_DYING_01"},
-	{V16_DYING_02,		M16_DYING_02_MP3,		"V16_DYING_02"},
-	{V16_GUY_01,		M16_GUY_01_MP3,		"V16_GUY_01"},
-	{V16_GUY_02,		M16_GUY_02_MP3,		"V16_GUY_02"},
-	{V16_GUY_03,		M16_GUY_03_MP3,		"V16_GUY_03"},
+	{V15_GUY_01,			M15_GUY_01_MP3,				"V15_GUY_01"},
+	{V15_GUY_02,			M15_GUY_02_MP3,				"V15_GUY_02"},
+	{V15_REED_01,			M15_REED_01_MP3,			"V15_REED_01"},
+	{V15_REED_02,			M15_REED_02_MP3,			"V15_REED_02"},
+	{V15_REED_03,			M15_REED_03_MP3,			"V15_REED_03"},
+	{V16_DYING_01,			M16_DYING_01_MP3,			"V16_DYING_01"},
+	{V16_DYING_02,			M16_DYING_02_MP3,			"V16_DYING_02"},
+	{V16_GUY_01,			M16_GUY_01_MP3,				"V16_GUY_01"},
+	{V16_GUY_02,			M16_GUY_02_MP3,				"V16_GUY_02"},
+	{V16_GUY_03,			M16_GUY_03_MP3,				"V16_GUY_03"},
 	{V17_ANDERSON_01,		M17_ANDERSON_01_MP3,		"V17_ANDERSON_01"},
-	{V17_BARBER_01,		M17_BARBER_01_MP3,		"V17_BARBER_01"},
+	{V17_BARBER_01,			M17_BARBER_01_MP3,			"V17_BARBER_01"},
 	{V17_CAMPBELL_01,		M17_CAMPBELL_01_MP3,		"V17_CAMPBELL_01"},
 	{V17_DEVONSHIRE_01,		M17_DEVONSHIRE_01_MP3,		"V17_DEVONSHIRE_01"},
-	{V17_EGGER_01,		M17_EGGER_01_MP3,		"V17_EGGER_01"},
-	{V17_EMERALD_01,		M17_EMERALD_01_MP3,		"V17_EMERALD_01"},
-	{V17_FLINGBESTER_01,		M17_FLINGBESTER_01_MP3,		"V17_FLINGBESTER_01"},
+	{V17_EGGER_01,			M17_EGGER_01_MP3,			"V17_EGGER_01"},
+	{V17_EMERALD_01,		M17_EMERALD_01_MP3,			"V17_EMERALD_01"},
+	{V17_FLINGBESTER_01,	M17_FLINGBESTER_01_MP3,		"V17_FLINGBESTER_01"},
 	{V17_GERSHWIN_01,		M17_GERSHWIN_01_MP3,		"V17_GERSHWIN_01"},
-	{V17_GUY_01,		M17_GUY_01_MP3,		"V17_GUY_01"},
-	{V17_GUY_02,		M17_GUY_02_MP3,		"V17_GUY_02"},
-	{V17_GUY_03,		M17_GUY_03_MP3,		"V17_GUY_03"},
-	{V17_GUY_04,		M17_GUY_04_MP3,		"V17_GUY_04"},
+	{V17_GUY_01,			M17_GUY_01_MP3,				"V17_GUY_01"},
+	{V17_GUY_02,			M17_GUY_02_MP3,				"V17_GUY_02"},
+	{V17_GUY_03,			M17_GUY_03_MP3,				"V17_GUY_03"},
+	{V17_GUY_04,			M17_GUY_04_MP3,				"V17_GUY_04"},
 	{V17_HEPHASTUS_01,		M17_HEPHASTUS_01_MP3,		"V17_HEPHASTUS_01"},
-	{V17_INIWA_01,		M17_INIWA_01_MP3,		"V17_INIWA_01"},
-	{V17_INIWA_02,		M17_INIWA_02_MP3,		"V17_INIWA_02"},
-	{V17_INIWA_03,		M17_INIWA_03_MP3,		"V17_INIWA_03"},
-	{V17_KEYCODE_01,		M17_KEYCODE_01_MP3,		"V17_KEYCODE_01"},
-	{V17_KEYCODE_02,		M17_KEYCODE_02_MP3,		"V17_KEYCODE_02"},
-	{V17_KEYCODE_03,		M17_KEYCODE_03_MP3,		"V17_KEYCODE_03"},
-	{V17_KEYCODE_04,		M17_KEYCODE_04_MP3,		"V17_KEYCODE_04"},
-	{V17_TOERIG_01,		M17_TOERIG_01_MP3,		"V17_TOERIG_01"},
-	{V17_TOERIG_02,		M17_TOERIG_02_MP3,		"V17_TOERIG_02"},
-	{V17_WARNER_01,		M17_WARNER_01_MP3,		"V17_WARNER_01"},
-	{V17_WARNER_02,		M17_WARNER_02_MP3,		"V17_WARNER_02"},
-	{V17_WARNER_03,		M17_WARNER_03_MP3,		"V17_WARNER_03"},
-	{V17_WARNER_04,		M17_WARNER_04_MP3,		"V17_WARNER_04"},
-	{V17_YORP_01,		M17_YORP_01_MP3,		"V17_YORP_01"},
-	{V17_YORP_02,		M17_YORP_02_MP3,		"V17_YORP_02"},
-	{V18_DERECHA_01,		M18_DERECHA_01_MP3,		"V18_DERECHA_01"},
-	{V18_GUY_01,		M18_GUY_01_MP3,		"V18_GUY_01"},
+	{V17_INIWA_01,			M17_INIWA_01_MP3,			"V17_INIWA_01"},
+	{V17_INIWA_02,			M17_INIWA_02_MP3,			"V17_INIWA_02"},
+	{V17_INIWA_03,			M17_INIWA_03_MP3,			"V17_INIWA_03"},
+	{V17_KEYCODE_01,		M17_KEYCODE_01_MP3,			"V17_KEYCODE_01"},
+	{V17_KEYCODE_02,		M17_KEYCODE_02_MP3,			"V17_KEYCODE_02"},
+	{V17_KEYCODE_03,		M17_KEYCODE_03_MP3,			"V17_KEYCODE_03"},
+	{V17_KEYCODE_04,		M17_KEYCODE_04_MP3,			"V17_KEYCODE_04"},
+	{V17_TOERIG_01,			M17_TOERIG_01_MP3,			"V17_TOERIG_01"},
+	{V17_TOERIG_02,			M17_TOERIG_02_MP3,			"V17_TOERIG_02"},
+	{V17_WARNER_01,			M17_WARNER_01_MP3,			"V17_WARNER_01"},
+	{V17_WARNER_02,			M17_WARNER_02_MP3,			"V17_WARNER_02"},
+	{V17_WARNER_03,			M17_WARNER_03_MP3,			"V17_WARNER_03"},
+	{V17_WARNER_04,			M17_WARNER_04_MP3,			"V17_WARNER_04"},
+	{V17_YORP_01,			M17_YORP_01_MP3,			"V17_YORP_01"},
+	{V17_YORP_02,			M17_YORP_02_MP3,			"V17_YORP_02"},
+	{V18_DERECHA_01,		M18_DERECHA_01_MP3,			"V18_DERECHA_01"},
+	{V18_GUY_01,			M18_GUY_01_MP3,				"V18_GUY_01"},
 	{V18_IZQUIERDA_01,		M18_IZQUIERDA_01_MP3,		"V18_IZQUIERDA_01"},
 	{V18_IZQUIERDA_02,		M18_IZQUIERDA_02_MP3,		"V18_IZQUIERDA_02"},
 	{V18_IZQUIERDA_03,		M18_IZQUIERDA_03_MP3,		"V18_IZQUIERDA_03"},
 	{V18_IZQUIERDA_04,		M18_IZQUIERDA_04_MP3,		"V18_IZQUIERDA_04"},
 	{V18_IZQUIERDA_05,		M18_IZQUIERDA_05_MP3,		"V18_IZQUIERDA_05"},
 	{V18_IZQUIERDA_06,		M18_IZQUIERDA_06_MP3,		"V18_IZQUIERDA_06"},
-	{V19_CAVEAT_01,		M19_CAVEAT_01_MP3,		"V19_CAVEAT_01"},
-	{V19_CAVEAT_02,		M19_CAVEAT_02_MP3,		"V19_CAVEAT_02"},
-	{V19_ENDER_01,		M19_ENDER_01_MP3,		"V19_ENDER_01"},
-	{V19_ENDER_02,		M19_ENDER_02_MP3,		"V19_ENDER_02"},
+	{V19_CAVEAT_01,			M19_CAVEAT_01_MP3,			"V19_CAVEAT_01"},
+	{V19_CAVEAT_02,			M19_CAVEAT_02_MP3,			"V19_CAVEAT_02"},
+	{V19_ENDER_01,			M19_ENDER_01_MP3,			"V19_ENDER_01"},
+	{V19_ENDER_02,			M19_ENDER_02_MP3,			"V19_ENDER_02"},
 	{V19_FRUSTRATO_01,		M19_FRUSTRATO_01_MP3,		"V19_FRUSTRATO_01"},
 	{V19_FRUSTRATO_02,		M19_FRUSTRATO_02_MP3,		"V19_FRUSTRATO_02"},
 	{V19_FRUSTRATO_03,		M19_FRUSTRATO_03_MP3,		"V19_FRUSTRATO_03"},
@@ -1014,14 +1014,14 @@ const SoundLookUp soundList[] =  {
 	{V19_FRUSTRATO_08,		M19_FRUSTRATO_08_MP3,		"V19_FRUSTRATO_08"},
 	{V19_FRUSTRATO_09,		M19_FRUSTRATO_09_MP3,		"V19_FRUSTRATO_09"},
 	{V19_FRUSTRATO_10,		M19_FRUSTRATO_10_MP3,		"V19_FRUSTRATO_10"},
-	{V19_GUY_01,		M19_GUY_01_MP3,		"V19_GUY_01"},
-	{V19_GUY_02,		M19_GUY_02_MP3,		"V19_GUY_02"},
-	{V19_GUY_03,		M19_GUY_03_MP3,		"V19_GUY_03"},
-	{V19_INTER_01,		M19_INTER_01_MP3,		"V19_INTER_01"},
-	{V19_INTER_02,		M19_INTER_02_MP3,		"V19_INTER_02"},
-	{V19_LONE_01,		M19_LONE_01_MP3,		"V19_LONE_01"},
-	{V19_LONE_02,		M19_LONE_02_MP3,		"V19_LONE_02"},
-	{V19_LONE_03,		M19_LONE_03_MP3,		"V19_LONE_03"},
+	{V19_GUY_01,			M19_GUY_01_MP3,				"V19_GUY_01"},
+	{V19_GUY_02,			M19_GUY_02_MP3,				"V19_GUY_02"},
+	{V19_GUY_03,			M19_GUY_03_MP3,				"V19_GUY_03"},
+	{V19_INTER_01,			M19_INTER_01_MP3,			"V19_INTER_01"},
+	{V19_INTER_02,			M19_INTER_02_MP3,			"V19_INTER_02"},
+	{V19_LONE_01,			M19_LONE_01_MP3,			"V19_LONE_01"},
+	{V19_LONE_02,			M19_LONE_02_MP3,			"V19_LONE_02"},
+	{V19_LONE_03,			M19_LONE_03_MP3,			"V19_LONE_03"},
 	{V19_PHILLIPS_01,		M19_PHILLIPS_01_MP3,		"V19_PHILLIPS_01"},
 	{V19_PHILLIPS_02,		M19_PHILLIPS_02_MP3,		"V19_PHILLIPS_02"},
 	{V19_PHILLIPS_03,		M19_PHILLIPS_03_MP3,		"V19_PHILLIPS_03"},
@@ -1031,59 +1031,59 @@ const SoundLookUp soundList[] =  {
 	{V19_RAILRIDER_02,		M19_RAILRIDER_02_MP3,		"V19_RAILRIDER_02"},
 	{V19_RAILRIDER_03,		M19_RAILRIDER_03_MP3,		"V19_RAILRIDER_03"},
 	{V19_RAILRIDER_04,		M19_RAILRIDER_04_MP3,		"V19_RAILRIDER_04"},
-	{V19_REDRUM_01,		M19_REDRUM_01_MP3,		"V19_REDRUM_01"},
-	{V19_REDRUM_02,		M19_REDRUM_02_MP3,		"V19_REDRUM_02"},
-	{V19_REDRUM_03,		M19_REDRUM_03_MP3,		"V19_REDRUM_03"},
-	{V19_REDRUM_04,		M19_REDRUM_04_MP3,		"V19_REDRUM_04"},
-	{V19_REDRUM_05,		M19_REDRUM_05_MP3,		"V19_REDRUM_05"},
-	{V19_REDRUM_06,		M19_REDRUM_06_MP3,		"V19_REDRUM_06"},
+	{V19_REDRUM_01,			M19_REDRUM_01_MP3,			"V19_REDRUM_01"},
+	{V19_REDRUM_02,			M19_REDRUM_02_MP3,			"V19_REDRUM_02"},
+	{V19_REDRUM_03,			M19_REDRUM_03_MP3,			"V19_REDRUM_03"},
+	{V19_REDRUM_04,			M19_REDRUM_04_MP3,			"V19_REDRUM_04"},
+	{V19_REDRUM_05,			M19_REDRUM_05_MP3,			"V19_REDRUM_05"},
+	{V19_REDRUM_06,			M19_REDRUM_06_MP3,			"V19_REDRUM_06"},
 	{V19_STANDARD_01,		M19_STANDARD_01_MP3,		"V19_STANDARD_01"},
 	{V19_STANDARD_02,		M19_STANDARD_02_MP3,		"V19_STANDARD_02"},
-	{V20_ARNIE_01,		M20_ARNIE_01_MP3,		"V20_ARNIE_01"},
-	{V20_ARNIE_02,		M20_ARNIE_02_MP3,		"V20_ARNIE_02"},
-	{V20_BRAD_01,		M20_BRAD_01_MP3,		"V20_BRAD_01"},
-	{V20_BRAD_02,		M20_BRAD_02_MP3,		"V20_BRAD_02"},
-	{V20_BUSTER_01,		M20_BUSTER_01_MP3,		"V20_BUSTER_01"},
-	{V20_BUSTER_02,		M20_BUSTER_02_MP3,		"V20_BUSTER_02"},
-	{V20_BUSTER_03,		M20_BUSTER_03_MP3,		"V20_BUSTER_03"},
-	{V20_COOPER_01,		M20_COOPER_01_MP3,		"V20_COOPER_01"},
-	{V20_COOPER_02,		M20_COOPER_02_MP3,		"V20_COOPER_02"},
-	{V20_DINERS_01,		M20_DINERS_01_MP3,		"V20_DINERS_01"},
-	{V20_DINERS_02,		M20_DINERS_02_MP3,		"V20_DINERS_02"},
-	{V20_DOLLY_01,		M20_DOLLY_01_MP3,		"V20_DOLLY_01"},
-	{V20_DOREK_01,		M20_DOREK_01_MP3,		"V20_DOREK_01"},
-	{V20_DOREK_02,		M20_DOREK_02_MP3,		"V20_DOREK_02"},
-	{V20_DOREK_03,		M20_DOREK_03_MP3,		"V20_DOREK_03"},
-	{V20_FARBLE_01,		M20_FARBLE_01_MP3,		"V20_FARBLE_01"},
-	{V20_FARBLE_02,		M20_FARBLE_02_MP3,		"V20_FARBLE_02"},
-	{V20_GRUNETT_01,		M20_GRUNETT_01_MP3,		"V20_GRUNETT_01"},
-	{V20_GRUNETT_02,		M20_GRUNETT_02_MP3,		"V20_GRUNETT_02"},
-	{V20_GUY_01,		M20_GUY_01_MP3,		"V20_GUY_01"},
-	{V20_GUY_02,		M20_GUY_02_MP3,		"V20_GUY_02"},
-	{V20_GUY_03,		M20_GUY_03_MP3,		"V20_GUY_03"},
-	{V20_GUY_04,		M20_GUY_04_MP3,		"V20_GUY_04"},
-	{V20_GUY_05,		M20_GUY_05_MP3,		"V20_GUY_05"},
-	{V20_GUY_06,		M20_GUY_06_MP3,		"V20_GUY_06"},
-	{V20_HUMBERT_01,		M20_HUMBERT_01_MP3,		"V20_HUMBERT_01"},
-	{V20_ILLIAC_01,		M20_ILLIAC_01_MP3,		"V20_ILLIAC_01"},
-	{V20_JACQUES_01,		M20_JAQUES_01_MP3,		"V20_JACQUES_01"},
-	{V20_JACQUES_02,		M20_JAQUES_02_MP3,		"V20_JACQUES_02"},
-	{V20_LUMBAR_01,		M20_LUMBAR_01_MP3,		"V20_LUMBAR_01"},
-	{V20_MANNY_01,		M20_MANNY_01_MP3,		"V20_MANNY_01"},
-	{V20_POLONEY_01,		M20_POLONEY_01_MP3,		"V20_POLONEY_01"},
-	{V20_POLONEY_02,		M20_POLONEY_02_MP3,		"V20_POLONEY_02"},
-	{V20_SARGE_01,		M20_SARGE_01_MP3,		"V20_SARGE_01"},
-	{V20_SARGE_02,		M20_SARGE_02_MP3,		"V20_SARGE_02"},
-	{V20_SARGE_03,		M20_SARGE_03_MP3,		"V20_SARGE_03"},
-	{V20_SARGE_04,		M20_SARGE_04_MP3,		"V20_SARGE_04"},
-	{V20_SARGE_05,		M20_SARGE_05_MP3,		"V20_SARGE_05"},
-	{V21_ANTIMA_01,		M21_ANTIMA_01_MP3,		"V21_ANTIMA_01"},
-	{V21_ANTIMA_02,		M21_ANTIMA_02_MP3,		"V21_ANTIMA_02"},
-	{V21_ANTIMA_03,		M21_ANTIMA_03_MP3,		"V21_ANTIMA_03"},
-	{V21_ANTIMA_04,		M21_ANTIMA_04_MP3,		"V21_ANTIMA_04"},
-	{V21_ANTIMA_05,		M21_ANTIMA_05_MP3,		"V21_ANTIMA_05"},
-	{V21_ANTIMA_06,		M21_ANTIMA_06_MP3,		"V21_ANTIMA_06"},
-	{V21_ANTIMA_07,		M21_ANTIMA_07_MP3,		"V21_ANTIMA_07"},
+	{V20_ARNIE_01,			M20_ARNIE_01_MP3,			"V20_ARNIE_01"},
+	{V20_ARNIE_02,			M20_ARNIE_02_MP3,			"V20_ARNIE_02"},
+	{V20_BRAD_01,			M20_BRAD_01_MP3,			"V20_BRAD_01"},
+	{V20_BRAD_02,			M20_BRAD_02_MP3,			"V20_BRAD_02"},
+	{V20_BUSTER_01,			M20_BUSTER_01_MP3,			"V20_BUSTER_01"},
+	{V20_BUSTER_02,			M20_BUSTER_02_MP3,			"V20_BUSTER_02"},
+	{V20_BUSTER_03,			M20_BUSTER_03_MP3,			"V20_BUSTER_03"},
+	{V20_COOPER_01,			M20_COOPER_01_MP3,			"V20_COOPER_01"},
+	{V20_COOPER_02,			M20_COOPER_02_MP3,			"V20_COOPER_02"},
+	{V20_DINERS_01,			M20_DINERS_01_MP3,			"V20_DINERS_01"},
+	{V20_DINERS_02,			M20_DINERS_02_MP3,			"V20_DINERS_02"},
+	{V20_DOLLY_01,			M20_DOLLY_01_MP3,			"V20_DOLLY_01"},
+	{V20_DOREK_01,			M20_DOREK_01_MP3,			"V20_DOREK_01"},
+	{V20_DOREK_02,			M20_DOREK_02_MP3,			"V20_DOREK_02"},
+	{V20_DOREK_03,			M20_DOREK_03_MP3,			"V20_DOREK_03"},
+	{V20_FARBLE_01,			M20_FARBLE_01_MP3,			"V20_FARBLE_01"},
+	{V20_FARBLE_02,			M20_FARBLE_02_MP3,			"V20_FARBLE_02"},
+	{V20_GRUNETT_01,		M20_GRUNETT_01_MP3,			"V20_GRUNETT_01"},
+	{V20_GRUNETT_02,		M20_GRUNETT_02_MP3,			"V20_GRUNETT_02"},
+	{V20_GUY_01,			M20_GUY_01_MP3,				"V20_GUY_01"},
+	{V20_GUY_02,			M20_GUY_02_MP3,				"V20_GUY_02"},
+	{V20_GUY_03,			M20_GUY_03_MP3,				"V20_GUY_03"},
+	{V20_GUY_04,			M20_GUY_04_MP3,				"V20_GUY_04"},
+	{V20_GUY_05,			M20_GUY_05_MP3,				"V20_GUY_05"},
+	{V20_GUY_06,			M20_GUY_06_MP3,				"V20_GUY_06"},
+	{V20_HUMBERT_01,		M20_HUMBERT_01_MP3,			"V20_HUMBERT_01"},
+	{V20_ILLIAC_01,			M20_ILLIAC_01_MP3,			"V20_ILLIAC_01"},
+	{V20_JACQUES_01,		M20_JAQUES_01_MP3,			"V20_JACQUES_01"},
+	{V20_JACQUES_02,		M20_JAQUES_02_MP3,			"V20_JACQUES_02"},
+	{V20_LUMBAR_01,			M20_LUMBAR_01_MP3,			"V20_LUMBAR_01"},
+	{V20_MANNY_01,			M20_MANNY_01_MP3,			"V20_MANNY_01"},
+	{V20_POLONEY_01,		M20_POLONEY_01_MP3,			"V20_POLONEY_01"},
+	{V20_POLONEY_02,		M20_POLONEY_02_MP3,			"V20_POLONEY_02"},
+	{V20_SARGE_01,			M20_SARGE_01_MP3,			"V20_SARGE_01"},
+	{V20_SARGE_02,			M20_SARGE_02_MP3,			"V20_SARGE_02"},
+	{V20_SARGE_03,			M20_SARGE_03_MP3,			"V20_SARGE_03"},
+	{V20_SARGE_04,			M20_SARGE_04_MP3,			"V20_SARGE_04"},
+	{V20_SARGE_05,			M20_SARGE_05_MP3,			"V20_SARGE_05"},
+	{V21_ANTIMA_01,			M21_ANTIMA_01_MP3,			"V21_ANTIMA_01"},
+	{V21_ANTIMA_02,			M21_ANTIMA_02_MP3,			"V21_ANTIMA_02"},
+	{V21_ANTIMA_03,			M21_ANTIMA_03_MP3,			"V21_ANTIMA_03"},
+	{V21_ANTIMA_04,			M21_ANTIMA_04_MP3,			"V21_ANTIMA_04"},
+	{V21_ANTIMA_05,			M21_ANTIMA_05_MP3,			"V21_ANTIMA_05"},
+	{V21_ANTIMA_06,			M21_ANTIMA_06_MP3,			"V21_ANTIMA_06"},
+	{V21_ANTIMA_07,			M21_ANTIMA_07_MP3,			"V21_ANTIMA_07"},
 	{V21_BRAN_ONOMI_01,		M21_BRAN_ONOMI_01_MP3,		"V21_BRAN_ONOMI_01"},
 	{V21_BRAN_ONOMI_02,		M21_BRAN_ONOMI_02_MP3,		"V21_BRAN_ONOMI_02"},
 	{V21_BRAN_ONOMI_03,		M21_BRAN_ONOMI_03_MP3,		"V21_BRAN_ONOMI_03"},
@@ -1101,34 +1101,34 @@ const SoundLookUp soundList[] =  {
 	{V21_DEBENSHIRE_02,		M21_DEBENSHIRE_02_MP3,		"V21_DEBENSHIRE_02"},
 	{V21_DEBENSHIRE_03,		M21_DEBENSHIRE_03_MP3,		"V21_DEBENSHIRE_03"},
 	{V21_DEBENSHIRE_04,		M21_DEBENSHIRE_04_MP3,		"V21_DEBENSHIRE_04"},
-	{V21_FEMURIA_01,		M21_FEMURIA_01_MP3,		"V21_FEMURIA_01"},
-	{V21_FEMURIA_02,		M21_FEMURIA_02_MP3,		"V21_FEMURIA_02"},
-	{V21_FEMURIA_03,		M21_FEMURIA_03_MP3,		"V21_FEMURIA_03"},
-	{V21_FEMURIA_04,		M21_FEMURIA_04_MP3,		"V21_FEMURIA_04"},
-	{V21_FEMURIA_05,		M21_FEMURIA_05_MP3,		"V21_FEMURIA_05"},
+	{V21_FEMURIA_01,		M21_FEMURIA_01_MP3,			"V21_FEMURIA_01"},
+	{V21_FEMURIA_02,		M21_FEMURIA_02_MP3,			"V21_FEMURIA_02"},
+	{V21_FEMURIA_03,		M21_FEMURIA_03_MP3,			"V21_FEMURIA_03"},
+	{V21_FEMURIA_04,		M21_FEMURIA_04_MP3,			"V21_FEMURIA_04"},
+	{V21_FEMURIA_05,		M21_FEMURIA_05_MP3,			"V21_FEMURIA_05"},
 	{V21_GLARATTE_01,		M21_GLARATTE_01_MP3,		"V21_GLARATTE_01"},
 	{V21_GLARATTE_02,		M21_GLARATTE_02_MP3,		"V21_GLARATTE_02"},
 	{V21_GLARATTE_03,		M21_GLARATTE_03_MP3,		"V21_GLARATTE_03"},
 	{V21_GLARATTE_04,		M21_GLARATTE_04_MP3,		"V21_GLARATTE_04"},
-	{V21_GUY_01,				M21_GUY_01_MP3,		"V21_GUY_01"},
-	{V21_GUY_02,				M21_GUY_02_MP3,		"V21_GUY_02"},
-	{V21_GUY_03,				M21_GUY_03_MP3,		"V21_GUY_03"},
-	{V21_GUY_04,				M21_GUY_04_MP3,		"V21_GUY_04"},
-	{V21_GUY_05,				M21_GUY_05_MP3,		"V21_GUY_05"},
-	{V21_GUY_06,				M21_GUY_06_MP3,		"V21_GUY_06"},
-	{V21_GUY_07,				M21_GUY_07_MP3,		"V21_GUY_07"},
-	{V21_GUY_08,		M21_GUY_08_MP3,		"V21_GUY_08"},
-	{V21_GUY_09,		M21_GUY_09_MP3,		"V21_GUY_09"},
+	{V21_GUY_01,			M21_GUY_01_MP3,				"V21_GUY_01"},
+	{V21_GUY_02,			M21_GUY_02_MP3,				"V21_GUY_02"},
+	{V21_GUY_03,			M21_GUY_03_MP3,				"V21_GUY_03"},
+	{V21_GUY_04,			M21_GUY_04_MP3,				"V21_GUY_04"},
+	{V21_GUY_05,			M21_GUY_05_MP3,				"V21_GUY_05"},
+	{V21_GUY_06,			M21_GUY_06_MP3,				"V21_GUY_06"},
+	{V21_GUY_07,			M21_GUY_07_MP3,				"V21_GUY_07"},
+	{V21_GUY_08,			M21_GUY_08_MP3,				"V21_GUY_08"},
+	{V21_GUY_09,			M21_GUY_09_MP3,				"V21_GUY_09"},
 	{V21_HYPERBOLE_01,		M21_HYPERBOLE_01_MP3,		"V21_HYPERBOLE_01"},
 	{V21_KREN_KREN_01,		M21_KREN_KREN_01_MP3,		"V21_KREN_KREN_01"},
 	{V21_KREN_KREN_02,		M21_KREN_KREN_02_MP3,		"V21_KREN_KREN_02"},
 	{V21_KREN_KREN_03,		M21_KREN_KREN_03_MP3,		"V21_KREN_KREN_03"},
 	{V21_KREN_KREN_04,		M21_KREN_KREN_04_MP3,		"V21_KREN_KREN_04"},
 	{V21_KREN_KREN_05,		M21_KREN_KREN_05_MP3,		"V21_KREN_KREN_05"},
-	{V21_LITOTE_01,		M21_LITOTE_01_MP3,		"V21_LITOTE_01"},
-	{V21_PERIOUS_01,		M21_PERIOUS_01_MP3,		"V21_PERIOUS_01"},
-	{V21_PERIOUS_02,		M21_PERIOUS_02_MP3,		"V21_PERIOUS_02"},
-	{V21_PERIOUS_03,		M21_PERIOUS_03_MP3,		"V21_PERIOUS_03"},
+	{V21_LITOTE_01,			M21_LITOTE_01_MP3,			"V21_LITOTE_01"},
+	{V21_PERIOUS_01,		M21_PERIOUS_01_MP3,			"V21_PERIOUS_01"},
+	{V21_PERIOUS_02,		M21_PERIOUS_02_MP3,			"V21_PERIOUS_02"},
+	{V21_PERIOUS_03,		M21_PERIOUS_03_MP3,			"V21_PERIOUS_03"},
 	{V21_PHAEDRUS_01,		M21_PHAEDRUS_01_MP3,		"V21_PHAEDRUS_01"},
 	{V21_PHAEDRUS_02,		M21_PHAEDRUS_02_MP3,		"V21_PHAEDRUS_02"},
 	{V21_PHAEDRUS_04,		M21_PHAEDRUS_04_MP3,		"V21_PHAEDRUS_04"},
@@ -1160,49 +1160,49 @@ const SoundLookUp soundList[] =  {
 	{V21_PHIPOLOSSI_04,		M21_PHIPOLOSSI_04_MP3,		"V21_PHIPOLOSSI_04"},
 	{V21_PHIPOLOSSI_05,		M21_PHIPOLOSSI_05_MP3,		"V21_PHIPOLOSSI_05"},
 	{V21_PHIPOLOSSI_06,		M21_PHIPOLOSSI_06_MP3,		"V21_PHIPOLOSSI_06"},
-	{V21_PLODDER_01,			M21_PLODDER_01_MP3,			"V21_PLODDER_01"},
-	{V21_PLODDER_02,			M21_PLODDER_02_MP3,			"V21_PLODDER_02"},
-	{V21_PLODDER_03,			M21_PLODDER_03_MP3,			"V21_PLODDER_03"},
-	{V21_PLODDER_04,			M21_PLODDER_04_MP3,			"V21_PLODDER_04"},
-	{V21_SARGE_01,		M21_SARGE_01_MP3,		"V21_SARGE_01"},
-	{V21_SARGE_02,		M21_SARGE_02_MP3,		"V21_SARGE_02"},
-	{V21_SARGE_03,		M21_SARGE_03_MP3,		"V21_SARGE_03"},
-	{V21_SARGE_04,		M21_SARGE_04_MP3,		"V21_SARGE_04"},
-	{V21_SARGE_05,		M21_SARGE_05_MP3,		"V21_SARGE_05"},
-	{V21_SARGE_06,		M21_SARGE_06_MP3,		"V21_SARGE_06"},
-	{V21_SARGE_07,		M21_SARGE_07_MP3,		"V21_SARGE_07"},
-	{V21_SARGE_08,		M21_SARGE_08_MP3,		"V21_SARGE_08"},
+	{V21_PLODDER_01,		M21_PLODDER_01_MP3,			"V21_PLODDER_01"},
+	{V21_PLODDER_02,		M21_PLODDER_02_MP3,			"V21_PLODDER_02"},
+	{V21_PLODDER_03,		M21_PLODDER_03_MP3,			"V21_PLODDER_03"},
+	{V21_PLODDER_04,		M21_PLODDER_04_MP3,			"V21_PLODDER_04"},
+	{V21_SARGE_01,			M21_SARGE_01_MP3,			"V21_SARGE_01"},
+	{V21_SARGE_02,			M21_SARGE_02_MP3,			"V21_SARGE_02"},
+	{V21_SARGE_03,			M21_SARGE_03_MP3,			"V21_SARGE_03"},
+	{V21_SARGE_04,			M21_SARGE_04_MP3,			"V21_SARGE_04"},
+	{V21_SARGE_05,			M21_SARGE_05_MP3,			"V21_SARGE_05"},
+	{V21_SARGE_06,			M21_SARGE_06_MP3,			"V21_SARGE_06"},
+	{V21_SARGE_07,			M21_SARGE_07_MP3,			"V21_SARGE_07"},
+	{V21_SARGE_08,			M21_SARGE_08_MP3,			"V21_SARGE_08"},
 	{V21_SATIRE_01,			M21_SATIRE_01_MP3,			"V21_SATIRE_01"},
 	{V21_SATIRE_02,			M21_SATIRE_02_MP3,			"V21_SATIRE_02"},
-	{V21_SHELLEY_01,			M21_SHELLEY_01_MP3,			"V21_SHELLEY_01"},
-	{V21_SHELLEY_02,			M21_SHELLEY_02_MP3,			"V21_SHELLEY_02"},
-	{V21_SHELLEY_03,			M21_SHELLEY_03_MP3,			"V21_SHELLEY_03"},
-	{V21_SHELLEY_04,			M21_SHELLEY_04_MP3,			"V21_SHELLEY_04"},
-	{V21_SHELLEY_05,			M21_SHELLEY_05_MP3,			"V21_SHELLEY_05"},
-	{V21_VERILITH_01,			M21_VERILITH_01_MP3,			"V21_VERILITH_01"},
-	{V21_VERILITH_02,			M21_VERILITH_02_MP3,			"V21_VERILITH_02"},
-	{V21_VERILITH_03,			M21_VERILITH_03_MP3,			"V21_VERILITH_03"},
-	{V21_VERILITH_04,			M21_VERILITH_04_MP3,			"V21_VERILITH_04"},
-	{V21_VERILITH_05,			M21_VERILITH_05_MP3,			"V21_VERILITH_05"},
-	{V22_GUY_01,			M22_GUY_01_MP3,			"V22_GUY_01"},
+	{V21_SHELLEY_01,		M21_SHELLEY_01_MP3,			"V21_SHELLEY_01"},
+	{V21_SHELLEY_02,		M21_SHELLEY_02_MP3,			"V21_SHELLEY_02"},
+	{V21_SHELLEY_03,		M21_SHELLEY_03_MP3,			"V21_SHELLEY_03"},
+	{V21_SHELLEY_04,		M21_SHELLEY_04_MP3,			"V21_SHELLEY_04"},
+	{V21_SHELLEY_05,		M21_SHELLEY_05_MP3,			"V21_SHELLEY_05"},
+	{V21_VERILITH_01,		M21_VERILITH_01_MP3,		"V21_VERILITH_01"},
+	{V21_VERILITH_02,		M21_VERILITH_02_MP3,		"V21_VERILITH_02"},
+	{V21_VERILITH_03,		M21_VERILITH_03_MP3,		"V21_VERILITH_03"},
+	{V21_VERILITH_04,		M21_VERILITH_04_MP3,		"V21_VERILITH_04"},
+	{V21_VERILITH_05,		M21_VERILITH_05_MP3,		"V21_VERILITH_05"},
+	{V22_GUY_01,			M22_GUY_01_MP3,				"V22_GUY_01"},
 	{V22_OSCURO_01,			M22_OSCURO_01_MP3,			"V22_OSCURO_01"},
 	{V22_OSCURO_02,			M22_OSCURO_02_MP3,			"V22_OSCURO_02"},
-	{V22_VERILITH_01,			M22_VERILITH_01_MP3,			"V22_VERILITH_01"},
-	{V22_VERILITH_02,			M22_VERILITH_02_MP3,			"V22_VERILITH_02"},
-	{V22_VERILITH_03,			M22_VERILITH_03_MP3,			"V22_VERILITH_03"},
-	{V22_VERILITH_04,			M22_VERILITH_04_MP3,			"V22_VERILITH_04"},
-	{V23_GUY_01,		M23_GUY_01_MP3,		"V23_GUY_01"},
-	{V23_GUY_02,		M23_GUY_02_MP3,		"V23_GUY_02"},
-	{V23_GUY_03,		M23_GUY_03_MP3,		"V23_GUY_03"},
+	{V22_VERILITH_01,		M22_VERILITH_01_MP3,		"V22_VERILITH_01"},
+	{V22_VERILITH_02,		M22_VERILITH_02_MP3,		"V22_VERILITH_02"},
+	{V22_VERILITH_03,		M22_VERILITH_03_MP3,		"V22_VERILITH_03"},
+	{V22_VERILITH_04,		M22_VERILITH_04_MP3,		"V22_VERILITH_04"},
+	{V23_GUY_01,			M23_GUY_01_MP3,				"V23_GUY_01"},
+	{V23_GUY_02,			M23_GUY_02_MP3,				"V23_GUY_02"},
+	{V23_GUY_03,			M23_GUY_03_MP3,				"V23_GUY_03"},
 	{V23_INSANITO_01,		M23_INSANITO_01_MP3,		"V23_INSANITO_01"},
 	{V23_INSANITO_02,		M23_INSANITO_02_MP3,		"V23_INSANITO_02"},
 	{V23_INSANITO_03,		M23_INSANITO_03_MP3,		"V23_INSANITO_03"},
 	{V23_INSANITO_04,		M23_INSANITO_04_MP3,		"V23_INSANITO_04"},
 	{V23_INSANITO_05,		M23_INSANITO_05_MP3,		"V23_INSANITO_05"},
 	{V23_VERILITH_01,		M23_VERILITH_01_MP3,		"V23_VERILITH_01"},
-	{V24_GUY_01,		M24_GUY_01_MP3,		"V24_GUY_01"},
-	{V24_GUY_02,		M24_GUY_02_MP3,		"V24_GUY_02"},
-	{V24_GUY_03,		M24_GUY_03_MP3,		"V24_GUY_03"},
+	{V24_GUY_01,			M24_GUY_01_MP3,				"V24_GUY_01"},
+	{V24_GUY_02,			M24_GUY_02_MP3,				"V24_GUY_02"},
+	{V24_GUY_03,			M24_GUY_03_MP3,				"V24_GUY_03"},
 	{V24_MANAGOTA_01,		M24_MANAGOTA_01_MP3,		"V24_MANAGOTA_01"},
 	{V24_MANAGOTA_02,		M24_MANAGOTA_02_MP3,		"V24_MANAGOTA_02"},
 	{V24_MANAGOTA_03,		M24_MANAGOTA_03_MP3,		"V24_MANAGOTA_03"},
@@ -1211,14 +1211,14 @@ const SoundLookUp soundList[] =  {
 	{V25_BBOW_02,			M25_BBOW_02_MP3,			"V25_BBOW_02"},
 	{V25_BBOW_03,			M25_BBOW_03_MP3,			"V25_BBOW_03"},
 	{V25_BBOW_04,			M25_BBOW_04_MP3,			"V25_BBOW_04"},
-	{V25_GUY_01,			M25_GUY_01_MP3,			"V25_GUY_01"},
-	{V25_GUY_02,			M25_GUY_02_MP3,			"V25_GUY_02"},
-	{V25_VERILITH_01,			M25_VERILITH_01_MP3,			"V25_VERILITH_01"},
-	{V26_GUY_01,			M26_GUY_01_MP3,			"V26_GUY_01"},
-	{V26_GUY_02,			M26_GUY_02_MP3,			"V26_GUY_02"},
-	{V26_GUY_03,			M26_GUY_03_MP3,			"V26_GUY_03"},
-	{V26_GUY_04,			M26_GUY_04_MP3,			"V26_GUY_04"},
-	{V26_GUY_05,			M26_GUY_05_MP3,			"V26_GUY_05"},
+	{V25_GUY_01,			M25_GUY_01_MP3,				"V25_GUY_01"},
+	{V25_GUY_02,			M25_GUY_02_MP3,				"V25_GUY_02"},
+	{V25_VERILITH_01,		M25_VERILITH_01_MP3,		"V25_VERILITH_01"},
+	{V26_GUY_01,			M26_GUY_01_MP3,				"V26_GUY_01"},
+	{V26_GUY_02,			M26_GUY_02_MP3,				"V26_GUY_02"},
+	{V26_GUY_03,			M26_GUY_03_MP3,				"V26_GUY_03"},
+	{V26_GUY_04,			M26_GUY_04_MP3,				"V26_GUY_04"},
+	{V26_GUY_05,			M26_GUY_05_MP3,				"V26_GUY_05"},
 	{V26_FDOE_01,			M26_FDOE_01_MP3,			"V26_FDOE_01"},
 	{V26_FDOE_02,			M26_FDOE_02_MP3,			"V26_FDOE_02"},
 	{V26_FDOE_03,			M26_FDOE_03_MP3,			"V26_FDOE_03"},
@@ -1230,19 +1230,19 @@ const SoundLookUp soundList[] =  {
 	{V27_BALE_01,			M27_BALE_01_MP3,			"V27_BALE_01"},
 	{V27_BALE_02,			M27_BALE_02_MP3,			"V27_BALE_02"},
 	{V27_BALE_03,			M27_BALE_03_MP3,			"V27_BALE_03"},
-	{V27_GUY_01,			M27_GUY_01_MP3,			"V27_GUY_01"},
-	{V27_GUY_02,			M27_GUY_02_MP3,			"V27_GUY_02"},
-	{V27_GUY_03,			M27_GUY_03_MP3,			"V27_GUY_03"},
-	{V27_ONABILDEN_01,			M27_ONABILDEN_01_MP3,			"V27_ONABILDEN_01"},
-	{V27_ONABILDEN_02,			M27_ONABILDEN_02_MP3,			"V27_ONABILDEN_02"},
-	{V27_ONABILDEN_03,			M27_ONABILDEN_03_MP3,			"V27_ONABILDEN_03"},
-	{V27_ONABILDEN_04,			M27_ONABILDEN_04_MP3,			"V27_ONABILDEN_04"},
+	{V27_GUY_01,			M27_GUY_01_MP3,				"V27_GUY_01"},
+	{V27_GUY_02,			M27_GUY_02_MP3,				"V27_GUY_02"},
+	{V27_GUY_03,			M27_GUY_03_MP3,				"V27_GUY_03"},
+	{V27_ONABILDEN_01,		M27_ONABILDEN_01_MP3,		"V27_ONABILDEN_01"},
+	{V27_ONABILDEN_02,		M27_ONABILDEN_02_MP3,		"V27_ONABILDEN_02"},
+	{V27_ONABILDEN_03,		M27_ONABILDEN_03_MP3,		"V27_ONABILDEN_03"},
+	{V27_ONABILDEN_04,		M27_ONABILDEN_04_MP3,		"V27_ONABILDEN_04"},
 	{V28_FINN_01,			M28_FINN_01_MP3,			"V28_FINN_01"},
 	{V28_FINN_02,			M28_FINN_02_MP3,			"V28_FINN_02"},
 	{V28_FINN_03,			M28_FINN_03_MP3,			"V28_FINN_03"},
-	{V28_GUY_01,				M28_GUY_01_MP3,				"V28_GUY_01"},
-	{V28_GUY_02,				M28_GUY_02_MP3,				"V28_GUY_02"},
-	{V28_GUY_03,				M28_GUY_03_MP3,				"V28_GUY_03"},
+	{V28_GUY_01,			M28_GUY_01_MP3,				"V28_GUY_01"},
+	{V28_GUY_02,			M28_GUY_02_MP3,				"V28_GUY_02"},
+	{V28_GUY_03,			M28_GUY_03_MP3,				"V28_GUY_03"},
 	{V29_ALERE_01,			M29_ALERE_01_MP3,			"V29_ALERE_01"},
 	{V29_ALERE_02,			M29_ALERE_02_MP3,			"V29_ALERE_02"},
 	{V29_ALERE_03,			M29_ALERE_03_MP3,			"V29_ALERE_03"},
@@ -1251,21 +1251,21 @@ const SoundLookUp soundList[] =  {
 	{V29_AOLOS_03,			M29_AOLOS_03_MP3,			"V29_AOLOS_03"},
 	{V29_AOLOS_04,			M29_AOLOS_04_MP3,			"V29_AOLOS_04"},
 	{V29_AOLOS_05,			M29_AOLOS_05_MP3,			"V29_AOLOS_05"},
-	{V29_GUY_01,		M29_GUY_01_MP3,		"V29_GUY_01"},
-	{V29_GUY_02,		M29_GUY_02_MP3,		"V29_GUY_02"},
-	{V29_GUY_03,		M29_GUY_03_MP3,		"V29_GUY_03"},
-	{V29_GUY_04,		M29_GUY_04_MP3,		"V29_GUY_04"},
-	{V29_GUY_05,		M29_GUY_05_MP3,		"V29_GUY_05"},
-	{V29_GUY_06,		M29_GUY_06_MP3,		"V29_GUY_06"},
-	{V29_GUY_07,		M29_GUY_07_MP3,		"V29_GUY_07"},
-	{V29_GUY_08,		M29_GUY_08_MP3,		"V29_GUY_08"},
-	{V29_GUY_09,		M29_GUY_09_MP3,		"V29_GUY_09"},
-	{V29_GUY_10,		M29_GUY_10_MP3,		"V29_GUY_10"},
-	{V29_GUY_11,		M29_GUY_11_MP3,		"V29_GUY_11"},
-	{V29_GUY_12,		M29_GUY_12_MP3,		"V29_GUY_12"},
-	{V29_GUY_13,		M29_GUY_13_MP3,		"V29_GUY_13"},
-	{V29_GUY_14,		M29_GUY_14_MP3,		"V29_GUY_14"},
-	{V29_GUY_15,		M29_GUY_15_MP3,		"V29_GUY_15"},
+	{V29_GUY_01,			M29_GUY_01_MP3,				"V29_GUY_01"},
+	{V29_GUY_02,			M29_GUY_02_MP3,				"V29_GUY_02"},
+	{V29_GUY_03,			M29_GUY_03_MP3,				"V29_GUY_03"},
+	{V29_GUY_04,			M29_GUY_04_MP3,				"V29_GUY_04"},
+	{V29_GUY_05,			M29_GUY_05_MP3,				"V29_GUY_05"},
+	{V29_GUY_06,			M29_GUY_06_MP3,				"V29_GUY_06"},
+	{V29_GUY_07,			M29_GUY_07_MP3,				"V29_GUY_07"},
+	{V29_GUY_08,			M29_GUY_08_MP3,				"V29_GUY_08"},
+	{V29_GUY_09,			M29_GUY_09_MP3,				"V29_GUY_09"},
+	{V29_GUY_10,			M29_GUY_10_MP3,				"V29_GUY_10"},
+	{V29_GUY_11,			M29_GUY_11_MP3,				"V29_GUY_11"},
+	{V29_GUY_12,			M29_GUY_12_MP3,				"V29_GUY_12"},
+	{V29_GUY_13,			M29_GUY_13_MP3,				"V29_GUY_13"},
+	{V29_GUY_14,			M29_GUY_14_MP3,				"V29_GUY_14"},
+	{V29_GUY_15,			M29_GUY_15_MP3,				"V29_GUY_15"},
 	{V29_KORENAAR_01,		M29_KORENAAR_01_MP3,		"V29_KORENAAR_01"},
 	{V29_KORENAAR_02,		M29_KORENAAR_02_MP3,		"V29_KORENAAR_02"},
 	{V29_KORENAAR_03,		M29_KORENAAR_03_MP3,		"V29_KORENAAR_03"},
@@ -1273,66 +1273,66 @@ const SoundLookUp soundList[] =  {
 	{V29_KORENAAR_05,		M29_KORENAAR_05_MP3,		"V29_KORENAAR_05"},
 	{V29_PHARIBOS_01,		M29_PHARIBOS_01_MP3,		"V29_PHARIBOS_01"},
 	{V29_PHARIBOS_02,		M29_PHARIBOS_02_MP3,		"V29_PHARIBOS_02"},
-	{V29_VELEGAL_01,		M29_VELEGAL_01_MP3,		"V29_VELEGAL_01"},
-	{V29_VELEGAL_02,		M29_VELEGAL_02_MP3,		"V29_VELEGAL_02"},
-	{V30_AOLOS_01,		M30_AOLOS_01_MP3,		"V30_AOLOS_01"},
-	{V30_AOLOS_02,		M30_AOLOS_02_MP3,		"V30_AOLOS_02"},
-	{V30_AOLOS_03,		M30_AOLOS_03_MP3,		"V30_AOLOS_03"},
-	{V30_AOLOS_04,		M30_AOLOS_04_MP3,		"V30_AOLOS_04"},
-	{V30_AOLOS_05,		M30_AOLOS_05_MP3,		"V30_AOLOS_05"},
-	{V30_AOLOS_06,		M30_AOLOS_06_MP3,		"V30_AOLOS_06"},
-	{V30_AOLOS_07,		M30_AOLOS_07_MP3,		"V30_AOLOS_07"},
-	{V30_AOLOS_08,		M30_AOLOS_08_MP3,		"V30_AOLOS_08"},
-	{V30_AOLOS_09,		M30_AOLOS_09_MP3,		"V30_AOLOS_09"},
-	{V30_AOLOS_11,		M30_AOLOS_11_MP3,		"V30_AOLOS_11"},
-	{V30_AOLOS_12,		M30_AOLOS_12_MP3,		"V30_AOLOS_12"},
-	{V30_AOLOS_13,		M30_AOLOS_13_MP3,		"V30_AOLOS_13"},
-	{V30_AOLOS_14,		M30_AOLOS_14_MP3,		"V30_AOLOS_14"},
-	{V30_AOLOS_15,		M30_AOLOS_15_MP3,		"V30_AOLOS_15"},
-	{V30_AOLOS_16,		M30_AOLOS_16_MP3,		"V30_AOLOS_16"},
-	{V30_AOLOS_17,		M30_AOLOS_17_MP3,		"V30_AOLOS_17"},
-	{V30_AOLOS_18,		M30_AOLOS_18_MP3,		"V30_AOLOS_18"},
-	{V30_AOLOS_19,		M30_AOLOS_19_MP3,		"V30_AOLOS_19"},
-	{V30_AOLOS_20,		M30_AOLOS_20_MP3,		"V30_AOLOS_20"},
-	{V30_CASINOX_01,		M30_CASINOX_01_MP3,		"V30_CASINOX_01"},
-	{V30_CASINOX_02,		M30_CASINOX_02_MP3,		"V30_CASINOX_02"},
-	{V30_CASINOX_03,		M30_CASINOX_03_MP3,		"V30_CASINOX_03"},
-	{V30_CASINOX_04,		M30_CASINOX_04_MP3,		"V30_CASINOX_04"},
-	{V30_CASINOX_05,		M30_CASINOX_05_MP3,		"V30_CASINOX_05"},
-	{V30_CASINOX_06,		M30_CASINOX_06_MP3,		"V30_CASINOX_06"},
-	{V30_CHICKEN_EXPLOSION_01,		M30_CHICKEN_EXPLOSION_01_MP3,		"V30_CHICKEN_EXPLOSION_01"},
-	{V30_CHICKEN_EXPLOSION_02,		M30_CHICKEN_EXPLOSION_02_MP3,		"V30_CHICKEN_EXPLOSION_02"},
+	{V29_VELEGAL_01,		M29_VELEGAL_01_MP3,			"V29_VELEGAL_01"},
+	{V29_VELEGAL_02,		M29_VELEGAL_02_MP3,			"V29_VELEGAL_02"},
+	{V30_AOLOS_01,			M30_AOLOS_01_MP3,			"V30_AOLOS_01"},
+	{V30_AOLOS_02,			M30_AOLOS_02_MP3,			"V30_AOLOS_02"},
+	{V30_AOLOS_03,			M30_AOLOS_03_MP3,			"V30_AOLOS_03"},
+	{V30_AOLOS_04,			M30_AOLOS_04_MP3,			"V30_AOLOS_04"},
+	{V30_AOLOS_05,			M30_AOLOS_05_MP3,			"V30_AOLOS_05"},
+	{V30_AOLOS_06,			M30_AOLOS_06_MP3,			"V30_AOLOS_06"},
+	{V30_AOLOS_07,			M30_AOLOS_07_MP3,			"V30_AOLOS_07"},
+	{V30_AOLOS_08,			M30_AOLOS_08_MP3,			"V30_AOLOS_08"},
+	{V30_AOLOS_09,			M30_AOLOS_09_MP3,			"V30_AOLOS_09"},
+	{V30_AOLOS_11,			M30_AOLOS_11_MP3,			"V30_AOLOS_11"},
+	{V30_AOLOS_12,			M30_AOLOS_12_MP3,			"V30_AOLOS_12"},
+	{V30_AOLOS_13,			M30_AOLOS_13_MP3,			"V30_AOLOS_13"},
+	{V30_AOLOS_14,			M30_AOLOS_14_MP3,			"V30_AOLOS_14"},
+	{V30_AOLOS_15,			M30_AOLOS_15_MP3,			"V30_AOLOS_15"},
+	{V30_AOLOS_16,			M30_AOLOS_16_MP3,			"V30_AOLOS_16"},
+	{V30_AOLOS_17,			M30_AOLOS_17_MP3,			"V30_AOLOS_17"},
+	{V30_AOLOS_18,			M30_AOLOS_18_MP3,			"V30_AOLOS_18"},
+	{V30_AOLOS_19,			M30_AOLOS_19_MP3,			"V30_AOLOS_19"},
+	{V30_AOLOS_20,			M30_AOLOS_20_MP3,			"V30_AOLOS_20"},
+	{V30_CASINOX_01,		M30_CASINOX_01_MP3,			"V30_CASINOX_01"},
+	{V30_CASINOX_02,		M30_CASINOX_02_MP3,			"V30_CASINOX_02"},
+	{V30_CASINOX_03,		M30_CASINOX_03_MP3,			"V30_CASINOX_03"},
+	{V30_CASINOX_04,		M30_CASINOX_04_MP3,			"V30_CASINOX_04"},
+	{V30_CASINOX_05,		M30_CASINOX_05_MP3,			"V30_CASINOX_05"},
+	{V30_CASINOX_06,		M30_CASINOX_06_MP3,			"V30_CASINOX_06"},
+	{V30_CHICKEN_EXPLOSION_01,	M30_CHICKEN_EXPLOSION_01_MP3,	"V30_CHICKEN_EXPLOSION_01"},
+	{V30_CHICKEN_EXPLOSION_02,	M30_CHICKEN_EXPLOSION_02_MP3,	"V30_CHICKEN_EXPLOSION_02"},
 	{V30_DOPEFISH_01,		M30_DOPEFISH_01_MP3,		"V30_DOPEFISH_01"},
 	{V30_DOPEFISH_02,		M30_DOPEFISH_02_MP3,		"V30_DOPEFISH_02"},
 	{V30_DOPEFISH_03,		M30_DOPEFISH_03_MP3,		"V30_DOPEFISH_03"},
 	{V30_DOPEFISH_04,		M30_DOPEFISH_04_MP3,		"V30_DOPEFISH_04"},
-	{V30_GUY_01,		M30_GUY_01_MP3,		"V30_GUY_01"},
-	{V30_GUY_02,		M30_GUY_02_MP3,		"V30_GUY_02"},
-	{V30_JOHN_01,		M30_JOHN_01_MP3,		"V30_JOHN_01"},
-	{V30_JOHN_02,		M30_JOHN_02_MP3,		"V30_JOHN_02"},
-	{V30_JOHN_03,		M30_JOHN_03_MP3,		"V30_JOHN_03"},
-	{V30_JOHN_04,		M30_JOHN_04_MP3,		"V30_JOHN_04"},
-	{V30_JOHN_05,		M30_JOHN_05_MP3,		"V30_JOHN_05"},
-	{V30_LUCAS_01,		M30_LUCAS_01_MP3,		"V30_LUCAS_01"},
-	{V30_LUCAS_02,		M30_LUCAS_02_MP3,		"V30_LUCAS_02"},
-	{V30_LUCAS_03,		M30_LUCAS_03_MP3,		"V30_LUCAS_03"},
-	{V30_LUCAS_04,		M30_LUCAS_04_MP3,		"V30_LUCAS_04"},
-	{V30_STEVIE_01,		M30_STEVIE_01_MP3,		"V30_STEVIE_01"},
-	{V30_STEVIE_02,		M30_STEVIE_02_MP3,		"V30_STEVIE_02"},
-	{V30_STEVIE_03,		M30_STEVIE_03_MP3,		"V30_STEVIE_03"},
-	{V30_STEVIE_04,		M30_STEVIE_04_MP3,		"V30_STEVIE_04"},
-	{V30_STEVIE_05,		M30_STEVIE_05_MP3,		"V30_STEVIE_05"},
-	{V30_STEVIE_06,		M30_STEVIE_06_MP3,		"V30_STEVIE_06"},
-	{V30_STEVIE_07,		M30_STEVIE_07_MP3,		"V30_STEVIE_07"},
-	{V30_STEVIE_08,		M30_STEVIE_08_MP3,		"V30_STEVIE_08"},
-	{V30_STEVIE_09,		M30_STEVIE_09_MP3,		"V30_STEVIE_09"},
-	{V30_STEVIE_10,		M30_STEVIE_10_MP3,		"V30_STEVIE_10"},
-	{V30_TOM_01,		M30_TOM_01_MP3,		"V30_TOM_01"},
-	{V30_TOM_02,		M30_TOM_02_MP3,		"V30_TOM_02"},
-	{V30_TOM_03,		M30_TOM_03_MP3,		"V30_TOM_03"},
-	{V30_TOM_04,		M30_TOM_04_MP3,		"V30_TOM_04"},
-	{V30_TOM_05,		M30_TOM_05_MP3,		"V30_TOM_05"},
-	{V30_TOM_06,		M30_TOM_06_MP3,		"V30_TOM_06"},
+	{V30_GUY_01,			M30_GUY_01_MP3,				"V30_GUY_01"},
+	{V30_GUY_02,			M30_GUY_02_MP3,				"V30_GUY_02"},
+	{V30_JOHN_01,			M30_JOHN_01_MP3,			"V30_JOHN_01"},
+	{V30_JOHN_02,			M30_JOHN_02_MP3,			"V30_JOHN_02"},
+	{V30_JOHN_03,			M30_JOHN_03_MP3,			"V30_JOHN_03"},
+	{V30_JOHN_04,			M30_JOHN_04_MP3,			"V30_JOHN_04"},
+	{V30_JOHN_05,			M30_JOHN_05_MP3,			"V30_JOHN_05"},
+	{V30_LUCAS_01,			M30_LUCAS_01_MP3,			"V30_LUCAS_01"},
+	{V30_LUCAS_02,			M30_LUCAS_02_MP3,			"V30_LUCAS_02"},
+	{V30_LUCAS_03,			M30_LUCAS_03_MP3,			"V30_LUCAS_03"},
+	{V30_LUCAS_04,			M30_LUCAS_04_MP3,			"V30_LUCAS_04"},
+	{V30_STEVIE_01,			M30_STEVIE_01_MP3,			"V30_STEVIE_01"},
+	{V30_STEVIE_02,			M30_STEVIE_02_MP3,			"V30_STEVIE_02"},
+	{V30_STEVIE_03,			M30_STEVIE_03_MP3,			"V30_STEVIE_03"},
+	{V30_STEVIE_04,			M30_STEVIE_04_MP3,			"V30_STEVIE_04"},
+	{V30_STEVIE_05,			M30_STEVIE_05_MP3,			"V30_STEVIE_05"},
+	{V30_STEVIE_06,			M30_STEVIE_06_MP3,			"V30_STEVIE_06"},
+	{V30_STEVIE_07,			M30_STEVIE_07_MP3,			"V30_STEVIE_07"},
+	{V30_STEVIE_08,			M30_STEVIE_08_MP3,			"V30_STEVIE_08"},
+	{V30_STEVIE_09,			M30_STEVIE_09_MP3,			"V30_STEVIE_09"},
+	{V30_STEVIE_10,			M30_STEVIE_10_MP3,			"V30_STEVIE_10"},
+	{V30_TOM_01,			M30_TOM_01_MP3,				"V30_TOM_01"},
+	{V30_TOM_02,			M30_TOM_02_MP3,				"V30_TOM_02"},
+	{V30_TOM_03,			M30_TOM_03_MP3,				"V30_TOM_03"},
+	{V30_TOM_04,			M30_TOM_04_MP3,				"V30_TOM_04"},
+	{V30_TOM_05,			M30_TOM_05_MP3,				"V30_TOM_05"},
+	{V30_TOM_06,			M30_TOM_06_MP3,				"V30_TOM_06"},
 	{V30_VERILITH_01,		M30_VERILITH_01_MP3,		"V30_VERILITH_01"},
 	{V30_VERILITH_02,		M30_VERILITH_02_MP3,		"V30_VERILITH_02"},
 	{V30_VERILITH_03,		M30_VERILITH_03_MP3,		"V30_VERILITH_03"},
@@ -1340,30 +1340,30 @@ const SoundLookUp soundList[] =  {
 	{V30_VERILITH_05,		M30_VERILITH_05_MP3,		"V30_VERILITH_05"},
 	{V30_VERILITH_06,		M30_VERILITH_06_MP3,		"V30_VERILITH_06"},
 	{V30_VERILITH_07,		M30_VERILITH_07_MP3,		"V30_VERILITH_07"},
-	{OUTRO_DOLLY_01,			OUTRO_DOLLY_01_MP3,			"OUTRO_DOLLY_01"},
-	{OUTRO_DOLLY_02,			OUTRO_DOLLY_02_MP3,			"OUTRO_DOLLY_02"},
-	{OUTRO_DOLLY_03,			OUTRO_DOLLY_03_MP3,			"OUTRO_DOLLY_03"},
-	{OUTRO_DOLLY_04,			OUTRO_DOLLY_04_MP3,			"OUTRO_DOLLY_04"},
-	{OUTRO_DOLLY_05,			OUTRO_DOLLY_05_MP3,			"OUTRO_DOLLY_05"},
-	{OUTRO_DOLLY_06,			OUTRO_DOLLY_06_MP3,			"OUTRO_DOLLY_06"},
-	{OUTRO_DOLLY_07,			OUTRO_DOLLY_07_MP3,			"OUTRO_DOLLY_07"},
-	{OUTRO_DOLLY_08,			OUTRO_DOLLY_08_MP3,			"OUTRO_DOLLY_08"},
-	{OUTRO_DOLLY_09,			OUTRO_DOLLY_09_MP3,			"OUTRO_DOLLY_09"},
-	{OUTRO_DOLLY_10,			OUTRO_DOLLY_10_MP3,			"OUTRO_DOLLY_10"},
-	{OUTRO_DOLLY_11,			OUTRO_DOLLY_11_MP3,			"OUTRO_DOLLY_11"},
-	{OUTRO_DOLLY_12,			OUTRO_DOLLY_12_MP3,			"OUTRO_DOLLY_12"},
-	{OUTRO_DOLLY_13,			OUTRO_DOLLY_13_MP3,			"OUTRO_DOLLY_13"},
-	{OUTRO_DOLLY_14,			OUTRO_DOLLY_14_MP3,			"OUTRO_DOLLY_14"},
-	{OUTRO_DOLLY_15,			OUTRO_DOLLY_15_MP3,			"OUTRO_DOLLY_15"},
-	{OUTRO_DOLLY_16,			OUTRO_DOLLY_16_MP3,			"OUTRO_DOLLY_16"},
-	{OUTRO_DOLLY_17,			OUTRO_DOLLY_17_MP3,			"OUTRO_DOLLY_17"},
-	{OUTRO_DOLLY_18,			OUTRO_DOLLY_18_MP3,			"OUTRO_DOLLY_18"},
-	{OUTRO_DOREK_01,			OUTRO_DOREK_01_MP3,			"OUTRO_DOREK_01"},
-	{OUTRO_DOREK_02,			OUTRO_DOREK_02_MP3,			"OUTRO_DOREK_02"},
-	{OUTRO_DOREK_03,			OUTRO_DOREK_03_MP3,			"OUTRO_DOREK_03"},
-	{OUTRO_DOREK_04,			OUTRO_DOREK_04_MP3,			"OUTRO_DOREK_04"},
-	{OUTRO_DOREK_05,			OUTRO_DOREK_05_MP3,			"OUTRO_DOREK_05"},
-	{OUTRO_DOREK_06,			OUTRO_DOREK_06_MP3,			"OUTRO_DOREK_06"},
+	{OUTRO_DOLLY_01,		OUTRO_DOLLY_01_MP3,			"OUTRO_DOLLY_01"},
+	{OUTRO_DOLLY_02,		OUTRO_DOLLY_02_MP3,			"OUTRO_DOLLY_02"},
+	{OUTRO_DOLLY_03,		OUTRO_DOLLY_03_MP3,			"OUTRO_DOLLY_03"},
+	{OUTRO_DOLLY_04,		OUTRO_DOLLY_04_MP3,			"OUTRO_DOLLY_04"},
+	{OUTRO_DOLLY_05,		OUTRO_DOLLY_05_MP3,			"OUTRO_DOLLY_05"},
+	{OUTRO_DOLLY_06,		OUTRO_DOLLY_06_MP3,			"OUTRO_DOLLY_06"},
+	{OUTRO_DOLLY_07,		OUTRO_DOLLY_07_MP3,			"OUTRO_DOLLY_07"},
+	{OUTRO_DOLLY_08,		OUTRO_DOLLY_08_MP3,			"OUTRO_DOLLY_08"},
+	{OUTRO_DOLLY_09,		OUTRO_DOLLY_09_MP3,			"OUTRO_DOLLY_09"},
+	{OUTRO_DOLLY_10,		OUTRO_DOLLY_10_MP3,			"OUTRO_DOLLY_10"},
+	{OUTRO_DOLLY_11,		OUTRO_DOLLY_11_MP3,			"OUTRO_DOLLY_11"},
+	{OUTRO_DOLLY_12,		OUTRO_DOLLY_12_MP3,			"OUTRO_DOLLY_12"},
+	{OUTRO_DOLLY_13,		OUTRO_DOLLY_13_MP3,			"OUTRO_DOLLY_13"},
+	{OUTRO_DOLLY_14,		OUTRO_DOLLY_14_MP3,			"OUTRO_DOLLY_14"},
+	{OUTRO_DOLLY_15,		OUTRO_DOLLY_15_MP3,			"OUTRO_DOLLY_15"},
+	{OUTRO_DOLLY_16,		OUTRO_DOLLY_16_MP3,			"OUTRO_DOLLY_16"},
+	{OUTRO_DOLLY_17,		OUTRO_DOLLY_17_MP3,			"OUTRO_DOLLY_17"},
+	{OUTRO_DOLLY_18,		OUTRO_DOLLY_18_MP3,			"OUTRO_DOLLY_18"},
+	{OUTRO_DOREK_01,		OUTRO_DOREK_01_MP3,			"OUTRO_DOREK_01"},
+	{OUTRO_DOREK_02,		OUTRO_DOREK_02_MP3,			"OUTRO_DOREK_02"},
+	{OUTRO_DOREK_03,		OUTRO_DOREK_03_MP3,			"OUTRO_DOREK_03"},
+	{OUTRO_DOREK_04,		OUTRO_DOREK_04_MP3,			"OUTRO_DOREK_04"},
+	{OUTRO_DOREK_05,		OUTRO_DOREK_05_MP3,			"OUTRO_DOREK_05"},
+	{OUTRO_DOREK_06,		OUTRO_DOREK_06_MP3,			"OUTRO_DOREK_06"},
 	{OUTRO_GUY_01,			OUTRO_GUY_01_MP3,			"OUTRO_GUY_01"},
 	{OUTRO_GUY_02,			OUTRO_GUY_02_MP3,			"OUTRO_GUY_02"},
 	{OUTRO_GUY_03,			OUTRO_GUY_03_MP3,			"OUTRO_GUY_03"},
@@ -1375,12 +1375,12 @@ const SoundLookUp soundList[] =  {
 	{OUTRO_JENKINS_03,		OUTRO_JENKINS_03_MP3,		"OUTRO_JENKINS_03"},
 	{OUTRO_JENKINS_04,		OUTRO_JENKINS_04_MP3,		"OUTRO_JENKINS_04"},
 	{OUTRO_JENKINS_05,		OUTRO_JENKINS_05_MP3,		"OUTRO_JENKINS_05"},
-	{OUTRO_SARGE_01,			OUTRO_SARGE_01_MP3,			"OUTRO_SARGE_01"},
-	{OUTRO_SARGE_02,			OUTRO_SARGE_02_MP3,			"OUTRO_SARGE_02"},
-	{OUTRO_SARGE_03,			OUTRO_SARGE_03_MP3,			"OUTRO_SARGE_03"},
-	{OUTRO_SARGE_04,			OUTRO_SARGE_04_MP3,			"OUTRO_SARGE_04"},
-	{OUTRO_SARGE_05,			OUTRO_SARGE_05_MP3,			"OUTRO_SARGE_05"},
-	{OUTRO_SARGE_06,			OUTRO_SARGE_06_MP3,			"OUTRO_SARGE_06"},
+	{OUTRO_SARGE_01,		OUTRO_SARGE_01_MP3,			"OUTRO_SARGE_01"},
+	{OUTRO_SARGE_02,		OUTRO_SARGE_02_MP3,			"OUTRO_SARGE_02"},
+	{OUTRO_SARGE_03,		OUTRO_SARGE_03_MP3,			"OUTRO_SARGE_03"},
+	{OUTRO_SARGE_04,		OUTRO_SARGE_04_MP3,			"OUTRO_SARGE_04"},
+	{OUTRO_SARGE_05,		OUTRO_SARGE_05_MP3,			"OUTRO_SARGE_05"},
+	{OUTRO_SARGE_06,		OUTRO_SARGE_06_MP3,			"OUTRO_SARGE_06"},
 	{GUY_GOT_A_JOB,			GUY_GOT_A_JOB_MP3,			"GUY_GOT_A_JOB"},
 	{GUY_WINS,				GUY_WINS_MP3,				"GUY_WINS"},
 	{GUY_ENERGY_CELL,		GUY_ENERGY_CELL_MP3,		"GUY_ENERGY_CELL"},


Commit: f7bc31f9e6d6c336b15b892636f83ab71991736d
    https://github.com/scummvm/scummvm/commit/f7bc31f9e6d6c336b15b892636f83ab71991736d
Author: Strangerke (strangerke at scummvm.org)
Date: 2019-09-03T17:17:29+02:00

Commit Message:
HDB: Some cleanup in ai-init

Changed paths:
    engines/hdb/ai-funcs.cpp
    engines/hdb/ai-init.cpp


diff --git a/engines/hdb/ai-funcs.cpp b/engines/hdb/ai-funcs.cpp
index d3d98d7..56f6e96 100644
--- a/engines/hdb/ai-funcs.cpp
+++ b/engines/hdb/ai-funcs.cpp
@@ -1414,7 +1414,6 @@ void AI::animEntFrames(AIEntity *e) {
 		e->draw = _pushrightGfx[e->animFrame];
 		max = _pushrightFrames;
 		break;
-
 	case STATE_GRABUP:
 		e->draw = _getGfx[DIR_UP];
 		max = 1;
@@ -1431,7 +1430,6 @@ void AI::animEntFrames(AIEntity *e) {
 		e->draw = _getGfx[DIR_RIGHT];
 		max = 1;
 		break;
-
 	case STATE_HORRIBLE1:
 		e->draw = _horrible1Gfx[e->animFrame];
 		max = _horrible1Frames;
@@ -1466,7 +1464,6 @@ void AI::animEntFrames(AIEntity *e) {
 		if (e->animFrame == max - 1)
 			e->state = STATE_DEAD;
 		break;
-
 	case STATE_PLUMMET:
 		e->draw = _plummetGfx[e->animFrame];
 		max = _plummetFrames;
diff --git a/engines/hdb/ai-init.cpp b/engines/hdb/ai-init.cpp
index 3ad935c..dcaf057 100644
--- a/engines/hdb/ai-init.cpp
+++ b/engines/hdb/ai-init.cpp
@@ -73,11 +73,11 @@ AIStateDef guy[] = {
 	{ STATE_HORRIBLE3,      GROUP_ENT_GUY_HORRIBLE3 },
 	{ STATE_HORRIBLE4,      GROUP_ENT_GUY_HORRIBLE4 },
 	{ STATE_GOODJOB,        GROUP_ENT_GUY_GOODJOB },
-	{ STATE_ENDSTATES, "" }                            // end of list indicator
+	{ STATE_ENDSTATES,      "" }      // end of list indicator
 };
 
 AIStateDef gemAttack[] = {
-	{ STATE_MOVEDOWN,       GROUP_ENT_GEM_WHITE_SIT },
+	{ STATE_MOVEDOWN,  GROUP_ENT_GEM_WHITE_SIT },
 	{ STATE_ENDSTATES, "" }
 };
 
@@ -96,157 +96,157 @@ AIStateDef dolly[] = {
 	{ STATE_ANGRY,          GROUP_ENT_DOLLY_ANGRY },
 	{ STATE_LAUGH,          GROUP_ENT_DOLLY_LAUGH },
 	{ STATE_PANIC,          GROUP_ENT_DOLLY_PANIC },
-	{ STATE_ENDSTATES, "" }
+	{ STATE_ENDSTATES,      "" }
 };
 
 AIStateDef sergeant[] = {
-	{ STATE_STANDDOWN,      GROUP_ENT_SERGEANT_STANDDOWN },
-	{ STATE_STANDUP,        GROUP_ENT_SERGEANT_STANDUP },
-	{ STATE_STANDLEFT,      GROUP_ENT_SERGEANT_STANDLEFT },
-	{ STATE_STANDRIGHT,     GROUP_ENT_SERGEANT_STANDRIGHT },
-	{ STATE_YELL,           GROUP_ENT_SERGEANT_YELL },
-	{ STATE_MOVEDOWN,       GROUP_ENT_SERGEANT_WALKDOWN },
-	{ STATE_MOVEUP,         GROUP_ENT_SERGEANT_WALKUP },
-	{ STATE_MOVELEFT,       GROUP_ENT_SERGEANT_WALKLEFT },
-	{ STATE_MOVERIGHT,      GROUP_ENT_SERGEANT_WALKRIGHT },
-	{ STATE_ENDSTATES, "" }
+	{ STATE_STANDDOWN,  GROUP_ENT_SERGEANT_STANDDOWN },
+	{ STATE_STANDUP,    GROUP_ENT_SERGEANT_STANDUP },
+	{ STATE_STANDLEFT,  GROUP_ENT_SERGEANT_STANDLEFT },
+	{ STATE_STANDRIGHT, GROUP_ENT_SERGEANT_STANDRIGHT },
+	{ STATE_YELL,       GROUP_ENT_SERGEANT_YELL },
+	{ STATE_MOVEDOWN,   GROUP_ENT_SERGEANT_WALKDOWN },
+	{ STATE_MOVEUP,     GROUP_ENT_SERGEANT_WALKUP },
+	{ STATE_MOVELEFT,   GROUP_ENT_SERGEANT_WALKLEFT },
+	{ STATE_MOVERIGHT,  GROUP_ENT_SERGEANT_WALKRIGHT },
+	{ STATE_ENDSTATES,  "" }
 };
 
 AIStateDef spacedude[] = {
-	{ STATE_MOVEDOWN,       GROUP_ENT_SPACEDUDE_WALKDOWN },
-	{ STATE_MOVEUP,         GROUP_ENT_SPACEDUDE_WALKUP },
-	{ STATE_MOVELEFT,       GROUP_ENT_SPACEDUDE_WALKLEFT },
-	{ STATE_MOVERIGHT,      GROUP_ENT_SPACEDUDE_WALKRIGHT },
+	{ STATE_MOVEDOWN,  GROUP_ENT_SPACEDUDE_WALKDOWN },
+	{ STATE_MOVEUP,    GROUP_ENT_SPACEDUDE_WALKUP },
+	{ STATE_MOVELEFT,  GROUP_ENT_SPACEDUDE_WALKLEFT },
+	{ STATE_MOVERIGHT, GROUP_ENT_SPACEDUDE_WALKRIGHT },
 	{ STATE_ENDSTATES, "" }
 };
 
 AIStateDef chicken[] = {
-	{ STATE_STANDDOWN,      GROUP_ENT_CHICKEN_STANDDOWN },
-	{ STATE_STANDUP,        GROUP_ENT_CHICKEN_STANDUP },
-	{ STATE_STANDLEFT,      GROUP_ENT_CHICKEN_STANDLEFT },
-	{ STATE_STANDRIGHT,     GROUP_ENT_CHICKEN_STANDRIGHT },
-	{ STATE_MOVEDOWN,       GROUP_ENT_CHICKEN_WALKDOWN },
-	{ STATE_MOVEUP,         GROUP_ENT_CHICKEN_WALKUP },
-	{ STATE_MOVELEFT,       GROUP_ENT_CHICKEN_WALKLEFT },
-	{ STATE_MOVERIGHT,      GROUP_ENT_CHICKEN_WALKRIGHT },
-	{ STATE_ENDSTATES, "" }
+	{ STATE_STANDDOWN,  GROUP_ENT_CHICKEN_STANDDOWN },
+	{ STATE_STANDUP,    GROUP_ENT_CHICKEN_STANDUP },
+	{ STATE_STANDLEFT,  GROUP_ENT_CHICKEN_STANDLEFT },
+	{ STATE_STANDRIGHT, GROUP_ENT_CHICKEN_STANDRIGHT },
+	{ STATE_MOVEDOWN,   GROUP_ENT_CHICKEN_WALKDOWN },
+	{ STATE_MOVEUP,     GROUP_ENT_CHICKEN_WALKUP },
+	{ STATE_MOVELEFT,   GROUP_ENT_CHICKEN_WALKLEFT },
+	{ STATE_MOVERIGHT,  GROUP_ENT_CHICKEN_WALKRIGHT },
+	{ STATE_ENDSTATES,  "" }
 };
 
 AIStateDef vortexian[] = {
-	{ STATE_STANDDOWN,      GROUP_ENT_VORTEXIAN_STANDDOWN },
+	{ STATE_STANDDOWN, GROUP_ENT_VORTEXIAN_STANDDOWN },
 	{ STATE_ENDSTATES, "" }
 };
 
 AIStateDef maintBot[] = {
-	{ STATE_STANDDOWN,      GROUP_ENT_MAINTBOT_STANDDOWN },
-	{ STATE_STANDUP,        GROUP_ENT_MAINTBOT_STANDUP },
-	{ STATE_STANDLEFT,      GROUP_ENT_MAINTBOT_STANDLEFT },
-	{ STATE_STANDRIGHT,     GROUP_ENT_MAINTBOT_STANDRIGHT },
-	{ STATE_MOVEDOWN,       GROUP_ENT_MAINTBOT_WALKDOWN },
-	{ STATE_MOVEUP,         GROUP_ENT_MAINTBOT_WALKUP },
-	{ STATE_MOVELEFT,       GROUP_ENT_MAINTBOT_WALKLEFT },
-	{ STATE_MOVERIGHT,      GROUP_ENT_MAINTBOT_WALKRIGHT },
-	{ STATE_USEDOWN,        GROUP_ENT_MAINTBOT_USEDOWN },
-	{ STATE_USEUP,          GROUP_ENT_MAINTBOT_USEUP },
-	{ STATE_USELEFT,        GROUP_ENT_MAINTBOT_USELEFT },
-	{ STATE_USERIGHT,       GROUP_ENT_MAINTBOT_USERIGHT },
-	{ STATE_ENDSTATES, "" }
+	{ STATE_STANDDOWN,  GROUP_ENT_MAINTBOT_STANDDOWN },
+	{ STATE_STANDUP,    GROUP_ENT_MAINTBOT_STANDUP },
+	{ STATE_STANDLEFT,  GROUP_ENT_MAINTBOT_STANDLEFT },
+	{ STATE_STANDRIGHT, GROUP_ENT_MAINTBOT_STANDRIGHT },
+	{ STATE_MOVEDOWN,   GROUP_ENT_MAINTBOT_WALKDOWN },
+	{ STATE_MOVEUP,     GROUP_ENT_MAINTBOT_WALKUP },
+	{ STATE_MOVELEFT,   GROUP_ENT_MAINTBOT_WALKLEFT },
+	{ STATE_MOVERIGHT,  GROUP_ENT_MAINTBOT_WALKRIGHT },
+	{ STATE_USEDOWN,    GROUP_ENT_MAINTBOT_USEDOWN },
+	{ STATE_USEUP,      GROUP_ENT_MAINTBOT_USEUP },
+	{ STATE_USELEFT,    GROUP_ENT_MAINTBOT_USELEFT },
+	{ STATE_USERIGHT,   GROUP_ENT_MAINTBOT_USERIGHT },
+	{ STATE_ENDSTATES,  "" }
 };
 
 AIStateDef scientist[] = {
-	{ STATE_BLINK,          GROUP_ENT_SCIENTIST_BLINK },
-	{ STATE_STANDDOWN,      GROUP_ENT_SCIENTIST_STANDDOWN },
-	{ STATE_STANDUP,        GROUP_ENT_SCIENTIST_STANDUP },
-	{ STATE_STANDLEFT,      GROUP_ENT_SCIENTIST_STANDLEFT },
-	{ STATE_STANDRIGHT,     GROUP_ENT_SCIENTIST_STANDRIGHT },
-	{ STATE_MOVEDOWN,       GROUP_ENT_SCIENTIST_WALKDOWN },
-	{ STATE_MOVEUP,         GROUP_ENT_SCIENTIST_WALKUP },
-	{ STATE_MOVELEFT,       GROUP_ENT_SCIENTIST_WALKLEFT },
-	{ STATE_MOVERIGHT,      GROUP_ENT_SCIENTIST_WALKRIGHT },
-	{ STATE_ENDSTATES, "" }
+	{ STATE_BLINK,      GROUP_ENT_SCIENTIST_BLINK },
+	{ STATE_STANDDOWN,  GROUP_ENT_SCIENTIST_STANDDOWN },
+	{ STATE_STANDUP,    GROUP_ENT_SCIENTIST_STANDUP },
+	{ STATE_STANDLEFT,  GROUP_ENT_SCIENTIST_STANDLEFT },
+	{ STATE_STANDRIGHT, GROUP_ENT_SCIENTIST_STANDRIGHT },
+	{ STATE_MOVEDOWN,   GROUP_ENT_SCIENTIST_WALKDOWN },
+	{ STATE_MOVEUP,     GROUP_ENT_SCIENTIST_WALKUP },
+	{ STATE_MOVELEFT,   GROUP_ENT_SCIENTIST_WALKLEFT },
+	{ STATE_MOVERIGHT,  GROUP_ENT_SCIENTIST_WALKRIGHT },
+	{ STATE_ENDSTATES,  "" }
 };
 
 AIStateDef worker[] = {
-	{ STATE_BLINK,          GROUP_ENT_WORKER_BLINK },
-	{ STATE_STANDDOWN,      GROUP_ENT_WORKER_STANDDOWN },
-	{ STATE_STANDUP,        GROUP_ENT_WORKER_STANDUP },
-	{ STATE_STANDLEFT,      GROUP_ENT_WORKER_STANDLEFT },
-	{ STATE_STANDRIGHT,     GROUP_ENT_WORKER_STANDRIGHT },
-	{ STATE_MOVEDOWN,       GROUP_ENT_WORKER_WALKDOWN },
-	{ STATE_MOVEUP,         GROUP_ENT_WORKER_WALKUP },
-	{ STATE_MOVELEFT,       GROUP_ENT_WORKER_WALKLEFT },
-	{ STATE_MOVERIGHT,      GROUP_ENT_WORKER_WALKRIGHT },
-	{ STATE_ENDSTATES, "" }
+	{ STATE_BLINK,      GROUP_ENT_WORKER_BLINK },
+	{ STATE_STANDDOWN,  GROUP_ENT_WORKER_STANDDOWN },
+	{ STATE_STANDUP,    GROUP_ENT_WORKER_STANDUP },
+	{ STATE_STANDLEFT,  GROUP_ENT_WORKER_STANDLEFT },
+	{ STATE_STANDRIGHT, GROUP_ENT_WORKER_STANDRIGHT },
+	{ STATE_MOVEDOWN,   GROUP_ENT_WORKER_WALKDOWN },
+	{ STATE_MOVEUP,     GROUP_ENT_WORKER_WALKUP },
+	{ STATE_MOVELEFT,   GROUP_ENT_WORKER_WALKLEFT },
+	{ STATE_MOVERIGHT,  GROUP_ENT_WORKER_WALKRIGHT },
+	{ STATE_ENDSTATES,  "" }
 };
 
 AIStateDef deadWorker[] = {
-	{ STATE_STANDDOWN,      GROUP_ENT_DEAD_WORKER_SIT },
+	{ STATE_STANDDOWN, GROUP_ENT_DEAD_WORKER_SIT },
 	{ STATE_ENDSTATES, "" }
 };
 
 AIStateDef accountant[] = {
-	{ STATE_STANDDOWN,      GROUP_ENT_ACCOUNTANT_STANDDOWN },
-	{ STATE_STANDUP,        GROUP_ENT_ACCOUNTANT_STANDUP },
-	{ STATE_STANDLEFT,      GROUP_ENT_ACCOUNTANT_STANDLEFT },
-	{ STATE_STANDRIGHT,     GROUP_ENT_ACCOUNTANT_STANDRIGHT },
-	{ STATE_ENDSTATES, "" }
+	{ STATE_STANDDOWN,  GROUP_ENT_ACCOUNTANT_STANDDOWN },
+	{ STATE_STANDUP,    GROUP_ENT_ACCOUNTANT_STANDUP },
+	{ STATE_STANDLEFT,  GROUP_ENT_ACCOUNTANT_STANDLEFT },
+	{ STATE_STANDRIGHT, GROUP_ENT_ACCOUNTANT_STANDRIGHT },
+	{ STATE_ENDSTATES,  "" }
 };
 
 // Enemies
 
 AIStateDef pushBot[] = {
-	{ STATE_MOVEDOWN,       GROUP_ENT_PUSHBOT_WALKDOWN },
-	{ STATE_MOVEUP,         GROUP_ENT_PUSHBOT_WALKUP },
-	{ STATE_MOVELEFT,       GROUP_ENT_PUSHBOT_WALKLEFT },
-	{ STATE_MOVERIGHT,      GROUP_ENT_PUSHBOT_WALKRIGHT },
+	{ STATE_MOVEDOWN,  GROUP_ENT_PUSHBOT_WALKDOWN },
+	{ STATE_MOVEUP,    GROUP_ENT_PUSHBOT_WALKUP },
+	{ STATE_MOVELEFT,  GROUP_ENT_PUSHBOT_WALKLEFT },
+	{ STATE_MOVERIGHT, GROUP_ENT_PUSHBOT_WALKRIGHT },
 	{ STATE_ENDSTATES, "" }
 };
 
 AIStateDef rightBot[] = {
-	{ STATE_MOVEDOWN,       GROUP_ENT_RIGHTBOT_WALKDOWN },
-	{ STATE_MOVEUP,         GROUP_ENT_RIGHTBOT_WALKUP },
-	{ STATE_MOVELEFT,       GROUP_ENT_RIGHTBOT_WALKLEFT },
-	{ STATE_MOVERIGHT,      GROUP_ENT_RIGHTBOT_WALKRIGHT },
+	{ STATE_MOVEDOWN,  GROUP_ENT_RIGHTBOT_WALKDOWN },
+	{ STATE_MOVEUP,    GROUP_ENT_RIGHTBOT_WALKUP },
+	{ STATE_MOVELEFT,  GROUP_ENT_RIGHTBOT_WALKLEFT },
+	{ STATE_MOVERIGHT, GROUP_ENT_RIGHTBOT_WALKRIGHT },
 	{ STATE_ENDSTATES, "" }
 };
 
 AIStateDef omniBot[] = {
-	{ STATE_MOVEDOWN,       GROUP_ENT_OMNIBOT_WALKDOWN },
-	{ STATE_MOVEUP,         GROUP_ENT_OMNIBOT_WALKUP },
-	{ STATE_MOVELEFT,       GROUP_ENT_OMNIBOT_WALKLEFT },
-	{ STATE_MOVERIGHT,      GROUP_ENT_OMNIBOT_WALKRIGHT },
+	{ STATE_MOVEDOWN,  GROUP_ENT_OMNIBOT_WALKDOWN },
+	{ STATE_MOVEUP,    GROUP_ENT_OMNIBOT_WALKUP },
+	{ STATE_MOVELEFT,  GROUP_ENT_OMNIBOT_WALKLEFT },
+	{ STATE_MOVERIGHT, GROUP_ENT_OMNIBOT_WALKRIGHT },
 	{ STATE_ENDSTATES, "" }
 };
 
 AIStateDef laser[] = {
-	{ STATE_STANDRIGHT,     GROUP_ENT_LASER_RIGHT },
-	{ STATE_STANDLEFT,      GROUP_ENT_LASER_LEFT },
-	{ STATE_STANDUP,        GROUP_ENT_LASER_UP },
-	{ STATE_STANDDOWN,      GROUP_ENT_LASER_DOWN },
-	{ STATE_ENDSTATES, "" }
+	{ STATE_STANDRIGHT, GROUP_ENT_LASER_RIGHT },
+	{ STATE_STANDLEFT,  GROUP_ENT_LASER_LEFT },
+	{ STATE_STANDUP,    GROUP_ENT_LASER_UP },
+	{ STATE_STANDDOWN,  GROUP_ENT_LASER_DOWN },
+	{ STATE_ENDSTATES,  "" }
 };
 
 AIStateDef diverter[] = {
-	{ STATE_DIVERTER_BL,    GROUP_ENT_DEFLECTORBL_SIT },
-	{ STATE_DIVERTER_BR,    GROUP_ENT_DEFLECTORBR_SIT },
-	{ STATE_DIVERTER_TL,    GROUP_ENT_DEFLECTORTL_SIT },
-	{ STATE_DIVERTER_TR,    GROUP_ENT_DEFLECTORTR_SIT },
-	{ STATE_ENDSTATES, "" }
+	{ STATE_DIVERTER_BL, GROUP_ENT_DEFLECTORBL_SIT },
+	{ STATE_DIVERTER_BR, GROUP_ENT_DEFLECTORBR_SIT },
+	{ STATE_DIVERTER_TL, GROUP_ENT_DEFLECTORTL_SIT },
+	{ STATE_DIVERTER_TR, GROUP_ENT_DEFLECTORTR_SIT },
+	{ STATE_ENDSTATES,   "" }
 };
 
 AIStateDef turnBot[] = {
-	{ STATE_MOVEDOWN,       GROUP_ENT_TURNBOT_WALKDOWN },
-	{ STATE_MOVEUP,         GROUP_ENT_TURNBOT_WALKUP },
-	{ STATE_MOVELEFT,       GROUP_ENT_TURNBOT_WALKLEFT },
-	{ STATE_MOVERIGHT,      GROUP_ENT_TURNBOT_WALKRIGHT },
+	{ STATE_MOVEDOWN,  GROUP_ENT_TURNBOT_WALKDOWN },
+	{ STATE_MOVEUP,    GROUP_ENT_TURNBOT_WALKUP },
+	{ STATE_MOVELEFT,  GROUP_ENT_TURNBOT_WALKLEFT },
+	{ STATE_MOVERIGHT, GROUP_ENT_TURNBOT_WALKRIGHT },
 	{ STATE_ENDSTATES, "" }
 };
 
 AIStateDef deadEye[] = {
-	{ STATE_MOVEDOWN,       GROUP_ENT_DEADEYE_WALKDOWN },
-	{ STATE_MOVEUP,         GROUP_ENT_DEADEYE_WALKUP },
-	{ STATE_MOVELEFT,       GROUP_ENT_DEADEYE_WALKLEFT },
-	{ STATE_MOVERIGHT,      GROUP_ENT_DEADEYE_WALKRIGHT },
+	{ STATE_MOVEDOWN,  GROUP_ENT_DEADEYE_WALKDOWN },
+	{ STATE_MOVEUP,    GROUP_ENT_DEADEYE_WALKUP },
+	{ STATE_MOVELEFT,  GROUP_ENT_DEADEYE_WALKLEFT },
+	{ STATE_MOVERIGHT, GROUP_ENT_DEADEYE_WALKRIGHT },
 	{ STATE_ENDSTATES, "" }
 };
 
@@ -256,56 +256,56 @@ AIStateDef meerkat[] = {
 	{ STATE_MEER_BITE,      GROUP_ENT_MEERKAT_BITE },
 	{ STATE_MEER_DISAPPEAR, GROUP_ENT_MEERKAT_DISAPPEAR },
 	{ STATE_MEER_LOOK,      GROUP_ENT_MEERKAT_LOOK },
-	{ STATE_ENDSTATES, "" }
+	{ STATE_ENDSTATES,      "" }
 };
 
 AIStateDef goodFairy[] = {
-	{ STATE_MOVEDOWN,       GROUP_ENT_GOODFAIRY_WALKDOWN },
-	{ STATE_MOVEUP,         GROUP_ENT_GOODFAIRY_WALKUP },
-	{ STATE_MOVELEFT,       GROUP_ENT_GOODFAIRY_WALKLEFT },
-	{ STATE_MOVERIGHT,      GROUP_ENT_GOODFAIRY_WALKRIGHT },
+	{ STATE_MOVEDOWN,  GROUP_ENT_GOODFAIRY_WALKDOWN },
+	{ STATE_MOVEUP,    GROUP_ENT_GOODFAIRY_WALKUP },
+	{ STATE_MOVELEFT,  GROUP_ENT_GOODFAIRY_WALKLEFT },
+	{ STATE_MOVERIGHT, GROUP_ENT_GOODFAIRY_WALKRIGHT },
 	{ STATE_ENDSTATES, "" }
 };
 
 AIStateDef badFairy[] = {
-	{ STATE_MOVEDOWN,       GROUP_ENT_BADFAIRY_WALKDOWN },
-	{ STATE_MOVEUP,         GROUP_ENT_BADFAIRY_WALKUP },
-	{ STATE_MOVELEFT,       GROUP_ENT_BADFAIRY_WALKLEFT },
-	{ STATE_MOVERIGHT,      GROUP_ENT_BADFAIRY_WALKRIGHT },
+	{ STATE_MOVEDOWN,  GROUP_ENT_BADFAIRY_WALKDOWN },
+	{ STATE_MOVEUP,    GROUP_ENT_BADFAIRY_WALKUP },
+	{ STATE_MOVELEFT,  GROUP_ENT_BADFAIRY_WALKLEFT },
+	{ STATE_MOVERIGHT, GROUP_ENT_BADFAIRY_WALKRIGHT },
 	{ STATE_ENDSTATES, "" }
 };
 
 AIStateDef gatePuddle[] = {
-	{ STATE_MOVEDOWN,       GROUP_ENT_GATEPUDDLE_STANDDOWN },
+	{ STATE_MOVEDOWN,  GROUP_ENT_GATEPUDDLE_STANDDOWN },
 	{ STATE_ENDSTATES, "" }
 };
 
 AIStateDef icePuff[] = {
-	{ STATE_ICEP_PEEK,      GROUP_ENT_ICEPUFF_PEEK },
-	{ STATE_ICEP_APPEAR,    GROUP_ENT_ICEPUFF_APPEAR },
-	{ STATE_ICEP_THROWDOWN, GROUP_ENT_ICEPUFF_THROWDOWN },
-	{ STATE_ICEP_THROWRIGHT,GROUP_ENT_ICEPUFF_THROWRIGHT },
-	{ STATE_ICEP_THROWLEFT, GROUP_ENT_ICEPUFF_THROWLEFT },
-	{ STATE_ICEP_DISAPPEAR, GROUP_ENT_ICEPUFF_DISAPPEAR },
-	{ STATE_ENDSTATES, "" }
+	{ STATE_ICEP_PEEK,       GROUP_ENT_ICEPUFF_PEEK },
+	{ STATE_ICEP_APPEAR,     GROUP_ENT_ICEPUFF_APPEAR },
+	{ STATE_ICEP_THROWDOWN,  GROUP_ENT_ICEPUFF_THROWDOWN },
+	{ STATE_ICEP_THROWRIGHT, GROUP_ENT_ICEPUFF_THROWRIGHT },
+	{ STATE_ICEP_THROWLEFT,  GROUP_ENT_ICEPUFF_THROWLEFT },
+	{ STATE_ICEP_DISAPPEAR,  GROUP_ENT_ICEPUFF_DISAPPEAR },
+	{ STATE_ENDSTATES,       "" }
 };
 
 AIStateDef buzzfly[] = {
-	{ STATE_MOVEDOWN,      GROUP_ENT_BUZZFLY_WALKDOWN },
-	{ STATE_MOVEUP,        GROUP_ENT_BUZZFLY_WALKUP },
-	{ STATE_MOVELEFT,      GROUP_ENT_BUZZFLY_WALKLEFT },
-	{ STATE_MOVERIGHT,     GROUP_ENT_BUZZFLY_WALKRIGHT },
+	{ STATE_MOVEDOWN,  GROUP_ENT_BUZZFLY_WALKDOWN },
+	{ STATE_MOVEUP,    GROUP_ENT_BUZZFLY_WALKUP },
+	{ STATE_MOVELEFT,  GROUP_ENT_BUZZFLY_WALKLEFT },
+	{ STATE_MOVERIGHT, GROUP_ENT_BUZZFLY_WALKRIGHT },
 	{ STATE_ENDSTATES, "" }
 };
 
 AIStateDef fatFrog[] = {
-	{ STATE_STANDDOWN,              GROUP_ENT_FATFROG_STANDDOWN },
-	{ STATE_STANDLEFT,              GROUP_ENT_FATFROG_STANDLEFT },
-	{ STATE_STANDRIGHT,             GROUP_ENT_FATFROG_STANDRIGHT },
-	{ STATE_LICKDOWN,               GROUP_ENT_FATFROG_LICKDOWN },
-	{ STATE_LICKLEFT,               GROUP_ENT_FATFROG_LICKLEFT },
-	{ STATE_LICKRIGHT,              GROUP_ENT_FATFROG_LICKRIGHT },
-	{ STATE_ENDSTATES, "" }
+	{ STATE_STANDDOWN,  GROUP_ENT_FATFROG_STANDDOWN },
+	{ STATE_STANDLEFT,  GROUP_ENT_FATFROG_STANDLEFT },
+	{ STATE_STANDRIGHT, GROUP_ENT_FATFROG_STANDRIGHT },
+	{ STATE_LICKDOWN,   GROUP_ENT_FATFROG_LICKDOWN },
+	{ STATE_LICKLEFT,   GROUP_ENT_FATFROG_LICKLEFT },
+	{ STATE_LICKRIGHT,  GROUP_ENT_FATFROG_LICKRIGHT },
+	{ STATE_ENDSTATES,  "" }
 };
 
 AIStateDef dragon[] = {
@@ -315,123 +315,123 @@ AIStateDef dragon[] = {
 // These are in the demo
 
 AIStateDef omniBotMissile[] = {
-	{ STATE_MOVEDOWN,       GROUP_ENT_OMNIBOT_MISSILE },
+	{ STATE_MOVEDOWN,  GROUP_ENT_OMNIBOT_MISSILE },
 	{ STATE_ENDSTATES, "" }
 };
 
 AIStateDef fourFirer[] = {
-	{ STATE_STANDDOWN,      GROUP_ENT_FOUR_LASER_DOWN },
-	{ STATE_STANDUP,        GROUP_ENT_FOUR_LASER_UP },
-	{ STATE_STANDLEFT,      GROUP_ENT_FOUR_LASER_LEFT },
-	{ STATE_STANDRIGHT,     GROUP_ENT_FOUR_LASER_RIGHT },
-	{ STATE_ENDSTATES, "" }
+	{ STATE_STANDDOWN,  GROUP_ENT_FOUR_LASER_DOWN },
+	{ STATE_STANDUP,    GROUP_ENT_FOUR_LASER_UP },
+	{ STATE_STANDLEFT,  GROUP_ENT_FOUR_LASER_LEFT },
+	{ STATE_STANDRIGHT, GROUP_ENT_FOUR_LASER_RIGHT },
+	{ STATE_ENDSTATES,  "" }
 };
 
 AIStateDef railRider[] = {
-	{ STATE_STANDDOWN,      GROUP_ENT_RAILRIDER_STANDDOWN },
-	{ STATE_STANDUP,        GROUP_ENT_RAILRIDER_STANDUP },
-	{ STATE_MOVEDOWN,       GROUP_ENT_RAILRIDER_WALKDOWN },
-	{ STATE_MOVEUP,         GROUP_ENT_RAILRIDER_WALKUP },
-	{ STATE_MOVELEFT,       GROUP_ENT_RAILRIDER_WALKLEFT },
-	{ STATE_MOVERIGHT,      GROUP_ENT_RAILRIDER_WALKRIGHT },
+	{ STATE_STANDDOWN, GROUP_ENT_RAILRIDER_STANDDOWN },
+	{ STATE_STANDUP,   GROUP_ENT_RAILRIDER_STANDUP },
+	{ STATE_MOVEDOWN,  GROUP_ENT_RAILRIDER_WALKDOWN },
+	{ STATE_MOVEUP,    GROUP_ENT_RAILRIDER_WALKUP },
+	{ STATE_MOVELEFT,  GROUP_ENT_RAILRIDER_WALKLEFT },
+	{ STATE_MOVERIGHT, GROUP_ENT_RAILRIDER_WALKRIGHT },
 	{ STATE_ENDSTATES, "" }
 };
 
 AIStateDef shockBot[] = {
-	{ STATE_MOVEDOWN,       GROUP_ENT_SHOCKBOT_WALK },
-	{ STATE_SHOCKING,       GROUP_SHOCK_SPARK_SIT },
+	{ STATE_MOVEDOWN,  GROUP_ENT_SHOCKBOT_WALK },
+	{ STATE_SHOCKING,  GROUP_SHOCK_SPARK_SIT },
 	{ STATE_ENDSTATES, "" }
 };
 
 // Pushables
 
 AIStateDef crate[] = {
-	{ STATE_STANDDOWN,      GROUP_ENT_CRATE_SIT },
-	{ STATE_FLOATING,       GROUP_ENT_CRATE_FLOAT },
+	{ STATE_STANDDOWN, GROUP_ENT_CRATE_SIT },
+	{ STATE_FLOATING,  GROUP_ENT_CRATE_FLOAT },
 	{ STATE_ENDSTATES, "" }
 };
 
 AIStateDef barrelLight[] = {
-	{ STATE_FLOATING,       GROUP_ENT_BARREL_LIGHT_FLOAT },
-	{ STATE_MELTED,         GROUP_ENT_BARREL_LIGHT_MELT },
-	{ STATE_STANDDOWN,      GROUP_ENT_BARREL_LIGHT_SIT },
+	{ STATE_FLOATING,  GROUP_ENT_BARREL_LIGHT_FLOAT },
+	{ STATE_MELTED,    GROUP_ENT_BARREL_LIGHT_MELT },
+	{ STATE_STANDDOWN, GROUP_ENT_BARREL_LIGHT_SIT },
 	{ STATE_ENDSTATES, "" }
 };
 
 AIStateDef barrelHeavy[] = {
-	{ STATE_FLOATING,       GROUP_ENT_BARREL_HEAVY_FLOAT },
-	{ STATE_MELTED,         GROUP_ENT_BARREL_HEAVY_MELT },
-	{ STATE_STANDDOWN,      GROUP_ENT_BARREL_HEAVY_SIT },
+	{ STATE_FLOATING,  GROUP_ENT_BARREL_HEAVY_FLOAT },
+	{ STATE_MELTED,    GROUP_ENT_BARREL_HEAVY_MELT },
+	{ STATE_STANDDOWN, GROUP_ENT_BARREL_HEAVY_SIT },
 	{ STATE_ENDSTATES, "" }
 };
 
 AIStateDef barrelExplode[] = {
-	{ STATE_EXPLODING,      GROUP_EXPLOSION_BOOM_SIT },
-	{ STATE_STANDDOWN,      GROUP_ENT_BARREL_EXPLODE_SIT },
+	{ STATE_EXPLODING, GROUP_EXPLOSION_BOOM_SIT },
+	{ STATE_STANDDOWN, GROUP_ENT_BARREL_EXPLODE_SIT },
 	{ STATE_ENDSTATES, "" }
 };
 
 AIStateDef frogStatue[] = {
-	{ STATE_STANDDOWN,      GROUP_ENT_FROGSTATUE_SIT },
+	{ STATE_STANDDOWN, GROUP_ENT_FROGSTATUE_SIT },
 	{ STATE_ENDSTATES, "" }
 };
 
 // Weapons
 
 AIStateDef club[] = {
-	{ STATE_STANDDOWN,      GROUP_ENT_CLUB_SIT },
+	{ STATE_STANDDOWN, GROUP_ENT_CLUB_SIT },
 	{ STATE_ENDSTATES, "" }
 };
 
 AIStateDef roboStunner[] = {
-	{ STATE_STANDDOWN,      GROUP_ENT_ROBOSTUNNER_SIT },
+	{ STATE_STANDDOWN, GROUP_ENT_ROBOSTUNNER_SIT },
 	{ STATE_ENDSTATES, "" }
 };
 
 AIStateDef slugSlinger[] = {
-	{ STATE_STANDDOWN,      GROUP_ENT_SLUGSLINGER_SIT },
+	{ STATE_STANDDOWN, GROUP_ENT_SLUGSLINGER_SIT },
 	{ STATE_ENDSTATES, "" }
 };
 
 // Items
 
 AIStateDef itemChicken[] = {
-	{ STATE_STANDDOWN,      GROUP_ENT_CHICKEN_STANDDOWN },
+	{ STATE_STANDDOWN, GROUP_ENT_CHICKEN_STANDDOWN },
 	{ STATE_ENDSTATES, "" }
 };
 
 AIStateDef envelopeWhite[] = {
-	{ STATE_STANDDOWN,      GROUP_ENT_ENVELOPE_WHITE_SIT },
+	{ STATE_STANDDOWN, GROUP_ENT_ENVELOPE_WHITE_SIT },
 	{ STATE_ENDSTATES, "" }
 };
 
 AIStateDef envelopeBlue[] = {
-	{ STATE_STANDDOWN,      GROUP_ENT_ENVELOPE_BLUE_SIT },
+	{ STATE_STANDDOWN, GROUP_ENT_ENVELOPE_BLUE_SIT },
 	{ STATE_ENDSTATES, "" }
 };
 
 AIStateDef envelopeRed[] = {
-	{ STATE_STANDDOWN,      GROUP_ENT_ENVELOPE_RED_SIT },
+	{ STATE_STANDDOWN, GROUP_ENT_ENVELOPE_RED_SIT },
 	{ STATE_ENDSTATES, "" }
 };
 
 AIStateDef transceiver[] = {
-	{ STATE_STANDDOWN,      GROUP_ENT_TRANSCEIVER_SIT },
+	{ STATE_STANDDOWN, GROUP_ENT_TRANSCEIVER_SIT },
 	{ STATE_ENDSTATES, "" }
 };
 
 AIStateDef cell[] = {
-	{ STATE_STANDDOWN,      GROUP_ENT_CELL_SIT },
+	{ STATE_STANDDOWN, GROUP_ENT_CELL_SIT },
 	{ STATE_ENDSTATES, "" }
 };
 
 AIStateDef gooCup[] = {
-	{ STATE_STANDDOWN,      GROUP_ENT_GOO_CUP_SIT },
+	{ STATE_STANDDOWN, GROUP_ENT_GOO_CUP_SIT },
 	{ STATE_ENDSTATES, "" }
 };
 
 AIStateDef gemWhite[] = {
-	{ STATE_STANDDOWN,      GROUP_ENT_GEM_WHITE_SIT },
+	{ STATE_STANDDOWN, GROUP_ENT_GEM_WHITE_SIT },
 	{ STATE_ENDSTATES, "" }
 };
 
@@ -441,147 +441,147 @@ AIStateDef cabKey[] = {
 };
 
 AIStateDef envelopeGreen[] = {
-	{ STATE_STANDDOWN,      GROUP_ENT_ENVELOPE_GREEN_SIT },
+	{ STATE_STANDDOWN, GROUP_ENT_ENVELOPE_GREEN_SIT },
 	{ STATE_ENDSTATES, "" }
 };
 
 AIStateDef teaCup[] = {
-	{ STATE_STANDDOWN,      GROUP_ENT_TEACUP_SIT },
+	{ STATE_STANDDOWN, GROUP_ENT_TEACUP_SIT },
 	{ STATE_ENDSTATES, "" }
 };
 
 AIStateDef cookie[] = {
-	{ STATE_STANDDOWN,      GROUP_ENT_COOKIE_SIT },
+	{ STATE_STANDDOWN, GROUP_ENT_COOKIE_SIT },
 	{ STATE_ENDSTATES, "" }
 };
 
 AIStateDef burger[] = {
-	{ STATE_STANDDOWN,      GROUP_ENT_BURGER_SIT },
+	{ STATE_STANDDOWN, GROUP_ENT_BURGER_SIT },
 	{ STATE_ENDSTATES, "" }
 };
 
 AIStateDef pda[] = {
-	{ STATE_STANDDOWN,      GROUP_ENT_PDA_SIT },
+	{ STATE_STANDDOWN, GROUP_ENT_PDA_SIT },
 	{ STATE_ENDSTATES, "" }
 };
 
 AIStateDef book[] = {
-	{ STATE_STANDDOWN,      GROUP_ENT_BOOK_SIT },
+	{ STATE_STANDDOWN, GROUP_ENT_BOOK_SIT },
 	{ STATE_ENDSTATES, "" }
 };
 
 AIStateDef clipboard[] = {
-	{ STATE_STANDDOWN,      GROUP_ENT_CLIPBOARD_SIT },
+	{ STATE_STANDDOWN, GROUP_ENT_CLIPBOARD_SIT },
 	{ STATE_ENDSTATES, "" }
 };
 
 AIStateDef note[] = {
-	{ STATE_STANDDOWN,      GROUP_ENT_NOTE_SIT },
+	{ STATE_STANDDOWN, GROUP_ENT_NOTE_SIT },
 	{ STATE_ENDSTATES, "" }
 };
 
 AIStateDef keycardWhite[] = {
-	{ STATE_STANDDOWN,      GROUP_ENT_KEYCARD_WHITE_SIT },
+	{ STATE_STANDDOWN, GROUP_ENT_KEYCARD_WHITE_SIT },
 	{ STATE_ENDSTATES, "" }
 };
 
 AIStateDef keycardBlue[] = {
-	{ STATE_STANDDOWN,      GROUP_ENT_KEYCARD_BLUE_SIT },
+	{ STATE_STANDDOWN, GROUP_ENT_KEYCARD_BLUE_SIT },
 	{ STATE_ENDSTATES, "" }
 };
 
 AIStateDef keycardRed[] = {
-	{ STATE_STANDDOWN,      GROUP_ENT_KEYCARD_RED_SIT },
+	{ STATE_STANDDOWN, GROUP_ENT_KEYCARD_RED_SIT },
 	{ STATE_ENDSTATES, "" }
 };
 
 AIStateDef keycardGreen[] = {
-	{ STATE_STANDDOWN,      GROUP_ENT_KEYCARD_GREEN_SIT },
+	{ STATE_STANDDOWN, GROUP_ENT_KEYCARD_GREEN_SIT },
 	{ STATE_ENDSTATES, "" }
 };
 
 AIStateDef keycardPurple[] = {
-	{ STATE_STANDDOWN,      GROUP_ENT_KEYCARD_PURPLE_SIT },
+	{ STATE_STANDDOWN, GROUP_ENT_KEYCARD_PURPLE_SIT },
 	{ STATE_ENDSTATES, "" }
 };
 
 AIStateDef keycardBlack[] = {
-	{ STATE_STANDDOWN,      GROUP_ENT_KEYCARD_BLACK_SIT },
+	{ STATE_STANDDOWN, GROUP_ENT_KEYCARD_BLACK_SIT },
 	{ STATE_ENDSTATES, "" }
 };
 
 AIStateDef magicEgg[] = {
-	{ STATE_STANDDOWN,      GROUP_ENT_MAGIC_EGG_SIT },
+	{ STATE_STANDDOWN, GROUP_ENT_MAGIC_EGG_SIT },
 	{ STATE_ENDSTATES, "" }
 };
 
 AIStateDef iceBlock[] = {
-	{ STATE_STANDDOWN,      GROUP_ENT_ICE_BLOCK_SIT },
+	{ STATE_STANDDOWN, GROUP_ENT_ICE_BLOCK_SIT },
 	{ STATE_ENDSTATES, "" }
 };
 
 AIStateDef gemBlue[] = {
-	{ STATE_STANDDOWN,      GROUP_ENT_GEM_BLUE_SIT },
+	{ STATE_STANDDOWN, GROUP_ENT_GEM_BLUE_SIT },
 	{ STATE_ENDSTATES, "" }
 };
 
 AIStateDef gemRed[] = {
-	{ STATE_STANDDOWN,      GROUP_ENT_GEM_RED_SIT },
+	{ STATE_STANDDOWN, GROUP_ENT_GEM_RED_SIT },
 	{ STATE_ENDSTATES, "" }
 };
 
 AIStateDef gemGreen[] = {
-	{ STATE_STANDDOWN,      GROUP_ENT_GEM_GREEN_SIT },
+	{ STATE_STANDDOWN, GROUP_ENT_GEM_GREEN_SIT },
 	{ STATE_ENDSTATES, "" }
 };
 
 AIStateDef dollyTool1[] = {
-	{ STATE_STANDDOWN,      GROUP_ENT_DOLLY_TOOL1_SIT },
+	{ STATE_STANDDOWN, GROUP_ENT_DOLLY_TOOL1_SIT },
 	{ STATE_ENDSTATES, "" }
 };
 
 AIStateDef dollyTool2[] = {
-	{ STATE_STANDDOWN,      GROUP_ENT_DOLLY_TOOL2_SIT },
+	{ STATE_STANDDOWN, GROUP_ENT_DOLLY_TOOL2_SIT },
 	{ STATE_ENDSTATES, "" }
 };
 
 AIStateDef dollyTool3[] = {
-	{ STATE_STANDDOWN,      GROUP_ENT_DOLLY_TOOL3_SIT },
+	{ STATE_STANDDOWN, GROUP_ENT_DOLLY_TOOL3_SIT },
 	{ STATE_ENDSTATES, "" }
 };
 
 AIStateDef dollyTool4[] = {
-	{ STATE_STANDDOWN,      GROUP_ENT_DOLLY_TOOL4_SIT },
+	{ STATE_STANDDOWN, GROUP_ENT_DOLLY_TOOL4_SIT },
 	{ STATE_ENDSTATES, "" }
 };
 
 AIStateDef seed[] = {
-	{ STATE_STANDDOWN,      GROUP_ENT_SEED_SIT },
+	{ STATE_STANDDOWN, GROUP_ENT_SEED_SIT },
 	{ STATE_ENDSTATES, "" }
 };
 
 AIStateDef soda[] = {
-	{ STATE_STANDDOWN,      GROUP_ENT_SODA_SIT },
+	{ STATE_STANDDOWN, GROUP_ENT_SODA_SIT },
 	{ STATE_ENDSTATES, "" }
 };
 
 AIStateDef router[] = {
-	{ STATE_STANDDOWN,      GROUP_ENT_ROUTER_SIT },
+	{ STATE_STANDDOWN, GROUP_ENT_ROUTER_SIT },
 	{ STATE_ENDSTATES, "" }
 };
 
 AIStateDef slicer[] = {
-	{ STATE_STANDDOWN,      GROUP_ENT_SLICER_SIT },
+	{ STATE_STANDDOWN, GROUP_ENT_SLICER_SIT },
 	{ STATE_ENDSTATES, "" }
 };
 
 AIStateDef package[] = {
-	{ STATE_STANDDOWN,      GROUP_ENT_PACKAGE_SIT },
+	{ STATE_STANDDOWN, GROUP_ENT_PACKAGE_SIT },
 	{ STATE_ENDSTATES, "" }
 };
 
 AIStateDef monkeystone[] = {
-	{ STATE_STANDDOWN,      GROUP_ENT_MONKEYSTONE_SIT },
+	{ STATE_STANDDOWN, GROUP_ENT_MONKEYSTONE_SIT },
 	{ STATE_ENDSTATES, "" }
 };
 
@@ -958,25 +958,24 @@ AI::AI() {
 }
 
 AI::~AI() {
-	for (uint i = 0; i < _ents->size(); i++) {
+	for (uint i = 0; i < _ents->size(); i++)
 		delete _ents->operator[](i);
-	}
 	delete _ents;
-	for (uint i = 0; i < _floats->size(); i++) {
+
+	for (uint i = 0; i < _floats->size(); i++)
 		delete _floats->operator[](i);
-	}
 	delete _floats;
-	for (uint i = 0; i < _arrowPaths->size(); i++) {
+
+	for (uint i = 0; i < _arrowPaths->size(); i++)
 		delete _arrowPaths->operator[](i);
-	}
 	delete _arrowPaths;
-	for (uint i = 0; i < _triggerList->size(); i++) {
+
+	for (uint i = 0; i < _triggerList->size(); i++)
 		delete _triggerList->operator[](i);
-	}
 	delete _triggerList;
-	for (uint i = 0; i < _hereList->size(); i++) {
+
+	for (uint i = 0; i < _hereList->size(); i++)
 		delete _hereList->operator[](i);
-	}
 	delete _hereList;
 
 	memset(&_inventory, 0, sizeof(InvEnt) * kMaxInventory);
@@ -1009,7 +1008,6 @@ AI::~AI() {
 }
 
 bool AI::init() {
-
 	_debugQMark = g_hdb->_gfx->loadIcon("icon_question_mark");
 
 	// Clear Waypoint list and load Waypoint graphics
@@ -1245,7 +1243,6 @@ void AI::restartSystem() {
 	// Clear Cinematic System
 	_cineActive = _cameraLock = _playerLock = _cineAborted = false;
 
-	int i;
 	if (_icepSnowballGfxDown) {
 		delete _icepSnowballGfxDown;
 		_icepSnowballGfxDown = NULL;
@@ -1264,7 +1261,7 @@ void AI::restartSystem() {
 		_tileFroglickMiddleUD = NULL;
 	}
 	if (_tileFroglickWiggleUD[0]) {
-		for (i = 0; i < 3; i++) {
+		for (int i = 0; i < 3; i++) {
 			delete _tileFroglickWiggleUD[i];
 			_tileFroglickWiggleUD[i] = NULL;
 		}
@@ -1275,13 +1272,13 @@ void AI::restartSystem() {
 		_tileFroglickMiddleLR = NULL;
 	}
 	if (_tileFroglickWiggleLeft[0]) {
-		for (i = 0; i < 3; i++) {
+		for (int i = 0; i < 3; i++) {
 			delete _tileFroglickWiggleLeft[i];
 			_tileFroglickWiggleLeft[i] = NULL;
 		}
 	}
 	if (_tileFroglickWiggleRight[0]) {
-		for (i = 0; i < 3; i++) {
+		for (int i = 0; i < 3; i++) {
 			delete _tileFroglickWiggleRight[i];
 			_tileFroglickWiggleRight[i] = NULL;
 		}
@@ -1312,7 +1309,7 @@ void AI::restartSystem() {
 		delete g_hdb->_window->_pzInfo.gfxFace[1];
 		g_hdb->_window->_pzInfo.gfxFace[1] = NULL;
 
-		for (i = 0; i < 10; i++) {
+		for (int i = 0; i < 10; i++) {
 			delete g_hdb->_window->_pzInfo.gfxNumber[i];
 			g_hdb->_window->_pzInfo.gfxNumber[i] = NULL;
 		}
@@ -1321,7 +1318,7 @@ void AI::restartSystem() {
 
 	// laser beams
 	if (_gfxLaserbeamUD[0]) {
-		for (i = 0; i < 4; i++) {
+		for (int i = 0; i < 4; i++) {
 			delete _gfxLaserbeamUD[i];
 			delete _gfxLaserbeamUDTop[i];
 			delete _gfxLaserbeamUDBottom[i];
@@ -1343,8 +1340,6 @@ void AI::restartSystem() {
 }
 
 void AI::save(Common::OutSaveFile *out) {
-	int i;
-
 	// Misc Variables
 	out->writeByte(_playerInvisible);
 	out->writeByte(_playerOnIce);
@@ -1353,7 +1348,7 @@ void AI::save(Common::OutSaveFile *out) {
 	out->writeSint32LE((int)_weaponSelected);
 
 	// Save Teleporters
-	for (i = 0; i < kMaxTeleporters; i++) {
+	for (int i = 0; i < kMaxTeleporters; i++) {
 		out->writeUint16LE(_teleporters[i].x1);
 		out->writeUint16LE(_teleporters[i].y1);
 		out->writeUint16LE(_teleporters[i].x2);
@@ -1381,14 +1376,14 @@ void AI::save(Common::OutSaveFile *out) {
 	out->writeSint32LE(_numMonkeystones);
 
 	// Save Inventory
-	for (i = 0; i < kMaxInventory; i++) {
+	for (int i = 0; i < kMaxInventory; i++) {
 		out->writeUint16LE(_inventory[i].keep);
 		_inventory[i].ent.save(out);
 	}
 	out->writeUint32LE(_numInventory);
 
 	// Save Deliveries
-	for (i = 0; i < kMaxDeliveries; i++) {
+	for (int i = 0; i < kMaxDeliveries; i++) {
 		out->write(_deliveries[i].itemTextName, 32);
 		out->write(_deliveries[i].itemGfxName, 32);
 		out->write(_deliveries[i].destTextName, 32);
@@ -1398,7 +1393,7 @@ void AI::save(Common::OutSaveFile *out) {
 	out->writeUint32LE(_numDeliveries);
 
 	// Save Waypoints
-	for (i = 0; i < kMaxWaypoints; i++) {
+	for (int i = 0; i < kMaxWaypoints; i++) {
 		out->writeSint32LE(_waypoints[i].x);
 		out->writeSint32LE(_waypoints[i].y);
 		out->writeSint32LE(_waypoints[i].level);
@@ -1406,7 +1401,7 @@ void AI::save(Common::OutSaveFile *out) {
 	out->writeUint32LE(_numWaypoints);
 
 	// Save Bridges
-	for (i = 0; i < kMaxBridges; i++) {
+	for (int i = 0; i < kMaxBridges; i++) {
 		out->writeUint16LE(_bridges[i].x);
 		out->writeUint16LE(_bridges[i].y);
 		out->writeSint32LE((int)_bridges[i].dir);
@@ -1416,7 +1411,7 @@ void AI::save(Common::OutSaveFile *out) {
 	out->writeUint32LE(_numBridges);
 
 	// Save Lua List
-	for (i = 0; i < kMaxLuaEnts; i++) {
+	for (int i = 0; i < kMaxLuaEnts; i++) {
 		out->writeUint16LE(_luaList[i].x);
 		out->writeUint16LE(_luaList[i].y);
 		out->writeUint16LE(_luaList[i].value1);
@@ -1428,7 +1423,7 @@ void AI::save(Common::OutSaveFile *out) {
 	out->writeUint32LE(_numLuaList);
 
 	// Save Auto Actions
-	for (i = 0; i < kMaxAutoActions; i++) {
+	for (int i = 0; i < kMaxAutoActions; i++) {
 		out->writeUint16LE(_autoActions[i].x);
 		out->writeUint16LE(_autoActions[i].y);
 		out->writeByte(_autoActions[i].activated);
@@ -1438,7 +1433,7 @@ void AI::save(Common::OutSaveFile *out) {
 	}
 
 	// Save Actions
-	for (i = 0; i < kMaxActions; i++) {
+	for (int i = 0; i < kMaxActions; i++) {
 		out->writeUint16LE(_actions[i].x1);
 		out->writeUint16LE(_actions[i].y1);
 		out->writeUint16LE(_actions[i].x2);
@@ -1449,7 +1444,7 @@ void AI::save(Common::OutSaveFile *out) {
 	}
 
 	// Save Fairystones
-	for (i = 0; i < kMaxFairystones; i++) {
+	for (int i = 0; i < kMaxFairystones; i++) {
 		out->writeUint16LE(_fairystones[i].srcX);
 		out->writeUint16LE(_fairystones[i].srcY);
 		out->writeUint16LE(_fairystones[i].destX);
@@ -1457,7 +1452,7 @@ void AI::save(Common::OutSaveFile *out) {
 	}
 
 	// Save Callbacks
-	for (i = 0; i < kMaxCallbacks; i++) {
+	for (int i = 0; i < kMaxCallbacks; i++) {
 		out->writeSint32LE((int)_callbacks[i].type);
 		out->writeUint16LE(_callbacks[i].x);
 		out->writeUint16LE(_callbacks[i].y);
@@ -1469,7 +1464,7 @@ void AI::save(Common::OutSaveFile *out) {
 
 	// Save AnimTargets
 	out->writeUint32LE(_animTargets.size());
-	for (i = 0; (uint)i < _animTargets.size(); i++) {
+	for (int i = 0; (uint)i < _animTargets.size(); i++) {
 		out->writeUint16LE(_animTargets[i]->x);
 		out->writeUint16LE(_animTargets[i]->y);
 		out->writeUint16LE(_animTargets[i]->start);
@@ -1483,7 +1478,7 @@ void AI::save(Common::OutSaveFile *out) {
 
 	// Save ArrowPaths
 	out->writeUint32LE(_arrowPaths->size());
-	for (i = 0; (uint)i < _arrowPaths->size(); i++) {
+	for (int i = 0; (uint)i < _arrowPaths->size(); i++) {
 		out->writeUint16LE(_arrowPaths->operator[](i)->type);
 		out->writeSint32LE((int)_arrowPaths->operator[](i)->dir);
 		out->writeUint16LE(_arrowPaths->operator[](i)->tileX);
@@ -1492,7 +1487,7 @@ void AI::save(Common::OutSaveFile *out) {
 
 	// Save HereT List
 	out->writeUint32LE(_hereList->size());
-	for (i = 0; (uint)i < _hereList->size(); i++) {
+	for (int i = 0; (uint)i < _hereList->size(); i++) {
 		out->writeUint16LE(_hereList->operator[](i)->x);
 		out->writeUint16LE(_hereList->operator[](i)->y);
 		out->write(_hereList->operator[](i)->entName, 32);
@@ -1500,7 +1495,7 @@ void AI::save(Common::OutSaveFile *out) {
 
 	// Save Triggers
 	out->writeUint32LE(_triggerList->size());
-	for (i = 0; (uint)i < _triggerList->size(); i++) {
+	for (int i = 0; (uint)i < _triggerList->size(); i++) {
 		out->write(_triggerList->operator[](i)->id, 32);
 		out->writeUint16LE(_triggerList->operator[](i)->x);
 		out->writeUint16LE(_triggerList->operator[](i)->y);
@@ -1510,28 +1505,22 @@ void AI::save(Common::OutSaveFile *out) {
 		out->write(_triggerList->operator[](i)->luaFuncUse, 32);
 	}
 
-	AIEntity *e;
-
 	// Save Floats
 	out->writeUint32LE(_floats->size());
-	for (i = 0; (uint)i < _floats->size(); i++) {
-		e = _floats->operator[](i);
-
+	for (int i = 0; (uint)i < _floats->size(); i++) {
+		AIEntity *e = _floats->operator[](i);
 		e->save(out);
 	}
 
 	// Save Ents
 	out->writeUint32LE(_ents->size());
-	for (i = 0; (uint)i < _ents->size(); i++) {
-		e = _ents->operator[](i);
-
+	for (int i = 0; (uint)i < _ents->size(); i++) {
+		AIEntity *e = _ents->operator[](i);
 		e->save(out);
 	}
 }
 
 void AI::loadSaveFile(Common::InSaveFile *in) {
-	int i;
-
 	// Clean everything out
 	restartSystem();
 
@@ -1543,7 +1532,7 @@ void AI::loadSaveFile(Common::InSaveFile *in) {
 	_weaponSelected = (AIType)in->readSint32LE();
 
 	// Load Teleporters
-	for (i = 0; i < kMaxTeleporters; i++) {
+	for (int i = 0; i < kMaxTeleporters; i++) {
 		_teleporters[i].x1 = in->readUint16LE();
 		_teleporters[i].y1 = in->readUint16LE();
 		_teleporters[i].x2 = in->readUint16LE();
@@ -1571,14 +1560,14 @@ void AI::loadSaveFile(Common::InSaveFile *in) {
 	_numMonkeystones = in->readSint32LE();
 
 	// Load Inventory
-	for (i = 0; i < kMaxInventory; i++) {
+	for (int i = 0; i < kMaxInventory; i++) {
 		_inventory[i].keep = in->readUint16LE();
 		_inventory[i].ent.load(in);
 	}
 	_numInventory = in->readUint32LE();
 
 	// Load Deliveries
-	for (i = 0; i < kMaxDeliveries; i++) {
+	for (int i = 0; i < kMaxDeliveries; i++) {
 		in->read(_deliveries[i].itemTextName, 32);
 		in->read(_deliveries[i].itemGfxName, 32);
 		in->read(_deliveries[i].destTextName, 32);
@@ -1588,7 +1577,7 @@ void AI::loadSaveFile(Common::InSaveFile *in) {
 	_numDeliveries = in->readUint32LE();
 
 	// Load Waypoints
-	for (i = 0; i < kMaxWaypoints; i++) {
+	for (int i = 0; i < kMaxWaypoints; i++) {
 		_waypoints[i].x = in->readSint32LE();
 		_waypoints[i].y = in->readSint32LE();
 		_waypoints[i].level = in->readSint32LE();
@@ -1596,7 +1585,7 @@ void AI::loadSaveFile(Common::InSaveFile *in) {
 	_numWaypoints = in->readUint32LE();
 
 	// Load Bridges
-	for (i = 0; i < kMaxBridges; i++) {
+	for (int i = 0; i < kMaxBridges; i++) {
 		_bridges[i].x = in->readUint16LE();
 		_bridges[i].y = in->readUint16LE();
 		_bridges[i].dir = (AIDir)in->readSint32LE();
@@ -1606,7 +1595,7 @@ void AI::loadSaveFile(Common::InSaveFile *in) {
 	_numBridges = in->readUint32LE();
 
 	// Load Lua List
-	for (i = 0; i < kMaxLuaEnts; i++) {
+	for (int i = 0; i < kMaxLuaEnts; i++) {
 		_luaList[i].x = in->readUint16LE();
 		_luaList[i].y = in->readUint16LE();
 		_luaList[i].value1 = in->readUint16LE();
@@ -1618,7 +1607,7 @@ void AI::loadSaveFile(Common::InSaveFile *in) {
 	_numLuaList = in->readUint32LE();
 
 	// Load Auto Actions
-	for (i = 0; i < kMaxAutoActions; i++) {
+	for (int i = 0; i < kMaxAutoActions; i++) {
 		_autoActions[i].x = in->readUint16LE();
 		_autoActions[i].y = in->readUint16LE();
 		_autoActions[i].activated = in->readByte();
@@ -1628,7 +1617,7 @@ void AI::loadSaveFile(Common::InSaveFile *in) {
 	}
 
 	// Load Actions
-	for (i = 0; i < kMaxActions; i++) {
+	for (int i = 0; i < kMaxActions; i++) {
 		_actions[i].x1 = in->readUint16LE();
 		_actions[i].y1 = in->readUint16LE();
 		_actions[i].x2 = in->readUint16LE();
@@ -1639,7 +1628,7 @@ void AI::loadSaveFile(Common::InSaveFile *in) {
 	}
 
 	// Load Fairystones
-	for (i = 0; i < kMaxFairystones; i++) {
+	for (int i = 0; i < kMaxFairystones; i++) {
 		_fairystones[i].srcX = in->readUint16LE();
 		_fairystones[i].srcY = in->readUint16LE();
 		_fairystones[i].destX = in->readUint16LE();
@@ -1647,7 +1636,7 @@ void AI::loadSaveFile(Common::InSaveFile *in) {
 	}
 
 	// Load Callbacks
-	for (i = 0; i < kMaxCallbacks; i++) {
+	for (int i = 0; i < kMaxCallbacks; i++) {
 		_callbacks[i].type = (CallbackType)in->readSint32LE();
 		_callbacks[i].x = in->readUint16LE();
 		_callbacks[i].y = in->readUint16LE();
@@ -1658,7 +1647,7 @@ void AI::loadSaveFile(Common::InSaveFile *in) {
 	_gatePuddles = in->readSint32LE();
 
 	// Cache Gfx for Panic Zone, if needed
-	for (i = 0; i < _numTeleporters; i++)
+	for (int i = 0; i < _numTeleporters; i++)
 		if (((_teleporters[i].anim1 == 2) ||
 			 (_teleporters[i].anim2 == 2)) &&
 			!g_hdb->_window->_pzInfo.gfxPanic) {
@@ -1667,7 +1656,7 @@ void AI::loadSaveFile(Common::InSaveFile *in) {
 		}
 
 	// Cache Graphics for Inventory and Deliveries
-	for (i = 0; i < _numInventory; i++) {
+	for (int i = 0; i < _numInventory; i++) {
 		AIEntity *temp = &_inventory[i].ent;
 
 		// Clear out all ptrs in entity before writing out
@@ -1689,7 +1678,7 @@ void AI::loadSaveFile(Common::InSaveFile *in) {
 		cacheEntGfx(temp, false);
 	}
 
-	for (i = 0; i < _numDeliveries; i++) {
+	for (int i = 0; i < _numDeliveries; i++) {
 		_deliveries[i].itemGfx = g_hdb->_gfx->getTileGfx(_deliveries[i].itemGfxName, -1);
 		_deliveries[i].destGfx = g_hdb->_gfx->getTileGfx(_deliveries[i].destGfxName, -1);
 	}
@@ -1717,7 +1706,7 @@ void AI::loadSaveFile(Common::InSaveFile *in) {
 	// Load ArrowPaths
 
 	uint32 arrowPathSize = in->readUint32LE();
-	for (i = 0; (uint)i < arrowPathSize; i++) {
+	for (int i = 0; (uint)i < arrowPathSize; i++) {
 		ArrowPath *arrowPath = new ArrowPath;
 
 		arrowPath->type = in->readUint16LE();
@@ -1742,7 +1731,7 @@ void AI::loadSaveFile(Common::InSaveFile *in) {
 
 	// Load Triggers
 	uint32 tsize = in->readUint32LE();
-	for (i = 0; (uint)i < tsize; i++) {
+	for (int i = 0; (uint)i < tsize; i++) {
 		Trigger *t = new Trigger;
 
 		in->read(t->id, 32);
@@ -1756,12 +1745,10 @@ void AI::loadSaveFile(Common::InSaveFile *in) {
 		_triggerList->push_back(t);
 	}
 
-	AIEntity *e;
-
 	// Load Floats
 	uint32 fsize = in->readUint32LE();
-	for (i = 0; (uint)i < fsize; i++) {
-		e = new AIEntity;
+	for (int i = 0; (uint)i < fsize; i++) {
+		AIEntity *e = new AIEntity;
 
 		e->load(in);
 
@@ -1774,8 +1761,8 @@ void AI::loadSaveFile(Common::InSaveFile *in) {
 
 	// Load Ents
 	uint32 esize = in->readUint32LE();
-	for (i = 0; (uint)i < esize; i++) {
-		e = new AIEntity;
+	for (int i = 0; (uint)i < esize; i++) {
+		AIEntity *e = new AIEntity;
 
 		e->load(in);
 


Commit: 5fe9b6f6e77041e8fd57f6b76e261a8ae3c6041e
    https://github.com/scummvm/scummvm/commit/5fe9b6f6e77041e8fd57f6b76e261a8ae3c6041e
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:29+02:00

Commit Message:
HDB: Minor fixes in Sound Effects code

Changed paths:
    engines/hdb/sound.cpp


diff --git a/engines/hdb/sound.cpp b/engines/hdb/sound.cpp
index fef2945..5e48846 100644
--- a/engines/hdb/sound.cpp
+++ b/engines/hdb/sound.cpp
@@ -1427,7 +1427,7 @@ bool Sound::init() {
 	int index = 0;
 	while (soundList[index].idx != LAST_SOUND) {
 		int index2 = soundList[index].idx;
-		_soundCache[index2].loaded = false;
+		_soundCache[index2].loaded = 0;
 		_soundCache[index2].name = soundList[index].name;
 		_soundCache[index2].luaName = soundList[index].luaName;
 		if (!scumm_stricmp(_soundCache[index2].name, ".wav"))
@@ -1492,7 +1492,7 @@ bool Sound::playSound(int index) {
 		if (stream == nullptr)
 			return false;
 
-		if (_soundCache[index].ext) {
+		if (_soundCache[index].ext == 1) {
 #ifdef USE_MAD
 			_soundCache[index].audioStream = Audio::makeMP3Stream(stream, DisposeAfterUse::YES);
 			_soundCache[index].loaded = 1;


Commit: 6c21dfbbe66fc046d56e1bf5ddf18c5c8c4e7591
    https://github.com/scummvm/scummvm/commit/6c21dfbbe66fc046d56e1bf5ddf18c5c8c4e7591
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:29+02:00

Commit Message:
HDB: Implemented demo differences for menu

Changed paths:
    engines/hdb/menu.cpp
    engines/hdb/menu.h
    engines/hdb/mpc.h


diff --git a/engines/hdb/menu.cpp b/engines/hdb/menu.cpp
index 64cf040..7bd457a 100644
--- a/engines/hdb/menu.cpp
+++ b/engines/hdb/menu.cpp
@@ -109,6 +109,10 @@ Menu::Menu() {
 	_controlButtonGfx = NULL;
 
 	_controlsGfx = NULL;
+	_screenshots1gfx = NULL;
+	_screenshots1agfx = NULL;
+	_screenshots2gfx = NULL;
+	_demoPlaqueGfx = NULL;
 
 	_vortexian[0] = _vortexian[1] = _vortexian[2] = NULL;
 
@@ -284,6 +288,13 @@ void Menu::startMenu() {
 	_controlButtonGfx = g_hdb->_gfx->loadPic(MENU_CONTROLS);
 	_controlsGfx = g_hdb->_gfx->loadPic(PIC_CONTROLSSCREEN);
 
+	if (g_hdb->isDemo()) {
+		_screenshots1gfx = g_hdb->_gfx->loadPic(PIC_DEMOSCREEN);
+		_screenshots1agfx = g_hdb->_gfx->loadPic(PIC_DEMOSCREEN2);
+		_screenshots2gfx = g_hdb->_gfx->loadPic(PIC_DEMO_BUY);
+		_demoPlaqueGfx =  g_hdb->_gfx->loadPic(PIC_DEMO);
+	}
+
 	_vortexian[0] = g_hdb->_gfx->loadTile(GROUP_ENT_VORTEXIAN_STANDDOWN"01");
 	_vortexian[1] = g_hdb->_gfx->loadTile(GROUP_ENT_VORTEXIAN_STANDDOWN"02");
 	_vortexian[2] = g_hdb->_gfx->loadTile(GROUP_ENT_VORTEXIAN_STANDDOWN"03");
@@ -379,6 +390,10 @@ void Menu::drawMenu() {
 		// draw version #
 		_versionGfx->drawMasked(kScreenWidth - 6 * 8, kScreenHeight - 8);
 
+		if (g_hdb->isDemo()) {
+			_demoPlaqueGfx->drawMasked(kScreenWidth / 2 - _demoPlaqueGfx->_width / 2, 2);
+		}
+
 		//
 		// see if the Options/GameFiles menu has scrolled off
 		//
@@ -671,7 +686,13 @@ void Menu::drawMenu() {
 		//-------------------------------------------------------------------
 		g_hdb->_gfx->draw3DStars();
 		drawNebula();
-		{
+
+		if (_quitActive == 2) { // XXXX
+			_screenshots1gfx->drawMasked(kQuitX, kQuitY);
+			_screenshots2gfx->drawMasked(kQuitX, kScreenHeight - _screenshots2gfx->_height);
+		} else if (_quitActive == 1) {
+			_screenshots1agfx->drawMasked(kQuitX, kQuitY);
+		} else if (_quitActive == 3 || !g_hdb->isDemo()) {
 			if (!_quitScreen)
 				_quitScreen = g_hdb->_gfx->loadPic(PIC_QUITSCREEN);
 			_quitScreen->drawMasked(kQuitX, kQuitY);
@@ -726,6 +747,19 @@ void Menu::freeMenu() {
 		delete _hdbLogoScreen;
 	_hdbLogoScreen = NULL;
 
+	if (_screenshots1gfx)
+		delete _screenshots1gfx;
+	_screenshots1gfx = NULL;
+	if (_screenshots1agfx)
+		delete _screenshots1agfx;
+	_screenshots1agfx = NULL;
+	if (_screenshots2gfx)
+		delete _screenshots2gfx;
+	_screenshots2gfx = NULL;
+	if (_demoPlaqueGfx)
+		delete _demoPlaqueGfx;
+	_demoPlaqueGfx = NULL;
+
 	if (_nebulaGfx[0]) {
 		for (int i = 0; i < kNebulaCount; i++) {
 			delete _nebulaGfx[i];
@@ -1050,7 +1084,7 @@ void Menu::processInput(int x, int y) {
 			y >= kMenuY + kMQuitY && y < kMenuY + kMQuitY + kMenuItemHeight) {
 			g_hdb->_sound->playSound(SND_BYE);
 			_quitTimer = g_hdb->getTimeSlice() + 1000;
-			_quitActive = true;
+			_quitActive = 1;
 			_menuActive = false;
 			return;
 		} else if (x >= kMenuX && x < kMenuX + kMenuItemWidth &&
@@ -1323,17 +1357,36 @@ void Menu::processInput(int x, int y) {
 		//-------------------------------------------------------------------
 		int	xit = getMenuKey();
 
-		if ((x >= kQuitNoX1 && x <= kQuitNoX2 && y > kQuitNoY1 && y < kQuitNoY2 && _quitTimer < g_hdb->getTimeSlice()) || xit) {
-			g_hdb->_sound->playSound(SND_MENU_BACKOUT);
-			delete _quitScreen;
-			_quitScreen = NULL;
+		if (!g_hdb->isDemo()) {
+			if ((x >= kQuitNoX1 && x <= kQuitNoX2 && y > kQuitNoY1 && y < kQuitNoY2 && _quitTimer < g_hdb->getTimeSlice()) || xit) {
+				g_hdb->_sound->playSound(SND_MENU_BACKOUT);
+				delete _quitScreen;
+				_quitScreen = NULL;
 
-			_menuActive = true;
-			_quitActive = 0;
-		} else if (_quitTimer < g_hdb->getTimeSlice()) {
-			if (x >= kQuitYesX1 && x <= kQuitYesX2 && y > kQuitYesY1 && y < kQuitYesY2) {
-				writeConfig();
-				g_hdb->quitGame();
+				_menuActive = true;
+				_quitActive = 0;
+			} else if (_quitTimer < g_hdb->getTimeSlice()) {
+				if (x >= kQuitYesX1 && x <= kQuitYesX2 && y > kQuitYesY1 && y < kQuitYesY2) {
+					writeConfig();
+					g_hdb->quitGame();
+				}
+			}
+		} else {
+			if ((_quitActive == 1 || _quitActive == 2) && _quitTimer < g_hdb->getTimeSlice()) {
+				_quitActive++;
+				_quitTimer = g_hdb->getTimeSlice() + 1000;
+			} else {
+				if (_quitActive == 3 && (x >= kQuitNoX1 && x <= kQuitNoX2 && y > kQuitNoY1 && y < kQuitNoY2 && _quitTimer < g_hdb->getTimeSlice())) {
+					g_hdb->_sound->playSound(SND_MENU_BACKOUT);
+					delete _quitScreen;
+					_quitScreen = NULL;
+
+					_menuActive = true;
+					_quitActive = 0;
+				} else if (_quitActive == 3 && _quitTimer < g_hdb->getTimeSlice()){
+					writeConfig();
+					g_hdb->quitGame();
+				}
 			}
 		}
 	}
diff --git a/engines/hdb/menu.h b/engines/hdb/menu.h
index b9d5aeb..7ce6450 100644
--- a/engines/hdb/menu.h
+++ b/engines/hdb/menu.h
@@ -216,6 +216,7 @@ public:
 	Picture	*_star[3], *_warpGfx;
 	uint32 _quitTimer;
 	Picture	*_starRedGfx[2], *_starGreenGfx[2], *_starBlueGfx[2], *_versionGfx;
+	Picture *_screenshots1gfx, *_screenshots1agfx, *_screenshots2gfx, *_demoPlaqueGfx;
 
 	bool _menuActive, _optionsScrolling, _newgameActive, _sayHDB;
 	int	_gamefilesActive, _clickDelay, _saveSlot, _optionsActive, _quitActive, _warpActive;
diff --git a/engines/hdb/mpc.h b/engines/hdb/mpc.h
index 6f2b734..f308139 100644
--- a/engines/hdb/mpc.h
+++ b/engines/hdb/mpc.h
@@ -567,6 +567,8 @@ namespace HDB {
 #define		MONKEYLOGO_SMILE				"monkeylogo_smile"
 #define		PIC_DEMOSCREEN					"pic_demoscreen"
 #define		PIC_DEMOSCREEN2					"pic_demoscreen2"
+#define		PIC_DEMO						"pic_demo"
+#define		PIC_DEMO_BUY					"pic_demo_buy"
 #define		BACKSCROLL_PLANET1				"backscroll_planet1"
 #define		BACKSCROLL_PLANET2				"backscroll_planet2"
 #define		BACKSCROLL_PLANET3				"backscroll_planet3"


Commit: 444327deafceef63855a0c052e706ed37c33d53c
    https://github.com/scummvm/scummvm/commit/444327deafceef63855a0c052e706ed37c33d53c
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:29+02:00

Commit Message:
HDB: Remove redundant function call

Changed paths:
    engines/hdb/ai-funcs.cpp


diff --git a/engines/hdb/ai-funcs.cpp b/engines/hdb/ai-funcs.cpp
index 56f6e96..fe39166 100644
--- a/engines/hdb/ai-funcs.cpp
+++ b/engines/hdb/ai-funcs.cpp
@@ -2338,9 +2338,6 @@ void AI::movePlayer(uint16 buttons) {
 			case STATE_STANDRIGHT:
 				if (checkForTouchplate(nx, ny))
 					break;
-				// TODO: CHECKME - Uselessly redundant call - nx and ny are not modified by the call
-				if (checkForTouchplate(nx, ny))
-					break;
 				if (checkActionList(_player, nx, ny, true))
 					return;
 				if (checkAutoList(_player, nx, ny))


Commit: 67d45170ede1288967dd3b3c241030a42e925a4d
    https://github.com/scummvm/scummvm/commit/67d45170ede1288967dd3b3c241030a42e925a4d
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:29+02:00

Commit Message:
HDB: More code differences for demo

Changed paths:
    engines/hdb/ai-bots.cpp
    engines/hdb/ai-funcs.cpp
    engines/hdb/ai-player.cpp


diff --git a/engines/hdb/ai-bots.cpp b/engines/hdb/ai-bots.cpp
index 3db6cd3..408d364 100644
--- a/engines/hdb/ai-bots.cpp
+++ b/engines/hdb/ai-bots.cpp
@@ -935,7 +935,7 @@ void aiMaintBotAction(AIEntity *e) {
 		if (!e->value2)
 			switch (e->sequence) {
 			case 50:
-				if (e->onScreen && !e->int1) {
+				if (e->onScreen && !e->int1 && !g_hdb->isDemo()) {
 					if (g_hdb->_rnd->getRandomNumber(1))
 						g_hdb->_sound->playSound(SND_MBOT_HMMM2);
 					else
@@ -994,7 +994,7 @@ void aiMaintBotAction(AIEntity *e) {
 			switch (e->sequence) {
 			// HMM
 			case 50:
-				if (e->onScreen && !e->int1)
+				if (e->onScreen && !e->int1 && !g_hdb->isDemo())
 					g_hdb->_sound->playSound(SND_MBOT_HMMM);
 				break;
 			// Look Right
@@ -1009,7 +1009,7 @@ void aiMaintBotAction(AIEntity *e) {
 				break;
 			// HMM2
 			case 25:
-				if (e->onScreen && !e->int1)
+				if (e->onScreen && !e->int1 && !g_hdb->isDemo())
 					g_hdb->_sound->playSound(SND_MBOT_HMMM2);
 				break;
 			// Decide direction and GO
@@ -1017,7 +1017,7 @@ void aiMaintBotAction(AIEntity *e) {
 				int dir = (g_hdb->_rnd->getRandomNumber(3)) + 1;
 				e->dir = dirList[dir];
 				g_hdb->_ai->findPath(e);
-				if (e->onScreen)
+				if (e->onScreen && !g_hdb->isDemo())
 					g_hdb->_sound->playSound(whistles[g_hdb->_rnd->getRandomNumber(2)]);
 				break;
 			}
@@ -1030,7 +1030,8 @@ void aiMaintBotAction(AIEntity *e) {
 		g_hdb->_ai->animateEntity(e);
 		if (hitPlayer(e->x, e->y)) {
 			g_hdb->_ai->killPlayer(DEATH_GRABBED);
-			g_hdb->_sound->playSound(SND_MBOT_DEATH);
+			if (!g_hdb->isDemo())
+				g_hdb->_sound->playSound(SND_MBOT_DEATH);
 		}
 	} else {
 		// Check if there's an arrow UNDER the bot, and if its RED
@@ -1049,7 +1050,8 @@ void aiMaintBotAction(AIEntity *e) {
 				return;
 			} else if (ar->type == 1) {
 				g_hdb->_ai->findPath(e);
-				g_hdb->_sound->playSound(whistles[g_hdb->_rnd->getRandomNumber(2)]);
+				if (!g_hdb->isDemo())
+					g_hdb->_sound->playSound(whistles[g_hdb->_rnd->getRandomNumber(2)]);
 			} else {
 				e->sequence = 64;
 				e->dir2 = e->dir;
diff --git a/engines/hdb/ai-funcs.cpp b/engines/hdb/ai-funcs.cpp
index fe39166..abdcd6e 100644
--- a/engines/hdb/ai-funcs.cpp
+++ b/engines/hdb/ai-funcs.cpp
@@ -1209,7 +1209,8 @@ void AI::animateEntity(AIEntity *e) {
 						} else {
 							addAnimateTarget(e->x, e->y, 0, 3, ANIM_NORMAL, false, false, GROUP_STEAM_PUFF_SIT);
 							removeEntity(e);
-							g_hdb->_sound->playSound(SND_BARREL_MELTING);
+							if (!g_hdb->isDemo())
+								g_hdb->_sound->playSound(SND_BARREL_MELTING);
 							return;
 						}
 					}
@@ -1217,7 +1218,8 @@ void AI::animateEntity(AIEntity *e) {
 					if (!checkFloating(e->tileX, e->tileY)) {
 						addAnimateTarget(e->x, e->y, 0, 3, ANIM_NORMAL, false, false, GROUP_STEAM_PUFF_SIT);
 						floatEntity(e, STATE_MELTED);
-						g_hdb->_sound->playSound(SND_BARREL_MELTING);
+						if (!g_hdb->isDemo())
+							g_hdb->_sound->playSound(SND_BARREL_MELTING);
 					}
 				} else if (flags & kFlagSlide) {
 					int xv = 0, yv = 0;
diff --git a/engines/hdb/ai-player.cpp b/engines/hdb/ai-player.cpp
index 4e70436..b93133f 100644
--- a/engines/hdb/ai-player.cpp
+++ b/engines/hdb/ai-player.cpp
@@ -761,7 +761,10 @@ void aiBarrelExplode(AIEntity *e) {
 	e->state = STATE_EXPLODING;
 	e->animDelay = e->animCycle;
 	e->animFrame = 0;
-	g_hdb->_sound->playSound(SND_BARREL_EXPLODE);
+
+	if (!g_hdb->isDemo())
+		g_hdb->_sound->playSound(SND_BARREL_EXPLODE);
+
 	g_hdb->_map->setBoomBarrel(e->tileX, e->tileY, 0);
 }
 
@@ -1052,6 +1055,9 @@ void aiSlugAttackDraw(AIEntity *e, int mx, int my) {
 }
 
 void aiSlugAttackInit(AIEntity *e) {
+	if (g_hdb->isDemo())
+		return;
+
 	int xv[5] = {9, 0, 0, -1, 1}, yv[5] = {9, -1, 1, 0, 0};
 	e->moveSpeed = kPlayerMoveSpeed << 1;
 	g_hdb->_ai->setEntityGoal(e, e->tileX + xv[e->dir], e->tileY + yv[e->dir]);
@@ -1416,7 +1422,10 @@ void aiMagicEggUse(AIEntity *e) {
 		if (spawned) {
 			g_hdb->_ai->addAnimateTarget(e->tileX * kTileWidth,
 			e->tileY * kTileHeight, 0, 3, ANIM_NORMAL, false, false, GROUP_EXPLOSION_BOOM_SIT);
-			g_hdb->_sound->playSound(SND_BARREL_EXPLODE);
+
+			if (!g_hdb->isDemo())
+				g_hdb->_sound->playSound(SND_BARREL_EXPLODE);
+
 			g_hdb->_ai->removeEntity(e);
 		}
 	}


Commit: d1b906a442536a6f6b7658a11dbb0e6718a56755
    https://github.com/scummvm/scummvm/commit/d1b906a442536a6f6b7658a11dbb0e6718a56755
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:29+02:00

Commit Message:
HDB: Implement rest of the demo differences

Changed paths:
    engines/hdb/detection.cpp
    engines/hdb/gfx.cpp
    engines/hdb/menu.cpp
    engines/hdb/window.cpp


diff --git a/engines/hdb/detection.cpp b/engines/hdb/detection.cpp
index 63563ba..6587b3c 100644
--- a/engines/hdb/detection.cpp
+++ b/engines/hdb/detection.cpp
@@ -121,7 +121,7 @@ static const ADGameDescription gameDescriptions[] = {
 	},
 	{
 		"hdb",
-		"alt",
+		"Handango",
 		AD_ENTRY1s("hyperdemo.msd", "2d4457b284a940b7058b36e5706b9951", 3094241),
 		Common::EN_ANY,
 		Common::kPlatformUnknown, // PPC
diff --git a/engines/hdb/gfx.cpp b/engines/hdb/gfx.cpp
index 3aa37e9..80e5ac8 100644
--- a/engines/hdb/gfx.cpp
+++ b/engines/hdb/gfx.cpp
@@ -960,6 +960,9 @@ void Gfx::getCursor(int *x, int *y) {
 }
 
 void Gfx::turnOnBonusStars(int which) {
+	if (!g_hdb->isDemo())
+		return;
+
 	_starsInfo.active = true;
 	for (int i = 0; i < 10; i++)
 		_starsInfo.starAngle[i] = (36 * (i + 1)) - 10;
diff --git a/engines/hdb/menu.cpp b/engines/hdb/menu.cpp
index 7bd457a..537035b 100644
--- a/engines/hdb/menu.cpp
+++ b/engines/hdb/menu.cpp
@@ -1339,10 +1339,11 @@ void Menu::processInput(int x, int y) {
 			_warpActive = 0;
 
 			char string[16];
-			if (map < 10)
-				sprintf(string, "MAP0%d", map);
-			else
-				sprintf(string, "MAP%d", map);
+			sprintf(string, "MAP%02d", map);
+
+			if (g_hdb->isDemo())
+				strcat(string, "_DEMO");
+
 			freeMenu();
 			g_hdb->setGameState(GAME_PLAY);
 			g_hdb->_sound->stopMusic();
diff --git a/engines/hdb/window.cpp b/engines/hdb/window.cpp
index 6c2dcc8..0633224 100644
--- a/engines/hdb/window.cpp
+++ b/engines/hdb/window.cpp
@@ -1320,7 +1320,7 @@ void Window::loadPanicZoneGfx() {
 }
 
 void Window::drawPanicZone() {
-	if (!_pzInfo.active)
+	if (!_pzInfo.active || !g_hdb->isDemo())
 		return;
 
 	switch (_pzInfo.sequence) {


Commit: 6e67fe35b900180d186289e6fadc4fd4904c899a
    https://github.com/scummvm/scummvm/commit/6e67fe35b900180d186289e6fadc4fd4904c899a
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:29+02:00

Commit Message:
HDB: Even more demo differences

Changed paths:
    engines/hdb/lua-script.cpp


diff --git a/engines/hdb/lua-script.cpp b/engines/hdb/lua-script.cpp
index 082fa04..f2552b4 100644
--- a/engines/hdb/lua-script.cpp
+++ b/engines/hdb/lua-script.cpp
@@ -977,13 +977,15 @@ static int animation(lua_State *L) {
 		break;
 	case 1:
 		g_hdb->_ai->addAnimateTarget((int)x, (int)y, 0, 3, ANIM_NORMAL, false, false, GROUP_EXPLOSION_BOOM_SIT);
-		if (playsnd)
-			g_hdb->_sound->playSound(SND_BARREL_EXPLODE);
+		if (!g_hdb->isDemo())
+			if (playsnd)
+				g_hdb->_sound->playSound(SND_BARREL_EXPLODE);
 		break;
 	case 2:
 		g_hdb->_ai->addAnimateTarget((int)x, (int)y, 0, 3, ANIM_FAST, false, false, GROUP_STEAM_PUFF_SIT);
-		if (playsnd)
-			g_hdb->_sound->playSound(SND_BARREL_MELTING);
+		if (!g_hdb->isDemo())
+			if (playsnd)
+				g_hdb->_sound->playSound(SND_BARREL_MELTING);
 		break;
 	case 3:
 		g_hdb->_ai->addAnimateTarget((int)x, (int)y, 0, 7, ANIM_NORMAL, false, false, TELEPORT_FLASH);


Commit: 78278af46a4fad3de35caa42d72fb2b8ef38612e
    https://github.com/scummvm/scummvm/commit/78278af46a4fad3de35caa42d72fb2b8ef38612e
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:30+02:00

Commit Message:
HDB: Check isDemo() first, otherwise it would crash

by trying to load Demo GFX

Changed paths:
    engines/hdb/menu.cpp


diff --git a/engines/hdb/menu.cpp b/engines/hdb/menu.cpp
index 537035b..9c36c9b 100644
--- a/engines/hdb/menu.cpp
+++ b/engines/hdb/menu.cpp
@@ -687,15 +687,15 @@ void Menu::drawMenu() {
 		g_hdb->_gfx->draw3DStars();
 		drawNebula();
 
-		if (_quitActive == 2) { // XXXX
+		if (_quitActive == 3 || !g_hdb->isDemo()) {
+			if (!_quitScreen)
+				_quitScreen = g_hdb->_gfx->loadPic(PIC_QUITSCREEN);
+			_quitScreen->drawMasked(kQuitX, kQuitY);
+		} else if (_quitActive == 2) { // XXXX
 			_screenshots1gfx->drawMasked(kQuitX, kQuitY);
 			_screenshots2gfx->drawMasked(kQuitX, kScreenHeight - _screenshots2gfx->_height);
 		} else if (_quitActive == 1) {
 			_screenshots1agfx->drawMasked(kQuitX, kQuitY);
-		} else if (_quitActive == 3 || !g_hdb->isDemo()) {
-			if (!_quitScreen)
-				_quitScreen = g_hdb->_gfx->loadPic(PIC_QUITSCREEN);
-			_quitScreen->drawMasked(kQuitX, kQuitY);
 		}
 	}
 }


Commit: 469fbe1c8a431fba8f33f41dcce64c64dc13fdb3
    https://github.com/scummvm/scummvm/commit/469fbe1c8a431fba8f33f41dcce64c64dc13fdb3
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:30+02:00

Commit Message:
HDB: Add isPPC Flag

Changed paths:
    engines/hdb/detection.cpp
    engines/hdb/hdb.h


diff --git a/engines/hdb/detection.cpp b/engines/hdb/detection.cpp
index 6587b3c..d1bd4ea 100644
--- a/engines/hdb/detection.cpp
+++ b/engines/hdb/detection.cpp
@@ -28,6 +28,11 @@
 #include "hdb/hdb.h"
 
 namespace HDB {
+
+enum {
+	kPPCFlag = ADGF_DEMO << 1
+};
+
 const char *HDBGame::getGameId() const { return _gameDescription->gameId; }
 Common::Platform HDBGame::getPlatform() const { return _gameDescription->platform; }
 
@@ -43,6 +48,10 @@ bool HDBGame::isDemo() const {
 	return (getGameFlags() & ADGF_DEMO);
 }
 
+bool HDBGame::isPPC() const {
+	return (getGameFlags() & kPPCFlag);
+}
+
 } // End of namespace HDB
 
 static const PlainGameDescriptor hdbGames[] = {
@@ -77,7 +86,7 @@ static const ADGameDescription gameDescriptions[] = {
 		AD_ENTRY1s("hyperspace.msd", "a62468904beb3efe16d4d64f3955a32e", 6825555),
 		Common::EN_ANY,
 		Common::kPlatformUnknown, // PPC
-		ADGF_NO_FLAGS,
+		kPPCFlag,
 		GUIO1(GUIO_NONE)
 	},
 
@@ -96,7 +105,7 @@ static const ADGameDescription gameDescriptions[] = {
 		"",
 		AD_ENTRY1s("hyperdemo.mpc", "f3bc878e179f00b8666a9846f3d9f9f5", 5236568),
 		Common::EN_ANY,
-		Common::kPlatformUnknown, // FIXME
+		Common::kPlatformWindows,
 		ADGF_DEMO,
 		GUIO1(GUIO_NONE)
 	},
@@ -116,7 +125,7 @@ static const ADGameDescription gameDescriptions[] = {
 		AD_ENTRY1s("hyperdemo.msd", "312525298ca9f5ac904883d1ce19dc0f", 3088651),
 		Common::EN_ANY,
 		Common::kPlatformUnknown, // PPC
-		ADGF_DEMO,
+		(ADGF_DEMO || kPPCFlag),
 		GUIO1(GUIO_NONE)
 	},
 	{
@@ -125,7 +134,7 @@ static const ADGameDescription gameDescriptions[] = {
 		AD_ENTRY1s("hyperdemo.msd", "2d4457b284a940b7058b36e5706b9951", 3094241),
 		Common::EN_ANY,
 		Common::kPlatformUnknown, // PPC
-		ADGF_DEMO,
+		(ADGF_DEMO || kPPCFlag),
 		GUIO1(GUIO_NONE)
 	},
 	AD_TABLE_END_MARKER
diff --git a/engines/hdb/hdb.h b/engines/hdb/hdb.h
index d55f8b3..7830f93 100644
--- a/engines/hdb/hdb.h
+++ b/engines/hdb/hdb.h
@@ -157,6 +157,7 @@ public:
 	uint32 getGameFlags() const;
 	Common::Platform getPlatform() const;
 	bool isDemo() const;
+	bool isPPC() const;
 
 	/*
 	Game System Pointers


Commit: 52f2af77f314278451fdc6a4e5a537283c409629
    https://github.com/scummvm/scummvm/commit/52f2af77f314278451fdc6a4e5a537283c409629
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:30+02:00

Commit Message:
HDB: Fix Null-deleting code

Changed paths:
    engines/hdb/gfx.cpp


diff --git a/engines/hdb/gfx.cpp b/engines/hdb/gfx.cpp
index 80e5ac8..f380b9f 100644
--- a/engines/hdb/gfx.cpp
+++ b/engines/hdb/gfx.cpp
@@ -725,9 +725,9 @@ int Gfx::animateTile(int tileIndex) {
 }
 
 bool Gfx::loadFont(const char *string) {
+
 	Common::SeekableReadStream *stream = g_hdb->_fileMan->findFirstData(string, TYPE_FONT);
 	if (!stream) {
-		delete stream;
 		return false;
 	}
 


Commit: 3acb70c759586faef9a5f9f5131c6da6e17e5f89
    https://github.com/scummvm/scummvm/commit/3acb70c759586faef9a5f9f5131c6da6e17e5f89
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:30+02:00

Commit Message:
HDB: Wrap ReadStreams pointing to compressed...

...files

Changed paths:
    engines/hdb/file-manager.cpp
    engines/hdb/file-manager.h
    engines/hdb/gfx.cpp


diff --git a/engines/hdb/file-manager.cpp b/engines/hdb/file-manager.cpp
index c205a4b..4ce790c 100644
--- a/engines/hdb/file-manager.cpp
+++ b/engines/hdb/file-manager.cpp
@@ -42,7 +42,7 @@ bool FileMan::openMPC(const Common::String &filename) {
 	uint32 offset;
 
 	if (!_mpcFile->open(filename)) {
-		error("FileMan::openMSD(): Error reading the MSD file");
+		error("FileMan::openMPC(): Error reading the MSD/MPC file");
 		return false;
 	}
 
@@ -50,7 +50,7 @@ bool FileMan::openMPC(const Common::String &filename) {
 
 	if (_dataHeader.id == MKTAG('M', 'P', 'C', 'C')) {
 		_compressed = true;
-		debug("COMPRESSED FILE");
+		debug("COMPRESSED MPC FILE");
 		return false;
 	}
 	else if (_dataHeader.id == MKTAG('M', 'P', 'C', 'U')) {
@@ -64,7 +64,7 @@ bool FileMan::openMPC(const Common::String &filename) {
 
 		_dataHeader.dirSize = _mpcFile->readUint32LE();
 
-		debug(8, "MPC: Read %d entries", _dataHeader.dirSize);
+		debug(8, "MPCU: Read %d entries", _dataHeader.dirSize);
 
 		for (uint32 fileIndex = 0; fileIndex < _dataHeader.dirSize; fileIndex++) {
 			MPCEntry *dirEntry = new MPCEntry();
@@ -82,12 +82,43 @@ bool FileMan::openMPC(const Common::String &filename) {
 		}
 
 		return true;
+	} else if (_dataHeader.id == MKTAG('M', 'S', 'D', 'C')) {
+		_compressed = true;
+		
+		offset = _mpcFile->readUint32LE();
+		_mpcFile->seek((int32)offset);
+
+		// Note: The MPC archive format assumes the offset to be uint32,
+		// but Common::File::seek() takes the offset as int32.
+
+		_dataHeader.dirSize = _mpcFile->readUint32LE();
+
+		debug(8, "MSDC: Read %d entries", _dataHeader.dirSize);
+
+		for (uint32 fileIndex = 0; fileIndex < _dataHeader.dirSize; fileIndex++) {
+			MPCEntry *dirEntry = new MPCEntry();
+
+			for (int i = 0; i < 64; i++) {
+				dirEntry->filename[i] = tolower(_mpcFile->readByte());
+			}
+
+			dirEntry->offset = _mpcFile->readUint32LE();
+			dirEntry->length = _mpcFile->readUint32LE();
+			dirEntry->ulength = _mpcFile->readUint32LE();
+			dirEntry->type = (DataType)_mpcFile->readUint32LE();
 
+			_dir.push_back(dirEntry);
+		}
+
+		return true;
+	} else if (_dataHeader.id == MKTAG('M', 'S', 'D', 'U')) {
+		_compressed = false;
+		debug("UNCOMPRESSED MSD FILE");
+		return false;
 	}
 
-	error("Invalid MPC File.");
+	error("Invalid MPC/MSD File.");
 	return false;
-
 }
 
 void FileMan::closeMPC() {
@@ -139,7 +170,11 @@ Common::SeekableReadStream *FileMan::findFirstData(const char *string, DataType
 	_mpcFile->read(buffer, file->ulength);
 
 	// Return buffer wrapped in a MemoryReadStream
-	return new Common::MemoryReadStream(buffer, file->ulength, DisposeAfterUse::YES);
+	
+	if (_compressed)
+		return Common::wrapCompressedReadStream(new Common::MemoryReadStream(buffer, file->ulength, DisposeAfterUse::YES));
+	else
+		return new Common::MemoryReadStream(buffer, file->ulength, DisposeAfterUse::YES);
 }
 
 int32 FileMan::getLength(const char *string, DataType type) {
diff --git a/engines/hdb/file-manager.h b/engines/hdb/file-manager.h
index d4cae4d..c7a6768 100644
--- a/engines/hdb/file-manager.h
+++ b/engines/hdb/file-manager.h
@@ -23,6 +23,8 @@
 #ifndef HDB_FILE_MANAGER_H
 #define HDB_FILE_MANAGER_H
 
+#include "common/zlib.h"
+
 namespace Common {
 	class File;
 }
diff --git a/engines/hdb/gfx.cpp b/engines/hdb/gfx.cpp
index f380b9f..5cf80a2 100644
--- a/engines/hdb/gfx.cpp
+++ b/engines/hdb/gfx.cpp
@@ -486,6 +486,8 @@ int Gfx::getTileIndex(const char *name) {
 
 Picture *Gfx::getPicture(const char *name) {
 	Common::SeekableReadStream *stream = g_hdb->_fileMan->findFirstData(name, TYPE_PIC);
+	if (stream == nullptr)
+		return nullptr;
 	Picture *picture = new Picture;
 	picture->load(stream);
 	delete stream;


Commit: b8bbc32a89e53f6eb271d848cdb4935494c0f43f
    https://github.com/scummvm/scummvm/commit/b8bbc32a89e53f6eb271d848cdb4935494c0f43f
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:30+02:00

Commit Message:
HDB: Add support for the PPC version

Changed paths:
    engines/hdb/ai-inventory.cpp
    engines/hdb/hdb.cpp
    engines/hdb/menu.cpp
    engines/hdb/sound.cpp
    engines/hdb/window.cpp


diff --git a/engines/hdb/ai-inventory.cpp b/engines/hdb/ai-inventory.cpp
index dbb7f3d..9eb91eb 100644
--- a/engines/hdb/ai-inventory.cpp
+++ b/engines/hdb/ai-inventory.cpp
@@ -305,7 +305,10 @@ bool AI::completeDelivery(const char *id) {
 			for (; i < _numDeliveries; i++)
 				memcpy(&_deliveries[i], &_deliveries[i + 1], sizeof(_deliveries[0]));
 			_numDeliveries--;
-			g_hdb->_sound->playVoice(GUY_COMPLETED, 1);
+			if (g_hdb->isPPC())
+				g_hdb->_sound->playSound(SND_QUEST_COMPLETE);
+			else
+				g_hdb->_sound->playVoice(GUY_COMPLETED, 1);
 			return true;
 		}
 	return false;
diff --git a/engines/hdb/hdb.cpp b/engines/hdb/hdb.cpp
index 900709f..12d0871 100644
--- a/engines/hdb/hdb.cpp
+++ b/engines/hdb/hdb.cpp
@@ -379,6 +379,10 @@ void HDBGame::setTargetXY(int x, int y) {
 	if (p->touchpWait)
 		return;
 
+	// Double-Clicking on the player to open inventory?
+	if (g_hdb->isPPC())
+		warning("STUB: Add double-click to inventory functionality for PPC version");
+
 	// If we're attacking...don't do anything else
 	AIState stateList[] = {
 		STATE_ATK_CLUB_UP,	STATE_ATK_CLUB_DOWN, STATE_ATK_CLUB_LEFT, STATE_ATK_CLUB_RIGHT,
diff --git a/engines/hdb/menu.cpp b/engines/hdb/menu.cpp
index 9c36c9b..3158e78 100644
--- a/engines/hdb/menu.cpp
+++ b/engines/hdb/menu.cpp
@@ -619,10 +619,16 @@ void Menu::drawMenu() {
 			_modeLoadGfx->drawMasked(centerPic(_modeLoadGfx), _oBannerY);
 			_menuBackoutGfx->drawMasked(kBackoutX, kBackoutY);
 
-
-			if (_saveGames[0].seconds) {
+			if (_saveGames[kAutoSaveSlot].seconds)
 				_vortexian[anim]->drawMasked(kVortSaveX, kVortSaveY);
+
+			if (g_hdb->isPPC()) {
+				g_hdb->_gfx->setCursor(kVortSaveTextX, kVortSaveY);
+				g_hdb->_gfx->drawText("Last Vortexian");
+				g_hdb->_gfx->setCursor(kVortSaveTextX, kVortSaveY + 12);
+				g_hdb->_gfx->drawText("Saved Game");
 			}
+
 			if (anim_time < g_hdb->getTimeSlice()) {
 				anim_time = g_hdb->getTimeSlice() + 50;
 				anim++;
@@ -760,6 +766,10 @@ void Menu::freeMenu() {
 		delete _demoPlaqueGfx;
 	_demoPlaqueGfx = NULL;
 
+	if (g_hdb->isPPC()) {
+		warning("FIXME: When handangoGfx is added, free it here");
+	}
+
 	if (_nebulaGfx[0]) {
 		for (int i = 0; i < kNebulaCount; i++) {
 			delete _nebulaGfx[i];
@@ -1279,6 +1289,22 @@ void Menu::processInput(int x, int y) {
 			g_hdb->_sound->playSound(SND_MENU_BACKOUT);
 		}
 
+		// Vortexian Load only exists on PocketPC!
+		if (g_hdb->isPPC()) {
+			// 5 Slots screen
+			// Vortexian autosave LOAD?
+			if (y > kVortSaveY && (y < kVortSaveY + 32) && (x >= kVortSaveX) && (x < kVortSaveX + 96) && _saveGames[kAutoSaveSlot].seconds) {
+				g_hdb->_sound->playSound(SND_VORTEX_SAVE);
+				if (g_hdb->loadGameState(kAutoSaveSlot).getCode() == Common::kNoError) {
+					_gamefilesActive = false;
+					freeMenu();
+					g_hdb->setGameState(GAME_PLAY);
+					return;
+				}
+			}
+
+		}
+
 		int i = 0;
 		for (; i < kNumSaveSlots; i++)
 			if (y >= (i * 32 + kSaveSlotY - 4) && y <= (i * 32 + kSaveSlotY + 24))
diff --git a/engines/hdb/sound.cpp b/engines/hdb/sound.cpp
index 5e48846..620fd4a 100644
--- a/engines/hdb/sound.cpp
+++ b/engines/hdb/sound.cpp
@@ -1567,7 +1567,7 @@ bool Sound::playSoundEx(int index, int channel, bool loop) {
 }
 
 bool Sound::playVoice(int index, int actor) {
-	if (!_voicesOn)
+	if (!_voicesOn || g_hdb->isPPC())
 		return false;
 
 	// make sure we aren't playing a line more than once this time (only on CHANNEL 0)
diff --git a/engines/hdb/window.cpp b/engines/hdb/window.cpp
index 0633224..57bf9cc 100644
--- a/engines/hdb/window.cpp
+++ b/engines/hdb/window.cpp
@@ -131,12 +131,17 @@ bool Window::init() {
 
 	_invWinInfo.width = kInvItemSpaceX * 3;
 	_invWinInfo.height = kInvItemSpaceY * 4;
-	_invWinInfo.x = kScreenWidth - _gfxInfobar->_width + 16;
+
+	warning("FIXME: Fully separate the PC and PPC versions of Window");
+
+	if (!g_hdb->isPPC())
+		_invWinInfo.x = kScreenWidth - _gfxInfobar->_width + 16;
 	_invWinInfo.y = 40;
 
 	_dlvsInfo.width = kInvItemSpaceX * 3;
 	_dlvsInfo.height = kInvItemSpaceY * 4;
-	_dlvsInfo.x = (kScreenWidth - _gfxInfobar->_width) + 16;
+	if (!g_hdb->isPPC())
+		_dlvsInfo.x = (kScreenWidth - _gfxInfobar->_width) + 16;
 	_dlvsInfo.y = 272;
 
 	_gemGfx = NULL;


Commit: 1184c542cd4178ff50d7d8459902b127be45c954
    https://github.com/scummvm/scummvm/commit/1184c542cd4178ff50d7d8459902b127be45c954
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:30+02:00

Commit Message:
JANITORIAL: Fix whitespace errors

Changed paths:
    engines/hdb/file-manager.cpp


diff --git a/engines/hdb/file-manager.cpp b/engines/hdb/file-manager.cpp
index 4ce790c..f05be01 100644
--- a/engines/hdb/file-manager.cpp
+++ b/engines/hdb/file-manager.cpp
@@ -84,7 +84,7 @@ bool FileMan::openMPC(const Common::String &filename) {
 		return true;
 	} else if (_dataHeader.id == MKTAG('M', 'S', 'D', 'C')) {
 		_compressed = true;
-		
+
 		offset = _mpcFile->readUint32LE();
 		_mpcFile->seek((int32)offset);
 
@@ -170,7 +170,7 @@ Common::SeekableReadStream *FileMan::findFirstData(const char *string, DataType
 	_mpcFile->read(buffer, file->ulength);
 
 	// Return buffer wrapped in a MemoryReadStream
-	
+
 	if (_compressed)
 		return Common::wrapCompressedReadStream(new Common::MemoryReadStream(buffer, file->ulength, DisposeAfterUse::YES));
 	else


Commit: 4539c04181b04c49868f2c1be16c0dbea78a6ddd
    https://github.com/scummvm/scummvm/commit/4539c04181b04c49868f2c1be16c0dbea78a6ddd
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:30+02:00

Commit Message:
HDB: Fix warnings

Changed paths:
    engines/hdb/detection.cpp


diff --git a/engines/hdb/detection.cpp b/engines/hdb/detection.cpp
index d1bd4ea..31f36b2 100644
--- a/engines/hdb/detection.cpp
+++ b/engines/hdb/detection.cpp
@@ -86,7 +86,7 @@ static const ADGameDescription gameDescriptions[] = {
 		AD_ENTRY1s("hyperspace.msd", "a62468904beb3efe16d4d64f3955a32e", 6825555),
 		Common::EN_ANY,
 		Common::kPlatformUnknown, // PPC
-		kPPCFlag,
+		(uint32)kPPCFlag,
 		GUIO1(GUIO_NONE)
 	},
 
@@ -125,7 +125,7 @@ static const ADGameDescription gameDescriptions[] = {
 		AD_ENTRY1s("hyperdemo.msd", "312525298ca9f5ac904883d1ce19dc0f", 3088651),
 		Common::EN_ANY,
 		Common::kPlatformUnknown, // PPC
-		(ADGF_DEMO || kPPCFlag),
+		(ADGF_DEMO || (uint32)kPPCFlag),
 		GUIO1(GUIO_NONE)
 	},
 	{
@@ -134,7 +134,7 @@ static const ADGameDescription gameDescriptions[] = {
 		AD_ENTRY1s("hyperdemo.msd", "2d4457b284a940b7058b36e5706b9951", 3094241),
 		Common::EN_ANY,
 		Common::kPlatformUnknown, // PPC
-		(ADGF_DEMO || kPPCFlag),
+		(ADGF_DEMO || (uint32)kPPCFlag),
 		GUIO1(GUIO_NONE)
 	},
 	AD_TABLE_END_MARKER


Commit: bcb0171891c967a5d0e282c9c9495b023e393901
    https://github.com/scummvm/scummvm/commit/bcb0171891c967a5d0e282c9c9495b023e393901
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:30+02:00

Commit Message:
HDB: Fix WAV format checker and other minor fixes

Changed paths:
    engines/hdb/sound.cpp


diff --git a/engines/hdb/sound.cpp b/engines/hdb/sound.cpp
index 620fd4a..9f82544 100644
--- a/engines/hdb/sound.cpp
+++ b/engines/hdb/sound.cpp
@@ -1430,11 +1430,11 @@ bool Sound::init() {
 		_soundCache[index2].loaded = 0;
 		_soundCache[index2].name = soundList[index].name;
 		_soundCache[index2].luaName = soundList[index].luaName;
-		if (!scumm_stricmp(_soundCache[index2].name, ".wav"))
+		if (index2 <= SND_UNLOCKED_ITEM || index2 == SND_BEEPBEEPBEEP)
 			_soundCache[index2].ext = -1;	// WAV
 		else
 			_soundCache[index2].ext = 1;		// MP3
-		debug(9, "Registering sound: sName: %s, \tsLuaName: %s, \tExtension: %s", soundList[index2].name, soundList[index2].luaName, _soundCache[index2].ext == 1 ? "MP3" : "WAV");
+		debug(9, "Registering sound: sName: %s, \tsLuaName: %s, \tExtension: %s", soundList[index].name, soundList[index].luaName, _soundCache[index].ext == 1 ? "MP3" : "WAV");
 		index++;
 		if (index > kMaxSounds)
 			error("Reached MAX_SOUNDS in Sound::Init() !");
@@ -1477,7 +1477,6 @@ void Sound::setMusicVolume(int volume) {
 }
 
 bool Sound::playSound(int index) {
-#if 0
 	if (index > _numSounds || !_sfxVolume)
 		return false;
 
@@ -1520,12 +1519,10 @@ bool Sound::playSound(int index) {
 	g_hdb->_mixer->setChannelVolume(_handles[soundChannel], _sfxVolume);
 
 	g_hdb->_mixer->playStream(Audio::Mixer::kSFXSoundType, &_handles[soundChannel], _soundCache[index].audioStream);
-#endif
 	return true;
 }
 
 bool Sound::playSoundEx(int index, int channel, bool loop) {
-#if 0
 	if (g_hdb->_mixer->isSoundHandleActive(_handles[channel]))
 		return false;
 
@@ -1543,7 +1540,7 @@ bool Sound::playSoundEx(int index, int channel, bool loop) {
 		if (stream == nullptr)
 			return false;
 
-		if (_soundCache[index].ext) {
+		if (_soundCache[index].ext == 1) {
 #ifdef USE_MAD
 			_soundCache[index].audioStream = Audio::makeMP3Stream(stream, DisposeAfterUse::YES);
 			_soundCache[index].loaded = 1;
@@ -1562,7 +1559,6 @@ bool Sound::playSoundEx(int index, int channel, bool loop) {
 	} else {
 		g_hdb->_mixer->playStream(Audio::Mixer::kSFXSoundType, &_handles[channel], _soundCache[index].audioStream);
 	}
-#endif
 	return true;
 }
 
@@ -1767,7 +1763,6 @@ int Sound::registerSound(const char *name) {
 
 bool Sound::freeSound(int index) {
 	if (_soundCache[index].loaded == 1) {
-		delete _soundCache[index].audioStream;
 		_soundCache[index].loaded = 0;
 		_soundCache[index].ext = 0;
 		return true;


Commit: 13d7a0c9347aa437a5365399dd5450c723fc75ff
    https://github.com/scummvm/scummvm/commit/13d7a0c9347aa437a5365399dd5450c723fc75ff
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:30+02:00

Commit Message:
HDB: Set DisposeAfterUse::NO in playStream()

Changed paths:
    engines/hdb/sound.cpp


diff --git a/engines/hdb/sound.cpp b/engines/hdb/sound.cpp
index 9f82544..2602a07 100644
--- a/engines/hdb/sound.cpp
+++ b/engines/hdb/sound.cpp
@@ -1518,7 +1518,17 @@ bool Sound::playSound(int index) {
 
 	g_hdb->_mixer->setChannelVolume(_handles[soundChannel], _sfxVolume);
 
-	g_hdb->_mixer->playStream(Audio::Mixer::kSFXSoundType, &_handles[soundChannel], _soundCache[index].audioStream);
+	g_hdb->_mixer->playStream(
+		Audio::Mixer::kSFXSoundType,
+		&_handles[soundChannel],
+		_soundCache[index].audioStream,
+		-1,
+		Audio::Mixer::kMaxChannelVolume,
+		0,
+		DisposeAfterUse::NO,
+		false,
+		false
+	);
 	return true;
 }
 
@@ -1555,9 +1565,29 @@ bool Sound::playSoundEx(int index, int channel, bool loop) {
 
 	if (loop) {
 		Audio::AudioStream *loopingStream = new Audio::LoopingAudioStream(_soundCache[index].audioStream, 0, DisposeAfterUse::YES);
-		g_hdb->_mixer->playStream(Audio::Mixer::kSFXSoundType, &_handles[channel], loopingStream);
+		g_hdb->_mixer->playStream(
+			Audio::Mixer::kSFXSoundType,
+			&_handles[channel],
+			loopingStream,
+			-1,
+			Audio::Mixer::kMaxChannelVolume,
+			0,
+			DisposeAfterUse::NO,
+			false,
+			false
+		);
 	} else {
-		g_hdb->_mixer->playStream(Audio::Mixer::kSFXSoundType, &_handles[channel], _soundCache[index].audioStream);
+		g_hdb->_mixer->playStream(
+			Audio::Mixer::kSFXSoundType,
+			&_handles[channel],
+			_soundCache[index].audioStream,
+			-1,
+			Audio::Mixer::kMaxChannelVolume,
+			0,
+			DisposeAfterUse::NO,
+			false,
+			false
+		);
 	}
 	return true;
 }
@@ -1587,7 +1617,17 @@ bool Sound::playVoice(int index, int actor) {
 
 	g_hdb->_mixer->setChannelVolume(*_voices[actor].handle, _sfxVolume);
 
-	g_hdb->_mixer->playStream(Audio::Mixer::kSpeechSoundType, _voices[actor].handle, audioStream);
+	g_hdb->_mixer->playStream(
+		Audio::Mixer::kSpeechSoundType,
+		_voices[actor].handle,
+		audioStream,
+		-1,
+		Audio::Mixer::kMaxChannelVolume,
+		0,
+		DisposeAfterUse::NO,
+		false,
+		false
+	);
 
 	_voices[actor].active = true;
 	_voicePlayed[index - FIRST_VOICE] = 1;
@@ -1682,7 +1722,17 @@ bool Sound::beginMusic(SoundType song, bool fadeIn, int ramp) {
 			g_hdb->_mixer->setChannelVolume(*_song1.handle, 0);
 		}
 
-		g_hdb->_mixer->playStream(Audio::Mixer::kMusicSoundType, _song1.handle, loopingStream);
+		g_hdb->_mixer->playStream(
+			Audio::Mixer::kMusicSoundType,
+			_song1.handle,
+			loopingStream,
+			-1,
+			Audio::Mixer::kMaxChannelVolume,
+			0,
+			DisposeAfterUse::NO,
+			false,
+			false
+		);
 		_song1.playing = true;
 #endif
 	} else if (!_song2.playing) {
@@ -1712,7 +1762,17 @@ bool Sound::beginMusic(SoundType song, bool fadeIn, int ramp) {
 			g_hdb->_mixer->setChannelVolume(*_song2.handle, 0);
 		}
 
-		g_hdb->_mixer->playStream(Audio::Mixer::kMusicSoundType, _song2.handle, loopingStream);
+		g_hdb->_mixer->playStream(
+			Audio::Mixer::kMusicSoundType,
+			_song2.handle,
+			loopingStream,
+			-1,
+			Audio::Mixer::kMaxChannelVolume,
+			0,
+			DisposeAfterUse::NO,
+			false,
+			false
+		);
 		_song2.playing = true;
 #endif
 	} else


Commit: c75e14cabb6893532b7def2caf427ce429c04492
    https://github.com/scummvm/scummvm/commit/c75e14cabb6893532b7def2caf427ce429c04492
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:30+02:00

Commit Message:
HDB: Remove redundant warning

Changed paths:
    engines/hdb/ai-bots.cpp


diff --git a/engines/hdb/ai-bots.cpp b/engines/hdb/ai-bots.cpp
index 408d364..8e06e94 100644
--- a/engines/hdb/ai-bots.cpp
+++ b/engines/hdb/ai-bots.cpp
@@ -362,7 +362,6 @@ void aiRightBotInit2(AIEntity *e) {
 		e->state = STATE_MOVERIGHT;
 		break;
 	case DIR_NONE:
-		warning("aiRightBotInit2: DIR_NONE found");
 		break;
 	}
 }


Commit: 102846becfb0b9b1f80b4903cc9e021d3b7dc172
    https://github.com/scummvm/scummvm/commit/102846becfb0b9b1f80b4903cc9e021d3b7dc172
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:30+02:00

Commit Message:
COMMON: Added PocketPC platform

Changed paths:
    common/platform.cpp
    common/platform.h


diff --git a/common/platform.cpp b/common/platform.cpp
index 0049666..818983f 100644
--- a/common/platform.cpp
+++ b/common/platform.cpp
@@ -55,6 +55,7 @@ const PlatformDescription g_platforms[] = {
 	{ "ios", "ios", "ios", "Apple iOS", kPlatformIOS },
 	{ "os2", "os2", "os2", "OS/2", kPlatformOS2 },
 	{ "beos", "beos", "beos", "BeOS", kPlatformBeOS },
+	{ "ppc", "ppc", "ppc", "PocketPC", kPlatformPocketPC },
 
 	{ nullptr, nullptr, nullptr, "Default", kPlatformUnknown }
 };
diff --git a/common/platform.h b/common/platform.h
index d6284be..3273730 100644
--- a/common/platform.h
+++ b/common/platform.h
@@ -60,6 +60,7 @@ enum Platform {
 	kPlatformIOS,
 	kPlatformOS2,
 	kPlatformBeOS,
+	kPlatformPocketPC,
 
 	kPlatformUnknown = -1
 };


Commit: 52f9e18d433fdb14d3171429837d4c1781fd719f
    https://github.com/scummvm/scummvm/commit/52f9e18d433fdb14d3171429837d4c1781fd719f
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:30+02:00

Commit Message:
HDB: Use PocketPC platform enum

Changed paths:
    engines/hdb/detection.cpp


diff --git a/engines/hdb/detection.cpp b/engines/hdb/detection.cpp
index 31f36b2..aa586f9 100644
--- a/engines/hdb/detection.cpp
+++ b/engines/hdb/detection.cpp
@@ -29,10 +29,6 @@
 
 namespace HDB {
 
-enum {
-	kPPCFlag = ADGF_DEMO << 1
-};
-
 const char *HDBGame::getGameId() const { return _gameDescription->gameId; }
 Common::Platform HDBGame::getPlatform() const { return _gameDescription->platform; }
 
@@ -49,7 +45,7 @@ bool HDBGame::isDemo() const {
 }
 
 bool HDBGame::isPPC() const {
-	return (getGameFlags() & kPPCFlag);
+	return (getPlatform() & Common::kPlatformPocketPC);
 }
 
 } // End of namespace HDB
@@ -85,8 +81,8 @@ static const ADGameDescription gameDescriptions[] = {
 		"",
 		AD_ENTRY1s("hyperspace.msd", "a62468904beb3efe16d4d64f3955a32e", 6825555),
 		Common::EN_ANY,
-		Common::kPlatformUnknown, // PPC
-		(uint32)kPPCFlag,
+		Common::kPlatformPocketPC,
+		ADGF_NO_FLAGS,
 		GUIO1(GUIO_NONE)
 	},
 
@@ -124,8 +120,8 @@ static const ADGameDescription gameDescriptions[] = {
 		"",
 		AD_ENTRY1s("hyperdemo.msd", "312525298ca9f5ac904883d1ce19dc0f", 3088651),
 		Common::EN_ANY,
-		Common::kPlatformUnknown, // PPC
-		(ADGF_DEMO || (uint32)kPPCFlag),
+		Common::kPlatformPocketPC,
+		ADGF_DEMO,
 		GUIO1(GUIO_NONE)
 	},
 	{
@@ -133,8 +129,8 @@ static const ADGameDescription gameDescriptions[] = {
 		"Handango",
 		AD_ENTRY1s("hyperdemo.msd", "2d4457b284a940b7058b36e5706b9951", 3094241),
 		Common::EN_ANY,
-		Common::kPlatformUnknown, // PPC
-		(ADGF_DEMO || (uint32)kPPCFlag),
+		Common::kPlatformPocketPC,
+		ADGF_DEMO,
 		GUIO1(GUIO_NONE)
 	},
 	AD_TABLE_END_MARKER


Commit: 446afec1ca56b169fcc4e356ca9d77dd10000ceb
    https://github.com/scummvm/scummvm/commit/446afec1ca56b169fcc4e356ca9d77dd10000ceb
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:30+02:00

Commit Message:
HDB: Reduce header dependency

Changed paths:
    engines/hdb/file-manager.cpp
    engines/hdb/file-manager.h


diff --git a/engines/hdb/file-manager.cpp b/engines/hdb/file-manager.cpp
index f05be01..c437cfd 100644
--- a/engines/hdb/file-manager.cpp
+++ b/engines/hdb/file-manager.cpp
@@ -22,6 +22,7 @@
 #include "common/debug.h"
 #include "common/file.h"
 #include "common/memstream.h"
+#include "common/zlib.h"
 
 #include "hdb/hdb.h"
 #include "hdb/file-manager.h"
diff --git a/engines/hdb/file-manager.h b/engines/hdb/file-manager.h
index c7a6768..d4cae4d 100644
--- a/engines/hdb/file-manager.h
+++ b/engines/hdb/file-manager.h
@@ -23,8 +23,6 @@
 #ifndef HDB_FILE_MANAGER_H
 #define HDB_FILE_MANAGER_H
 
-#include "common/zlib.h"
-
 namespace Common {
 	class File;
 }


Commit: 517a261fbf7f8692396048a9b18f9bb0840dfa1b
    https://github.com/scummvm/scummvm/commit/517a261fbf7f8692396048a9b18f9bb0840dfa1b
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:30+02:00

Commit Message:
HDB: Added Handango flag

Changed paths:
    engines/hdb/detection.cpp
    engines/hdb/hdb.h


diff --git a/engines/hdb/detection.cpp b/engines/hdb/detection.cpp
index aa586f9..9b6f411 100644
--- a/engines/hdb/detection.cpp
+++ b/engines/hdb/detection.cpp
@@ -29,6 +29,10 @@
 
 namespace HDB {
 
+enum HDBGameFeatures {
+	GF_HANDANGO = (1 << 0)
+};
+
 const char *HDBGame::getGameId() const { return _gameDescription->gameId; }
 Common::Platform HDBGame::getPlatform() const { return _gameDescription->platform; }
 
@@ -48,6 +52,10 @@ bool HDBGame::isPPC() const {
 	return (getPlatform() & Common::kPlatformPocketPC);
 }
 
+bool HDBGame::isHandango() const {
+	return (getGameFlags() & GF_HANDANGO);
+}
+
 } // End of namespace HDB
 
 static const PlainGameDescriptor hdbGames[] = {
@@ -130,7 +138,7 @@ static const ADGameDescription gameDescriptions[] = {
 		AD_ENTRY1s("hyperdemo.msd", "2d4457b284a940b7058b36e5706b9951", 3094241),
 		Common::EN_ANY,
 		Common::kPlatformPocketPC,
-		ADGF_DEMO,
+		(ADGF_DEMO | GF_HANDANGO),
 		GUIO1(GUIO_NONE)
 	},
 	AD_TABLE_END_MARKER
diff --git a/engines/hdb/hdb.h b/engines/hdb/hdb.h
index 7830f93..57a493c 100644
--- a/engines/hdb/hdb.h
+++ b/engines/hdb/hdb.h
@@ -158,6 +158,7 @@ public:
 	Common::Platform getPlatform() const;
 	bool isDemo() const;
 	bool isPPC() const;
+	bool isHandango() const;
 
 	/*
 	Game System Pointers


Commit: d93c6ec72466e27ffa390c0f6f3933d2ed6640b1
    https://github.com/scummvm/scummvm/commit/d93c6ec72466e27ffa390c0f6f3933d2ed6640b1
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:30+02:00

Commit Message:
HDB: Set Music and Voice to DisposeAfterUse::YES

Changed paths:
    engines/hdb/sound.cpp


diff --git a/engines/hdb/sound.cpp b/engines/hdb/sound.cpp
index 2602a07..e31fb6a 100644
--- a/engines/hdb/sound.cpp
+++ b/engines/hdb/sound.cpp
@@ -1624,7 +1624,7 @@ bool Sound::playVoice(int index, int actor) {
 		-1,
 		Audio::Mixer::kMaxChannelVolume,
 		0,
-		DisposeAfterUse::NO,
+		DisposeAfterUse::YES,
 		false,
 		false
 	);
@@ -1729,7 +1729,7 @@ bool Sound::beginMusic(SoundType song, bool fadeIn, int ramp) {
 			-1,
 			Audio::Mixer::kMaxChannelVolume,
 			0,
-			DisposeAfterUse::NO,
+			DisposeAfterUse::YES,
 			false,
 			false
 		);
@@ -1769,7 +1769,7 @@ bool Sound::beginMusic(SoundType song, bool fadeIn, int ramp) {
 			-1,
 			Audio::Mixer::kMaxChannelVolume,
 			0,
-			DisposeAfterUse::NO,
+			DisposeAfterUse::YES,
 			false,
 			false
 		);


Commit: c1d2468f075698fddd9cb0f825d6ee1e0752b3bd
    https://github.com/scummvm/scummvm/commit/c1d2468f075698fddd9cb0f825d6ee1e0752b3bd
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:30+02:00

Commit Message:
HDB: Section off PPC-specific code

Changed paths:
    engines/hdb/gfx.cpp
    engines/hdb/hdb.cpp
    engines/hdb/input.cpp
    engines/hdb/menu.cpp
    engines/hdb/menu.h


diff --git a/engines/hdb/gfx.cpp b/engines/hdb/gfx.cpp
index 5cf80a2..b41394b 100644
--- a/engines/hdb/gfx.cpp
+++ b/engines/hdb/gfx.cpp
@@ -218,9 +218,12 @@ void Gfx::loadSaveFile(Common::InSaveFile *in) {
 		_snowInfo.xvindex[i] = in->readSint32LE();
 
 	setSky(_currentSky);
-	turnOffSnow();
-	if (_snowInfo.active)
-		turnOnSnow();
+
+	if (!g_hdb->isPPC()) {
+		turnOffSnow();
+		if (_snowInfo.active)
+			turnOnSnow();
+	}
 }
 
 double Gfx::getSin(int index) {
@@ -254,6 +257,10 @@ void Gfx::updateVideo() {
 }
 
 void Gfx::drawPointer() {
+
+	if (g_hdb->isPPC())
+		return;
+
 	static int anim = 0;
 	static uint32 animTime = 0;
 
@@ -272,7 +279,8 @@ void Gfx::drawPointer() {
 }
 
 void Gfx::setPointerState(int value) {
-	_pointerDisplayable = value;
+	if (!g_hdb->isPPC())
+		_pointerDisplayable = value;
 }
 
 void Gfx::setFade(bool fadeIn, bool black, int steps) {
diff --git a/engines/hdb/hdb.cpp b/engines/hdb/hdb.cpp
index 12d0871..f4c46df 100644
--- a/engines/hdb/hdb.cpp
+++ b/engines/hdb/hdb.cpp
@@ -147,7 +147,8 @@ bool HDBGame::init() {
 	_gameShutdown = false;
 	_pauseFlag = 0;
 	_systemInit = true;
-	_loadingScreenGfx = _gfx->loadPic(PIC_LOADSCREEN);
+	if (!g_hdb->isPPC())
+		_loadingScreenGfx = _gfx->loadPic(PIC_LOADSCREEN);
 
 	return true;
 }
@@ -806,7 +807,10 @@ void HDBGame::checkProgress() {
 }
 
 void HDBGame::drawLoadingScreen() {
-	_loadingScreenGfx->draw(0, 0);
+	if (g_hdb->isPPC())
+		_gfx->fillScreen(0);
+	else
+		_loadingScreenGfx->draw(0, 0);
 }
 
 struct MapName {
diff --git a/engines/hdb/input.cpp b/engines/hdb/input.cpp
index 8c02d1e..51f31a4 100644
--- a/engines/hdb/input.cpp
+++ b/engines/hdb/input.cpp
@@ -45,6 +45,9 @@ bool Input::init() {
 	_keyDebug = Common::KEYCODE_F1;
 	_keyQuit = Common::KEYCODE_F10;
 
+	if (g_hdb->isPPC())
+		return true;
+
 	_mouseX = kScreenWidth / 2;
 	_mouseY = kScreenHeight / 2;
 
@@ -255,6 +258,10 @@ void Input::stylusMove(int x, int y) {
 }
 
 void Input::updateMouse(int newX, int newY) {
+
+	if (g_hdb->isPPC())
+		return;
+
 	_mouseX = newX;
 	_mouseY = newY;
 
@@ -280,6 +287,10 @@ void Input::updateMouse(int newX, int newY) {
 }
 
 void Input::updateMouseButtons(int l, int m, int r) {
+
+	if (g_hdb->isPPC())
+		return;
+
 	_mouseLButton += l;
 	_mouseMButton += m;
 	_mouseRButton += r;
@@ -322,6 +333,10 @@ void Input::updateMouseButtons(int l, int m, int r) {
 }
 
 void Input::updateKeys(Common::Event event, bool keyDown) {
+
+	if (g_hdb->isPPC())
+		return;
+
 	static int current = 0, last = 0;
 
 	if (keyDown && event.kbd.keycode == _keyQuit) {
diff --git a/engines/hdb/menu.cpp b/engines/hdb/menu.cpp
index 3158e78..5f8297f 100644
--- a/engines/hdb/menu.cpp
+++ b/engines/hdb/menu.cpp
@@ -147,20 +147,32 @@ Menu::~Menu() {
 }
 
 bool Menu::init() {
-	_gCheckEmpty = g_hdb->_gfx->loadPic(G_CHECK_EMPTY);
-	_gCheckOff = g_hdb->_gfx->loadPic(G_CHECK_OFF);
-	_gCheckOn = g_hdb->_gfx->loadPic(G_CHECK_ON);
-	_gCheckLeft = g_hdb->_gfx->loadPic(G_CHECK_LEFT);
-	_gCheckRight = g_hdb->_gfx->loadPic(G_CHECK_RIGHT);
 
-	_contArrowUp = g_hdb->_gfx->loadPic(CTRL_ARROWUP);
-	_contArrowDown = g_hdb->_gfx->loadPic(CTRL_ARROWDN);
-	_contArrowLeft = g_hdb->_gfx->loadPic(CTRL_ARROWLEFT);
-	_contArrowRight = g_hdb->_gfx->loadPic(CTRL_ARROWRIGHT);
-	_contAssign = g_hdb->_gfx->loadPic(CTRL_ASSIGN);
+	if (g_hdb->isPPC()) {
+		if (g_hdb->isDemo()) {
+			warning("STUB: Load DEMOTITLESCREEN");
+			warning("STUB: Load PIC_HANDANGO");
+		}
+		else
+			_hdbLogoScreen = g_hdb->_gfx->loadPic(TITLESCREEN);
 
-	_warpPlaque = g_hdb->_gfx->loadPic(WARP_PLAQUE);
-	_hdbLogoScreen = g_hdb->_gfx->loadPic(TITLESCREEN);
+
+	} else {
+		_gCheckEmpty = g_hdb->_gfx->loadPic(G_CHECK_EMPTY);
+		_gCheckOff = g_hdb->_gfx->loadPic(G_CHECK_OFF);
+		_gCheckOn = g_hdb->_gfx->loadPic(G_CHECK_ON);
+		_gCheckLeft = g_hdb->_gfx->loadPic(G_CHECK_LEFT);
+		_gCheckRight = g_hdb->_gfx->loadPic(G_CHECK_RIGHT);
+
+		_contArrowUp = g_hdb->_gfx->loadPic(CTRL_ARROWUP);
+		_contArrowDown = g_hdb->_gfx->loadPic(CTRL_ARROWDN);
+		_contArrowLeft = g_hdb->_gfx->loadPic(CTRL_ARROWLEFT);
+		_contArrowRight = g_hdb->_gfx->loadPic(CTRL_ARROWRIGHT);
+		_contAssign = g_hdb->_gfx->loadPic(CTRL_ASSIGN);
+
+		_warpPlaque = g_hdb->_gfx->loadPic(WARP_PLAQUE);
+		_hdbLogoScreen = g_hdb->_gfx->loadPic(TITLESCREEN);
+	}
 
 	return true;
 }
@@ -1532,7 +1544,11 @@ void Menu::drawToggle(int x, int y, bool flag) {
 }
 
 void Menu::drawWarpScreen() {
-	_warpPlaque->drawMasked(centerPic(_warpPlaque), 64);
+	if (g_hdb->isPPC()) {
+		g_hdb->_gfx->setCursor(0, kWarpY + 176);
+		g_hdb->_gfx->centerPrint("MONKEYSTONE WARP ZONE!");
+	} else
+		_warpPlaque->drawMasked(centerPic(_warpPlaque), 64);
 }
 
 } // End of Namespace
diff --git a/engines/hdb/menu.h b/engines/hdb/menu.h
index 7ce6450..84a4042 100644
--- a/engines/hdb/menu.h
+++ b/engines/hdb/menu.h
@@ -216,7 +216,7 @@ public:
 	Picture	*_star[3], *_warpGfx;
 	uint32 _quitTimer;
 	Picture	*_starRedGfx[2], *_starGreenGfx[2], *_starBlueGfx[2], *_versionGfx;
-	Picture *_screenshots1gfx, *_screenshots1agfx, *_screenshots2gfx, *_demoPlaqueGfx;
+	Picture *_screenshots1gfx, *_screenshots1agfx, *_screenshots2gfx, *_demoPlaqueGfx, *_handangoGfx;
 
 	bool _menuActive, _optionsScrolling, _newgameActive, _sayHDB;
 	int	_gamefilesActive, _clickDelay, _saveSlot, _optionsActive, _quitActive, _warpActive;


Commit: 6e357d9d9749f399c5c1a347d4e8d6f7881ce081
    https://github.com/scummvm/scummvm/commit/6e357d9d9749f399c5c1a347d4e8d6f7881ce081
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:30+02:00

Commit Message:
HDB: Minor PPC fixes

Changed paths:
    engines/hdb/gfx.cpp
    engines/hdb/menu.cpp


diff --git a/engines/hdb/gfx.cpp b/engines/hdb/gfx.cpp
index b41394b..6c743ea 100644
--- a/engines/hdb/gfx.cpp
+++ b/engines/hdb/gfx.cpp
@@ -257,10 +257,6 @@ void Gfx::updateVideo() {
 }
 
 void Gfx::drawPointer() {
-
-	if (g_hdb->isPPC())
-		return;
-
 	static int anim = 0;
 	static uint32 animTime = 0;
 
@@ -279,8 +275,7 @@ void Gfx::drawPointer() {
 }
 
 void Gfx::setPointerState(int value) {
-	if (!g_hdb->isPPC())
-		_pointerDisplayable = value;
+	_pointerDisplayable = value;
 }
 
 void Gfx::setFade(bool fadeIn, bool black, int steps) {
diff --git a/engines/hdb/menu.cpp b/engines/hdb/menu.cpp
index 5f8297f..8516d0c 100644
--- a/engines/hdb/menu.cpp
+++ b/engines/hdb/menu.cpp
@@ -151,7 +151,8 @@ bool Menu::init() {
 	if (g_hdb->isPPC()) {
 		if (g_hdb->isDemo()) {
 			warning("STUB: Load DEMOTITLESCREEN");
-			warning("STUB: Load PIC_HANDANGO");
+			if (g_hdb->isHandango())
+				warning("STUB: Load PIC_HANDANGO");
 		}
 		else
 			_hdbLogoScreen = g_hdb->_gfx->loadPic(TITLESCREEN);


Commit: 0fb3ad7ba05983fe64cc5f64294d58fa394935d1
    https://github.com/scummvm/scummvm/commit/0fb3ad7ba05983fe64cc5f64294d58fa394935d1
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:30+02:00

Commit Message:
HDB: Make Platform specific constants into variables

Changed paths:
    engines/hdb/ai-init.cpp
    engines/hdb/ai-inventory.cpp
    engines/hdb/ai-waypoint.cpp
    engines/hdb/ai.h
    engines/hdb/gfx.cpp
    engines/hdb/hdb.cpp
    engines/hdb/hdb.h
    engines/hdb/input.cpp
    engines/hdb/map.cpp
    engines/hdb/menu.cpp
    engines/hdb/menu.h
    engines/hdb/window.cpp
    engines/hdb/window.h


diff --git a/engines/hdb/ai-init.cpp b/engines/hdb/ai-init.cpp
index dcaf057..70146ec 100644
--- a/engines/hdb/ai-init.cpp
+++ b/engines/hdb/ai-init.cpp
@@ -955,6 +955,8 @@ AI::AI() {
 
 	memset(_waypointGfx, 0, sizeof(_waypointGfx));
 	_debugQMark = NULL;
+
+	_youGotY = g_hdb->_screenHeight - 16;
 }
 
 AI::~AI() {
diff --git a/engines/hdb/ai-inventory.cpp b/engines/hdb/ai-inventory.cpp
index 9eb91eb..85fde5e 100644
--- a/engines/hdb/ai-inventory.cpp
+++ b/engines/hdb/ai-inventory.cpp
@@ -272,7 +272,7 @@ void AI::printYouGotMsg(const char *name) {
 		return;
 
 	sprintf(_youGotBuffer, "Got %s", name);
-	g_hdb->_window->textOut(_youGotBuffer, kYouGotX, kYouGotY, 120);
+	g_hdb->_window->textOut(_youGotBuffer, kYouGotX, g_hdb->_ai->_youGotY, 120);
 }
 
 void AI::newDelivery(const char *itemTextName, const char *itemGfxName, const char *destTextName, const char *destGfxName, const char *id) {
diff --git a/engines/hdb/ai-waypoint.cpp b/engines/hdb/ai-waypoint.cpp
index cbeb246..702e41b 100644
--- a/engines/hdb/ai-waypoint.cpp
+++ b/engines/hdb/ai-waypoint.cpp
@@ -429,8 +429,8 @@ void AI::drawWayPoints() {
 		int	x = _waypoints[i].x * kTileWidth;
 		int	y = _waypoints[i].y * kTileHeight;
 
-		if (x > mapX - 32 && (x < (mapX + kScreenWidth)) &&
-			y > mapY - 32 && (y < (mapY + kScreenHeight)))
+		if (x > mapX - 32 && (x < (mapX + g_hdb->_screenWidth)) &&
+			y > mapY - 32 && (y < (mapY + g_hdb->_screenHeight)))
 			_waypointGfx[anim]->drawMasked(x - mapX, y - mapY, alpha);
 	}
 
diff --git a/engines/hdb/ai.h b/engines/hdb/ai.h
index 6bf3af8..bd41890 100644
--- a/engines/hdb/ai.h
+++ b/engines/hdb/ai.h
@@ -57,7 +57,6 @@ enum {
 	kRunToggleDelay = 2,
 	kMsgDelay = 3,
 	kYouGotX = -1,
-	kYouGotY = (kScreenHeight - 16),
 	kNumSaveSlots = 8,
 	kAutoSaveSlot = 0
 };
@@ -1095,6 +1094,9 @@ public:
 		return _gatePuddles;
 	}
 
+	// Platform-Specific Constants
+	int _youGotY;
+
 	// Player Variables
 	bool _playerDead;
 	bool _playerInvisible;	// While on RailRider for example
diff --git a/engines/hdb/gfx.cpp b/engines/hdb/gfx.cpp
index 6c743ea..987a567 100644
--- a/engines/hdb/gfx.cpp
+++ b/engines/hdb/gfx.cpp
@@ -38,7 +38,7 @@ Gfx::Gfx() {
 	_tLookupArray = NULL;
 	_starsInfo.active = false;
 	_gfxCache = new Common::Array<GfxCache *>;
-	_globalSurface.create(kScreenWidth, kScreenHeight, g_hdb->_format);
+	_globalSurface.create(g_hdb->_screenWidth, g_hdb->_screenHeight, g_hdb->_format);
 	_pointerDisplayable = 1;
 	_sines = new Common::SineTable(360);
 	_cosines = new Common::CosineTable(360);
@@ -87,9 +87,9 @@ bool Gfx::init() {
 	setCursor(0, 0);
 
 	_eLeft = 0;
-	_eRight = kScreenWidth;
+	_eRight = g_hdb->_screenWidth;
 	_eTop = 0;
-	_eBottom = kScreenHeight;
+	_eBottom = g_hdb->_screenHeight;
 
 	// Load Game Font
 	if (!loadFont("normalprop"))
@@ -234,7 +234,7 @@ double Gfx::getCos(int index) {
 }
 
 void Gfx::fillScreen(uint32 color) {
-	_globalSurface.fillRect(Common::Rect(kScreenWidth, kScreenHeight), color);
+	_globalSurface.fillRect(Common::Rect(g_hdb->_screenWidth, g_hdb->_screenHeight), color);
 	g_system->fillScreen(color);
 }
 
@@ -246,10 +246,10 @@ void Gfx::updateVideo() {
 
 	g_hdb->checkProgress();
 
-	int left = kScreenWidth / 2 - g_hdb->_progressGfx->_width / 2;
+	int left = g_hdb->_screenWidth / 2 - g_hdb->_progressGfx->_width / 2;
 
 	Common::Rect clip(g_hdb->_progressGfx->getSurface()->getBounds());
-	clip.moveTo(left, kProgressY);
+	clip.moveTo(left, g_hdb->_progressY);
 	clip.clip(g_hdb->_gfx->_globalSurface.getBounds());
 	if (!clip.isEmpty()) {
 		g_system->copyRectToScreen(g_hdb->_gfx->_globalSurface.getBasePtr(clip.left, clip.top), g_hdb->_gfx->_globalSurface.pitch, clip.left, clip.top, clip.width(), clip.height());
@@ -304,8 +304,8 @@ void Gfx::updateFade() {
 		return;
 
 	Graphics::ManagedSurface fadeBuffer1, fadeBuffer2;
-	fadeBuffer1.create(kScreenWidth, kScreenHeight, g_hdb->_format);
-	fadeBuffer2.create(kScreenWidth, kScreenHeight, g_hdb->_format);
+	fadeBuffer1.create(g_hdb->_screenWidth, g_hdb->_screenHeight, g_hdb->_format);
+	fadeBuffer2.create(g_hdb->_screenWidth, g_hdb->_screenHeight, g_hdb->_format);
 
 	fadeBuffer2.blitFrom(_globalSurface);
 
@@ -320,9 +320,9 @@ void Gfx::updateFade() {
 		if (!_fadeInfo.isBlack) {
 			// Black Fade
 
-			for (int y = 0; y < kScreenHeight; y++) {
+			for (int y = 0; y < g_hdb->_screenHeight; y++) {
 				ptr = (uint16 *)fadeBuffer1.getBasePtr(0, y);
-				for (int x = 0; x < kScreenWidth; x++) {
+				for (int x = 0; x < g_hdb->_screenWidth; x++) {
 					value = *ptr;
 					if (value) {
 						g_hdb->_format.colorToRGB(value, r, g, b);
@@ -337,9 +337,9 @@ void Gfx::updateFade() {
 		} else {
 			// White Fade
 
-			for (int y = 0; y < kScreenHeight; y++) {
+			for (int y = 0; y < g_hdb->_screenHeight; y++) {
 				ptr = (uint16 *)fadeBuffer1.getBasePtr(0, y);
-				for (int x = 0; x < kScreenWidth; x++) {
+				for (int x = 0; x < g_hdb->_screenWidth; x++) {
 					value = *ptr;
 					g_hdb->_format.colorToRGB(value, r, g, b);
 					r += (255 - r) * (256 - _fadeInfo.curStep) / 256;
@@ -400,8 +400,8 @@ void Gfx::updateFade() {
 void Gfx::turnOnSnow() {
 	_snowInfo.active = true;
 	for (int i = 0; i < MAX_SNOW; i++) {
-		_snowInfo.x[i] = g_hdb->_rnd->getRandomNumber(kScreenWidth - 1);
-		_snowInfo.y[i] = g_hdb->_rnd->getRandomNumber(kScreenHeight - 1);
+		_snowInfo.x[i] = g_hdb->_rnd->getRandomNumber(g_hdb->_screenWidth - 1);
+		_snowInfo.y[i] = g_hdb->_rnd->getRandomNumber(g_hdb->_screenHeight - 1);
 		_snowInfo.yv[i] = g_hdb->_rnd->getRandomNumber(2) + 1;
 		_snowInfo.xvindex[i] = g_hdb->_rnd->getRandomNumber(MAX_SNOW_XV - 1);
 	}
@@ -642,8 +642,8 @@ void Gfx::setSky(int skyIndex) {
 
 void Gfx::setup3DStars() {
 	for (int i = 0; i < kNum3DStars; i++) {
-		_stars3D[i].x = g_hdb->_rnd->getRandomNumber(kScreenWidth - 1);
-		_stars3D[i].y = g_hdb->_rnd->getRandomNumber(kScreenHeight - 1);
+		_stars3D[i].x = g_hdb->_rnd->getRandomNumber(g_hdb->_screenWidth - 1);
+		_stars3D[i].y = g_hdb->_rnd->getRandomNumber(g_hdb->_screenHeight - 1);
 		_stars3D[i].speed = g_hdb->_rnd->getRandomNumber(255);
 		_stars3D[i].speed >>= 1;
 		_stars3D[i].color = _stars3D[i].speed / 64;
@@ -652,8 +652,8 @@ void Gfx::setup3DStars() {
 
 void Gfx::setup3DStarsLeft() {
 	for (int i = 0; i < kNum3DStars; i++) {
-		_stars3DSlow[i].x = g_hdb->_rnd->getRandomNumber(kScreenWidth - 1);
-		_stars3DSlow[i].y = g_hdb->_rnd->getRandomNumber(kScreenHeight - 1);
+		_stars3DSlow[i].x = g_hdb->_rnd->getRandomNumber(g_hdb->_screenWidth - 1);
+		_stars3DSlow[i].y = g_hdb->_rnd->getRandomNumber(g_hdb->_screenHeight - 1);
 		_stars3DSlow[i].speed = ((double) (1 + g_hdb->_rnd->getRandomNumber(4))) / 6.0;
 		_stars3DSlow[i].color = (int) (_stars3DSlow[i].speed * 4.00);
 	}
@@ -664,7 +664,7 @@ void Gfx::draw3DStars() {
 	for (int i = 0; i < kNum3DStars; i++) {
 		_starField[_stars3D[i].color]->drawMasked((int)_stars3D[i].x, (int)_stars3D[i].y);
 		_stars3D[i].y += (_stars3D[i].speed >> 5) + 1;
-		if (_stars3D[i].y > kScreenHeight) {
+		if (_stars3D[i].y > g_hdb->_screenHeight) {
 			_stars3D[i].y = 0;
 		}
 	}
@@ -676,7 +676,7 @@ void Gfx::draw3DStarsLeft() {
 		_starField[_stars3DSlow[i].color]->drawMasked((int)_stars3DSlow[i].x, (int)_stars3DSlow[i].y);
 		_stars3DSlow[i].x -= _stars3DSlow[i].speed;
 		if (_stars3DSlow[i].x < 0) {
-			_stars3DSlow[i].x = kScreenWidth - 1;
+			_stars3DSlow[i].x = g_hdb->_screenWidth - 1;
 		}
 	}
 }
@@ -690,8 +690,8 @@ void Gfx::drawSky() {
 		draw3DStarsLeft();
 	} else if (tile == _tileSkyClouds) {
 		static int offset = 0, wait = 0;
-		for (int j = -64; j < kScreenHeight; j += 64) {
-			for (int i = -64; i < kScreenWidth; i += 64) {
+		for (int j = -64; j < g_hdb->_screenHeight; j += 64) {
+			for (int i = -64; i < g_hdb->_screenWidth; i += 64) {
 				if (_skyClouds)
 					_skyClouds->draw(i + offset, j + offset);
 			}
@@ -719,8 +719,8 @@ void Gfx::drawSnow() {
 		if (_snowInfo.xvindex[i] == MAX_SNOW_XV)
 			_snowInfo.xvindex[i] = 0;
 		if (_snowInfo.x[i] < 0)
-			_snowInfo.x[i] = kScreenWidth - 1;
-		if (_snowInfo.y[i] > kScreenHeight - 1)
+			_snowInfo.x[i] = g_hdb->_screenWidth - 1;
+		if (_snowInfo.y[i] > g_hdb->_screenHeight - 1)
 			_snowInfo.y[i] = 0;
 	}
 }
@@ -848,10 +848,10 @@ void Gfx::drawText(const char *string) {
 
 		// Advance the cursor
 		_cursorX += width + _fontHeader.kerning + kFontIncrement;
-		if (_cursorX > kScreenWidth) {
+		if (_cursorX > g_hdb->_screenWidth) {
 			_cursorX = 0;
 			_cursorY += _fontHeader.height + _fontHeader.leading;
-			if (_cursorY + _fontHeader.height > kScreenHeight)
+			if (_cursorY + _fontHeader.height > g_hdb->_screenHeight)
 				_cursorY = 0;
 		}
 	}
@@ -926,7 +926,7 @@ void Gfx::centerPrint(const char *string) {
 			totalWidth += _charInfoBlocks[string[i]]->width;
 	}
 
-	setCursor(kScreenWidth / 2 - totalWidth / 2, _cursorX);
+	setCursor(g_hdb->_screenWidth / 2 - totalWidth / 2, _cursorX);
 	drawText(string);
 }
 
@@ -1037,7 +1037,7 @@ void Gfx::drawBonusStars() {
 void Gfx::drawDebugInfo(Tile *_debugLogo, int fps) {
 	char buff[64];
 
-	_debugLogo->drawMasked(kScreenWidth - 32, 0);
+	_debugLogo->drawMasked(g_hdb->_screenWidth - 32, 0);
 
 	// Draw  FPS
 	setCursor(0, 0);
diff --git a/engines/hdb/hdb.cpp b/engines/hdb/hdb.cpp
index f4c46df..d243224 100644
--- a/engines/hdb/hdb.cpp
+++ b/engines/hdb/hdb.cpp
@@ -44,6 +44,19 @@ namespace HDB {
 HDBGame* g_hdb;
 
 HDBGame::HDBGame(OSystem *syst, const ADGameDescription *gameDesc) : Engine(syst), _gameDescription(gameDesc) {
+	if (isPPC()) {
+		_screenWidth = 240;
+		_screenHeight = 320;
+		_screenDrawWidth = 240;
+		_screenDrawHeight = 320;
+	} else {
+		_screenWidth = 640;
+		_screenHeight = 480;
+		_screenDrawWidth = _screenWidth - 160;
+		_screenDrawHeight = 480;
+	}
+	_progressY = _screenHeight - 64;
+
 	_format = Graphics::PixelFormat(2, 5, 6, 5, 0, 11, 5, 0, 0);
 	_systemInit = false;
 	g_hdb = this;
@@ -330,9 +343,9 @@ void HDBGame::paint() {
 		// if the graphic has never been loaded, load it now and leave it in memory
 		if (!_logoGfx)
 			_logoGfx = _gfx->loadPic(TITLELOGO);
-		_logoGfx->drawMasked(kScreenWidth / 2 - _logoGfx->_width / 2, 10);
+		_logoGfx->drawMasked(_screenWidth / 2 - _logoGfx->_width / 2, 10);
 
-		int	x = kScreenWidth / 2 - _progressGfx->_width / 2;
+		int	x = _screenWidth / 2 - _progressGfx->_width / 2;
 		int pixels = _progressGfx->_width - _progressMarkGfx->_width;
 		_progressXOffset = (int)(((double)pixels / _progressMax) * (double)_progressCurrent) + x;
 		break;
@@ -342,7 +355,7 @@ void HDBGame::paint() {
 	if (_debugFlag == 1) {
 		_gfx->drawDebugInfo(_debugLogo, _frames.size());
 	} else if (_debugFlag == 2) {
-		_debugLogo->drawMasked(kScreenWidth - 32, 0);
+		_debugLogo->drawMasked(_screenWidth - 32, 0);
 	}
 
 	_gfx->updateVideo();
@@ -799,11 +812,11 @@ void HDBGame::checkProgress() {
 	if (!_progressActive)
 		return;
 
-	x = kScreenWidth / 2 - _progressGfx->_width / 2;
-	_progressGfx->drawMasked(x, kProgressY);
+	x = _screenWidth / 2 - _progressGfx->_width / 2;
+	_progressGfx->drawMasked(x, g_hdb->_progressY);
 	for (i = x; i < _progressXOffset; i += _progressMarkGfx->_width)
-		_progressMarkGfx->drawMasked(i, kProgressY);
-	_progressMarkGfx->drawMasked(_progressXOffset, kProgressY);
+		_progressMarkGfx->drawMasked(i, g_hdb->_progressY);
+	_progressMarkGfx->drawMasked(_progressXOffset, g_hdb->_progressY);
 }
 
 void HDBGame::drawLoadingScreen() {
@@ -873,7 +886,7 @@ Common::Error HDBGame::run() {
 	}
 
 	// Initializes Graphics
-	initGraphics(kScreenWidth, kScreenHeight, &_format);
+	initGraphics(_screenWidth, _screenHeight, &_format);
 
 	start();
 
diff --git a/engines/hdb/hdb.h b/engines/hdb/hdb.h
index 57a493c..3535d45 100644
--- a/engines/hdb/hdb.h
+++ b/engines/hdb/hdb.h
@@ -49,10 +49,6 @@ class Sound;
 class Window;
 
 enum {
-	kScreenWidth = 640,
-	kScreenHeight = 480,
-	kScreenDrawWidth = (kScreenWidth - 160), // visible pixels wide
-	kScreenDrawHeight = 480,
 	kTileWidth = 32,
 	kTileHeight = 32,
 	kMaxSkies = 10,
@@ -63,8 +59,7 @@ enum {
 	kAnimFrameDelay = kGameFPS / 30,
 	kAnimSlowFrames = kAnimFrameDelay * 10,
 	kAnimMediumFrames = kAnimFrameDelay * 6,
-	kAnimFastFrames = kAnimFrameDelay * 2,
-	kProgressY = (kScreenHeight - 64)
+	kAnimFastFrames = kAnimFrameDelay * 2
 };
 
 }
@@ -160,6 +155,14 @@ public:
 	bool isPPC() const;
 	bool isHandango() const;
 
+	// Platform-Specific Constants
+
+	int _screenWidth;
+	int _screenHeight;
+	int _screenDrawWidth; // visible pixels wide
+	int _screenDrawHeight;
+	int _progressY;
+
 	/*
 	Game System Pointers
 	*/
diff --git a/engines/hdb/input.cpp b/engines/hdb/input.cpp
index 51f31a4..e6a0e9c 100644
--- a/engines/hdb/input.cpp
+++ b/engines/hdb/input.cpp
@@ -48,8 +48,8 @@ bool Input::init() {
 	if (g_hdb->isPPC())
 		return true;
 
-	_mouseX = kScreenWidth / 2;
-	_mouseY = kScreenHeight / 2;
+	_mouseX = g_hdb->_screenWidth / 2;
+	_mouseY = g_hdb->_screenHeight / 2;
 
 	_mouseLButton = _mouseMButton = _mouseRButton = 0;
 
@@ -155,7 +155,7 @@ void Input::stylusDown(int x, int y) {
 		{
 		// Is Player Dead? Click on TRY AGAIN
 		if (g_hdb->_ai->playerDead()) {
-			if (y >= kTryRestartY && y <= kTryRestartY + 24) {
+			if (y >= g_hdb->_window->_tryRestartY && y <= g_hdb->_window->_tryRestartY + 24) {
 				if (g_hdb->loadGameState(kAutoSaveSlot).getCode() == Common::kNoError) {
 					g_hdb->_window->clearTryAgain();
 					g_hdb->setGameState(GAME_PLAY);
@@ -208,7 +208,7 @@ void Input::stylusDown(int x, int y) {
 		worldY = ((worldY + y) / kTileHeight) * kTileHeight;
 
 		// Don't allow a click into INV/DELIVERIES area to go into the world
-		if (x >= (kScreenWidth - 32 * 5))
+		if (x >= (g_hdb->_screenWidth - 32 * 5))
 			return;
 
 		// Toggle Walk Speed if we clicked Player
@@ -221,9 +221,9 @@ void Input::stylusDown(int x, int y) {
 			lastRunning = g_system->getMillis() + 1000 * kRunToggleDelay;
 			g_hdb->_ai->togglePlayerRunning();
 			if (g_hdb->_ai->playerRunning())
-				g_hdb->_window->centerTextOut("Running Speed", kScreenHeight - 32, kRunToggleDelay * kGameFPS);
+				g_hdb->_window->centerTextOut("Running Speed", g_hdb->_screenHeight - 32, kRunToggleDelay * kGameFPS);
 			else
-				g_hdb->_window->centerTextOut("Walking Speed", kScreenHeight - 32, kRunToggleDelay * kGameFPS);
+				g_hdb->_window->centerTextOut("Walking Speed", g_hdb->_screenHeight - 32, kRunToggleDelay * kGameFPS);
 			g_hdb->_sound->playSound(SND_SWITCH_USE);
 		}
 
@@ -267,13 +267,13 @@ void Input::updateMouse(int newX, int newY) {
 
 	if (_mouseX < 0)
 		_mouseX = 0;
-	else if (_mouseX >= kScreenWidth)
-		_mouseX = kScreenWidth - 1;
+	else if (_mouseX >= g_hdb->_screenWidth)
+		_mouseX = g_hdb->_screenWidth - 1;
 
 	if (_mouseY < 0)
 		_mouseY = 0;
-	else if (_mouseY >= kScreenHeight)
-		_mouseY = kScreenHeight - 1;
+	else if (_mouseY >= g_hdb->_screenHeight)
+		_mouseY = g_hdb->_screenHeight - 1;
 
 	// Turn Cursor back on?
 	if (!g_hdb->_gfx->getPointer()) {
@@ -298,9 +298,9 @@ void Input::updateMouseButtons(int l, int m, int r) {
 	// Check if LButton has been pressed
 	// Check if LButton has been lifted
 	if (_mouseLButton) {
-		if (_mouseX > (kScreenWidth - 32 * 5) && _mouseY < 240) {
+		if (_mouseX > (g_hdb->_screenWidth - 32 * 5) && _mouseY < 240) {
 			g_hdb->_window->checkInvSelect(_mouseX, _mouseY);
-		} else if (_mouseX > (kScreenWidth - 32 * 5) && _mouseY >= 240) {
+		} else if (_mouseX > (g_hdb->_screenWidth - 32 * 5) && _mouseY >= 240) {
 			g_hdb->_window->checkDlvSelect(_mouseX, _mouseY);
 		} else {
 			if (g_hdb->getPause() && g_hdb->getGameState() == GAME_PLAY) {
diff --git a/engines/hdb/map.cpp b/engines/hdb/map.cpp
index 8c2de33..2c9bbd5 100644
--- a/engines/hdb/map.cpp
+++ b/engines/hdb/map.cpp
@@ -1162,8 +1162,8 @@ void Map::centerMapXY(int x, int y) {
 		y = maxy;
 	}
 
-	x -= (kScreenDrawWidth / 2);
-	y -= (kScreenDrawHeight / 2);
+	x -= (g_hdb->_screenDrawWidth / 2);
+	y -= (g_hdb->_screenDrawHeight / 2);
 
 	setMapXY(x, y);
 }
diff --git a/engines/hdb/menu.cpp b/engines/hdb/menu.cpp
index 8516d0c..b93b1b7 100644
--- a/engines/hdb/menu.cpp
+++ b/engines/hdb/menu.cpp
@@ -125,6 +125,10 @@ Menu::Menu() {
 
 	_versionGfx = NULL;
 	_warpGfx = NULL;
+
+	_menuExitY = g_hdb->_screenHeight - 80;
+	_backoutY = g_hdb->_screenHeight - 32;
+	_warpBackoutY = _backoutY;
 }
 
 Menu::~Menu() {
@@ -343,7 +347,7 @@ void Menu::startMenu() {
 	if (!_fStars[0].y) {
 		for (int i = 0; i < kMaxStars; i++) {
 			_fStars[i].y = -30;
-			_fStars[i].x = g_hdb->_rnd->getRandomNumber(kScreenWidth - 1);
+			_fStars[i].x = g_hdb->_rnd->getRandomNumber(g_hdb->_screenWidth - 1);
 			_fStars[i].speed = g_hdb->_rnd->getRandomNumber(4) + 1;
 			_fStars[i].anim = g_hdb->_rnd->getRandomNumber(2);
 			_fStars[i].delay = 5;
@@ -357,7 +361,7 @@ void Menu::startMenu() {
 		g_hdb->_gfx->setup3DStars();	// setup the star info
 
 		_nebulaWhich = g_hdb->_rnd->getRandomNumber(kNebulaCount - 1);
-		_nebulaX = g_hdb->_rnd->getRandomNumber(kScreenWidth - 1) + 10;
+		_nebulaX = g_hdb->_rnd->getRandomNumber(g_hdb->_screenWidth - 1) + 10;
 		_nebulaY = -20;
 		_nebulaYVel = g_hdb->_rnd->getRandomNumber(9) + 2;
 	}
@@ -401,10 +405,10 @@ void Menu::drawMenu() {
 		drawRocketAndSelections();
 
 		// draw version #
-		_versionGfx->drawMasked(kScreenWidth - 6 * 8, kScreenHeight - 8);
+		_versionGfx->drawMasked(g_hdb->_screenWidth - 6 * 8, g_hdb->_screenHeight - 8);
 
 		if (g_hdb->isDemo()) {
-			_demoPlaqueGfx->drawMasked(kScreenWidth / 2 - _demoPlaqueGfx->_width / 2, 2);
+			_demoPlaqueGfx->drawMasked(g_hdb->_screenWidth / 2 - _demoPlaqueGfx->_width / 2, 2);
 		}
 
 		//
@@ -415,7 +419,7 @@ void Menu::drawMenu() {
 			_rocketX += -_optionsXV;
 			_oBannerY += _optionsXV / 3;
 			_optionsXV += 3;
-			if (_optionsScrollX > kScreenWidth + 10) {
+			if (_optionsScrollX > g_hdb->_screenWidth + 10) {
 				switch (_nextScreen) {
 				case 0: _optionsActive = true; break;
 				case 1: _gamefilesActive = 1; break;
@@ -468,7 +472,7 @@ void Menu::drawMenu() {
 		// Draw WARP
 		//
 		if (g_hdb->getCheatingOn() && _warpGfx)
-			_warpGfx->drawMasked(0, kScreenHeight - _warpGfx->_height);
+			_warpGfx->drawMasked(0, g_hdb->_screenHeight - _warpGfx->_height);
 		//#endif
 	} else if (_newgameActive) {
 		//-------------------------------------------------------------------
@@ -521,7 +525,7 @@ void Menu::drawMenu() {
 
 			// title logo
 			_titleLogo->drawMasked(centerPic(_titleLogo), _rocketY + kMTitleY);
-			_menuBackoutGfx->drawMasked(kBackoutX, kBackoutY);
+			_menuBackoutGfx->drawMasked(kBackoutX, g_hdb->_menu->_backoutY);
 		}
 	} else if (_optionsActive) {
 		//-------------------------------------------------------------------
@@ -585,7 +589,7 @@ void Menu::drawMenu() {
 
 			// title logo
 			_titleLogo->drawMasked(centerPic(_titleLogo), _rocketY + kMTitleY);
-			_menuBackoutGfx->drawMasked(kBackoutX, kBackoutY);
+			_menuBackoutGfx->drawMasked(kBackoutX, g_hdb->_menu->_backoutY);
 
 			// Ignore Controls Screen Button
 			//_controlButtonGfx->drawMasked(centerPic(_controlButtonGfx), kMControlsY);
@@ -630,7 +634,7 @@ void Menu::drawMenu() {
 			_titleLogo->drawMasked(centerPic(_titleLogo), _rocketY + kMTitleY);
 			// CHOOSE SLOT screen
 			_modeLoadGfx->drawMasked(centerPic(_modeLoadGfx), _oBannerY);
-			_menuBackoutGfx->drawMasked(kBackoutX, kBackoutY);
+			_menuBackoutGfx->drawMasked(kBackoutX, g_hdb->_menu->_backoutY);
 
 			if (_saveGames[kAutoSaveSlot].seconds)
 				_vortexian[anim]->drawMasked(kVortSaveX, kVortSaveY);
@@ -655,7 +659,7 @@ void Menu::drawMenu() {
 				_slotGfx->drawMasked(kSaveSlotX - 8, i * 32 + (kSaveSlotY - 4));
 				if (seconds || _saveGames[i].mapName[0]) {
 
-					g_hdb->_gfx->setTextEdges(0, kScreenWidth + 60, 0, kScreenHeight);
+					g_hdb->_gfx->setTextEdges(0, g_hdb->_screenWidth + 60, 0, g_hdb->_screenHeight);
 					g_hdb->_gfx->setCursor(kSaveSlotX, i * 32 + kSaveSlotY);
 					g_hdb->_gfx->drawText(_saveGames[i].mapName);
 
@@ -675,7 +679,7 @@ void Menu::drawMenu() {
 		drawWarpScreen();
 		// title logo
 		_titleLogo->drawMasked(centerPic(_titleLogo), _rocketY + kMTitleY);
-		_menuBackoutGfx->drawMasked(kWarpBackoutX, kWarpBackoutY);
+		_menuBackoutGfx->drawMasked(kWarpBackoutX, g_hdb->_menu->_warpBackoutY);
 
 		char string[32];
 		for (int i = 0; i < 10; i++) {
@@ -712,7 +716,7 @@ void Menu::drawMenu() {
 			_quitScreen->drawMasked(kQuitX, kQuitY);
 		} else if (_quitActive == 2) { // XXXX
 			_screenshots1gfx->drawMasked(kQuitX, kQuitY);
-			_screenshots2gfx->drawMasked(kQuitX, kScreenHeight - _screenshots2gfx->_height);
+			_screenshots2gfx->drawMasked(kQuitX, g_hdb->_screenHeight - _screenshots2gfx->_height);
 		} else if (_quitActive == 1) {
 			_screenshots1agfx->drawMasked(kQuitX, kQuitY);
 		}
@@ -935,9 +939,9 @@ void Menu::drawTitle() {
 		// draw nebula
 		_nebulaGfx[_nebulaWhich]->draw(_nebulaX, _nebulaY);
 		_nebulaY += _nebulaYVel;
-		if (_nebulaY > kScreenHeight + (kScreenHeight / 2)) {
+		if (_nebulaY > g_hdb->_screenHeight + (g_hdb->_screenHeight / 2)) {
 			_nebulaWhich = g_hdb->_rnd->getRandomNumber(kNebulaCount - 1);
-			_nebulaX = g_hdb->_rnd->getRandomNumber(kScreenWidth - 1) + 10;
+			_nebulaX = g_hdb->_rnd->getRandomNumber(g_hdb->_screenWidth - 1) + 10;
 			_nebulaY = -11 * 8;
 			_nebulaYVel = g_hdb->_rnd->getRandomNumber(3) + 1;
 			if (_nebulaWhich > 4)		// galaxy?
@@ -1035,13 +1039,13 @@ void Menu::drawTitle() {
 		g_hdb->_gfx->fillScreen(0);
 		{
 			_titleCycle++;
-			_rocketY = kScreenHeight;	// ycoord
+			_rocketY = g_hdb->_screenHeight;	// ycoord
 			_rocketYVel = -1;		// yspeed
 			_rocketEx = 0;			// exhaust toggle
 			g_hdb->_gfx->setup3DStars();	// setup the star info
 
 			_nebulaWhich = g_hdb->_rnd->getRandomNumber(kNebulaCount - 1);
-			_nebulaX = g_hdb->_rnd->getRandomNumber(kScreenWidth - 1) + 10;
+			_nebulaX = g_hdb->_rnd->getRandomNumber(g_hdb->_screenWidth - 1) + 10;
 			_nebulaY = -11 * 8;
 			_nebulaYVel = g_hdb->_rnd->getRandomNumber(9) + 2;
 			if (_nebulaWhich > 4)		// galaxy?
@@ -1192,7 +1196,7 @@ void Menu::processInput(int x, int y) {
 		if (!g_hdb->getCheatingOn())
 			open = (x >= _nebulaX && x < _nebulaX + 16 && y >= _nebulaY && y < _nebulaY + 16);
 		else
-			open = (y > kMenuExitY && x < kMenuExitXLeft);
+			open = (y > g_hdb->_menu->_menuExitY && x < kMenuExitXLeft);
 
 		if (open) {
 
@@ -1208,7 +1212,7 @@ void Menu::processInput(int x, int y) {
 		//-------------------------------------------------------------------
 		int	xit = getMenuKey();
 
-		if (y >= kMenuExitY || y < kMenuExitYTop || xit) {
+		if (y >= g_hdb->_menu->_menuExitY || y < kMenuExitYTop || xit) {
 			_optionsScrolling = true;
 			_optionsXV = -5;
 			g_hdb->_sound->playSound(SND_MENU_BACKOUT);
@@ -1221,7 +1225,7 @@ void Menu::processInput(int x, int y) {
 			_newgameActive = false;
 			g_hdb->changeGameState();
 			// that's it!  the Game Loop takes over from here...
-		} else if (y >= kModeActionY - 10 && y <= kMenuExitY) {
+		} else if (y >= kModeActionY - 10 && y <= g_hdb->_menu->_menuExitY) {
 			// ACTION MODE area
 			g_hdb->setActionMode(1);
 			g_hdb->_sound->playSound(SND_MENU_ACCEPT);
@@ -1277,11 +1281,11 @@ void Menu::processInput(int x, int y) {
 				g_hdb->_sound->setVoiceStatus(value);
 				g_hdb->_sound->playSound(SND_GUI_INPUT);
 			}
-		} else if (y >= kMenuExitY || y < kMenuExitYTop || xit) {
+		} else if (y >= g_hdb->_menu->_menuExitY || y < kMenuExitYTop || xit) {
 			g_hdb->_sound->playSound(SND_MENU_BACKOUT);
 			_optionsScrolling = true;
 			_optionsXV = -5;
-		} else if (x >= (kScreenWidth / 2 - _controlButtonGfx->_width / 2) && x < (kScreenWidth / 2 + _controlButtonGfx->_width / 2) &&
+		} else if (x >= (g_hdb->_screenWidth / 2 - _controlButtonGfx->_width / 2) && x < (g_hdb->_screenWidth / 2 + _controlButtonGfx->_width / 2) &&
 			y >= kMControlsY && y < kMControlsY + _controlButtonGfx->_height) {
 			// CONTROLS BUTTON!
 
@@ -1296,7 +1300,7 @@ void Menu::processInput(int x, int y) {
 		//-------------------------------------------------------------------
 		int	xit = getMenuKey();
 
-		if (y >= kMenuExitY + 15 || y < kMenuExitYTop || xit) {
+		if (y >= g_hdb->_menu->_menuExitY + 15 || y < kMenuExitYTop || xit) {
 			_optionsScrolling = true;
 			_optionsXV = -5;
 			g_hdb->_sound->playSound(SND_MENU_BACKOUT);
@@ -1353,7 +1357,7 @@ void Menu::processInput(int x, int y) {
 		//-------------------------------------------------------------------
 		int	xit = getMenuKey();
 
-		if ((y >= kMenuExitY && x < kMenuExitXLeft) || xit) {
+		if ((y >= g_hdb->_menu->_menuExitY && x < kMenuExitXLeft) || xit) {
 			_menuActive = true;
 			_warpActive = false;
 			g_hdb->_sound->playSound(SND_MENU_BACKOUT);
@@ -1443,9 +1447,9 @@ void Menu::drawNebula() {
 	_nebulaGfx[_nebulaWhich]->draw(_nebulaX, _nebulaY);
 	_nebulaY += _nebulaYVel;
 
-	if (_nebulaY > kScreenHeight + (kScreenHeight / 2)) {
+	if (_nebulaY > g_hdb->_screenHeight + (g_hdb->_screenHeight / 2)) {
 		_nebulaWhich = g_hdb->_rnd->getRandomNumber(kNebulaCount - 1);
-		_nebulaX = g_hdb->_rnd->getRandomNumber(kScreenWidth - 1) + 10;
+		_nebulaX = g_hdb->_rnd->getRandomNumber(g_hdb->_screenWidth - 1) + 10;
 		_nebulaY = -11 * 8;
 		_nebulaYVel = g_hdb->_rnd->getRandomNumber(3) + 1;
 		if (_nebulaWhich > 4)		// galaxy?
@@ -1457,7 +1461,7 @@ void Menu::drawNebula() {
 	//
 	for (int i = 0; i < kMaxStars; i++) {
 		_fStars[i].y += _fStars[i].speed;
-		if (_fStars[i].y > kScreenHeight) {
+		if (_fStars[i].y > g_hdb->_screenHeight) {
 			_fStars[i].y = (g_hdb->_rnd->getRandomNumber(29) + 30) * -1;
 			_fStars[i].speed = g_hdb->_rnd->getRandomNumber(4) + 1;
 		}
diff --git a/engines/hdb/menu.h b/engines/hdb/menu.h
index 84a4042..319b51f 100644
--- a/engines/hdb/menu.h
+++ b/engines/hdb/menu.h
@@ -49,7 +49,7 @@ namespace HDB {
 #define	TITLE_DELAY2		0.5				// time to spend doing OOH OOH
 #define	TITLE_DELAY3		1				// time to wait before ending title
 
-#define centerPic(x)	(kScreenWidth / 2 - x->_width / 2)
+#define centerPic(x)	(g_hdb->_screenWidth / 2 - x->_width / 2)
 
 enum {
 	kStarRedX = 70,
@@ -71,7 +71,6 @@ enum {
 	kMLoadY = 48 * 1,
 	kMControlsY = 270,
 
-	kMenuExitY = kScreenHeight - 80,
 	kMenuExitXLeft = 60,
 	kMenuExitYTop = 48,
 	kMenuVortSaveY = 220,
@@ -131,10 +130,8 @@ enum {
 	kAssignY = kControlY + 150,
 
 	kBackoutX = 0,
-	kBackoutY = kScreenHeight - 32,
 
 	kWarpBackoutX = kBackoutX,
-	kWarpBackoutY = kBackoutY,
 
 	kWarpX = 214,
 	kWarpY = 160,
@@ -192,6 +189,11 @@ public:
 		return _menuKey;
 	}
 
+	// Platform-specific Constants
+	int _menuExitY;
+	int _backoutY;
+	int _warpBackoutY;
+
 	Save _saveGames[kNumSaveSlots + 1];
 
 	int _starWarp;
diff --git a/engines/hdb/window.cpp b/engines/hdb/window.cpp
index 57bf9cc..d206372 100644
--- a/engines/hdb/window.cpp
+++ b/engines/hdb/window.cpp
@@ -33,6 +33,15 @@
 
 namespace HDB {
 
+Window::Window() {
+	_dlvItemTextY = (g_hdb->_screenHeight - 30);
+	_textOutCenterX = ((g_hdb->_screenWidth - kTileWidth * 5) / 2);
+	_pauseY = (g_hdb->_screenHeight / 2 - 64);
+	_tryY1 = (g_hdb->_screenHeight >> 2);	// TRY
+	_tryY2 = (_tryY1 + 32);			// AGAIN
+	_tryRestartY = ((g_hdb->_screenHeight >> 2) * 3);	// (ok)
+}
+
 Window::~Window() {
 	delete _gfxTL;
 	delete _gfxTM;
@@ -135,13 +144,13 @@ bool Window::init() {
 	warning("FIXME: Fully separate the PC and PPC versions of Window");
 
 	if (!g_hdb->isPPC())
-		_invWinInfo.x = kScreenWidth - _gfxInfobar->_width + 16;
+		_invWinInfo.x = g_hdb->_screenWidth - _gfxInfobar->_width + 16;
 	_invWinInfo.y = 40;
 
 	_dlvsInfo.width = kInvItemSpaceX * 3;
 	_dlvsInfo.height = kInvItemSpaceY * 4;
 	if (!g_hdb->isPPC())
-		_dlvsInfo.x = (kScreenWidth - _gfxInfobar->_width) + 16;
+		_dlvsInfo.x = (g_hdb->_screenWidth - _gfxInfobar->_width) + 16;
 	_dlvsInfo.y = 272;
 
 	_gemGfx = NULL;
@@ -446,11 +455,11 @@ void Window::setInfobarDark(int value) {
 
 void Window::drawPause() {
 	if (g_hdb->getPause())
-		_gfxPausePlaque->drawMasked(480 / 2 - _gfxPausePlaque->_width / 2, kPauseY);
+		_gfxPausePlaque->drawMasked(480 / 2 - _gfxPausePlaque->_width / 2, g_hdb->_window->_pauseY);
 }
 
 void Window::checkPause(int x, int y) {
-	if (x >= 480 / 2 - _gfxPausePlaque->_width / 2 && 480 / 2 + _gfxPausePlaque->_width / 2 > x && y >= kPauseY && y < kPauseY + _gfxPausePlaque->_height) {
+	if (x >= 480 / 2 - _gfxPausePlaque->_width / 2 && 480 / 2 + _gfxPausePlaque->_width / 2 > x && y >= g_hdb->_window->_pauseY && y < g_hdb->_window->_pauseY + _gfxPausePlaque->_height) {
 		g_hdb->togglePause();
 		g_hdb->_sound->playSound(SND_POP);
 	}
@@ -528,10 +537,10 @@ void Window::openDialog(const char *title, int tileIndex, const char *string, in
 
 	int px, py;
 	g_hdb->_ai->getPlayerXY(&px, &py);
-	if (py < (kScreenHeight >> 1) - 16)
-		_dialogInfo.y = (kScreenHeight >> 1) + 16;
+	if (py < (g_hdb->_screenHeight >> 1) - 16)
+		_dialogInfo.y = (g_hdb->_screenHeight >> 1) + 16;
 	else
-		_dialogInfo.y = (kScreenHeight >> 1) - (_dialogInfo.height + 64);
+		_dialogInfo.y = (g_hdb->_screenHeight >> 1) - (_dialogInfo.height + 64);
 
 	if (_dialogInfo.y < 16)
 		_dialogInfo.y = 16;
@@ -596,11 +605,11 @@ void Window::drawDialog() {
 
 	int e1, e2, e3, e4;
 	g_hdb->_gfx->getTextEdges(&e1, &e2, &e3, &e4);
-	g_hdb->_gfx->setTextEdges(_dialogInfo.x + 10, 480, 0, kScreenHeight);
+	g_hdb->_gfx->setTextEdges(_dialogInfo.x + 10, 480, 0, g_hdb->_screenHeight);
 	g_hdb->_gfx->setCursor(0, _dialogInfo.y - 7);
 	if (_dialogInfo.title)
 		g_hdb->_gfx->drawText(_dialogInfo.title);
-	g_hdb->_gfx->setTextEdges(_dialogInfo.x + 16, _dialogInfo.x + _dialogInfo.width - 16, 0, kScreenHeight);
+	g_hdb->_gfx->setTextEdges(_dialogInfo.x + 16, _dialogInfo.x + _dialogInfo.width - 16, 0, g_hdb->_screenHeight);
 	g_hdb->_gfx->setCursor(0, _dialogInfo.y + 16);
 	if (_dialogInfo.string)
 		g_hdb->_gfx->drawText(_dialogInfo.string);
@@ -751,7 +760,7 @@ void Window::openDialogChoice(const char *title, const char *text, const char *f
 	_dialogChoiceInfo.titleWidth = titleWidth;
 
 	_dialogChoiceInfo.x = (480 >> 1) - (_dialogChoiceInfo.width >> 1);
-	_dialogChoiceInfo.y = (kScreenHeight >> 1) - ((_dialogChoiceInfo.height >> 1) + 32);
+	_dialogChoiceInfo.y = (g_hdb->_screenHeight >> 1) - ((_dialogChoiceInfo.height >> 1) + 32);
 	if (_dialogChoiceInfo.y < 0)
 		_dialogChoiceInfo.y = 0;
 
@@ -951,7 +960,7 @@ void Window::nextMsgQueued() {
 
 	_msgInfo.width = width + 32;
 	_msgInfo.x = (480 >> 1) - (_msgInfo.width >> 1);
-	_msgInfo.y = (kScreenHeight >> 2) - (_msgInfo.height >> 1);
+	_msgInfo.y = (g_hdb->_screenHeight >> 2) - (_msgInfo.height >> 1);
 
 	for (xx = 0; xx < _numMsgQueue - 1; xx++)
 	{
@@ -979,7 +988,7 @@ void Window::drawInventory() {
 	if (_infobarDimmed > 1)
 		return;
 
-	_gfxInfobar->draw(kScreenWidth - _gfxInfobar->_width, 0);
+	_gfxInfobar->draw(g_hdb->_screenWidth - _gfxInfobar->_width, 0);
 
 	baseX = drawX = _invWinInfo.x;
 	drawY = _invWinInfo.y;
@@ -1037,7 +1046,7 @@ void Window::drawInventory() {
 		_gfxInvSelect->drawMasked(drawX, drawY);
 
 		if (sel) {
-			int centerX = baseX - 4 + (kScreenWidth - baseX) / 2;
+			int centerX = baseX - 4 + (g_hdb->_screenWidth - baseX) / 2;
 			drawY = _invWinInfo.y + (kInvItemSpaceY * 4) + 16;
 			g_hdb->_gfx->setCursor(centerX - g_hdb->_gfx->stringLength(sel->printedName) / 2, drawY);
 			g_hdb->_gfx->drawText(sel->printedName);
@@ -1159,7 +1168,7 @@ void Window::drawDeliveries() {
 	// Draw Delivery Items
 	int inv = 0;
 	for (; inv < g_hdb->_ai->getDeliveriesAmount(); inv++) {
-		int centerX = baseX + (kScreenWidth - baseX) / 2;
+		int centerX = baseX + (g_hdb->_screenWidth - baseX) / 2;
 		DlvEnt *d = g_hdb->_ai->getDeliveryItem(inv);
 		if (_dlvsInfo.animate && inv == g_hdb->_ai->getDeliveriesAmount() - 1) {
 			if (_dlvsInfo.go1) {
@@ -1169,7 +1178,7 @@ void Window::drawDeliveries() {
 					if (d->itemGfx)
 						d->itemGfx->drawMasked(drawX, drawY);
 
-					g_hdb->_gfx->setCursor(centerX - g_hdb->_gfx->stringLength(d->itemTextName) / 2, kDlvItemTextY);
+					g_hdb->_gfx->setCursor(centerX - g_hdb->_gfx->stringLength(d->itemTextName) / 2, g_hdb->_window->_dlvItemTextY);
 					g_hdb->_gfx->drawText(d->itemTextName);
 					if (!_dlvsInfo.go2) {
 						_dlvsInfo.go2 = true;
@@ -1183,7 +1192,7 @@ void Window::drawDeliveries() {
 					// Draw TO
 					_gfxArrowTo->drawMasked(_dlvsInfo.x + kDlvItemSpaceX * _dlvsInfo.selected + 8, drawY + kTileHeight);
 
-					g_hdb->_gfx->setCursor(centerX - g_hdb->_gfx->stringLength("to") / 2, kDlvItemTextY + 12);
+					g_hdb->_gfx->setCursor(centerX - g_hdb->_gfx->stringLength("to") / 2, g_hdb->_window->_dlvItemTextY + 12);
 					g_hdb->_gfx->drawText("to");
 					if (!_dlvsInfo.go3) {
 						_dlvsInfo.go3 = true;
@@ -1199,7 +1208,7 @@ void Window::drawDeliveries() {
 					if (d->destGfx)
 						d->destGfx->drawMasked(drawX, drawY + kTileHeight + 16);
 
-					g_hdb->_gfx->setCursor(centerX - (g_hdb->_gfx->stringLength(d->destTextName) + g_hdb->_gfx->stringLength("to")) / 2, kDlvItemTextY + 12);
+					g_hdb->_gfx->setCursor(centerX - (g_hdb->_gfx->stringLength(d->destTextName) + g_hdb->_gfx->stringLength("to")) / 2, g_hdb->_window->_dlvItemTextY + 12);
 					g_hdb->_gfx->drawText("to ");
 					g_hdb->_gfx->drawText(d->destTextName);
 
@@ -1219,15 +1228,15 @@ void Window::drawDeliveries() {
 				d->destGfx->drawMasked(drawX, drawY + kTileHeight + 16);
 
 			if (!_dlvsInfo.animate && inv == _dlvsInfo.selected) {
-				g_hdb->_gfx->setCursor(centerX - g_hdb->_gfx->stringLength(d->itemTextName)/2, kDlvItemTextY);
+				g_hdb->_gfx->setCursor(centerX - g_hdb->_gfx->stringLength(d->itemTextName)/2, g_hdb->_window->_dlvItemTextY);
 				g_hdb->_gfx->drawText(d->itemTextName);
-				g_hdb->_gfx->setCursor(centerX - (g_hdb->_gfx->stringLength(d->destTextName) + g_hdb->_gfx->stringLength("to ")) / 2, kDlvItemTextY + 12);
+				g_hdb->_gfx->setCursor(centerX - (g_hdb->_gfx->stringLength(d->destTextName) + g_hdb->_gfx->stringLength("to ")) / 2, g_hdb->_window->_dlvItemTextY + 12);
 				g_hdb->_gfx->drawText("to ");
 				g_hdb->_gfx->drawText(d->destTextName);
 			}
 
 			drawX += kDlvItemSpaceX;
-			if (drawX >= kScreenWidth) {
+			if (drawX >= g_hdb->_screenWidth) {
 				drawX = baseX;
 				drawY += kDlvItemSpaceY + 8;
 			}
@@ -1249,8 +1258,8 @@ void Window::drawDeliveries() {
 
 	// If the infobar is dimmed out, this where we dim the whole thing
 	if (_infobarDimmed) {
-		for (int j = 0; j < kScreenHeight; j += kTileHeight) {
-			for (int i = (kScreenWidth - _gfxInfobar->_width); i < kScreenWidth; i += kTileWidth)
+		for (int j = 0; j < g_hdb->_screenHeight; j += kTileHeight) {
+			for (int i = (g_hdb->_screenWidth - _gfxInfobar->_width); i < g_hdb->_screenWidth; i += kTileWidth)
 				_gfxDarken->drawMasked(i, j);
 		}
 	}
@@ -1286,8 +1295,8 @@ void Window::drawTryAgain() {
 		_gfxAgain = g_hdb->_gfx->loadPic(GAME_AGAIN);
 		_gfxLevelRestart = g_hdb->_gfx->loadPic(GAME_TA_LEVELRESTART);
 
-		_tryAgainInfo.y1 = kTryY1;
-		_tryAgainInfo.y2 = kTryY2;
+		_tryAgainInfo.y1 = g_hdb->_window->_tryY1;
+		_tryAgainInfo.y2 = g_hdb->_window->_tryY2;
 		_tryAgainInfo.x1 = 480 / 2 - _gfxTry->_width / 2;;
 		_tryAgainInfo.x2 = 480 / 2 - _gfxAgain->_width / 2;
 	}
@@ -1296,7 +1305,7 @@ void Window::drawTryAgain() {
 
 	_gfxTry->drawMasked((int)_tryAgainInfo.x1 + xv, (int)_tryAgainInfo.y1 + yv);
 	_gfxAgain->drawMasked((int)_tryAgainInfo.x2 + yv, (int)_tryAgainInfo.y2 + xv);
-	_gfxLevelRestart->drawMasked((int)(480 / 2 - _gfxLevelRestart->_width + xv), kTryRestartY + yv);
+	_gfxLevelRestart->drawMasked((int)(480 / 2 - _gfxLevelRestart->_width + xv), g_hdb->_window->_tryRestartY + yv);
 }
 
 void Window::clearTryAgain() {
@@ -1375,7 +1384,7 @@ void Window::drawPanicZone() {
 			_pzInfo.gfxPanic->drawMasked(_pzInfo.x1 + xx, _pzInfo.y1 + yy);
 			_pzInfo.gfxZone->drawMasked(_pzInfo.x2 + yy, _pzInfo.y2 + xx);
 			if (_pzInfo.y1 < -_pzInfo.gfxPanic->_height &&
-				_pzInfo.y2 > kScreenHeight) {
+				_pzInfo.y2 > g_hdb->_screenHeight) {
 				g_hdb->_sound->playSound(SND_PANIC_COUNT);
 				_pzInfo.sequence++;
 				_pzInfo.timer = 30 + g_hdb->getTime();
@@ -1420,9 +1429,9 @@ void Window::startPanicZone() {
 		loadPanicZoneGfx();
 
 	_pzInfo.x1 = -(_pzInfo.gfxPanic->_width + 5);
-	_pzInfo.y1 = (kScreenHeight / 4) - (_pzInfo.gfxPanic->_height >> 1);
+	_pzInfo.y1 = (g_hdb->_screenHeight / 4) - (_pzInfo.gfxPanic->_height >> 1);
 	_pzInfo.x2 = 480 + (_pzInfo.gfxZone->_width >> 1);
-	_pzInfo.y2 = (kScreenHeight / 4) * 3 - (_pzInfo.gfxZone->_height >> 1);
+	_pzInfo.y2 = (g_hdb->_screenHeight / 4) * 3 - (_pzInfo.gfxZone->_height >> 1);
 	_pzInfo.xv = 10;			// horizontal speed
 	_pzInfo.yv = -12;			// vertical speed
 	_pzInfo.timer = 30;			// 30 seconds to get out!
@@ -1443,7 +1452,7 @@ void Window::textOut(const char *text, int x, int y, int timer) {
 	if (x < 0) {
 		int pw, lines;
 		g_hdb->_gfx->getDimensions(t->text, &pw, &lines);
-		t->x = kTextOutCenterX - pw / 2;
+		t->x = g_hdb->_window->_textOutCenterX - pw / 2;
 	}
 
 	_textOutList.push_back(t);
@@ -1452,7 +1461,7 @@ void Window::textOut(const char *text, int x, int y, int timer) {
 void Window::centerTextOut(const char *text, int y, int timer) {
 	int width, lines;
 	g_hdb->_gfx->getDimensions(text, &width, &lines);
-	textOut(text, kTextOutCenterX - ((width - 8) >> 1), y, timer);
+	textOut(text, g_hdb->_window->_textOutCenterX - ((width - 8) >> 1), y, timer);
 }
 
 void Window::drawTextOut() {
@@ -1461,7 +1470,7 @@ void Window::drawTextOut() {
 
 	int e1, e2, e3, e4;
 	g_hdb->_gfx->getTextEdges(&e1, &e2, &e3, &e4);
-	g_hdb->_gfx->setTextEdges(0, 480, 0, kScreenHeight);
+	g_hdb->_gfx->setTextEdges(0, 480, 0, g_hdb->_screenHeight);
 
 	uint32 time = g_system->getMillis();
 
diff --git a/engines/hdb/window.h b/engines/hdb/window.h
index 672cae5..0597437 100644
--- a/engines/hdb/window.h
+++ b/engines/hdb/window.h
@@ -39,16 +39,10 @@ enum {
 	kDlvItemSpaceX = 48,
 	kDlvItemSpaceY = (kTileHeight * 2 + 16),
 	kDlvItemPerLine = 3,
-	kDlvItemTextY = (kScreenHeight - 30),
 	kPanicXStop = 480 / 3,
 	kPanicZoneFaceX = 480 - 32,
 	kPanicZoneFaceY = 5,
-	kNumCrazy = 37,
-	kTextOutCenterX = ((kScreenWidth - kTileWidth * 5) / 2),
-	kPauseY = (kScreenHeight / 2 - 64),
-	kTryY1 = (kScreenHeight >> 2),	// TRY
-	kTryY2 = (kTryY1 + 32),			// AGAIN
-	kTryRestartY = ((kScreenHeight >> 2) * 3)	// (ok)
+	kNumCrazy = 37
 };
 
 enum PZValue {
@@ -188,7 +182,7 @@ struct TOut {
 
 class Window {
 public:
-
+	Window();
 	~Window();
 
 	bool init();
@@ -291,6 +285,14 @@ public:
 	}
 	void closeTextOut();
 
+	// Platform-specific Constants
+	int _dlvItemTextY;
+	int _textOutCenterX;
+	int _pauseY;
+	int _tryY1;	// TRY
+	int _tryY2;			// AGAIN
+	int _tryRestartY;	// (ok)
+
 	Tile *getGemGfx() {
 		return _gemGfx;
 	}


Commit: a9e65176a15d17ad68c68392614e7a5ed7382e5d
    https://github.com/scummvm/scummvm/commit/a9e65176a15d17ad68c68392614e7a5ed7382e5d
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:30+02:00

Commit Message:
HDB: Add more Platform-specific Constants

Changed paths:
    engines/hdb/ai-init.cpp
    engines/hdb/hdb.cpp
    engines/hdb/lua-script.cpp
    engines/hdb/lua-script.h
    engines/hdb/map.cpp
    engines/hdb/map.h


diff --git a/engines/hdb/ai-init.cpp b/engines/hdb/ai-init.cpp
index 70146ec..1e6336e 100644
--- a/engines/hdb/ai-init.cpp
+++ b/engines/hdb/ai-init.cpp
@@ -956,7 +956,10 @@ AI::AI() {
 	memset(_waypointGfx, 0, sizeof(_waypointGfx));
 	_debugQMark = NULL;
 
-	_youGotY = g_hdb->_screenHeight - 16;
+	if (g_hdb->isPPC())
+		_youGotY = 306;
+	else
+		_youGotY = g_hdb->_screenHeight - 16;
 }
 
 AI::~AI() {
diff --git a/engines/hdb/hdb.cpp b/engines/hdb/hdb.cpp
index d243224..6e42ae0 100644
--- a/engines/hdb/hdb.cpp
+++ b/engines/hdb/hdb.cpp
@@ -49,13 +49,14 @@ HDBGame::HDBGame(OSystem *syst, const ADGameDescription *gameDesc) : Engine(syst
 		_screenHeight = 320;
 		_screenDrawWidth = 240;
 		_screenDrawHeight = 320;
+		_progressY = 280;
 	} else {
 		_screenWidth = 640;
 		_screenHeight = 480;
 		_screenDrawWidth = _screenWidth - 160;
 		_screenDrawHeight = 480;
+		_progressY = _screenHeight - 64;
 	}
-	_progressY = _screenHeight - 64;
 
 	_format = Graphics::PixelFormat(2, 5, 6, 5, 0, 11, 5, 0, 0);
 	_systemInit = false;
diff --git a/engines/hdb/lua-script.cpp b/engines/hdb/lua-script.cpp
index f2552b4..a34028c 100644
--- a/engines/hdb/lua-script.cpp
+++ b/engines/hdb/lua-script.cpp
@@ -98,6 +98,15 @@ struct ScriptPatch {
 };
 
 LuaScript::LuaScript() {
+
+	if (g_hdb->isPPC()) {
+		_cameraXOff = 0;
+		_cameraYOff = 0;
+	} else {
+		_cameraXOff = (32 * 3 + 24);	// 3.75 Tiles Extra
+		_cameraYOff = (32 * 2 + 16);	// 2.50 Tiles Extra
+	}
+
 	_state = NULL;
 	_systemInit = false;
 }
@@ -520,8 +529,8 @@ static int cineDrawPic(lua_State *L) {
 
 	g_hdb->_lua->checkParameters("cineDrawPic", 4);
 
-	x += kCameraXOff;
-	y += kCameraYOff;
+	x += g_hdb->_lua->_cameraXOff;
+	y += g_hdb->_lua->_cameraYOff;
 
 	lua_pop(L, 4);
 	g_hdb->_ai->cineDrawPic(id, pic, (int)x, (int)y);
@@ -537,8 +546,8 @@ static int cineDrawMaskedPic(lua_State *L) {
 
 	g_hdb->_lua->checkParameters("cineDrawMaskedPic", 4);
 
-	x += kCameraXOff;
-	y += kCameraYOff;
+	x += g_hdb->_lua->_cameraXOff;
+	y += g_hdb->_lua->_cameraYOff;
 
 	lua_pop(L, 4);
 	g_hdb->_ai->cineDrawMaskedPic(id, pic, (int)x, (int)y);
@@ -557,10 +566,10 @@ static int cineMovePic(lua_State *L) {
 
 	g_hdb->_lua->checkParameters("cineMovePic", 7);
 
-	x1 += kCameraXOff;
-	y1 += kCameraYOff;
-	x2 += kCameraXOff;
-	y2 += kCameraYOff;
+	x1 += g_hdb->_lua->_cameraXOff;
+	y1 += g_hdb->_lua->_cameraYOff;
+	x2 += g_hdb->_lua->_cameraXOff;
+	y2 += g_hdb->_lua->_cameraYOff;
 
 	lua_pop(L, 7);
 
@@ -580,10 +589,10 @@ static int cineMoveMaskedPic(lua_State *L) {
 
 	g_hdb->_lua->checkParameters("cineMoveMaskedPic", 7);
 
-	x1 += kCameraXOff;
-	y1 += kCameraYOff;
-	x2 += kCameraXOff;
-	y2 += kCameraYOff;
+	x1 += g_hdb->_lua->_cameraXOff;
+	y1 += g_hdb->_lua->_cameraYOff;
+	x2 += g_hdb->_lua->_cameraXOff;
+	y2 += g_hdb->_lua->_cameraYOff;
 
 	lua_pop(L, 7);
 
@@ -687,8 +696,8 @@ static int cineTextOut(lua_State *L) {
 
 	g_hdb->_lua->checkParameters("cineTextOut", 4);
 
-	x += kCameraXOff;
-	y += kCameraYOff;
+	x += g_hdb->_lua->_cameraXOff;
+	y += g_hdb->_lua->_cameraYOff;
 
 	lua_pop(L, 4);
 	g_hdb->_ai->cineTextOut(string, (int)x, (int)y, (int)timer);
@@ -702,7 +711,7 @@ static int cineCenterTextOut(lua_State *L) {
 
 	g_hdb->_lua->checkParameters("cineCenterTextOut", 3);
 
-	y += kCameraYOff;
+	y += g_hdb->_lua->_cameraYOff;
 
 	lua_pop(L, 3);
 	g_hdb->_ai->cineCenterTextOut(string, (int)y, (int)timer);
diff --git a/engines/hdb/lua-script.h b/engines/hdb/lua-script.h
index 3e1ab50..a239aa2 100644
--- a/engines/hdb/lua-script.h
+++ b/engines/hdb/lua-script.h
@@ -27,11 +27,6 @@ struct lua_State;
 
 namespace HDB {
 
-enum {
-	kCameraXOff = (32 * 3 + 24),	// 3.75 Tiles Extra
-	kCameraYOff = (32 * 2 + 16)		// 2.50 Tiles Extra
-};
-
 struct Global {
 	char	global[32];			// name of global variable
 	int		valueOrString;	// value = 0, string = 1
@@ -79,6 +74,10 @@ public:
 		return _systemInit;
 	}
 
+	// Platform-specific Constants
+	int _cameraXOff;
+	int _cameraYOff;
+
 private:
 	lua_State *_state;
 	int _pcallErrorhandlerRegistryIndex;
diff --git a/engines/hdb/map.cpp b/engines/hdb/map.cpp
index 2c9bbd5..9f00826 100644
--- a/engines/hdb/map.cpp
+++ b/engines/hdb/map.cpp
@@ -29,6 +29,19 @@
 namespace HDB {
 
 Map::Map() {
+
+	if (g_hdb->isPPC()) {
+		_screenXTiles = 9;
+		_screenYTiles = 11;
+		_screenTileWidth = 8;
+		_screenTileHeight = 10;
+	} else {
+		_screenXTiles = 17;
+		_screenYTiles = 16;
+		_screenTileWidth = 16;
+		_screenTileHeight = 16;
+	}
+
 	_mapLoaded = false;
 
 	_animCycle = 0;
@@ -836,8 +849,8 @@ void Map::draw() {
 		when we're at the very bottom of the map.
 	*/
 
-	int maxTileX = (_mapTileXOff >= -8) ? kScreenXTiles - 1 : kScreenXTiles;
-	int maxTileY = (!_mapTileYOff) ? kScreenYTiles - 1 : kScreenYTiles;
+	int maxTileX = (_mapTileXOff >= -8) ? g_hdb->_map->_screenXTiles - 1 : g_hdb->_map->_screenXTiles;
+	int maxTileY = (!_mapTileYOff) ? g_hdb->_map->_screenYTiles - 1 : g_hdb->_map->_screenYTiles;
 
 	if (matrixY + (maxTileY - 1)*_width > _height * _width) {
 		return;
@@ -933,7 +946,7 @@ void Map::draw() {
 }
 
 void Map::drawEnts() {
-	g_hdb->_ai->drawEnts(_mapX, _mapY, kScreenXTiles * kTileWidth, kScreenYTiles * kTileHeight);
+	g_hdb->_ai->drawEnts(_mapX, _mapY, g_hdb->_map->_screenXTiles * kTileWidth, g_hdb->_map->_screenYTiles * kTileHeight);
 }
 
 void Map::drawGratings() {
@@ -952,6 +965,12 @@ void Map::drawForegrounds() {
 	debug(8, "Foregrounds Count: %d", _numForegrounds);
 }
 
+bool Map::onScreen(int x, int y) {
+	if ((x >= _mapX / kTileWidth) && (x < (_mapX / kTileWidth) + g_hdb->_map->_screenXTiles) && (y >= _mapY / kTileHeight) && (y < (_mapY / kTileHeight) + g_hdb->_map->_screenYTiles))
+		return true;
+	return false;
+}
+
 uint32 Map::getMapBGTileFlags(int x, int y) {
 	if (x < 0 || x >= _width || y < 0 || y >= _height) {
 		return 0;
@@ -1113,39 +1132,39 @@ void Map::centerMapXY(int x, int y) {
 	int minx, miny, maxx, maxy;
 
 	// Scan from centerX to right edge
-	maxx = (_width - (kScreenTileWidth / 2)) * kTileWidth;
-	for (int i = checkx + 1; i <= checkx + (kScreenTileWidth / 2); i++) {
+	maxx = (_width - (g_hdb->_map->_screenTileWidth / 2)) * kTileWidth;
+	for (int i = checkx + 1; i <= checkx + (g_hdb->_map->_screenTileWidth / 2); i++) {
 		if (!getMapBGTileIndex(i, checky)) {
-			maxx = (i - (kScreenTileWidth / 2)) * kTileWidth;
+			maxx = (i - (g_hdb->_map->_screenTileWidth / 2)) * kTileWidth;
 			break;
 		}
 	}
 
 	// Scan from centerX to left edge
 	minx = 0;
-	for (int i = checkx - 1; i >= checkx - (kScreenTileWidth / 2); i--) {
+	for (int i = checkx - 1; i >= checkx - (g_hdb->_map->_screenTileWidth / 2); i--) {
 		if (!getMapBGTileIndex(i, checky)) {
 			// +1 because we don't want to see one whole tile
-			minx = (1 + i + (kScreenTileWidth / 2)) * kTileWidth;
+			minx = (1 + i + (g_hdb->_map->_screenTileWidth / 2)) * kTileWidth;
 			break;
 		}
 	}
 
 	// Scan from centerY to bottom edge
-	maxy = (_height - (kScreenTileHeight / 2)) * kTileHeight;
-	for (int i = checky + 1; i <= checky + (kScreenTileHeight / 2); i++) {
+	maxy = (_height - (g_hdb->_map->_screenTileHeight / 2)) * kTileHeight;
+	for (int i = checky + 1; i <= checky + (g_hdb->_map->_screenTileHeight / 2); i++) {
 		if (!getMapBGTileIndex(checkx, i)) {
-			maxy = (i - (kScreenTileHeight / 2)) * kTileHeight;
+			maxy = (i - (g_hdb->_map->_screenTileHeight / 2)) * kTileHeight;
 			break;
 		}
 	}
 
 	// Scan from centerY to top edge
 	miny = 0;
-	for (int i = checky - 1; i >= checky - (kScreenTileHeight / 2); i--) {
+	for (int i = checky - 1; i >= checky - (g_hdb->_map->_screenTileHeight / 2); i--) {
 		if (!getMapBGTileIndex(checkx, i)) {
 			// +1 because we don't want to see one whole tile
-			miny = (1 + i + (kScreenTileHeight / 2)) * kTileHeight;
+			miny = (1 + i + (g_hdb->_map->_screenTileHeight / 2)) * kTileHeight;
 			break;
 		}
 	}
@@ -1169,11 +1188,11 @@ void Map::centerMapXY(int x, int y) {
 }
 
 bool Map::checkEntOnScreen(AIEntity *e) {
-	return ((e->x > _mapX - 32) && (e->x < _mapX + kScreenXTiles * kTileWidth) && (e->y > _mapY - 32) && (e->y < kScreenYTiles * kTileHeight));
+	return ((e->x > _mapX - 32) && (e->x < _mapX + g_hdb->_map->_screenXTiles * kTileWidth) && (e->y > _mapY - 32) && (e->y < g_hdb->_map->_screenYTiles * kTileHeight));
 }
 
 bool Map::checkXYOnScreen(int x, int y) {
-	return ((x > _mapX - 32) && (x < _mapX + kScreenXTiles * kTileWidth) && (y > _mapY - 32) && (y < kScreenYTiles * kTileHeight));
+	return ((x > _mapX - 32) && (x < _mapX + g_hdb->_map->_screenXTiles * kTileWidth) && (y > _mapY - 32) && (y < g_hdb->_map->_screenYTiles * kTileHeight));
 }
 
 bool Map::checkOneTileExistInRange(int tileIndex, int count) {
diff --git a/engines/hdb/map.h b/engines/hdb/map.h
index 89b9b86..8341985 100644
--- a/engines/hdb/map.h
+++ b/engines/hdb/map.h
@@ -26,12 +26,8 @@
 namespace HDB {
 
 enum {
-	kScreenXTiles = 17,
-	kScreenYTiles = 16,
-	kScreenTileWidth = 16,
-	kScreenTileHeight = 16,
 	kMaxGratings = 250,
-	kMaxForegrounds = 250
+	kMaxForegrounds = 250,
 };
 
 struct MSMIcon {
@@ -90,11 +86,7 @@ public:
 		return _mapLoaded;
 	}
 
-	bool onScreen(int x, int y) {
-		if ((x >= _mapX / kTileWidth) && (x < (_mapX / kTileWidth) + kScreenXTiles) && (y >= _mapY / kTileHeight) && (y < (_mapY / kTileHeight) + kScreenYTiles))
-			return true;
-		return false;
-	}
+	bool onScreen(int x, int y);
 	int mapPixelWidth() {
 		return _width * kTileWidth;
 	}
@@ -146,6 +138,12 @@ public:
 		memset(_mapLaserBeams, 0, _width * _height);
 	}
 
+	// Platform-specific Constants;
+	int _screenXTiles;
+	int _screenYTiles;
+	int _screenTileWidth;
+	int _screenTileHeight;
+
 	uint16 _width, _height;
 	int _mapX, _mapY; // Coordinates of Map
 	int _mapTileX, _mapTileY; // Tile Coordinates of Map


Commit: f3d0bca83a215e836cbac2fa8aae9371fe9c84ca
    https://github.com/scummvm/scummvm/commit/f3d0bca83a215e836cbac2fa8aae9371fe9c84ca
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:30+02:00

Commit Message:
HDB: Fix warning

Changed paths:
    engines/hdb/map.h


diff --git a/engines/hdb/map.h b/engines/hdb/map.h
index 8341985..e6701d8 100644
--- a/engines/hdb/map.h
+++ b/engines/hdb/map.h
@@ -27,7 +27,7 @@ namespace HDB {
 
 enum {
 	kMaxGratings = 250,
-	kMaxForegrounds = 250,
+	kMaxForegrounds = 250
 };
 
 struct MSMIcon {


Commit: a7828397af799209591cf2b2c3bead0ecf42f376
    https://github.com/scummvm/scummvm/commit/a7828397af799209591cf2b2c3bead0ecf42f376
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:30+02:00

Commit Message:
HDB: Made rendering pipeline to match original

Changed paths:
    engines/hdb/gfx.cpp
    engines/hdb/hdb.cpp


diff --git a/engines/hdb/gfx.cpp b/engines/hdb/gfx.cpp
index 987a567..cc43b06 100644
--- a/engines/hdb/gfx.cpp
+++ b/engines/hdb/gfx.cpp
@@ -254,6 +254,8 @@ void Gfx::updateVideo() {
 	if (!clip.isEmpty()) {
 		g_system->copyRectToScreen(g_hdb->_gfx->_globalSurface.getBasePtr(clip.left, clip.top), g_hdb->_gfx->_globalSurface.pitch, clip.left, clip.top, clip.width(), clip.height());
 	}
+
+	g_system->updateScreen();
 }
 
 void Gfx::drawPointer() {
@@ -303,6 +305,9 @@ void Gfx::updateFade() {
 	if (!_fadeInfo.active && !_fadeInfo.stayFaded)
 		return;
 
+	debug(7, "updateFade: active: %d stayFaded: %d isBlack: %d speed: %d isFadeIn: %d curStep: %d", _fadeInfo.active,
+			_fadeInfo.stayFaded, _fadeInfo.isBlack, _fadeInfo.speed, _fadeInfo.isFadeIn, _fadeInfo.curStep);
+
 	Graphics::ManagedSurface fadeBuffer1, fadeBuffer2;
 	fadeBuffer1.create(g_hdb->_screenWidth, g_hdb->_screenHeight, g_hdb->_format);
 	fadeBuffer2.create(g_hdb->_screenWidth, g_hdb->_screenHeight, g_hdb->_format);
diff --git a/engines/hdb/hdb.cpp b/engines/hdb/hdb.cpp
index 6e42ae0..3d2bf3b 100644
--- a/engines/hdb/hdb.cpp
+++ b/engines/hdb/hdb.cpp
@@ -803,7 +803,6 @@ void HDBGame::drawProgressBar() {
 	GameState temp = _gameState;
 	_gameState = GAME_LOADING;
 	paint();
-	g_system->updateScreen();
 	_gameState = temp;
 }
 
@@ -1048,7 +1047,6 @@ Common::Error HDBGame::run() {
 
 		paint();
 
-		g_system->updateScreen();
 		if (g_hdb->getDebug()) {
 			g_hdb->_frames.push_back(g_system->getMillis());
 			while (g_hdb->_frames[0] < g_system->getMillis() - 1000)


Commit: 7b7420144fd220b1742f6397d61fdb2972629aea
    https://github.com/scummvm/scummvm/commit/7b7420144fd220b1742f6397d61fdb2972629aea
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:30+02:00

Commit Message:
HDB: De not create fade screen on every frame

Changed paths:
    engines/hdb/gfx.cpp
    engines/hdb/gfx.h


diff --git a/engines/hdb/gfx.cpp b/engines/hdb/gfx.cpp
index cc43b06..eda51b7 100644
--- a/engines/hdb/gfx.cpp
+++ b/engines/hdb/gfx.cpp
@@ -91,6 +91,10 @@ bool Gfx::init() {
 	_eTop = 0;
 	_eBottom = g_hdb->_screenHeight;
 
+	// Need two main memory screen-sized surfaces for screen fading
+	_fadeBuffer1.create(g_hdb->_screenWidth, g_hdb->_screenHeight, g_hdb->_format);
+	_fadeBuffer2.create(g_hdb->_screenWidth, g_hdb->_screenHeight, g_hdb->_format);
+
 	// Load Game Font
 	if (!loadFont("normalprop"))
 		return false;
@@ -308,15 +312,11 @@ void Gfx::updateFade() {
 	debug(7, "updateFade: active: %d stayFaded: %d isBlack: %d speed: %d isFadeIn: %d curStep: %d", _fadeInfo.active,
 			_fadeInfo.stayFaded, _fadeInfo.isBlack, _fadeInfo.speed, _fadeInfo.isFadeIn, _fadeInfo.curStep);
 
-	Graphics::ManagedSurface fadeBuffer1, fadeBuffer2;
-	fadeBuffer1.create(g_hdb->_screenWidth, g_hdb->_screenHeight, g_hdb->_format);
-	fadeBuffer2.create(g_hdb->_screenWidth, g_hdb->_screenHeight, g_hdb->_format);
-
-	fadeBuffer2.blitFrom(_globalSurface);
+	_fadeBuffer2.blitFrom(_globalSurface);
 
 	do {
 		// Copy pristine copy of background to modification buffer
-		fadeBuffer1.blitFrom(fadeBuffer2);
+		_fadeBuffer1.blitFrom(_fadeBuffer2);
 
 		// do the actual alphablending
 
@@ -326,7 +326,7 @@ void Gfx::updateFade() {
 			// Black Fade
 
 			for (int y = 0; y < g_hdb->_screenHeight; y++) {
-				ptr = (uint16 *)fadeBuffer1.getBasePtr(0, y);
+				ptr = (uint16 *)_fadeBuffer1.getBasePtr(0, y);
 				for (int x = 0; x < g_hdb->_screenWidth; x++) {
 					value = *ptr;
 					if (value) {
@@ -343,7 +343,7 @@ void Gfx::updateFade() {
 			// White Fade
 
 			for (int y = 0; y < g_hdb->_screenHeight; y++) {
-				ptr = (uint16 *)fadeBuffer1.getBasePtr(0, y);
+				ptr = (uint16 *)_fadeBuffer1.getBasePtr(0, y);
 				for (int x = 0; x < g_hdb->_screenWidth; x++) {
 					value = *ptr;
 					g_hdb->_format.colorToRGB(value, r, g, b);
@@ -356,7 +356,7 @@ void Gfx::updateFade() {
 			}
 		}
 
-		_globalSurface.blitFrom(fadeBuffer1);
+		_globalSurface.blitFrom(_fadeBuffer1);
 
 		// step the fading values to the next one and
 		// see if we're done yet
diff --git a/engines/hdb/gfx.h b/engines/hdb/gfx.h
index 903b579..976b182 100644
--- a/engines/hdb/gfx.h
+++ b/engines/hdb/gfx.h
@@ -157,6 +157,8 @@ private:
 	TileLookup *_tLookupArray;
 	uint16 _skyTiles[kMaxSkies];
 
+	Graphics::ManagedSurface _fadeBuffer1, _fadeBuffer2;
+
 	Common::Array<GfxCache *> *_gfxCache;
 
 	int _currentSky;	// 0 if no Sky, 1+ for which Sky to use


Commit: 02d855b066b0d46c9e9a8ddac45ebc2a50d6a6a0
    https://github.com/scummvm/scummvm/commit/02d855b066b0d46c9e9a8ddac45ebc2a50d6a6a0
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:30+02:00

Commit Message:
HDB: Replaced font name with a constant

Changed paths:
    engines/hdb/gfx.cpp
    engines/hdb/gfx.h


diff --git a/engines/hdb/gfx.cpp b/engines/hdb/gfx.cpp
index eda51b7..cc8f983 100644
--- a/engines/hdb/gfx.cpp
+++ b/engines/hdb/gfx.cpp
@@ -96,7 +96,7 @@ bool Gfx::init() {
 	_fadeBuffer2.create(g_hdb->_screenWidth, g_hdb->_screenHeight, g_hdb->_format);
 
 	// Load Game Font
-	if (!loadFont("normalprop"))
+	if (!loadFont(HDB_FONT))
 		return false;
 
 	// Read total number of tiles in game
diff --git a/engines/hdb/gfx.h b/engines/hdb/gfx.h
index 976b182..923b5b7 100644
--- a/engines/hdb/gfx.h
+++ b/engines/hdb/gfx.h
@@ -32,6 +32,8 @@ namespace Common {
 
 namespace HDB {
 
+#define HDB_FONT "normalprop"
+
 struct TileLookup {
 	const char *filename;
 	Tile *tData;


Commit: abaf1336a72453b42d2e7f955ec548f952f8e6a4
    https://github.com/scummvm/scummvm/commit/abaf1336a72453b42d2e7f955ec548f952f8e6a4
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:31+02:00

Commit Message:
HDB: Hid noisy debug messages, removed one unneeded stub

Changed paths:
    engines/hdb/ai-cinematic.cpp
    engines/hdb/hdb.cpp


diff --git a/engines/hdb/ai-cinematic.cpp b/engines/hdb/ai-cinematic.cpp
index 572f059..d2ce89a 100644
--- a/engines/hdb/ai-cinematic.cpp
+++ b/engines/hdb/ai-cinematic.cpp
@@ -108,7 +108,7 @@ void AI::processCines() {
 					g_hdb->_lua->callFunction(func, 0);
 			}
 			break;
-		case C_STARTMAP: 
+		case C_STARTMAP:
 			{
 				const char *title = _cine[i]->title;
 				// free all gfx alloc'ed during cine
@@ -709,7 +709,7 @@ void AI::cineDialog(const char *title, const char *string, int seconds) {
 	if (!title || !string)
 		warning("cineDialog: Missing Title or Text");
 	cmd->cmdType = C_DIALOG;
-	debug("In cineDialog: C_DIALOG created. cmd->start: %d, cmd->title: %s", cmd->start, cmd->title);
+	debug(6, "In cineDialog: C_DIALOG created. cmd->start: %d, cmd->title: %s", cmd->start, cmd->title);
 	_cine.push_back(cmd);
 }
 
diff --git a/engines/hdb/hdb.cpp b/engines/hdb/hdb.cpp
index 3d2bf3b..5cd5615 100644
--- a/engines/hdb/hdb.cpp
+++ b/engines/hdb/hdb.cpp
@@ -285,14 +285,12 @@ bool HDBGame::restartMap() {
 	_ai->getPlayerXY(&x, &y);
 	_map->centerMapXY(x + 16, y + 16);
 
-	warning("STUB: Cheating - Lua Validation");
-
-	debug(1, "Action List Info:");
+	debug(5, "Action List Info:");
 	for (int k = 0; k < 20; k++) {
-		debug(1, "Action %d: entityName: %s", k, _ai->_actions[k].entityName);
-		debug(1, "Action %d: x1: %d, y1: %d", k, _ai->_actions[k].x1, _ai->_actions[k].y1);
-		debug(1, "Action %d: x2: %d, y2: %d", k, _ai->_actions[k].x2, _ai->_actions[k].y2);
-		debug(1, "Action %d: luaFuncInit: %s, luaFuncUse: %s", k, _ai->_actions[k].luaFuncInit, _ai->_actions[k].luaFuncUse);
+		debug(5, "Action %d: entityName: %s", k, _ai->_actions[k].entityName);
+		debug(5, "Action %d: x1: %d, y1: %d", k, _ai->_actions[k].x1, _ai->_actions[k].y1);
+		debug(5, "Action %d: x2: %d, y2: %d", k, _ai->_actions[k].x2, _ai->_actions[k].y2);
+		debug(5, "Action %d: luaFuncInit: %s, luaFuncUse: %s", k, _ai->_actions[k].luaFuncInit, _ai->_actions[k].luaFuncUse);
 	}
 
 	return true;


Commit: a5ee5fbd18fad42de4e75dabdefa5cd818fe26c3
    https://github.com/scummvm/scummvm/commit/a5ee5fbd18fad42de4e75dabdefa5cd818fe26c3
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:31+02:00

Commit Message:
HDB: Add Platform-specific constants for Menu

Changed paths:
    engines/hdb/menu.cpp
    engines/hdb/menu.h


diff --git a/engines/hdb/menu.cpp b/engines/hdb/menu.cpp
index b93b1b7..9785db1 100644
--- a/engines/hdb/menu.cpp
+++ b/engines/hdb/menu.cpp
@@ -37,6 +37,141 @@
 namespace HDB {
 
 Menu::Menu() {
+
+	if (g_hdb->isPPC()) {
+		_menuX = 18 * 8;
+		_menuY = 16;
+		_menuItemWidth = 88;
+		_menuItemHeight = 40;
+		_mResumeY = 48 * 4;
+		_mQuitY = 48 * 3;
+		_mOptionsY = 48 * 2;
+		_mLoadY = 48 * 1;
+		_mControlsY = 160;
+		_menuExitXLeft = 60;
+		_menuExitY = (g_hdb->_screenHeight - 80);
+		_menuExitYTop = 48;
+		_menuVortSaveY = 220;
+		_menuVortSaveX = 76;
+		_mRocketX = 0;
+		_mRocketY = 10;
+		_mRocketYBottom = 21 * 8;
+		_mRocketEXHX = 0;
+		_mRocketEXHX2 = 0;
+		_mTitleY = 27 * 8;
+		_oohOhhX = 88;
+		_oohOhhY = 128;
+		_newGameX = 20;
+		_newGameX2 = _newGameX + 50;
+		_modePuzzleY = 70;
+		_modeActionY = 160;
+		_optionsX = 2 * 8;
+		_optionsY = 6 * 8;
+		_vortSaveX = 80;
+		_vortSaveTextX = _vortSaveX + 40;
+		_vortSaveY = 220;
+		_saveSlotX = 8;
+		_saveSlotY = 68;
+		_quitX = 0;
+		_quitY = 0;
+		_quitYesX1 = (146 - 16);
+		_quitYesX2 = (211 - 16);
+		_quitYesY1 = (287);
+		_quitYesY2 = (312);
+		_quitNoX1 = (65 - 16);
+		_quitNoX2 = (130 - 16);
+		_quitNoY1 = (287);
+		_quitNoY2 = (312);
+		_controlX = 0;
+		_controlY = 0;
+		_controlUpX = 0;
+		_controlUpY = 0;
+		_controlDownX = 0;
+		_controlDownY = 0;
+		_controlLeftX = 0;
+		_controlLeftY = 0;
+		_controlRightX = 0;
+		_controlRightY = 0;
+		_controlUseX = 0;
+		_controlUseY = 0;
+		_controlWidth = 0;
+		_controlHeight = 0;
+		_assignX = 0;
+		_assignY = 0;
+		_backoutX = 0;
+		_backoutY = 0;
+		_warpBackoutX = (g_hdb->_screenWidth - _menuBackoutGfx->_width);
+		_warpBackoutY = (g_hdb->_screenHeight - _menuBackoutGfx->_height);
+		_warpX = 0;
+		_warpY = 4;
+	} else {
+		_menuX = 48 * 8;
+		_menuY = 80;
+		_menuItemWidth = 88;
+		_menuItemHeight = 40;
+		_mResumeY = 48 * 4;
+		_mQuitY = 48 * 3;
+		_mOptionsY = 48 * 2;
+		_mLoadY = 48 * 1;
+		_mControlsY = 270;
+		_menuExitXLeft = 60;
+		_menuExitY = (g_hdb->_screenHeight - 80);
+		_menuExitYTop = 48;
+		_menuVortSaveY = 220;
+		_menuVortSaveX = 76;
+		_mRocketX = 18 * 8;
+		_mRocketY = 48;
+		_mRocketYBottom = 28 * 8;
+		_mRocketEXHX = 6 * 8 - 4;
+		_mRocketEXHX2 = 11 * 8 - 4;
+		_mTitleY = 34 * 8;
+		_oohOhhX = 256;
+		_oohOhhY = 224;
+		_newGameX = 220;
+		_newGameX2 = _newGameX + 50;
+		_modePuzzleY = 130;
+		_modeActionY = 220;
+		_optionsX = 26 * 8;
+		_optionsY = 10 * 8;
+		_vortSaveX = (200 - 44);
+		_vortSaveTextX = _vortSaveX + 40;
+		_vortSaveY = 72;
+		_saveSlotX = 200;
+		_saveSlotY = 80;
+		_quitX = 0;
+		_quitY = 0;
+		_quitYesX1 = (30 * 8 + _quitX);
+		_quitYesX2 = (38 * 8 + 4 + _quitX);
+		_quitYesY1 = (50 * 8 + _quitY);
+		_quitYesY2 = (53 * 8 + 4 + _quitY);
+		_quitNoX1 = (41 * 8 + _quitX);
+		_quitNoX2 = (49 * 8 + 4 + _quitX);
+		_quitNoY1 = (50 * 8 + _quitY);
+		_quitNoY2 = (53 * 8 + 4 + _quitY);
+		_controlX = 60;
+		_controlY = 40;
+		_controlUpX = (276 + _controlX);
+		_controlUpY = (114 + _controlY);
+		_controlDownX = (276 + _controlX);
+		_controlDownY = (129 + _controlY);
+		_controlLeftX = (396 + _controlX);
+		_controlLeftY = (114 + _controlY);
+		_controlRightX = (396 + _controlX);
+		_controlRightY = (129 + _controlY);
+		_controlUseX = (330 + _controlX);
+		_controlUseY = (209 + _controlY);
+		_controlWidth = 32;
+		_controlHeight = 16;
+		_assignX = (_controlX + 20 * 8);
+		_assignY = (_controlY + 150);
+		_backoutX = 0;
+		_backoutY = g_hdb->_screenHeight - 32;
+		_warpBackoutX = _backoutX;
+		_warpBackoutY = _backoutY;
+		_warpX = 214;
+		_warpY = 160;
+	}
+
 	_starWarp = 0;
 	_rocketEx = 0;
 	_titleActive = false;
@@ -46,8 +181,8 @@ Menu::Menu() {
 	_newgameActive = false;
 	_warpActive = false;
 	_optionsScrolling = false;
-	_optionsScrollX = kMenuX;
-	_rocketX = kMRocketX;
+	_optionsScrollX = _menuX;
+	_rocketX = _mRocketX;
 	_sayHDB = false;
 	_menuKey = 0;
 
@@ -125,10 +260,6 @@ Menu::Menu() {
 
 	_versionGfx = NULL;
 	_warpGfx = NULL;
-
-	_menuExitY = g_hdb->_screenHeight - 80;
-	_backoutY = g_hdb->_screenHeight - 32;
-	_warpBackoutY = _backoutY;
 }
 
 Menu::~Menu() {
@@ -366,10 +497,10 @@ void Menu::startMenu() {
 		_nebulaYVel = g_hdb->_rnd->getRandomNumber(9) + 2;
 	}
 
-	_optionsScrollX = kMenuX;
+	_optionsScrollX = _menuX;
 	_oBannerY = -48;
-	_rocketY = kMRocketY;
-	_rocketX = kMRocketX;
+	_rocketY = _mRocketY;
+	_rocketX = _mRocketX;
 	_menuActive = true;
 	_clickDelay = 30;
 
@@ -432,9 +563,7 @@ void Menu::drawMenu() {
 			}
 		}
 
-		//
 		// Draw the Secret Stars! (tm)
-		//
 		if (g_hdb->getStarsMonkeystone7() == STARS_MONKEYSTONE_7 ||
 			g_hdb->getStarsMonkeystone14() == STARS_MONKEYSTONE_14 ||
 			g_hdb->getStarsMonkeystone21() == STARS_MONKEYSTONE_21) {
@@ -488,9 +617,9 @@ void Menu::drawMenu() {
 			_rocketX += -_optionsXV;
 			_oBannerY += _optionsXV / 3;
 			_optionsXV -= 3;
-			if (_optionsScrollX < kMenuX) {
-				_optionsScrollX = kMenuX;
-				_rocketX = kMRocketX;
+			if (_optionsScrollX < _menuX) {
+				_optionsScrollX = _menuX;
+				_rocketX = _mRocketX;
 				_oBannerY = -48;
 				_optionsScrolling = false;
 				_newgameActive = false;
@@ -502,30 +631,30 @@ void Menu::drawMenu() {
 			drawNebula();
 			_newGfx->drawMasked(centerPic(_newGfx), _oBannerY);
 
-			_modePuzzleGfx->drawMasked(kNewGameX, kModePuzzleY);
-			_modePuzzleGfx->drawMasked(kNewGameX, kModeActionY);
+			_modePuzzleGfx->drawMasked(_newGameX, _modePuzzleY);
+			_modePuzzleGfx->drawMasked(_newGameX, _modeActionY);
 
-			g_hdb->_gfx->setCursor(kNewGameX2, kModePuzzleY - 10);
+			g_hdb->_gfx->setCursor(_newGameX2, _modePuzzleY - 10);
 			g_hdb->_gfx->drawText("PUZZLE MODE");
-			g_hdb->_gfx->setCursor(kNewGameX2, kModePuzzleY + 10);
+			g_hdb->_gfx->setCursor(_newGameX2, _modePuzzleY + 10);
 			g_hdb->_gfx->drawText("In this mode, the focus");
-			g_hdb->_gfx->setCursor(kNewGameX2, kModePuzzleY + 22);
+			g_hdb->_gfx->setCursor(_newGameX2, _modePuzzleY + 22);
 			g_hdb->_gfx->drawText("is on solving puzzles and");
-			g_hdb->_gfx->setCursor(kNewGameX2, kModePuzzleY + 34);
+			g_hdb->_gfx->setCursor(_newGameX2, _modePuzzleY + 34);
 			g_hdb->_gfx->drawText("avoiding enemies.");
 
-			g_hdb->_gfx->setCursor(kNewGameX2, kModeActionY - 10);
+			g_hdb->_gfx->setCursor(_newGameX2, _modeActionY - 10);
 			g_hdb->_gfx->drawText("ACTION MODE");
-			g_hdb->_gfx->setCursor(kNewGameX2, kModeActionY + 10);
+			g_hdb->_gfx->setCursor(_newGameX2, _modeActionY + 10);
 			g_hdb->_gfx->drawText("In this mode, the focus");
-			g_hdb->_gfx->setCursor(kNewGameX2, kModeActionY + 22);
+			g_hdb->_gfx->setCursor(_newGameX2, _modeActionY + 22);
 			g_hdb->_gfx->drawText("is on solving puzzles and");
-			g_hdb->_gfx->setCursor(kNewGameX2, kModeActionY + 34);
+			g_hdb->_gfx->setCursor(_newGameX2, _modeActionY + 34);
 			g_hdb->_gfx->drawText("attacking enemies!");
 
 			// title logo
-			_titleLogo->drawMasked(centerPic(_titleLogo), _rocketY + kMTitleY);
-			_menuBackoutGfx->drawMasked(kBackoutX, g_hdb->_menu->_backoutY);
+			_titleLogo->drawMasked(centerPic(_titleLogo), _rocketY + _mTitleY);
+			_menuBackoutGfx->drawMasked(_backoutX, g_hdb->_menu->_backoutY);
 		}
 	} else if (_optionsActive) {
 		//-------------------------------------------------------------------
@@ -541,9 +670,9 @@ void Menu::drawMenu() {
 			_rocketX += -_optionsXV;
 			_oBannerY += _optionsXV / 3;
 			_optionsXV -= 3;
-			if (_optionsScrollX < kMenuX) {
-				_optionsScrollX = kMenuX;
-				_rocketX = kMRocketX;
+			if (_optionsScrollX < _menuX) {
+				_optionsScrollX = _menuX;
+				_rocketX = _mRocketX;
 				_oBannerY = -48;
 				_optionsScrolling = false;
 				_optionsActive = false;
@@ -559,27 +688,27 @@ void Menu::drawMenu() {
 			drawNebula();
 			_optionsGfx->drawMasked(centerPic(_optionsGfx), _oBannerY);
 
-			g_hdb->_gfx->setCursor(kOptionsX + kOptionSPC, kOptionsY);
+			g_hdb->_gfx->setCursor(_optionsX + kOptionSPC, _optionsY);
 			if (!g_hdb->_sound->getMusicVolume())
 				g_hdb->_gfx->drawText("Music OFF");
 			else
 				g_hdb->_gfx->drawText("Music Volume");
 
-			drawSlider(kOptionsX, kOptionsY + 20, g_hdb->_sound->getMusicVolume());
+			drawSlider(_optionsX, _optionsY + 20, g_hdb->_sound->getMusicVolume());
 
-			g_hdb->_gfx->setCursor(kOptionsX + kOptionSPC, kOptionsY + kOptionLineSPC * 2);
+			g_hdb->_gfx->setCursor(_optionsX + kOptionSPC, _optionsY + kOptionLineSPC * 2);
 			if (!g_hdb->_sound->getSFXVolume())
 				g_hdb->_gfx->drawText("Sound Effects OFF");
 			else
 				g_hdb->_gfx->drawText("Sound Effects Volume");
 
-			drawSlider(kOptionsX, kOptionsY + kOptionLineSPC * 2 + 20, g_hdb->_sound->getSFXVolume());
+			drawSlider(_optionsX, _optionsY + kOptionLineSPC * 2 + 20, g_hdb->_sound->getSFXVolume());
 
 			// Voices ON or OFF
-			drawToggle(kOptionsX, kOptionsY + kOptionLineSPC * 4 + 20, g_hdb->_sound->getVoiceStatus());
+			drawToggle(_optionsX, _optionsY + kOptionLineSPC * 4 + 20, g_hdb->_sound->getVoiceStatus());
 
 			if (!g_hdb->isVoiceless()) {
-				g_hdb->_gfx->setCursor(kOptionsX + kOptionSPC + 24, kOptionsY + kOptionLineSPC * 4 + 24);
+				g_hdb->_gfx->setCursor(_optionsX + kOptionSPC + 24, _optionsY + kOptionLineSPC * 4 + 24);
 				if (!g_hdb->_sound->getVoiceStatus())
 					g_hdb->_gfx->drawText("Voice Dialogue OFF");
 				else
@@ -588,11 +717,11 @@ void Menu::drawMenu() {
 
 
 			// title logo
-			_titleLogo->drawMasked(centerPic(_titleLogo), _rocketY + kMTitleY);
-			_menuBackoutGfx->drawMasked(kBackoutX, g_hdb->_menu->_backoutY);
+			_titleLogo->drawMasked(centerPic(_titleLogo), _rocketY + _mTitleY);
+			_menuBackoutGfx->drawMasked(_backoutX, g_hdb->_menu->_backoutY);
 
 			// Ignore Controls Screen Button
-			//_controlButtonGfx->drawMasked(centerPic(_controlButtonGfx), kMControlsY);
+			//_controlButtonGfx->drawMasked(centerPic(_controlButtonGfx), _mControlsY);
 		} else if (_optionsActive == 2) {
 			//
 			// Draw CONTROLS screen
@@ -616,9 +745,9 @@ void Menu::drawMenu() {
 			_rocketX += -_optionsXV;
 			_oBannerY += _optionsXV / 3;
 			_optionsXV -= 3;
-			if (_optionsScrollX < kMenuX) {
-				_optionsScrollX = kMenuX;
-				_rocketX = kMRocketX;
+			if (_optionsScrollX < _menuX) {
+				_optionsScrollX = _menuX;
+				_rocketX = _mRocketX;
 				_oBannerY = -48;
 				_optionsScrolling = false;
 				_gamefilesActive = false;
@@ -631,18 +760,18 @@ void Menu::drawMenu() {
 			static uint32 anim_time = 0;
 
 			drawNebula();
-			_titleLogo->drawMasked(centerPic(_titleLogo), _rocketY + kMTitleY);
+			_titleLogo->drawMasked(centerPic(_titleLogo), _rocketY + _mTitleY);
 			// CHOOSE SLOT screen
 			_modeLoadGfx->drawMasked(centerPic(_modeLoadGfx), _oBannerY);
-			_menuBackoutGfx->drawMasked(kBackoutX, g_hdb->_menu->_backoutY);
+			_menuBackoutGfx->drawMasked(_backoutX, g_hdb->_menu->_backoutY);
 
 			if (_saveGames[kAutoSaveSlot].seconds)
-				_vortexian[anim]->drawMasked(kVortSaveX, kVortSaveY);
+				_vortexian[anim]->drawMasked(_vortSaveX, _vortSaveY);
 
 			if (g_hdb->isPPC()) {
-				g_hdb->_gfx->setCursor(kVortSaveTextX, kVortSaveY);
+				g_hdb->_gfx->setCursor(_vortSaveTextX, _vortSaveY);
 				g_hdb->_gfx->drawText("Last Vortexian");
-				g_hdb->_gfx->setCursor(kVortSaveTextX, kVortSaveY + 12);
+				g_hdb->_gfx->setCursor(_vortSaveTextX, _vortSaveY + 12);
 				g_hdb->_gfx->drawText("Saved Game");
 			}
 
@@ -656,14 +785,14 @@ void Menu::drawMenu() {
 			for (int i = 0; i < kNumSaveSlots; i++) {
 				int seconds = _saveGames[i].seconds;
 
-				_slotGfx->drawMasked(kSaveSlotX - 8, i * 32 + (kSaveSlotY - 4));
+				_slotGfx->drawMasked(_saveSlotX - 8, i * 32 + (_saveSlotY - 4));
 				if (seconds || _saveGames[i].mapName[0]) {
 
 					g_hdb->_gfx->setTextEdges(0, g_hdb->_screenWidth + 60, 0, g_hdb->_screenHeight);
-					g_hdb->_gfx->setCursor(kSaveSlotX, i * 32 + kSaveSlotY);
+					g_hdb->_gfx->setCursor(_saveSlotX, i * 32 + _saveSlotY);
 					g_hdb->_gfx->drawText(_saveGames[i].mapName);
 
-					g_hdb->_gfx->setCursor(kSaveSlotX + 180, i * 32 + kSaveSlotY);
+					g_hdb->_gfx->setCursor(_saveSlotX + 180, i * 32 + _saveSlotY);
 					char buff[16];
 					sprintf(buff, "%02d:%02d", seconds / 3600, (seconds / 60) % 60);
 					g_hdb->_gfx->drawText(buff);
@@ -678,28 +807,28 @@ void Menu::drawMenu() {
 		drawNebula();
 		drawWarpScreen();
 		// title logo
-		_titleLogo->drawMasked(centerPic(_titleLogo), _rocketY + kMTitleY);
-		_menuBackoutGfx->drawMasked(kWarpBackoutX, g_hdb->_menu->_warpBackoutY);
+		_titleLogo->drawMasked(centerPic(_titleLogo), _rocketY + _mTitleY);
+		_menuBackoutGfx->drawMasked(_warpBackoutX, g_hdb->_menu->_warpBackoutY);
 
 		char string[32];
 		for (int i = 0; i < 10; i++) {
 			sprintf(string, "Map %2d", i);
-			g_hdb->_gfx->setCursor(kWarpX + 4, i * 16 + kWarpY);
+			g_hdb->_gfx->setCursor(_warpX + 4, i * 16 + _warpY);
 			g_hdb->_gfx->drawText(string);
 		}
 		for (int i = 0; i < 10; i++) {
 			sprintf(string, "Map %d", i + 10);
-			g_hdb->_gfx->setCursor(kWarpX + 80, i * 16 + kWarpY);
+			g_hdb->_gfx->setCursor(_warpX + 80, i * 16 + _warpY);
 			g_hdb->_gfx->drawText(string);
 		}
 		for (int i = 0; i < 10; i++) {
 			sprintf(string, "Map %d", i + 20);
-			g_hdb->_gfx->setCursor(kWarpX + 160, i * 16 + kWarpY);
+			g_hdb->_gfx->setCursor(_warpX + 160, i * 16 + _warpY);
 			g_hdb->_gfx->drawText(string);
 		}
 
 		if (_warpActive > 1) {
-			g_hdb->_gfx->setCursor(kWarpX + 60, kWarpY + 164);
+			g_hdb->_gfx->setCursor(_warpX + 60, _warpY + 164);
 			sprintf(string, "Warping to MAP%d", _warpActive - 2);
 			g_hdb->_gfx->centerPrint(string);
 		}
@@ -713,12 +842,12 @@ void Menu::drawMenu() {
 		if (_quitActive == 3 || !g_hdb->isDemo()) {
 			if (!_quitScreen)
 				_quitScreen = g_hdb->_gfx->loadPic(PIC_QUITSCREEN);
-			_quitScreen->drawMasked(kQuitX, kQuitY);
+			_quitScreen->drawMasked(_quitX, _quitY);
 		} else if (_quitActive == 2) { // XXXX
-			_screenshots1gfx->drawMasked(kQuitX, kQuitY);
-			_screenshots2gfx->drawMasked(kQuitX, g_hdb->_screenHeight - _screenshots2gfx->_height);
+			_screenshots1gfx->drawMasked(_quitX, _quitY);
+			_screenshots2gfx->drawMasked(_quitX, g_hdb->_screenHeight - _screenshots2gfx->_height);
 		} else if (_quitActive == 1) {
-			_screenshots1agfx->drawMasked(kQuitX, kQuitY);
+			_screenshots1agfx->drawMasked(_quitX, _quitY);
 		}
 	}
 }
@@ -919,7 +1048,7 @@ void Menu::drawTitle() {
 	case 2:
 		// draw entire screen & ooh ooh
 		_titleScreen->draw(0, 0);
-		_oohOohGfx->draw(kOohOhhX, kOohOhhY);
+		_oohOohGfx->draw(_oohOhhX, _oohOhhY);
 		break;
 
 	case 4: // fadeout monkeystone logo
@@ -949,25 +1078,25 @@ void Menu::drawTitle() {
 		}
 
 		// draw rocket
-		_rocketMain->drawMasked(kMRocketX, _rocketY);
-		_rocketSecond->drawMasked(kMRocketX + 40, _rocketY + kMRocketYBottom);
+		_rocketMain->drawMasked(_mRocketX, _rocketY);
+		_rocketSecond->drawMasked(_mRocketX + 40, _rocketY + _mRocketYBottom);
 
 		// exhaust
 		if (_rocketEx < 5) {
-			_rocketEx1->drawMasked(kMRocketX + kMRocketEXHX, _rocketY + kMRocketYBottom);
-			_rocketEx2->drawMasked(kMRocketX + kMRocketEXHX2, _rocketY + kMRocketYBottom);
+			_rocketEx1->drawMasked(_mRocketX + _mRocketEXHX, _rocketY + _mRocketYBottom);
+			_rocketEx2->drawMasked(_mRocketX + _mRocketEXHX2, _rocketY + _mRocketYBottom);
 		} else if (_rocketEx >= 5 && _rocketEx < 10) {
-			_rocketEx2->drawMasked(kMRocketX + kMRocketEXHX, _rocketY + kMRocketYBottom);
-			_rocketEx1->drawMasked(kMRocketX + kMRocketEXHX2, _rocketY + kMRocketYBottom);
+			_rocketEx2->drawMasked(_mRocketX + _mRocketEXHX, _rocketY + _mRocketYBottom);
+			_rocketEx1->drawMasked(_mRocketX + _mRocketEXHX2, _rocketY + _mRocketYBottom);
 		} else {
 			_rocketEx = 0;
-			_rocketEx1->drawMasked(kMRocketX + kMRocketEXHX, _rocketY + kMRocketYBottom);
-			_rocketEx2->drawMasked(kMRocketX + kMRocketEXHX2, _rocketY + kMRocketYBottom);
+			_rocketEx1->drawMasked(_mRocketX + _mRocketEXHX, _rocketY + _mRocketYBottom);
+			_rocketEx2->drawMasked(_mRocketX + _mRocketEXHX2, _rocketY + _mRocketYBottom);
 		}
 		_rocketEx++;
 
 		// title logo
-		_titleLogo->drawMasked(centerPic(_titleLogo), _rocketY + kMTitleY);
+		_titleLogo->drawMasked(centerPic(_titleLogo), _rocketY + _mTitleY);
 
 		break;
 	}
@@ -1058,8 +1187,8 @@ void Menu::drawTitle() {
 		_titleDelay = 1;
 
 		_rocketY += _rocketYVel;
-		if (_rocketY < kMRocketY) {
-			_rocketY = kMRocketY;
+		if (_rocketY < _mRocketY) {
+			_rocketY = _mRocketY;
 			_titleCycle = 12;
 			_titleDelay = 1;
 		}
@@ -1107,30 +1236,30 @@ void Menu::processInput(int x, int y) {
 	if (_menuActive) {
 		int	resume = getMenuKey();
 		// quit game?
-		if (x >= kMenuX && x < kMenuX + kMenuItemWidth &&
-			y >= kMenuY + kMQuitY && y < kMenuY + kMQuitY + kMenuItemHeight) {
+		if (x >= _menuX && x < _menuX + _menuItemWidth &&
+			y >= _menuY + _mQuitY && y < _menuY + _mQuitY + _menuItemHeight) {
 			g_hdb->_sound->playSound(SND_BYE);
 			_quitTimer = g_hdb->getTimeSlice() + 1000;
 			_quitActive = 1;
 			_menuActive = false;
 			return;
-		} else if (x >= kMenuX && x < kMenuX + kMenuItemWidth &&
-			y >= kMenuY && y < kMenuY + kMenuItemHeight) {
+		} else if (x >= _menuX && x < _menuX + _menuItemWidth &&
+			y >= _menuY && y < _menuY + _menuItemHeight) {
 			// new game?
 			_optionsScrolling = true;
 			_optionsXV = 5;
 			g_hdb->_sound->playSound(SND_MENU_ACCEPT);
 			g_hdb->_sound->freeSound(SND_HDB);
 			_nextScreen = 2;
-		} else if (x >= kMenuX && x < kMenuX + kMenuItemWidth &&
-			y >= kMenuY + kMLoadY && y < kMenuY + kMLoadY + kMenuItemHeight) {
+		} else if (x >= _menuX && x < _menuX + _menuItemWidth &&
+			y >= _menuY + _mLoadY && y < _menuY + _mLoadY + _menuItemHeight) {
 			// game files?
 				_optionsScrolling = true;
 				_optionsXV = 5;
 				g_hdb->_sound->playSound(SND_MENU_ACCEPT);
 				_nextScreen = 1;
-		} else if (x >= kMenuX && x < kMenuX + kMenuItemWidth &&
-			y >= kMenuY + kMOptionsY && y < kMenuY + kMOptionsY + kMenuItemHeight) {
+		} else if (x >= _menuX && x < _menuX + _menuItemWidth &&
+			y >= _menuY + _mOptionsY && y < _menuY + _mOptionsY + _menuItemHeight) {
 			// options?
 			SoundType temp;
 			temp = g_hdb->_sound->whatSongIsPlaying();
@@ -1140,8 +1269,8 @@ void Menu::processInput(int x, int y) {
 			_optionsXV = 5;
 			_nextScreen = 0;
 			g_hdb->_sound->playSound(SND_MENU_ACCEPT);
-		} else if (((x >= kMenuX && x < kMenuX + kMenuItemWidth &&
-			y >= kMenuY + kMResumeY && y < kMenuY + kMResumeY + kMenuItemHeight) || resume) &&
+		} else if (((x >= _menuX && x < _menuX + _menuItemWidth &&
+			y >= _menuY + _mResumeY && y < _menuY + _mResumeY + _menuItemHeight) || resume) &&
 			(true == g_hdb->_map->isLoaded() || _saveGames[5].seconds)) {
 			// resume game? ( must be playing already or have an autosave )
 			g_hdb->_sound->playSound(SND_POP);
@@ -1196,7 +1325,7 @@ void Menu::processInput(int x, int y) {
 		if (!g_hdb->getCheatingOn())
 			open = (x >= _nebulaX && x < _nebulaX + 16 && y >= _nebulaY && y < _nebulaY + 16);
 		else
-			open = (y > g_hdb->_menu->_menuExitY && x < kMenuExitXLeft);
+			open = (y > g_hdb->_menu->_menuExitY && x < _menuExitXLeft);
 
 		if (open) {
 
@@ -1212,20 +1341,20 @@ void Menu::processInput(int x, int y) {
 		//-------------------------------------------------------------------
 		int	xit = getMenuKey();
 
-		if (y >= g_hdb->_menu->_menuExitY || y < kMenuExitYTop || xit) {
+		if (y >= g_hdb->_menu->_menuExitY || y < _menuExitYTop || xit) {
 			_optionsScrolling = true;
 			_optionsXV = -5;
 			g_hdb->_sound->playSound(SND_MENU_BACKOUT);
 		}
 
 		// PUZZLE MODE area
-		if (y >= kModePuzzleY - 10 && y <= kModeActionY - 10) {
+		if (y >= _modePuzzleY - 10 && y <= _modeActionY - 10) {
 			g_hdb->setActionMode(0);
 			g_hdb->_sound->playSound(SND_MENU_ACCEPT);
 			_newgameActive = false;
 			g_hdb->changeGameState();
 			// that's it!  the Game Loop takes over from here...
-		} else if (y >= kModeActionY - 10 && y <= g_hdb->_menu->_menuExitY) {
+		} else if (y >= _modeActionY - 10 && y <= g_hdb->_menu->_menuExitY) {
 			// ACTION MODE area
 			g_hdb->setActionMode(1);
 			g_hdb->_sound->playSound(SND_MENU_ACCEPT);
@@ -1248,32 +1377,32 @@ void Menu::processInput(int x, int y) {
 
 		int	offset;
 		// Slider 1
-		if (x >= 0 && x <= kOptionsX + 200 &&
-			y >= kOptionsY + 20 && y <= kOptionsY + 36) {
+		if (x >= 0 && x <= _optionsX + 200 &&
+			y >= _optionsY + 20 && y <= _optionsY + 36) {
 			int oldVol = g_hdb->_sound->getMusicVolume();
-			if (x < kOptionsX) {
+			if (x < _optionsX) {
 				if (oldVol) {
 					g_hdb->_sound->stopMusic();
 					g_hdb->_sound->setMusicVolume(0);
 					g_hdb->_sound->playSound(SND_GUI_INPUT);
 				}
 			} else {
-				offset = ((x - kOptionsX) * 256) / 200;
+				offset = ((x - _optionsX) * 256) / 200;
 				g_hdb->_sound->setMusicVolume(offset);
 				if (!oldVol)
 					g_hdb->_sound->startMusic(_resumeSong);
 			}
-		} else if (x >= 0 && x <= kOptionsX + 200 &&
-			y >= kOptionsY + kOptionLineSPC * 2 + 20 && y <= kOptionsY + kOptionLineSPC * 2 + 36) {
+		} else if (x >= 0 && x <= _optionsX + 200 &&
+			y >= _optionsY + kOptionLineSPC * 2 + 20 && y <= _optionsY + kOptionLineSPC * 2 + 36) {
 			// Slider 2
-			if (x >= kOptionsX)
-				offset = ((x - kOptionsX) * 256) / 200;
+			if (x >= _optionsX)
+				offset = ((x - _optionsX) * 256) / 200;
 			else
 				offset = 0;
 			g_hdb->_sound->setSFXVolume(offset);
 			g_hdb->_sound->playSound(SND_MENU_SLIDER);
-		} else if (x >= kOptionsX && x <= kOptionsX + 200 &&
-			y >= kOptionsY + kOptionLineSPC * 4 + 24 && y <= kOptionsY + kOptionLineSPC * 4 + 40) {
+		} else if (x >= _optionsX && x <= _optionsX + 200 &&
+			y >= _optionsY + kOptionLineSPC * 4 + 24 && y <= _optionsY + kOptionLineSPC * 4 + 40) {
 			// Voices ON/OFF
 			if (!g_hdb->isVoiceless()) {
 				int value = g_hdb->_sound->getVoiceStatus();
@@ -1281,12 +1410,12 @@ void Menu::processInput(int x, int y) {
 				g_hdb->_sound->setVoiceStatus(value);
 				g_hdb->_sound->playSound(SND_GUI_INPUT);
 			}
-		} else if (y >= g_hdb->_menu->_menuExitY || y < kMenuExitYTop || xit) {
+		} else if (y >= g_hdb->_menu->_menuExitY || y < _menuExitYTop || xit) {
 			g_hdb->_sound->playSound(SND_MENU_BACKOUT);
 			_optionsScrolling = true;
 			_optionsXV = -5;
 		} else if (x >= (g_hdb->_screenWidth / 2 - _controlButtonGfx->_width / 2) && x < (g_hdb->_screenWidth / 2 + _controlButtonGfx->_width / 2) &&
-			y >= kMControlsY && y < kMControlsY + _controlButtonGfx->_height) {
+			y >= _mControlsY && y < _mControlsY + _controlButtonGfx->_height) {
 			// CONTROLS BUTTON!
 
 			// Ignore Controls Button
@@ -1300,7 +1429,7 @@ void Menu::processInput(int x, int y) {
 		//-------------------------------------------------------------------
 		int	xit = getMenuKey();
 
-		if (y >= g_hdb->_menu->_menuExitY + 15 || y < kMenuExitYTop || xit) {
+		if (y >= g_hdb->_menu->_menuExitY + 15 || y < _menuExitYTop || xit) {
 			_optionsScrolling = true;
 			_optionsXV = -5;
 			g_hdb->_sound->playSound(SND_MENU_BACKOUT);
@@ -1310,7 +1439,7 @@ void Menu::processInput(int x, int y) {
 		if (g_hdb->isPPC()) {
 			// 5 Slots screen
 			// Vortexian autosave LOAD?
-			if (y > kVortSaveY && (y < kVortSaveY + 32) && (x >= kVortSaveX) && (x < kVortSaveX + 96) && _saveGames[kAutoSaveSlot].seconds) {
+			if (y > _vortSaveY && (y < _vortSaveY + 32) && (x >= _vortSaveX) && (x < _vortSaveX + 96) && _saveGames[kAutoSaveSlot].seconds) {
 				g_hdb->_sound->playSound(SND_VORTEX_SAVE);
 				if (g_hdb->loadGameState(kAutoSaveSlot).getCode() == Common::kNoError) {
 					_gamefilesActive = false;
@@ -1324,7 +1453,7 @@ void Menu::processInput(int x, int y) {
 
 		int i = 0;
 		for (; i < kNumSaveSlots; i++)
-			if (y >= (i * 32 + kSaveSlotY - 4) && y <= (i * 32 + kSaveSlotY + 24))
+			if (y >= (i * 32 + _saveSlotY - 4) && y <= (i * 32 + _saveSlotY + 24))
 				break;
 		if (i >= kNumSaveSlots)
 			return;
@@ -1357,23 +1486,23 @@ void Menu::processInput(int x, int y) {
 		//-------------------------------------------------------------------
 		int	xit = getMenuKey();
 
-		if ((y >= g_hdb->_menu->_menuExitY && x < kMenuExitXLeft) || xit) {
+		if ((y >= g_hdb->_menu->_menuExitY && x < _menuExitXLeft) || xit) {
 			_menuActive = true;
 			_warpActive = false;
 			g_hdb->_sound->playSound(SND_MENU_BACKOUT);
 			_clickDelay = 10;
-		} else if (y >= kWarpY && y < kWarpY + 160) {
+		} else if (y >= _warpY && y < _warpY + 160) {
 			int map;
 
-			if (x > kWarpX + 160)
+			if (x > _warpX + 160)
 				map = 20;
 			else
-				if (x > kWarpX + 80)
+				if (x > _warpX + 80)
 					map = 10;
 				else
 					map = 0;
 
-			map += (y - kWarpY) / 16;
+			map += (y - _warpY) / 16;
 
 			_warpActive = map + 2;
 			g_hdb->paint();
@@ -1402,7 +1531,7 @@ void Menu::processInput(int x, int y) {
 		int	xit = getMenuKey();
 
 		if (!g_hdb->isDemo()) {
-			if ((x >= kQuitNoX1 && x <= kQuitNoX2 && y > kQuitNoY1 && y < kQuitNoY2 && _quitTimer < g_hdb->getTimeSlice()) || xit) {
+			if ((x >= _quitNoX1 && x <= _quitNoX2 && y > _quitNoY1 && y < _quitNoY2 && _quitTimer < g_hdb->getTimeSlice()) || xit) {
 				g_hdb->_sound->playSound(SND_MENU_BACKOUT);
 				delete _quitScreen;
 				_quitScreen = NULL;
@@ -1410,7 +1539,7 @@ void Menu::processInput(int x, int y) {
 				_menuActive = true;
 				_quitActive = 0;
 			} else if (_quitTimer < g_hdb->getTimeSlice()) {
-				if (x >= kQuitYesX1 && x <= kQuitYesX2 && y > kQuitYesY1 && y < kQuitYesY2) {
+				if (x >= _quitYesX1 && x <= _quitYesX2 && y > _quitYesY1 && y < _quitYesY2) {
 					writeConfig();
 					g_hdb->quitGame();
 				}
@@ -1420,7 +1549,7 @@ void Menu::processInput(int x, int y) {
 				_quitActive++;
 				_quitTimer = g_hdb->getTimeSlice() + 1000;
 			} else {
-				if (_quitActive == 3 && (x >= kQuitNoX1 && x <= kQuitNoX2 && y > kQuitNoY1 && y < kQuitNoY2 && _quitTimer < g_hdb->getTimeSlice())) {
+				if (_quitActive == 3 && (x >= _quitNoX1 && x <= _quitNoX2 && y > _quitNoY1 && y < _quitNoY2 && _quitTimer < g_hdb->getTimeSlice())) {
 					g_hdb->_sound->playSound(SND_MENU_BACKOUT);
 					delete _quitScreen;
 					_quitScreen = NULL;
@@ -1485,33 +1614,33 @@ void Menu::drawRocketAndSelections() {
 	}
 
 	// menu items
-	_newGfx->drawMasked(_optionsScrollX, kMenuY);
-	_modeLoadGfx->drawMasked(_optionsScrollX, kMenuY + kMLoadY);
-	_optionsGfx->drawMasked(_optionsScrollX, kMenuY + kMOptionsY);
-	_quitGfx->drawMasked(_optionsScrollX, kMenuY + kMQuitY);
+	_newGfx->drawMasked(_optionsScrollX, _menuY);
+	_modeLoadGfx->drawMasked(_optionsScrollX, _menuY + _mLoadY);
+	_optionsGfx->drawMasked(_optionsScrollX, _menuY + _mOptionsY);
+	_quitGfx->drawMasked(_optionsScrollX, _menuY + _mQuitY);
 	if (g_hdb->_map->isLoaded() || _saveGames[5].seconds)
-		_resumeGfx->drawMasked(_optionsScrollX, kMenuY + kMResumeY);
+		_resumeGfx->drawMasked(_optionsScrollX, _menuY + _mResumeY);
 
 	// draw rocket
 	_rocketMain->drawMasked(_rocketX, _rocketY);
-	_rocketSecond->drawMasked(_rocketX + 40, _rocketY + kMRocketYBottom);
+	_rocketSecond->drawMasked(_rocketX + 40, _rocketY + _mRocketYBottom);
 
 	// exhaust
 	if (_rocketEx < 5) {
-		_rocketEx1->drawMasked(kMRocketX + kMRocketEXHX, _rocketY + kMRocketYBottom);
-		_rocketEx2->drawMasked(kMRocketX + kMRocketEXHX2, _rocketY + kMRocketYBottom);
+		_rocketEx1->drawMasked(_mRocketX + _mRocketEXHX, _rocketY + _mRocketYBottom);
+		_rocketEx2->drawMasked(_mRocketX + _mRocketEXHX2, _rocketY + _mRocketYBottom);
 	} else if (_rocketEx >= 5 && _rocketEx < 10) {
-		_rocketEx2->drawMasked(kMRocketX + kMRocketEXHX, _rocketY + kMRocketYBottom);
-		_rocketEx1->drawMasked(kMRocketX + kMRocketEXHX2, _rocketY + kMRocketYBottom);
+		_rocketEx2->drawMasked(_mRocketX + _mRocketEXHX, _rocketY + _mRocketYBottom);
+		_rocketEx1->drawMasked(_mRocketX + _mRocketEXHX2, _rocketY + _mRocketYBottom);
 	} else {
 		_rocketEx = 0;
-		_rocketEx1->drawMasked(kMRocketX + kMRocketEXHX, _rocketY + kMRocketYBottom);
-		_rocketEx2->drawMasked(kMRocketX + kMRocketEXHX2, _rocketY + kMRocketYBottom);
+		_rocketEx1->drawMasked(_mRocketX + _mRocketEXHX, _rocketY + _mRocketYBottom);
+		_rocketEx2->drawMasked(_mRocketX + _mRocketEXHX2, _rocketY + _mRocketYBottom);
 	}
 	_rocketEx++;
 
 	// title logo
-	_titleLogo->drawMasked(centerPic(_titleLogo), _rocketY + kMTitleY);
+	_titleLogo->drawMasked(centerPic(_titleLogo), _rocketY + _mTitleY);
 }
 
 void Menu::drawSlider(int x, int y, int offset) {
@@ -1550,7 +1679,7 @@ void Menu::drawToggle(int x, int y, bool flag) {
 
 void Menu::drawWarpScreen() {
 	if (g_hdb->isPPC()) {
-		g_hdb->_gfx->setCursor(0, kWarpY + 176);
+		g_hdb->_gfx->setCursor(0, _warpY + 176);
 		g_hdb->_gfx->centerPrint("MONKEYSTONE WARP ZONE!");
 	} else
 		_warpPlaque->drawMasked(centerPic(_warpPlaque), 64);
diff --git a/engines/hdb/menu.h b/engines/hdb/menu.h
index 319b51f..c9b1b8d 100644
--- a/engines/hdb/menu.h
+++ b/engines/hdb/menu.h
@@ -59,89 +59,12 @@ enum {
 	kStarBlueX = 70,
 	kStarBlueY = 180,
 
-	kMenuX = 48 * 8,
-	kMenuY = 80,
-
-	kMenuItemWidth = 88,
-	kMenuItemHeight = 40,
-
-	kMResumeY =	48 * 4,
-	kMQuitY = 48 * 3,
-	kMOptionsY = 48 * 2,
-	kMLoadY = 48 * 1,
-	kMControlsY = 270,
-
-	kMenuExitXLeft = 60,
-	kMenuExitYTop = 48,
-	kMenuVortSaveY = 220,
-	kMenuVortSaveX = 76,
-
-	kMRocketX = 18 * 8,
-	kMRocketY = 48,
-	kMRocketYBottom = 28 * 8,
-	kMRocketEXHX = 6 * 8 - 4,
-	kMRocketEXHX2 = 11 * 8 - 4,
-	kMTitleY = 34 * 8,
-	kOohOhhX = 256,
-	kOohOhhY = 224,
-
-	kNewGameX = 220,
-	kNewGameX2 = kNewGameX + 50,
-
-	kModePuzzleY = 130,
-	kModeActionY = 220,
-
-	kOptionsX = 8 * 26,
-	kOptionsY = 8 * 10,
-
-	kVortSaveX = 200 - 44,
-	kVortSaveTextX = kVortSaveX + 40,
-	kVortSaveY = 72,
-	kSaveSlotX = 200,
-	kSaveSlotY = 80,
-
-	kQuitX = 0,
-	kQuitY = 0,
-	kQuitYesX1 = 30 * 8,
-	kQuitYesX2 = 38 * 8 + 4,
-	kQuitYesY1 = 50 * 8,
-	kQuitYesY2 = 53 * 8 + 4,
-	kQuitNoX1 = 41 * 8,
-	kQuitNoX2 = 49 * 8 + 4,
-	kQuitNoY1 = 50 * 8,
-	kQuitNoY2 = 53 * 8 + 4,
-
-	kControlX = 60,
-	kControlY = 40,
-	kControlUpX = 276 + kControlX,
-	kControlUpY = 114 + kControlY,
-	kControlDownX = 276 + kControlX,
-	kControlDownY = 129 + kControlY,
-	kControlLeftX = 396 + kControlX,
-	kControlLeftY = 114 + kControlY,
-	kControlRightX = 396 + kControlX,
-	kControlRightY = 129 + kControlY,
-	kControlUseX = 330 + kControlX,
-	kControlUseY = 209 + kControlY,
-	kControlWidth = 32,
-	kControlHeight = 16,
-
-	kAssignX = kControlX + 20 * 8,
-	kAssignY = kControlY + 150,
-
-	kBackoutX = 0,
-
-	kWarpBackoutX = kBackoutX,
-
-	kWarpX = 214,
-	kWarpY = 160,
+	kOptionSPC = 16,
+	kOptionLineSPC = 32,
 
 	kScreenFade = 512,
 	kNebulaCount = 7,
 	kMaxStars = 10,
-
-	kOptionSPC = 16,
-	kOptionLineSPC = 32
 };
 
 struct Star {
@@ -190,9 +113,70 @@ public:
 	}
 
 	// Platform-specific Constants
+	int _menuX, _menuY;
+	int _menuItemWidth;
+	int _menuItemHeight;
+	int _mResumeY;
+	int _mQuitY;
+	int _mOptionsY;
+	int _mLoadY;
+	int _mControlsY;
+	int _menuExitXLeft;
 	int _menuExitY;
+	int _menuExitYTop;
+	int _menuVortSaveY;
+	int _menuVortSaveX;
+	int _mRocketX;
+	int _mRocketY;
+	int _mRocketYBottom;
+	int _mRocketEXHX;
+	int _mRocketEXHX2;
+	int _mTitleY;
+	int _oohOhhX;
+	int _oohOhhY;
+	int _newGameX;
+	int _newGameX2;
+	int _modePuzzleY;
+	int _modeActionY;
+	int _optionsX;
+	int _optionsY;
+	int _vortSaveX;
+	int _vortSaveTextX;
+	int _vortSaveY;
+	int _saveSlotX;
+	int _saveSlotY;
+	int _quitX;
+	int _quitY;
+	int _quitYesX1;
+	int _quitYesX2;
+	int _quitYesY1;
+	int _quitYesY2;
+	int _quitNoX1;
+	int _quitNoX2;
+	int _quitNoY1;
+	int _quitNoY2;
+	int _controlX;
+	int _controlY;
+	int _controlUpX;
+	int _controlUpY;
+	int _controlDownX;
+	int _controlDownY;
+	int _controlLeftX;
+	int _controlLeftY;
+	int _controlRightX;
+	int _controlRightY;
+	int _controlUseX;
+	int _controlUseY;
+	int _controlWidth;
+	int _controlHeight;
+	int _assignX;
+	int _assignY;
+	int _backoutX;
 	int _backoutY;
+	int _warpBackoutX;
 	int _warpBackoutY;
+	int _warpX;
+	int _warpY;
 
 	Save _saveGames[kNumSaveSlots + 1];
 


Commit: 63f9cd97add918b03affaae516f6bc72de6b3826
    https://github.com/scummvm/scummvm/commit/63f9cd97add918b03affaae516f6bc72de6b3826
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:31+02:00

Commit Message:
HDB: Fix PPC crash due to _menuBackoutGfx

Changed paths:
    engines/hdb/menu.cpp


diff --git a/engines/hdb/menu.cpp b/engines/hdb/menu.cpp
index 9785db1..dd88c4a 100644
--- a/engines/hdb/menu.cpp
+++ b/engines/hdb/menu.cpp
@@ -100,8 +100,6 @@ Menu::Menu() {
 		_assignY = 0;
 		_backoutX = 0;
 		_backoutY = 0;
-		_warpBackoutX = (g_hdb->_screenWidth - _menuBackoutGfx->_width);
-		_warpBackoutY = (g_hdb->_screenHeight - _menuBackoutGfx->_height);
 		_warpX = 0;
 		_warpY = 4;
 	} else {
@@ -431,8 +429,12 @@ void Menu::startMenu() {
 	_quitGfx = g_hdb->_gfx->loadPic(MENU_QUIT);
 	_resumeGfx = g_hdb->_gfx->loadPic(MENU_RESUME);
 	_slotGfx = g_hdb->_gfx->loadPic(GAMEFILE_SLOT);
-	_menuBackoutGfx = g_hdb->_gfx->loadPic(MENU_BACK);
 	_menuBackspaceGfx = g_hdb->_gfx->loadPic(MENU_BACKSPACE);
+	_menuBackoutGfx = g_hdb->_gfx->loadPic(MENU_BACK);
+	if (g_hdb->isPPC()) {
+		_warpBackoutX = (g_hdb->_screenWidth - _menuBackoutGfx->_width);
+		_warpBackoutY = (g_hdb->_screenHeight - _menuBackoutGfx->_height);
+	}
 	_controlButtonGfx = g_hdb->_gfx->loadPic(MENU_CONTROLS);
 	_controlsGfx = g_hdb->_gfx->loadPic(PIC_CONTROLSSCREEN);
 


Commit: b51881c4468a72d5cfd41682c7daef7037c2a2a1
    https://github.com/scummvm/scummvm/commit/b51881c4468a72d5cfd41682c7daef7037c2a2a1
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:31+02:00

Commit Message:
HDB: Change song names for PPC

Changed paths:
    engines/hdb/sound.cpp


diff --git a/engines/hdb/sound.cpp b/engines/hdb/sound.cpp
index e31fb6a..f713fe8 100644
--- a/engines/hdb/sound.cpp
+++ b/engines/hdb/sound.cpp
@@ -1695,6 +1695,24 @@ void Sound::stopMusic() {
 }
 
 bool Sound::beginMusic(SoundType song, bool fadeIn, int ramp) {
+	const char *songName = soundList[song].name;
+
+	if (g_hdb->isPPC()) {
+		switch (song) {
+		case SONG_JEEBIES:
+			songName = "jeebies.mp3";
+			break;
+		case SONG_VIBRACIOUS:
+			songName = "vibracious.mp3";
+			break;
+		case SONG_ARETHERE:
+			songName = "are_we_there_yet.mp3";
+			break;
+		default:
+			break;
+		}
+	}
+
 	if (!_song1.playing) {
 		// Start fading out SONG2 if its playing
 		if (_song2.playing) {
@@ -1705,7 +1723,7 @@ bool Sound::beginMusic(SoundType song, bool fadeIn, int ramp) {
 
 		// Load up the song
 #ifdef USE_MAD
-		Common::SeekableReadStream *stream = SearchMan.createReadStreamForMember(soundList[song].name);
+		Common::SeekableReadStream *stream = SearchMan.createReadStreamForMember(songName);
 		if (stream == nullptr)
 			return false;
 
@@ -1745,7 +1763,7 @@ bool Sound::beginMusic(SoundType song, bool fadeIn, int ramp) {
 
 		// Load up the song
 #ifdef USE_MAD
-		Common::SeekableReadStream *stream = SearchMan.createReadStreamForMember(soundList[song].name);
+		Common::SeekableReadStream *stream = SearchMan.createReadStreamForMember(songName);
 		if (stream == nullptr)
 			return false;
 


Commit: b2fded7dca7ec07b8a8d58ce901948018d0adbcc
    https://github.com/scummvm/scummvm/commit/b2fded7dca7ec07b8a8d58ce901948018d0adbcc
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:31+02:00

Commit Message:
HDB: Fix _screenDrawWidth and _screenDrawHeight

Changed paths:
    engines/hdb/gfx.cpp
    engines/hdb/map.cpp
    engines/hdb/window.cpp


diff --git a/engines/hdb/gfx.cpp b/engines/hdb/gfx.cpp
index cc8f983..4dbd705 100644
--- a/engines/hdb/gfx.cpp
+++ b/engines/hdb/gfx.cpp
@@ -1015,8 +1015,8 @@ void Gfx::drawBonusStars() {
 
 	for (int i = 0; i < 10; i++) {
 		_starsInfo.gfx[_starsInfo.anim]->drawMasked(
-			(int)(480 / 2 + ((float)_starsInfo.radius / 2)) + (int)((double)_starsInfo.radius * _cosines->at(_starsInfo.starAngle[i]) - w),
-			(480 / 2) + (int)((double)_starsInfo.radius * _sines->at(_starsInfo.starAngle[i]) - h)
+			(int)(g_hdb->_screenDrawWidth / 2 + ((float)_starsInfo.radius / 2)) + (int)((double)_starsInfo.radius * _cosines->at(_starsInfo.starAngle[i]) - w),
+			(g_hdb->_screenDrawHeight / 2) + (int)((double)_starsInfo.radius * _sines->at(_starsInfo.starAngle[i]) - h)
 		);
 
 		int angle = (int)(_starsInfo.starAngle[i] + _starsInfo.angleSpeed);
diff --git a/engines/hdb/map.cpp b/engines/hdb/map.cpp
index 9f00826..898a2c7 100644
--- a/engines/hdb/map.cpp
+++ b/engines/hdb/map.cpp
@@ -1110,14 +1110,14 @@ void Map::getMapXY(int *x, int *y) {
 void Map::setMapXY(int x, int y) {
 	if (x < 0) {
 		x = 0;
-	} else if (x > (_width * kTileWidth - 480)) {
-		x = _width * kTileWidth - 480;
+	} else if (x > (_width * kTileWidth - g_hdb->_screenDrawWidth)) {
+		x = _width * kTileWidth - g_hdb->_screenDrawWidth;
 	}
 
 	if (y < 0) {
 		y = 0;
-	} else if (y > (_height * kTileHeight - 480)) {
-		y = _height * kTileHeight - 480;
+	} else if (y > (_height * kTileHeight - g_hdb->_screenDrawHeight)) {
+		y = _height * kTileHeight - g_hdb->_screenDrawHeight;
 	}
 
 	_mapX = x;
diff --git a/engines/hdb/window.cpp b/engines/hdb/window.cpp
index d206372..508e327 100644
--- a/engines/hdb/window.cpp
+++ b/engines/hdb/window.cpp
@@ -455,11 +455,12 @@ void Window::setInfobarDark(int value) {
 
 void Window::drawPause() {
 	if (g_hdb->getPause())
-		_gfxPausePlaque->drawMasked(480 / 2 - _gfxPausePlaque->_width / 2, g_hdb->_window->_pauseY);
+		_gfxPausePlaque->drawMasked(g_hdb->_screenDrawWidth / 2 - _gfxPausePlaque->_width / 2, g_hdb->_window->_pauseY);
 }
 
 void Window::checkPause(int x, int y) {
-	if (x >= 480 / 2 - _gfxPausePlaque->_width / 2 && 480 / 2 + _gfxPausePlaque->_width / 2 > x && y >= g_hdb->_window->_pauseY && y < g_hdb->_window->_pauseY + _gfxPausePlaque->_height) {
+	if (x >= g_hdb->_screenDrawWidth / 2 - _gfxPausePlaque->_width / 2 && g_hdb->_screenDrawWidth / 2 + _gfxPausePlaque->_width / 2 > x
+		&& y >= g_hdb->_window->_pauseY && y < g_hdb->_window->_pauseY + _gfxPausePlaque->_height) {
 		g_hdb->togglePause();
 		g_hdb->_sound->playSound(SND_POP);
 	}
@@ -523,7 +524,7 @@ void Window::openDialog(const char *title, int tileIndex, const char *string, in
 	else
 		strcpy(_dialogInfo.string, string);
 	g_hdb->_gfx->getTextEdges(&e1, &e2, &e3, &e4);
-	g_hdb->_gfx->setTextEdges(kDialogTextLeft, kDialogTextRight, 0, 480);
+	g_hdb->_gfx->setTextEdges(kDialogTextLeft, kDialogTextRight, 0, g_hdb->_screenDrawHeight);
 	g_hdb->_gfx->getDimensions(string, &width, &height);
 	g_hdb->_gfx->getDimensions(title, &titleWidth, &titleHeight);
 	g_hdb->_gfx->setTextEdges(e1, e2, e3, e4);
@@ -533,7 +534,7 @@ void Window::openDialog(const char *title, int tileIndex, const char *string, in
 	if (titleWidth > w)
 		w = titleWidth;
 
-	_dialogInfo.x = (480 >> 1) - (w >> 1);
+	_dialogInfo.x = (g_hdb->_screenDrawWidth >> 1) - (w >> 1);
 
 	int px, py;
 	g_hdb->_ai->getPlayerXY(&px, &py);
@@ -605,7 +606,7 @@ void Window::drawDialog() {
 
 	int e1, e2, e3, e4;
 	g_hdb->_gfx->getTextEdges(&e1, &e2, &e3, &e4);
-	g_hdb->_gfx->setTextEdges(_dialogInfo.x + 10, 480, 0, g_hdb->_screenHeight);
+	g_hdb->_gfx->setTextEdges(_dialogInfo.x + 10, g_hdb->_screenDrawWidth, 0, g_hdb->_screenHeight);
 	g_hdb->_gfx->setCursor(0, _dialogInfo.y - 7);
 	if (_dialogInfo.title)
 		g_hdb->_gfx->drawText(_dialogInfo.title);
@@ -727,7 +728,7 @@ void Window::openDialogChoice(const char *title, const char *text, const char *f
 	int		width, height, titleWidth, titleHeight;
 	int		e1, e2, e3, e4, i;
 
-	if (true == _dialogInfo.active)
+	if (_dialogInfo.active)
 		return;
 
 	memset(&_dialogChoiceInfo, 0, sizeof(_dialogChoiceInfo));
@@ -741,7 +742,7 @@ void Window::openDialogChoice(const char *title, const char *text, const char *f
 	_dialogChoiceInfo.active = true;
 
 	g_hdb->_gfx->getTextEdges(&e1, &e2, &e3, &e4);
-	g_hdb->_gfx->setTextEdges(kOpenDialogTextLeft, kOpenDialogTextRight, 0, 480);
+	g_hdb->_gfx->setTextEdges(kOpenDialogTextLeft, kOpenDialogTextRight, 0, g_hdb->_screenDrawHeight);
 	g_hdb->_gfx->getDimensions(text, &width, &height);
 	g_hdb->_gfx->getDimensions(title, &titleWidth, &titleHeight);
 
@@ -759,7 +760,7 @@ void Window::openDialogChoice(const char *title, const char *text, const char *f
 	_dialogChoiceInfo.width = width + 48;
 	_dialogChoiceInfo.titleWidth = titleWidth;
 
-	_dialogChoiceInfo.x = (480 >> 1) - (_dialogChoiceInfo.width >> 1);
+	_dialogChoiceInfo.x = (g_hdb->_screenDrawWidth >> 1) - (_dialogChoiceInfo.width >> 1);
 	_dialogChoiceInfo.y = (g_hdb->_screenHeight >> 1) - ((_dialogChoiceInfo.height >> 1) + 32);
 	if (_dialogChoiceInfo.y < 0)
 		_dialogChoiceInfo.y = 0;
@@ -804,11 +805,11 @@ void Window::drawDialogChoice() {
 	}
 
 	g_hdb->_gfx->getTextEdges(&e1, &e2, &e3, &e4);
-	g_hdb->_gfx->setTextEdges(_dialogChoiceInfo.x + 10, kOpenDialogTextRight, 0, 480);
+	g_hdb->_gfx->setTextEdges(_dialogChoiceInfo.x + 10, kOpenDialogTextRight, 0, g_hdb->_screenDrawHeight);
 	g_hdb->_gfx->setCursor(0, _dialogChoiceInfo.y - 7);
 	if (_dialogChoiceInfo.title)
 		g_hdb->_gfx->drawText(_dialogChoiceInfo.title);
-	g_hdb->_gfx->setTextEdges(_dialogChoiceInfo.x + 16, kOpenDialogTextRight, 0, 480);
+	g_hdb->_gfx->setTextEdges(_dialogChoiceInfo.x + 16, kOpenDialogTextRight, 0, g_hdb->_screenDrawHeight);
 	g_hdb->_gfx->setCursor(0, _dialogChoiceInfo.y + 16);
 	if (_dialogChoiceInfo.text)
 		g_hdb->_gfx->drawText(_dialogChoiceInfo.text);
@@ -888,14 +889,14 @@ void Window::openMessageBar(const char *title, int time) {
 	strcpy(_msgInfo.title, title);
 
 	g_hdb->_gfx->getTextEdges(&e1, &e2, &e3, &e4);
-	g_hdb->_gfx->setTextEdges(kDialogTextLeft, kDialogTextRight, 0, 480);
+	g_hdb->_gfx->setTextEdges(kDialogTextLeft, kDialogTextRight, 0, g_hdb->_screenDrawHeight);
 	g_hdb->_gfx->getDimensions(title, &width, &height);
 	g_hdb->_gfx->setTextEdges(e1, e2, e3, e4);
 
 	_msgInfo.height = (height + 2) * 16;
 	_msgInfo.width = width + 32;
 
-	_msgInfo.x = (480 >> 1) - (_msgInfo.width >> 1);
+	_msgInfo.x = (g_hdb->_screenDrawWidth >> 1) - (_msgInfo.width >> 1);
 	_msgInfo.active = true;
 }
 
@@ -952,14 +953,14 @@ void Window::nextMsgQueued() {
 	_msgInfo.timer = (_msgQueueWait[0] * kGameFPS);
 
 	g_hdb->_gfx->getTextEdges(&e1, &e2, &e3, &e4);
-	g_hdb->_gfx->setTextEdges(kDialogTextLeft, kDialogTextRight, 0, 480);
+	g_hdb->_gfx->setTextEdges(kDialogTextLeft, kDialogTextRight, 0, g_hdb->_screenDrawHeight);
 	g_hdb->_gfx->getDimensions(_msgInfo.title, &width, &height);
 	g_hdb->_gfx->setTextEdges(e1, e2, e3, e4);
 
 	_msgInfo.height = (height + 2) * 16;
 
 	_msgInfo.width = width + 32;
-	_msgInfo.x = (480 >> 1) - (_msgInfo.width >> 1);
+	_msgInfo.x = (g_hdb->_screenDrawWidth >> 1) - (_msgInfo.width >> 1);
 	_msgInfo.y = (g_hdb->_screenHeight >> 2) - (_msgInfo.height >> 1);
 
 	for (xx = 0; xx < _numMsgQueue - 1; xx++)
@@ -1297,15 +1298,15 @@ void Window::drawTryAgain() {
 
 		_tryAgainInfo.y1 = g_hdb->_window->_tryY1;
 		_tryAgainInfo.y2 = g_hdb->_window->_tryY2;
-		_tryAgainInfo.x1 = 480 / 2 - _gfxTry->_width / 2;;
-		_tryAgainInfo.x2 = 480 / 2 - _gfxAgain->_width / 2;
+		_tryAgainInfo.x1 = g_hdb->_screenDrawWidth / 2 - _gfxTry->_width / 2;;
+		_tryAgainInfo.x2 = g_hdb->_screenDrawWidth / 2 - _gfxAgain->_width / 2;
 	}
 
 	int xv = g_hdb->_rnd->getRandomNumber(3) - 2, yv = g_hdb->_rnd->getRandomNumber(3) - 2;
 
 	_gfxTry->drawMasked((int)_tryAgainInfo.x1 + xv, (int)_tryAgainInfo.y1 + yv);
 	_gfxAgain->drawMasked((int)_tryAgainInfo.x2 + yv, (int)_tryAgainInfo.y2 + xv);
-	_gfxLevelRestart->drawMasked((int)(480 / 2 - _gfxLevelRestart->_width + xv), g_hdb->_window->_tryRestartY + yv);
+	_gfxLevelRestart->drawMasked((int)(g_hdb->_screenDrawWidth / 2 - _gfxLevelRestart->_width + xv), g_hdb->_window->_tryRestartY + yv);
 }
 
 void Window::clearTryAgain() {
@@ -1430,7 +1431,7 @@ void Window::startPanicZone() {
 
 	_pzInfo.x1 = -(_pzInfo.gfxPanic->_width + 5);
 	_pzInfo.y1 = (g_hdb->_screenHeight / 4) - (_pzInfo.gfxPanic->_height >> 1);
-	_pzInfo.x2 = 480 + (_pzInfo.gfxZone->_width >> 1);
+	_pzInfo.x2 = g_hdb->_screenDrawWidth + (_pzInfo.gfxZone->_width >> 1);
 	_pzInfo.y2 = (g_hdb->_screenHeight / 4) * 3 - (_pzInfo.gfxZone->_height >> 1);
 	_pzInfo.xv = 10;			// horizontal speed
 	_pzInfo.yv = -12;			// vertical speed
@@ -1470,7 +1471,7 @@ void Window::drawTextOut() {
 
 	int e1, e2, e3, e4;
 	g_hdb->_gfx->getTextEdges(&e1, &e2, &e3, &e4);
-	g_hdb->_gfx->setTextEdges(0, 480, 0, g_hdb->_screenHeight);
+	g_hdb->_gfx->setTextEdges(0, g_hdb->_screenDrawWidth, 0, g_hdb->_screenHeight);
 
 	uint32 time = g_system->getMillis();
 


Commit: 8062f98b5afd80acb414b746146516379e24a37c
    https://github.com/scummvm/scummvm/commit/8062f98b5afd80acb414b746146516379e24a37c
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:31+02:00

Commit Message:
HDB: Add Window Platform-specific Constants

Changed paths:
    engines/hdb/window.cpp
    engines/hdb/window.h


diff --git a/engines/hdb/window.cpp b/engines/hdb/window.cpp
index 508e327..2fe4409 100644
--- a/engines/hdb/window.cpp
+++ b/engines/hdb/window.cpp
@@ -34,12 +34,48 @@
 namespace HDB {
 
 Window::Window() {
-	_dlvItemTextY = (g_hdb->_screenHeight - 30);
-	_textOutCenterX = ((g_hdb->_screenWidth - kTileWidth * 5) / 2);
+	if (g_hdb->isPPC()) {
+		_weaponX = (g_hdb->_screenWidth - 34);
+		_weaponY = 2;
+		_invItemSpace = 36;
+		_invItemPerLine = 5;
+		_textOutCenterX = 120;
+		_dlvItemSpaceX = 0;
+		_dlvItemSpaceY = 0;
+		_dlvItemPerLine = 0;
+		_dlvItemTextY = 0;
+		_dialogTextLeft = 8;
+		_dialogTextRight = 208;
+		_openDialogTextLeft = 0;
+		_openDialogTextRight = 228;
+		_tryY1 = 60;	// TRY
+		_tryY2 = 100;			// AGAIN
+		_tryRestartY = 240;	// (ok)
+		_panicXStop = g_hdb->_screenDrawWidth / 4;
+		_panicZoneFaceX = g_hdb->_screenDrawWidth - 32;
+	} else {
+		_weaponX = (480 - 34);
+		_weaponY = 2;
+		_invItemSpaceX = 48;
+		_invItemSpaceY = 40;
+		_invItemPerLine = 3;
+		_textOutCenterX = ((g_hdb->_screenWidth - kTileWidth * 5) / 2);
+		_dlvItemSpaceX = 48;
+		_dlvItemSpaceY = kTileHeight * 2 + 16;
+		_dlvItemPerLine = 3;
+		_dlvItemTextY = (g_hdb->_screenHeight - 30);
+		_dialogTextLeft = 64;
+		_dialogTextRight = _dialogTextLeft + kTileWidth * 9;
+		_openDialogTextLeft = _dialogTextLeft;
+		_openDialogTextRight = _dialogTextRight + kTileWidth * 2;
+		_tryY1 = (g_hdb->_screenHeight >> 2);	// TRY
+		_tryY2 = (_tryY1 + 32);			// AGAIN
+		_tryRestartY = ((g_hdb->_screenHeight >> 2) * 3);	// (ok)
+		_panicXStop = g_hdb->_screenDrawWidth / 3;
+		_panicZoneFaceX = g_hdb->_screenDrawWidth - 32;
+	}
+
 	_pauseY = (g_hdb->_screenHeight / 2 - 64);
-	_tryY1 = (g_hdb->_screenHeight >> 2);	// TRY
-	_tryY2 = (_tryY1 + 32);			// AGAIN
-	_tryRestartY = ((g_hdb->_screenHeight >> 2) * 3);	// (ok)
 }
 
 Window::~Window() {
@@ -138,8 +174,8 @@ bool Window::init() {
 
 	_infobarDimmed = 0;
 
-	_invWinInfo.width = kInvItemSpaceX * 3;
-	_invWinInfo.height = kInvItemSpaceY * 4;
+	_invWinInfo.width = _invItemSpaceX * 3;
+	_invWinInfo.height = _invItemSpaceY * 4;
 
 	warning("FIXME: Fully separate the PC and PPC versions of Window");
 
@@ -147,8 +183,8 @@ bool Window::init() {
 		_invWinInfo.x = g_hdb->_screenWidth - _gfxInfobar->_width + 16;
 	_invWinInfo.y = 40;
 
-	_dlvsInfo.width = kInvItemSpaceX * 3;
-	_dlvsInfo.height = kInvItemSpaceY * 4;
+	_dlvsInfo.width = _invItemSpaceX * 3;
+	_dlvsInfo.height = _invItemSpaceY * 4;
 	if (!g_hdb->isPPC())
 		_dlvsInfo.x = (g_hdb->_screenWidth - _gfxInfobar->_width) + 16;
 	_dlvsInfo.y = 272;
@@ -524,7 +560,7 @@ void Window::openDialog(const char *title, int tileIndex, const char *string, in
 	else
 		strcpy(_dialogInfo.string, string);
 	g_hdb->_gfx->getTextEdges(&e1, &e2, &e3, &e4);
-	g_hdb->_gfx->setTextEdges(kDialogTextLeft, kDialogTextRight, 0, g_hdb->_screenDrawHeight);
+	g_hdb->_gfx->setTextEdges(_dialogTextLeft, _dialogTextRight, 0, g_hdb->_screenDrawHeight);
 	g_hdb->_gfx->getDimensions(string, &width, &height);
 	g_hdb->_gfx->getDimensions(title, &titleWidth, &titleHeight);
 	g_hdb->_gfx->setTextEdges(e1, e2, e3, e4);
@@ -573,8 +609,8 @@ void Window::drawDialog() {
 		if (gfx2) {
 			int xOff = 40 * _pzInfo.active;
 			Tile *gfx = g_hdb->_ai->getPlayerWeaponSelGfx();
-			gfx->drawMasked(kWeaponX - xOff - 1, kWeaponY);
-			gfx2->drawMasked(kWeaponX - xOff, kWeaponY);
+			gfx->drawMasked(_weaponX - xOff - 1, _weaponY);
+			gfx2->drawMasked(_weaponX - xOff, _weaponY);
 			drawWeapon();
 		}
 	}
@@ -742,7 +778,7 @@ void Window::openDialogChoice(const char *title, const char *text, const char *f
 	_dialogChoiceInfo.active = true;
 
 	g_hdb->_gfx->getTextEdges(&e1, &e2, &e3, &e4);
-	g_hdb->_gfx->setTextEdges(kOpenDialogTextLeft, kOpenDialogTextRight, 0, g_hdb->_screenDrawHeight);
+	g_hdb->_gfx->setTextEdges(_openDialogTextLeft, _openDialogTextRight, 0, g_hdb->_screenDrawHeight);
 	g_hdb->_gfx->getDimensions(text, &width, &height);
 	g_hdb->_gfx->getDimensions(title, &titleWidth, &titleHeight);
 
@@ -805,11 +841,11 @@ void Window::drawDialogChoice() {
 	}
 
 	g_hdb->_gfx->getTextEdges(&e1, &e2, &e3, &e4);
-	g_hdb->_gfx->setTextEdges(_dialogChoiceInfo.x + 10, kOpenDialogTextRight, 0, g_hdb->_screenDrawHeight);
+	g_hdb->_gfx->setTextEdges(_dialogChoiceInfo.x + 10, _openDialogTextRight, 0, g_hdb->_screenDrawHeight);
 	g_hdb->_gfx->setCursor(0, _dialogChoiceInfo.y - 7);
 	if (_dialogChoiceInfo.title)
 		g_hdb->_gfx->drawText(_dialogChoiceInfo.title);
-	g_hdb->_gfx->setTextEdges(_dialogChoiceInfo.x + 16, kOpenDialogTextRight, 0, g_hdb->_screenDrawHeight);
+	g_hdb->_gfx->setTextEdges(_dialogChoiceInfo.x + 16, _openDialogTextRight, 0, g_hdb->_screenDrawHeight);
 	g_hdb->_gfx->setCursor(0, _dialogChoiceInfo.y + 16);
 	if (_dialogChoiceInfo.text)
 		g_hdb->_gfx->drawText(_dialogChoiceInfo.text);
@@ -889,7 +925,7 @@ void Window::openMessageBar(const char *title, int time) {
 	strcpy(_msgInfo.title, title);
 
 	g_hdb->_gfx->getTextEdges(&e1, &e2, &e3, &e4);
-	g_hdb->_gfx->setTextEdges(kDialogTextLeft, kDialogTextRight, 0, g_hdb->_screenDrawHeight);
+	g_hdb->_gfx->setTextEdges(_dialogTextLeft, _dialogTextRight, 0, g_hdb->_screenDrawHeight);
 	g_hdb->_gfx->getDimensions(title, &width, &height);
 	g_hdb->_gfx->setTextEdges(e1, e2, e3, e4);
 
@@ -953,7 +989,7 @@ void Window::nextMsgQueued() {
 	_msgInfo.timer = (_msgQueueWait[0] * kGameFPS);
 
 	g_hdb->_gfx->getTextEdges(&e1, &e2, &e3, &e4);
-	g_hdb->_gfx->setTextEdges(kDialogTextLeft, kDialogTextRight, 0, g_hdb->_screenDrawHeight);
+	g_hdb->_gfx->setTextEdges(_dialogTextLeft, _dialogTextRight, 0, g_hdb->_screenDrawHeight);
 	g_hdb->_gfx->getDimensions(_msgInfo.title, &width, &height);
 	g_hdb->_gfx->setTextEdges(e1, e2, e3, e4);
 
@@ -1006,15 +1042,15 @@ void Window::drawInventory() {
 
 		e->standdownGfx[0]->drawMasked(drawX, drawY);
 
-		drawX += kInvItemSpaceX;
-		if (drawX >= baseX + (kInvItemSpaceX * kInvItemPerLine)) {
+		drawX += _invItemSpaceX;
+		if (drawX >= baseX + (_invItemSpaceX * _invItemPerLine)) {
 			drawX = baseX;
-			drawY += kInvItemSpaceY;
+			drawY += _invItemSpaceY;
 		}
 	}
 
 	// Draw the Gem
-	drawY = _invWinInfo.y + kInvItemSpaceY * 4 - 8;
+	drawY = _invWinInfo.y + _invItemSpaceY * 4 - 8;
 	drawX = baseX - 8;
 	_gemGfx->drawMasked(drawX, drawY);
 
@@ -1027,7 +1063,7 @@ void Window::drawInventory() {
 	// Draw the mini monkeystone
 	mstones = g_hdb->_ai->getMonkeystoneAmount();
 	if (mstones) {
-		drawX = baseX + kInvItemSpaceX * 2 - 8;
+		drawX = baseX + _invItemSpaceX * 2 - 8;
 		_mstoneGfx->drawMasked(drawX, drawY + 8);
 
 		// Draw the monkeystone amount
@@ -1042,13 +1078,13 @@ void Window::drawInventory() {
 			_invWinInfo.selection = 0;
 
 		// Draw the Inventory Select Cursor
-		drawX = baseX + (_invWinInfo.selection % kInvItemPerLine) * kInvItemSpaceX;
-		drawY = _invWinInfo.y + (_invWinInfo.selection / kInvItemPerLine) * kInvItemSpaceY;
+		drawX = baseX + (_invWinInfo.selection % _invItemPerLine) * _invItemSpaceX;
+		drawY = _invWinInfo.y + (_invWinInfo.selection / _invItemPerLine) * _invItemSpaceY;
 		_gfxInvSelect->drawMasked(drawX, drawY);
 
 		if (sel) {
 			int centerX = baseX - 4 + (g_hdb->_screenWidth - baseX) / 2;
-			drawY = _invWinInfo.y + (kInvItemSpaceY * 4) + 16;
+			drawY = _invWinInfo.y + (_invItemSpaceY * 4) + 16;
 			g_hdb->_gfx->setCursor(centerX - g_hdb->_gfx->stringLength(sel->printedName) / 2, drawY);
 			g_hdb->_gfx->drawText(sel->printedName);
 		}
@@ -1057,12 +1093,12 @@ void Window::drawInventory() {
 
 void Window::checkInvSelect(int x, int y) {
 	if (x >= _invWinInfo.x && x < _invWinInfo.x + _invWinInfo.width && y >= _invWinInfo.y && y < _invWinInfo.y + _invWinInfo.height) {
-		int xc = (x - _invWinInfo.x) / kInvItemSpaceX;
-		int yc = (y - _invWinInfo.y) / kInvItemSpaceY;
-		if (yc * kInvItemPerLine + xc > g_hdb->_ai->getInvAmount())
+		int xc = (x - _invWinInfo.x) / _invItemSpaceX;
+		int yc = (y - _invWinInfo.y) / _invItemSpaceY;
+		if (yc * _invItemPerLine + xc > g_hdb->_ai->getInvAmount())
 			return;
 
-		_invWinInfo.selection = yc * kInvItemPerLine + xc;
+		_invWinInfo.selection = yc * _invItemPerLine + xc;
 
 		// If this is a weapon, choose it
 		AIType t = g_hdb->_ai->getInvItemType(_invWinInfo.selection);
@@ -1191,7 +1227,7 @@ void Window::drawDeliveries() {
 			if (_dlvsInfo.go2) {
 				if (_dlvsInfo.delay2 < g_hdb->getTimeSlice()) {
 					// Draw TO
-					_gfxArrowTo->drawMasked(_dlvsInfo.x + kDlvItemSpaceX * _dlvsInfo.selected + 8, drawY + kTileHeight);
+					_gfxArrowTo->drawMasked(_dlvsInfo.x + _dlvItemSpaceX * _dlvsInfo.selected + 8, drawY + kTileHeight);
 
 					g_hdb->_gfx->setCursor(centerX - g_hdb->_gfx->stringLength("to") / 2, g_hdb->_window->_dlvItemTextY + 12);
 					g_hdb->_gfx->drawText("to");
@@ -1236,10 +1272,10 @@ void Window::drawDeliveries() {
 				g_hdb->_gfx->drawText(d->destTextName);
 			}
 
-			drawX += kDlvItemSpaceX;
+			drawX += _dlvItemSpaceX;
 			if (drawX >= g_hdb->_screenWidth) {
 				drawX = baseX;
-				drawY += kDlvItemSpaceY + 8;
+				drawY += _dlvItemSpaceY + 8;
 			}
 		}
 	}
@@ -1252,8 +1288,8 @@ void Window::drawDeliveries() {
 		int dx, dy, rowtwo;
 
 		rowtwo = _dlvsInfo.selected > 2;
-		dx = 8 + _dlvsInfo.x + kDlvItemSpaceX * (_dlvsInfo.selected % 3);
-		dy = _dlvsInfo.y + kTileHeight + (kDlvItemSpaceY + 8) * rowtwo;
+		dx = 8 + _dlvsInfo.x + _dlvItemSpaceX * (_dlvsInfo.selected % 3);
+		dy = _dlvsInfo.y + kTileHeight + (_dlvItemSpaceY + 8) * rowtwo;
 		_gfxArrowTo->drawMasked(dx, dy);
 	}
 
@@ -1279,9 +1315,9 @@ void Window::checkDlvSelect(int x, int y) {
 
 	// Click on a Delivery to select it for inspection?
 	if (x >= _dlvsInfo.x && x < _dlvsInfo.x + _dlvsInfo.width && y >= _dlvsInfo.y && y < _dlvsInfo.y + _dlvsInfo.height) {
-		int xc = (x - _dlvsInfo.x) / kDlvItemSpaceX;
-		int yc = (y - _dlvsInfo.y) / kDlvItemSpaceY;
-		int value = yc * kDlvItemPerLine + xc;
+		int xc = (x - _dlvsInfo.x) / _dlvItemSpaceX;
+		int yc = (y - _dlvsInfo.y) / _dlvItemSpaceY;
+		int value = yc * _dlvItemPerLine + xc;
 		if (value < amt)
 			setSelectedDelivery(value);
 	}
@@ -1357,7 +1393,7 @@ void Window::drawPanicZone() {
 			_pzInfo.y1++;
 			_pzInfo.x2 += _pzInfo.yv;
 			_pzInfo.y2--;
-			if (_pzInfo.x1 > kPanicXStop) {
+			if (_pzInfo.x1 > _panicXStop) {
 				_pzInfo.timer = 30;
 				_pzInfo.sequence++;
 			}
@@ -1395,7 +1431,7 @@ void Window::drawPanicZone() {
 	case PANICZONE_COUNTDOWN:
 		{
 			static int last_seconds = 0, seconds = 0;
-			_pzInfo.gfxFace[seconds & 1]->drawMasked(kPanicZoneFaceX, kPanicZoneFaceY);
+			_pzInfo.gfxFace[seconds & 1]->drawMasked(_panicZoneFaceX, kPanicZoneFaceY);
 
 			// make knocking timer sound
 			if (last_seconds != seconds)
@@ -1404,10 +1440,10 @@ void Window::drawPanicZone() {
 			last_seconds = seconds;
 			seconds = _pzInfo.timer - g_hdb->getTime();
 			if (seconds >= 10) {
-				_pzInfo.gfxNumber[seconds / 10]->drawMasked(kPanicZoneFaceX, kPanicZoneFaceY + 32);
-				_pzInfo.gfxNumber[seconds % 10]->drawMasked(kPanicZoneFaceX + 16, kPanicZoneFaceY + 32);
+				_pzInfo.gfxNumber[seconds / 10]->drawMasked(_panicZoneFaceX, kPanicZoneFaceY + 32);
+				_pzInfo.gfxNumber[seconds % 10]->drawMasked(_panicZoneFaceX + 16, kPanicZoneFaceY + 32);
 			} else
-				_pzInfo.gfxNumber[seconds]->drawMasked(kPanicZoneFaceX + 8, kPanicZoneFaceY + 32);
+				_pzInfo.gfxNumber[seconds]->drawMasked(_panicZoneFaceX + 8, kPanicZoneFaceY + 32);
 
 			// time until death!
 			if (!seconds) {
diff --git a/engines/hdb/window.h b/engines/hdb/window.h
index 0597437..682a4e4 100644
--- a/engines/hdb/window.h
+++ b/engines/hdb/window.h
@@ -26,21 +26,7 @@
 namespace HDB {
 
 enum {
-	kDialogTextLeft = 64,
-	kDialogTextRight = (kDialogTextLeft + kTileWidth * 9),
-	kOpenDialogTextLeft = kDialogTextLeft,
-	kOpenDialogTextRight = (kDialogTextRight + kTileWidth * 2),
 	kMaxMsgQueue = 10,
-	kWeaponX = (480 - 34),
-	kWeaponY = 2,
-	kInvItemSpaceX = 48,
-	kInvItemSpaceY = 40,
-	kInvItemPerLine = 3,
-	kDlvItemSpaceX = 48,
-	kDlvItemSpaceY = (kTileHeight * 2 + 16),
-	kDlvItemPerLine = 3,
-	kPanicXStop = 480 / 3,
-	kPanicZoneFaceX = 480 - 32,
 	kPanicZoneFaceY = 5,
 	kNumCrazy = 37
 };
@@ -286,12 +272,24 @@ public:
 	void closeTextOut();
 
 	// Platform-specific Constants
+	int _weaponX, _weaponY;
+	int _invItemSpace, _invItemSpaceX, _invItemSpaceY;
+	int _invItemPerLine;
+	int _dlvItemSpaceX;
+	int _dlvItemSpaceY;
+	int _dlvItemPerLine;
 	int _dlvItemTextY;
+	int _dialogTextLeft;
+	int _dialogTextRight;
+	int _openDialogTextLeft;
+	int _openDialogTextRight;
 	int _textOutCenterX;
 	int _pauseY;
 	int _tryY1;	// TRY
 	int _tryY2;			// AGAIN
 	int _tryRestartY;	// (ok)
+	int _panicXStop;
+	int _panicZoneFaceX;
 
 	Tile *getGemGfx() {
 		return _gemGfx;


Commit: e3ec3480ae6078194feef75b43f98deb2dfbda24
    https://github.com/scummvm/scummvm/commit/e3ec3480ae6078194feef75b43f98deb2dfbda24
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:31+02:00

Commit Message:
HDB: Fix warning

Changed paths:
    engines/hdb/menu.h


diff --git a/engines/hdb/menu.h b/engines/hdb/menu.h
index c9b1b8d..2bf3206 100644
--- a/engines/hdb/menu.h
+++ b/engines/hdb/menu.h
@@ -64,7 +64,7 @@ enum {
 
 	kScreenFade = 512,
 	kNebulaCount = 7,
-	kMaxStars = 10,
+	kMaxStars = 10
 };
 
 struct Star {


Commit: 345c017ff7c2bafc800c3054ade8adda3eccffa1
    https://github.com/scummvm/scummvm/commit/345c017ff7c2bafc800c3054ade8adda3eccffa1
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:31+02:00

Commit Message:
HDB: Section off WIN32 specific-code

Changed paths:
    engines/hdb/ai-funcs.cpp
    engines/hdb/input.cpp
    engines/hdb/menu.cpp


diff --git a/engines/hdb/ai-funcs.cpp b/engines/hdb/ai-funcs.cpp
index abdcd6e..7faa888 100644
--- a/engines/hdb/ai-funcs.cpp
+++ b/engines/hdb/ai-funcs.cpp
@@ -2224,11 +2224,14 @@ void AI::getItemSound(AIType type) {
 	case ITEM_ENV_RED:
 	case ITEM_ENV_BLUE:
 	case ITEM_ENV_GREEN:
-		if (g_hdb->_sound->getVoiceStatus())
-			g_hdb->_sound->playVoice(GUY_GOT_SOMETHING, 1);
-		else
-			g_hdb->_sound->playSound(SND_GET_THING);
-		break;
+		if (!g_hdb->isPPC()) {
+			if (g_hdb->_sound->getVoiceStatus())
+				g_hdb->_sound->playVoice(GUY_GOT_SOMETHING, 1);
+			else
+				g_hdb->_sound->playSound(SND_GET_THING);
+			break;
+		}
+		// fall through if it is PPC
 	default: g_hdb->_sound->playSound(SND_GET_THING);
 	}
 }
diff --git a/engines/hdb/input.cpp b/engines/hdb/input.cpp
index e6a0e9c..72e1111 100644
--- a/engines/hdb/input.cpp
+++ b/engines/hdb/input.cpp
@@ -164,6 +164,10 @@ void Input::stylusDown(int x, int y) {
 			return;
 		}
 
+		if (g_hdb->isPPC()) {
+			warning("STUB: Add PPC code for Deliveries\Inventory");
+		}
+
 		// Is Dialog Active?
 		if (g_hdb->_window->dialogActive()) {
 			g_hdb->_window->closeDialog();
@@ -207,9 +211,11 @@ void Input::stylusDown(int x, int y) {
 		worldX = ((worldX + x) / kTileWidth) * kTileWidth;
 		worldY = ((worldY + y) / kTileHeight) * kTileHeight;
 
-		// Don't allow a click into INV/DELIVERIES area to go into the world
-		if (x >= (g_hdb->_screenWidth - 32 * 5))
-			return;
+		if (!g_hdb->isPPC()) {
+			// Don't allow a click into INV/DELIVERIES area to go into the world
+			if (x >= (g_hdb->_screenWidth - 32 * 5))
+				return;
+		}
 
 		// Toggle Walk Speed if we clicked Player
 		int nx, ny;
diff --git a/engines/hdb/menu.cpp b/engines/hdb/menu.cpp
index dd88c4a..6302427 100644
--- a/engines/hdb/menu.cpp
+++ b/engines/hdb/menu.cpp
@@ -706,18 +706,19 @@ void Menu::drawMenu() {
 
 			drawSlider(_optionsX, _optionsY + kOptionLineSPC * 2 + 20, g_hdb->_sound->getSFXVolume());
 
-			// Voices ON or OFF
-			drawToggle(_optionsX, _optionsY + kOptionLineSPC * 4 + 20, g_hdb->_sound->getVoiceStatus());
-
-			if (!g_hdb->isVoiceless()) {
-				g_hdb->_gfx->setCursor(_optionsX + kOptionSPC + 24, _optionsY + kOptionLineSPC * 4 + 24);
-				if (!g_hdb->_sound->getVoiceStatus())
-					g_hdb->_gfx->drawText("Voice Dialogue OFF");
-				else
-					g_hdb->_gfx->drawText("Voice Dialogue ON");
+			if (!g_hdb->isPPC()) {
+				// Voices ON or OFF
+				drawToggle(_optionsX, _optionsY + kOptionLineSPC * 4 + 20, g_hdb->_sound->getVoiceStatus());
+
+				if (!g_hdb->isVoiceless()) {
+					g_hdb->_gfx->setCursor(_optionsX + kOptionSPC + 24, _optionsY + kOptionLineSPC * 4 + 24);
+					if (!g_hdb->_sound->getVoiceStatus())
+						g_hdb->_gfx->drawText("Voice Dialogue OFF");
+					else
+						g_hdb->_gfx->drawText("Voice Dialogue ON");
+				}
 			}
 
-
 			// title logo
 			_titleLogo->drawMasked(centerPic(_titleLogo), _rocketY + _mTitleY);
 			_menuBackoutGfx->drawMasked(_backoutX, g_hdb->_menu->_backoutY);
@@ -767,8 +768,10 @@ void Menu::drawMenu() {
 			_modeLoadGfx->drawMasked(centerPic(_modeLoadGfx), _oBannerY);
 			_menuBackoutGfx->drawMasked(_backoutX, g_hdb->_menu->_backoutY);
 
-			if (_saveGames[kAutoSaveSlot].seconds)
-				_vortexian[anim]->drawMasked(_vortSaveX, _vortSaveY);
+			if (!g_hdb->isPPC()) {
+				if (_saveGames[kAutoSaveSlot].seconds)
+					_vortexian[anim]->drawMasked(_vortSaveX, _vortSaveY);
+			}
 
 			if (g_hdb->isPPC()) {
 				g_hdb->_gfx->setCursor(_vortSaveTextX, _vortSaveY);
@@ -1086,14 +1089,17 @@ void Menu::drawTitle() {
 		// exhaust
 		if (_rocketEx < 5) {
 			_rocketEx1->drawMasked(_mRocketX + _mRocketEXHX, _rocketY + _mRocketYBottom);
-			_rocketEx2->drawMasked(_mRocketX + _mRocketEXHX2, _rocketY + _mRocketYBottom);
+			if (!g_hdb->isPPC())
+				_rocketEx2->drawMasked(_mRocketX + _mRocketEXHX2, _rocketY + _mRocketYBottom);
 		} else if (_rocketEx >= 5 && _rocketEx < 10) {
 			_rocketEx2->drawMasked(_mRocketX + _mRocketEXHX, _rocketY + _mRocketYBottom);
-			_rocketEx1->drawMasked(_mRocketX + _mRocketEXHX2, _rocketY + _mRocketYBottom);
+			if (!g_hdb->isPPC())
+				_rocketEx1->drawMasked(_mRocketX + _mRocketEXHX2, _rocketY + _mRocketYBottom);
 		} else {
 			_rocketEx = 0;
 			_rocketEx1->drawMasked(_mRocketX + _mRocketEXHX, _rocketY + _mRocketYBottom);
-			_rocketEx2->drawMasked(_mRocketX + _mRocketEXHX2, _rocketY + _mRocketYBottom);
+			if (!g_hdb->isPPC())
+				_rocketEx2->drawMasked(_mRocketX + _mRocketEXHX2, _rocketY + _mRocketYBottom);
 		}
 		_rocketEx++;
 
@@ -1630,14 +1636,20 @@ void Menu::drawRocketAndSelections() {
 	// exhaust
 	if (_rocketEx < 5) {
 		_rocketEx1->drawMasked(_mRocketX + _mRocketEXHX, _rocketY + _mRocketYBottom);
-		_rocketEx2->drawMasked(_mRocketX + _mRocketEXHX2, _rocketY + _mRocketYBottom);
+		if (!g_hdb->isPPC()) {
+			_rocketEx2->drawMasked(_mRocketX + _mRocketEXHX2, _rocketY + _mRocketYBottom);
+		}
 	} else if (_rocketEx >= 5 && _rocketEx < 10) {
 		_rocketEx2->drawMasked(_mRocketX + _mRocketEXHX, _rocketY + _mRocketYBottom);
-		_rocketEx1->drawMasked(_mRocketX + _mRocketEXHX2, _rocketY + _mRocketYBottom);
+		if (!g_hdb->isPPC()) {
+			_rocketEx1->drawMasked(_mRocketX + _mRocketEXHX2, _rocketY + _mRocketYBottom);
+		}
 	} else {
 		_rocketEx = 0;
 		_rocketEx1->drawMasked(_mRocketX + _mRocketEXHX, _rocketY + _mRocketYBottom);
-		_rocketEx2->drawMasked(_mRocketX + _mRocketEXHX2, _rocketY + _mRocketYBottom);
+		if (!g_hdb->isPPC()) {
+			_rocketEx2->drawMasked(_mRocketX + _mRocketEXHX2, _rocketY + _mRocketYBottom);
+		}
 	}
 	_rocketEx++;
 


Commit: 89e4c9f5a9b919b020f37681fc30f08c458b2770
    https://github.com/scummvm/scummvm/commit/89e4c9f5a9b919b020f37681fc30f08c458b2770
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:31+02:00

Commit Message:
HDB: Integrate PPC version of Window

Changed paths:
    engines/hdb/input.cpp
    engines/hdb/window.cpp
    engines/hdb/window.h


diff --git a/engines/hdb/input.cpp b/engines/hdb/input.cpp
index 72e1111..be34fad 100644
--- a/engines/hdb/input.cpp
+++ b/engines/hdb/input.cpp
@@ -165,7 +165,7 @@ void Input::stylusDown(int x, int y) {
 		}
 
 		if (g_hdb->isPPC()) {
-			warning("STUB: Add PPC code for Deliveries\Inventory");
+			warning("STUB: Add PPC code for Deliveries\\Inventory");
 		}
 
 		// Is Dialog Active?
diff --git a/engines/hdb/window.cpp b/engines/hdb/window.cpp
index 2fe4409..0d74c59 100644
--- a/engines/hdb/window.cpp
+++ b/engines/hdb/window.cpp
@@ -117,10 +117,16 @@ Window::~Window() {
 	delete _gfxInvSelect;
 	delete _gfxHandright;
 
-	delete _gfxInfobar;
-	delete _gfxDarken;
-	delete _gfxPausePlaque;
-	delete _mstoneGfx;
+	if (g_hdb->isPPC()) {
+		delete _gfxInfobar;
+		delete _gfxDarken;
+		delete _gfxPausePlaque;
+		delete _mstoneGfx;
+	} else {
+		delete _gfxResources;
+		delete _gfxDeliveries;
+	}
+
 
 	delete _gemGfx;
 }
@@ -167,27 +173,36 @@ bool Window::init() {
 	_gfxInvSelect = g_hdb->_gfx->loadPic(INVENTORY_NORMAL);
 	_gfxHandright = g_hdb->_gfx->loadPic(MENU_HAND_POINTRIGHT);
 
-	_gfxInfobar = g_hdb->_gfx->loadPic(PIC_INFOBAR);
-	_gfxDarken = g_hdb->_gfx->loadPic(SCREEN_DARKEN);
-	_gfxPausePlaque = g_hdb->_gfx->loadPic(PAUSE_PLAQUE);
-	_mstoneGfx = g_hdb->_gfx->loadPic(MINI_MSTONE);
+	if (g_hdb->isPPC()) {
 
-	_infobarDimmed = 0;
+		_gfxResources = g_hdb->_gfx->loadPic(MENU_TITLE_RESOURCES);
+		_gfxDeliveries = g_hdb->_gfx->loadPic(MENU_TITLE_DELIVERIES);
 
-	_invWinInfo.width = _invItemSpaceX * 3;
-	_invWinInfo.height = _invItemSpaceY * 4;
+		_invWinInfo.width = g_hdb->_screenWidth - 32;
+		_invWinInfo.height = 112;
 
-	warning("FIXME: Fully separate the PC and PPC versions of Window");
+		_dlvsInfo.width = g_hdb->_screenWidth - 48;
+		_dlvsInfo.height = 160;
+		_dlvsInfo.selected = 0;
 
-	if (!g_hdb->isPPC())
+	} else {
+		_gfxInfobar = g_hdb->_gfx->loadPic(PIC_INFOBAR);
+		_gfxDarken = g_hdb->_gfx->loadPic(SCREEN_DARKEN);
+		_gfxPausePlaque = g_hdb->_gfx->loadPic(PAUSE_PLAQUE);
+		_mstoneGfx = g_hdb->_gfx->loadPic(MINI_MSTONE);
+
+		_infobarDimmed = 0;
+
+		_invWinInfo.width = _invItemSpaceX * 3;
+		_invWinInfo.height = _invItemSpaceY * 4;
 		_invWinInfo.x = g_hdb->_screenWidth - _gfxInfobar->_width + 16;
-	_invWinInfo.y = 40;
+		_invWinInfo.y = 40;
 
-	_dlvsInfo.width = _invItemSpaceX * 3;
-	_dlvsInfo.height = _invItemSpaceY * 4;
-	if (!g_hdb->isPPC())
+		_dlvsInfo.width = _invItemSpaceX * 3;
+		_dlvsInfo.height = _invItemSpaceY * 4;
 		_dlvsInfo.x = (g_hdb->_screenWidth - _gfxInfobar->_width) + 16;
-	_dlvsInfo.y = 272;
+		_dlvsInfo.y = 272;
+	}
 
 	_gemGfx = NULL;
 
@@ -486,10 +501,14 @@ void Window::restartSystem() {
 }
 
 void Window::setInfobarDark(int value) {
+	if (g_hdb->isPPC())
+		return;
 	_infobarDimmed = value;
 }
 
 void Window::drawPause() {
+	if (g_hdb->isPPC())
+		return;
 	if (g_hdb->getPause())
 		_gfxPausePlaque->drawMasked(g_hdb->_screenDrawWidth / 2 - _gfxPausePlaque->_width / 2, g_hdb->_window->_pauseY);
 }
@@ -503,6 +522,16 @@ void Window::checkPause(int x, int y) {
 }
 
 void Window::drawWeapon() {
+	if (!g_hdb->isPPC())
+		return;
+
+	int	 xoff = 40 * _pzInfo.active;
+	char word[3];
+	if (ITEM_CLUB != g_hdb->_ai->getPlayerWeapon()) {
+		sprintf(word, "%d", g_hdb->_ai->getGemAmount());
+		g_hdb->_gfx->setCursor(_weaponX + 4 - xoff, _weaponY + kTileHeight + 2);
+		g_hdb->_gfx->drawText(word);
+	}
 }
 
 void Window::chooseWeapon(AIType wType) {
@@ -1015,78 +1044,159 @@ void Window::closeMsg() {
 
 void Window::drawInventory() {
 	int baseX, drawX, drawY;
-	// static uint32 timer = g_hdb->getTimeSlice() + 300; // unused
+	static uint32 timer = g_hdb->getTimeSlice() + 300; // unused
 	AIEntity *e, *sel;
 	char string[8];
 	int gems, mstones;
 
-	// INFOBAR blit - only once per frame
-	// note: if 2, don't draw ANY info at all
-	if (_infobarDimmed > 1)
-		return;
+	if (g_hdb->isPPC()) {
+		if (!_invWinInfo.active)
+			return;
 
-	_gfxInfobar->draw(g_hdb->_screenWidth - _gfxInfobar->_width, 0);
+		drawBorder(_invWinInfo.x, _invWinInfo.y, _invWinInfo.width, _invWinInfo.height, false);
+
+		_gfxTitleL->drawMasked(_invWinInfo.x, _invWinInfo.y - 10);
+		int blocks = _gfxResources->_width / 16;
+		for (int i = 0; i < blocks; i++)
+			_gfxTitleM->drawMasked(_invWinInfo.x + 16 * (i + 1), _invWinInfo.y - 10);
+		_gfxTitleR->drawMasked(_invWinInfo.x + 16 * (blocks + 1), _invWinInfo.y - 10);
 
-	baseX = drawX = _invWinInfo.x;
-	drawY = _invWinInfo.y;
+		_gfxResources->drawMasked(_invWinInfo.x + 16, _invWinInfo.y - 6);
 
-	// Draw Inv Items
-	sel = NULL;
-	if (_invWinInfo.selection >= g_hdb->_ai->getInvAmount())
-		_invWinInfo.selection = g_hdb->_ai->getInvAmount();
+		//
+		// blink the INV hand...
+		//
+		if (g_hdb->getTimeSlice() > timer - 150)
+			_gfxHandright->drawMasked(g_hdb->_screenWidth - _gfxHandright->_width, _invWinInfo.y + _invItemSpace * 2);
 
-	for (int inv = 0; inv < g_hdb->_ai->getInvAmount(); inv++) {
-		e = g_hdb->_ai->getInvItem(inv);
-		if (inv == _invWinInfo.selection)
-			sel = e;
+		if (timer < g_hdb->getTimeSlice())
+			timer = g_hdb->getTimeSlice() + 300;
 
-		e->standdownGfx[0]->drawMasked(drawX, drawY);
+		baseX = drawX = _invWinInfo.x + 16;
+		drawY = _invWinInfo.y + 16;
 
-		drawX += _invItemSpaceX;
-		if (drawX >= baseX + (_invItemSpaceX * _invItemPerLine)) {
-			drawX = baseX;
-			drawY += _invItemSpaceY;
+		// Draw Inv Items
+		sel = NULL;
+		if (_invWinInfo.selection >= g_hdb->_ai->getInvAmount())
+			_invWinInfo.selection = g_hdb->_ai->getInvAmount() - 1;
+
+		for (int inv = 0; inv < g_hdb->_ai->getInvAmount(); inv++) {
+			e = g_hdb->_ai->getInvItem(inv);
+			if (inv == _invWinInfo.selection)
+				sel = e;
+
+			e->standdownGfx[0]->drawMasked(drawX, drawY);
+
+			drawX += _invItemSpace;
+			if (drawX >= baseX + (_invItemSpace * _invItemPerLine)) {
+				drawX = baseX;
+				drawY += _invItemSpace;
+			}
 		}
-	}
 
-	// Draw the Gem
-	drawY = _invWinInfo.y + _invItemSpaceY * 4 - 8;
-	drawX = baseX - 8;
-	_gemGfx->drawMasked(drawX, drawY);
-
-	// Draw the Gem Amount
-	gems = g_hdb->_ai->getGemAmount();
-	sprintf(string, "%d", gems);
-	g_hdb->_gfx->setCursor(drawX + 32, drawY + 8);
-	g_hdb->_gfx->drawText(string);
-
-	// Draw the mini monkeystone
-	mstones = g_hdb->_ai->getMonkeystoneAmount();
-	if (mstones) {
-		drawX = baseX + _invItemSpaceX * 2 - 8;
-		_mstoneGfx->drawMasked(drawX, drawY + 8);
-
-		// Draw the monkeystone amount
-		sprintf(string, "%d", mstones);
-		g_hdb->_gfx->setCursor(drawX + 28, drawY + 8);
+		// Draw the gems
+		drawY = _invWinInfo.y + 8 + _invItemSpace * 2;
+		drawX = baseX + _invItemSpace * 4 + 8;
+		_gemGfx->drawMasked(drawX, drawY);
+		gems = g_hdb->_ai->getGemAmount();
+		sprintf(string, "%d", gems);
+		g_hdb->_gfx->setCursor(drawX + 22, drawY + 8);
 		g_hdb->_gfx->drawText(string);
-	}
 
-	// If you have an inventory, draw the selection cursor
-	if (g_hdb->_ai->getInvAmount()) {
-		if (_invWinInfo.selection < 0)
-			_invWinInfo.selection = 0;
-
-		// Draw the Inventory Select Cursor
-		drawX = baseX + (_invWinInfo.selection % _invItemPerLine) * _invItemSpaceX;
-		drawY = _invWinInfo.y + (_invWinInfo.selection / _invItemPerLine) * _invItemSpaceY;
-		_gfxInvSelect->drawMasked(drawX, drawY);
-
-		if (sel) {
-			int centerX = baseX - 4 + (g_hdb->_screenWidth - baseX) / 2;
-			drawY = _invWinInfo.y + (_invItemSpaceY * 4) + 16;
-			g_hdb->_gfx->setCursor(centerX - g_hdb->_gfx->stringLength(sel->printedName) / 2, drawY);
-			g_hdb->_gfx->drawText(sel->printedName);
+		// if you have an inventory, draw the selection cursor
+		if (g_hdb->_ai->getInvAmount()) {
+			if (_invWinInfo.selection < 0)
+				_invWinInfo.selection = 0;
+
+			// Draw the inventory select cursor
+			if (_invWinInfo.selection > 4)
+				drawX = baseX + (_invWinInfo.selection - 5) * _invItemSpace;
+			else
+				drawX = baseX + _invWinInfo.selection * _invItemSpace;
+
+			if (_invWinInfo.selection < 5)
+				drawY = _invWinInfo.y + 16;
+			else
+				drawY = _invWinInfo.y + 16 + _invItemSpace;
+
+			_gfxInvSelect->drawMasked(drawX, drawY);
+
+			// Draw the name of the inventory item
+			if (sel) {
+				drawY = _invWinInfo.y + 8 + _invItemSpace * 2;
+				g_hdb->_gfx->setCursor(baseX, drawY + 8);
+				g_hdb->_gfx->drawText(sel->printedName);
+			}
+		}
+	} else {
+		// INFOBAR blit - only once per frame
+		// note: if 2, don't draw ANY info at all
+		if (_infobarDimmed > 1)
+			return;
+
+		_gfxInfobar->draw(g_hdb->_screenWidth - _gfxInfobar->_width, 0);
+
+		baseX = drawX = _invWinInfo.x;
+		drawY = _invWinInfo.y;
+
+		// Draw Inv Items
+		sel = NULL;
+		if (_invWinInfo.selection >= g_hdb->_ai->getInvAmount())
+			_invWinInfo.selection = g_hdb->_ai->getInvAmount() - 1;
+
+		for (int inv = 0; inv < g_hdb->_ai->getInvAmount(); inv++) {
+			e = g_hdb->_ai->getInvItem(inv);
+			if (inv == _invWinInfo.selection)
+				sel = e;
+
+			e->standdownGfx[0]->drawMasked(drawX, drawY);
+
+			drawX += _invItemSpaceX;
+			if (drawX >= baseX + (_invItemSpaceX * _invItemPerLine)) {
+				drawX = baseX;
+				drawY += _invItemSpaceY;
+			}
+		}
+
+		// Draw the Gem
+		drawY = _invWinInfo.y + _invItemSpaceY * 4 - 8;
+		drawX = baseX - 8;
+		_gemGfx->drawMasked(drawX, drawY);
+
+		// Draw the Gem Amount
+		gems = g_hdb->_ai->getGemAmount();
+		sprintf(string, "%d", gems);
+		g_hdb->_gfx->setCursor(drawX + 32, drawY + 8);
+		g_hdb->_gfx->drawText(string);
+
+		// Draw the mini monkeystone
+		mstones = g_hdb->_ai->getMonkeystoneAmount();
+		if (mstones) {
+			drawX = baseX + _invItemSpaceX * 2 - 8;
+			_mstoneGfx->drawMasked(drawX, drawY + 8);
+
+			// Draw the monkeystone amount
+			sprintf(string, "%d", mstones);
+			g_hdb->_gfx->setCursor(drawX + 28, drawY + 8);
+			g_hdb->_gfx->drawText(string);
+		}
+
+		// If you have an inventory, draw the selection cursor
+		if (g_hdb->_ai->getInvAmount()) {
+			if (_invWinInfo.selection < 0)
+				_invWinInfo.selection = 0;
+
+			// Draw the Inventory Select Cursor
+			drawX = baseX + (_invWinInfo.selection % _invItemPerLine) * _invItemSpaceX;
+			drawY = _invWinInfo.y + (_invWinInfo.selection / _invItemPerLine) * _invItemSpaceY;
+			_gfxInvSelect->drawMasked(drawX, drawY);
+
+			if (sel) {
+				int centerX = baseX - 4 + (g_hdb->_screenWidth - baseX) / 2;
+				drawY = _invWinInfo.y + (_invItemSpaceY * 4) + 16;
+				g_hdb->_gfx->setCursor(centerX - g_hdb->_gfx->stringLength(sel->printedName) / 2, drawY);
+				g_hdb->_gfx->drawText(sel->printedName);
+			}
 		}
 	}
 }
@@ -1124,6 +1234,93 @@ void Window::checkInvSelect(int x, int y) {
 	return;
 }
 
+void Window::openInventory() {
+	if (!g_hdb->isPPC())
+		return;
+
+	int	px, py;
+
+	if (_invWinInfo.active)
+		return;
+
+	centerTextOut(g_hdb->getInMapName(), 304, 60 * 3);
+
+	if (!g_hdb->_ai->getInvAmount() && !g_hdb->_ai->getGemAmount()) {
+		if (!g_hdb->_ai->getDeliveriesAmount())
+			openMessageBar("You have nothing.", 3);
+		else
+			openDeliveries(false);
+		return;
+	}
+
+	_invWinInfo.x = (g_hdb->_screenWidth >> 1) - (_invWinInfo.width >> 1) - 8;
+
+	g_hdb->_ai->getPlayerXY(&px, &py);
+	if (py < (g_hdb->_screenHeight >> 1) - 16)
+		_invWinInfo.y = (g_hdb->_screenHeight >> 1) + 16;
+	else
+		_invWinInfo.y = 16;
+
+	g_hdb->_sound->playSound(SND_POP);
+	_invWinInfo.active = true;
+}
+
+bool Window::checkInvClose(int x, int y) {
+	if (!g_hdb->isPPC())
+		return false;
+
+	if (x >= g_hdb->_screenWidth - _gfxHandright->_width &&
+		y >= _invWinInfo.y && y < _invWinInfo.y + _invItemSpace * 3) {
+		closeInv();
+		openDeliveries(0);
+		return true;
+	} else if (x >= _invWinInfo.x && x < _invWinInfo.x + _invWinInfo.width &&
+		y >= _invWinInfo.y && y < _invWinInfo.y + _invWinInfo.height) {
+		int xc = (x - _invWinInfo.x) / _invItemSpace;
+		int yc = (y - _invWinInfo.y) / _invItemSpace;
+		if (yc * 5 + xc > g_hdb->_ai->getInvAmount()) {
+			closeInv();
+			return true;
+		}
+		_invWinInfo.selection = yc * 5 + xc;
+		g_hdb->_sound->playSound(SND_MENU_SLIDER);
+
+		static AIType lastWeaponSelected = AI_NONE;
+		Tile *gfx;
+
+		if (!g_hdb->getActionMode())
+			return false;
+
+		AIType t = g_hdb->_ai->getInvItemType(_invWinInfo.selection);
+		gfx = g_hdb->_ai->getInvItemGfx(_invWinInfo.selection);
+
+		switch (t) {
+		case ITEM_CLUB:
+		case ITEM_ROBOSTUNNER:
+		case ITEM_SLUGSLINGER:
+			g_hdb->_ai->setPlayerWeapon(t, gfx);
+			if (t == lastWeaponSelected) {
+				closeInv();
+				return false;
+			}
+			lastWeaponSelected = t;
+			g_hdb->_sound->playSound(SND_MENU_ACCEPT);
+			return true;
+		}
+		g_hdb->_sound->playSound(SND_CELLHOLDER_USE_REJECT);
+	}
+
+	return false;
+}
+
+void Window::closeInv() {
+	if (!g_hdb->isPPC())
+		return;
+
+	g_hdb->_sound->playSound(SND_DIALOG_CLOSE);
+	_invWinInfo.active = false;
+}
+
 void Window::openDeliveries(bool animate) {
 	// Load Gfx
 	for (int i = 0; i < g_hdb->_ai->getDeliveriesAmount(); i++) {
@@ -1134,6 +1331,19 @@ void Window::openDeliveries(bool animate) {
 			d->destGfx = g_hdb->_gfx->loadTile(d->destGfxName);
 	}
 
+	if (g_hdb->isPPC()) {
+		// calc the X & Y for the window
+		_dlvsInfo.x = (g_hdb->_screenWidth >> 1) - (_dlvsInfo.width >> 1) - 8;
+
+		int px, py;
+
+		g_hdb->_ai->getPlayerXY(&px, &py);
+		if (py < (g_hdb->_screenHeight >> 1) - 16)
+			_dlvsInfo.y = (g_hdb->_screenHeight >> 1);
+		else
+			_dlvsInfo.y = 16;
+	}
+
 	g_hdb->_sound->playSound(SND_POP);
 	_dlvsInfo.animate = animate;
 	_dlvsInfo.delay1 = g_hdb->getTimeSlice() + 500;
@@ -1147,11 +1357,15 @@ void Window::openDeliveries(bool animate) {
 	// Make sure cursor isn't on an empty delivery
 	if (_dlvsInfo.selected >= g_hdb->_ai->getDeliveriesAmount())
 		_dlvsInfo.selected = g_hdb->_ai->getDeliveriesAmount() - 1;
+
+	if (g_hdb->isPPC())
+		_dlvsInfo.active = true;
 }
 
 void Window::drawDeliveries() {
-	//static uint32 timer = g_hdb->getTimeSlice() + 300; //unused
-
+	static uint32 timer = g_hdb->getTimeSlice() + 300; //unused
+	int drawX, drawY, baseX;
+	DlvEnt *d;
 	int crazySounds[kNumCrazy] = {
 		SND_GUI_INPUT,
 		SND_MAIL_PROCESS,
@@ -1192,112 +1406,219 @@ void Window::drawDeliveries() {
 		SND_MANNY_CRASH
 	};
 
-	if (_infobarDimmed > 1)
-		return;
+	if (g_hdb->isPPC()) {
+		if (!_dlvsInfo.active)
+			return;
 
-	int baseX = _dlvsInfo.x;
-	int drawX = _dlvsInfo.x;
-	int drawY = _dlvsInfo.y;
+		// draw the window first
+		drawBorder(_dlvsInfo.x, _dlvsInfo.y, _dlvsInfo.width, _dlvsInfo.height, false);
 
-	if (_dlvsInfo.selected >= g_hdb->_ai->getDeliveriesAmount())
-		_dlvsInfo.selected = g_hdb->_ai->getDeliveriesAmount() - 1;
+		_gfxTitleL->drawMasked(_dlvsInfo.x, _dlvsInfo.y - 10);
+		int blocks = _gfxDeliveries->_width / 16;
+		for (int i = 0; i < blocks; i++)
+			_gfxTitleM->drawMasked(_dlvsInfo.x + 16 * (i + 1), _dlvsInfo.y - 10);
+		_gfxTitleR->drawMasked(_dlvsInfo.x + (blocks + 1) * 16, _dlvsInfo.y - 10);
+
+		_gfxDeliveries->drawMasked(_dlvsInfo.x + 16, _dlvsInfo.y - 6);
 
-	// Draw Delivery Items
-	int inv = 0;
-	for (; inv < g_hdb->_ai->getDeliveriesAmount(); inv++) {
-		int centerX = baseX + (g_hdb->_screenWidth - baseX) / 2;
-		DlvEnt *d = g_hdb->_ai->getDeliveryItem(inv);
-		if (_dlvsInfo.animate && inv == g_hdb->_ai->getDeliveriesAmount() - 1) {
-			if (_dlvsInfo.go1) {
-				if (_dlvsInfo.delay1 < g_hdb->getTimeSlice()) {
-					// Draw Item
-					_gfxIndent->draw(drawX, drawY);
-					if (d->itemGfx)
+		//
+		// blink the DELIVERY hand...
+		//
+		if (g_hdb->_ai->getInvAmount()) {
+			if (g_hdb->getTimeSlice() > timer - 150)
+				_gfxHandright->drawMasked(_dlvsInfo.x + _dlvsInfo.width, _dlvsInfo.y + _invItemSpace * 2);
+
+			if (timer < g_hdb->getTimeSlice())
+				timer = g_hdb->getTimeSlice() + 300;
+		}
+
+		baseX = drawX = _dlvsInfo.x + 16;
+		drawY = _dlvsInfo.y + 16;
+
+		// Draw delivery items
+		int inv;
+		for (inv = 0; inv < g_hdb->_ai->getInvAmount(); inv++) {
+			d = g_hdb->_ai->getDeliveryItem(inv);
+			if (_dlvsInfo.animate && inv == g_hdb->_ai->getDeliveriesAmount() - 1) {
+				if (_dlvsInfo.go1) {
+					if (_dlvsInfo.delay1 < g_hdb->getTimeSlice()) {
+						// draw Item
+						_gfxIndent->draw(drawX, drawY);
 						d->itemGfx->drawMasked(drawX, drawY);
 
-					g_hdb->_gfx->setCursor(centerX - g_hdb->_gfx->stringLength(d->itemTextName) / 2, g_hdb->_window->_dlvItemTextY);
-					g_hdb->_gfx->drawText(d->itemTextName);
-					if (!_dlvsInfo.go2) {
-						_dlvsInfo.go2 = true;
-						_dlvsInfo.delay2 = g_hdb->getTimeSlice() + 500;
+						g_hdb->_gfx->setCursor(drawX, drawY + _invItemSpace * 2 + 20);
+						g_hdb->_gfx->centerPrint(d->itemTextName);
+						if (!_dlvsInfo.go2) {
+							_dlvsInfo.go2 = true;
+							_dlvsInfo.delay2 = g_hdb->getTimeSlice() + 500;
+							g_hdb->_sound->playSound(crazySounds[g_hdb->_rnd->getRandomNumber(kNumCrazy - 1)]);
+						}
+					}
+				}
+				if (_dlvsInfo.go2) {
+					if (_dlvsInfo.delay2 < g_hdb->getTimeSlice()) {
+						// arrow TO...
+						_gfxArrowTo->drawMasked(_dlvsInfo.x + 24 + _invItemSpace * _dlvsInfo.selected, drawY + _invItemSpace);
+
+						g_hdb->_gfx->setCursor(drawX, drawY + _invItemSpace * 2 + 32);
+						g_hdb->_gfx->centerPrint("to");
+						if (!_dlvsInfo.go3) {
+							_dlvsInfo.go3 = true;
+							_dlvsInfo.delay3 = g_hdb->getTimeSlice() + 500;
+							g_hdb->_sound->playSound(crazySounds[g_hdb->_rnd->getRandomNumber(kNumCrazy - 1)]);
+						}
+					}
+				}
+				if (_dlvsInfo.go3) {
+					if (_dlvsInfo.delay3 < g_hdb->getTimeSlice()) {
+						// draw Deliveree
+						_gfxIndent->draw(drawX, drawY + _invItemSpace + 16);
+						d->destGfx->drawMasked(drawX, drawY + _invItemSpace + 16);
+
+						g_hdb->_gfx->setCursor(drawX, drawY + _invItemSpace * 2 + 44);
+						g_hdb->_gfx->centerPrint(d->destTextName);
+
 						g_hdb->_sound->playSound(crazySounds[g_hdb->_rnd->getRandomNumber(kNumCrazy - 1)]);
+						_dlvsInfo.animate = false;
 					}
 				}
+			} else {
+				// draw Item
+				_gfxIndent->draw(drawX, drawY);
+				d->itemGfx->drawMasked(drawX, drawY);
+
+				// draw Deliveree
+				_gfxIndent->draw(drawX, drawY + _invItemSpace + 16);
+				d->destGfx->drawMasked(drawX, drawY + _invItemSpace + 16);
+
+				if (!_dlvsInfo.animate && inv == _dlvsInfo.selected) {
+					g_hdb->_gfx->setCursor(drawX, drawY + _invItemSpace * 2 + 20);
+					g_hdb->_gfx->centerPrint(d->itemTextName);
+					g_hdb->_gfx->setCursor(drawX, drawY + _invItemSpace * 2 + 32);
+					g_hdb->_gfx->centerPrint("to");
+					g_hdb->_gfx->setCursor(drawX, drawY + _invItemSpace * 2 + 44);
+					g_hdb->_gfx->centerPrint(d->destTextName);
+				}
+
+				drawX += _invItemSpace;
 			}
-			if (_dlvsInfo.go2) {
-				if (_dlvsInfo.delay2 < g_hdb->getTimeSlice()) {
-					// Draw TO
-					_gfxArrowTo->drawMasked(_dlvsInfo.x + _dlvItemSpaceX * _dlvsInfo.selected + 8, drawY + kTileHeight);
-
-					g_hdb->_gfx->setCursor(centerX - g_hdb->_gfx->stringLength("to") / 2, g_hdb->_window->_dlvItemTextY + 12);
-					g_hdb->_gfx->drawText("to");
-					if (!_dlvsInfo.go3) {
-						_dlvsInfo.go3 = true;
-						_dlvsInfo.delay3 = g_hdb->getTimeSlice() + 500;
+		}
+
+		if (!inv) {
+			g_hdb->_gfx->setCursor(baseX, _dlvsInfo.y + 32);
+			g_hdb->_gfx->drawText("No Deliveries");
+		} else if (!_dlvsInfo.animate) {
+			// arrow TO...
+			_gfxArrowTo->drawMasked(_dlvsInfo.x + 24 + _invItemSpace * _dlvsInfo.selected, drawY + _invItemSpace);
+		}
+	} else {
+		if (_infobarDimmed > 1)
+			return;
+
+		baseX = _dlvsInfo.x;
+		drawX = _dlvsInfo.x;
+		drawY = _dlvsInfo.y;
+
+		if (_dlvsInfo.selected >= g_hdb->_ai->getDeliveriesAmount())
+			_dlvsInfo.selected = g_hdb->_ai->getDeliveriesAmount() - 1;
+
+		// Draw Delivery Items
+		int inv = 0;
+		for (; inv < g_hdb->_ai->getDeliveriesAmount(); inv++) {
+			int centerX = baseX + (g_hdb->_screenWidth - baseX) / 2;
+			d = g_hdb->_ai->getDeliveryItem(inv);
+			if (_dlvsInfo.animate && inv == g_hdb->_ai->getDeliveriesAmount() - 1) {
+				if (_dlvsInfo.go1) {
+					if (_dlvsInfo.delay1 < g_hdb->getTimeSlice()) {
+						// Draw Item
+						_gfxIndent->draw(drawX, drawY);
+						if (d->itemGfx)
+							d->itemGfx->drawMasked(drawX, drawY);
+
+						g_hdb->_gfx->setCursor(centerX - g_hdb->_gfx->stringLength(d->itemTextName) / 2, g_hdb->_window->_dlvItemTextY);
+						g_hdb->_gfx->drawText(d->itemTextName);
+						if (!_dlvsInfo.go2) {
+							_dlvsInfo.go2 = true;
+							_dlvsInfo.delay2 = g_hdb->getTimeSlice() + 500;
+							g_hdb->_sound->playSound(crazySounds[g_hdb->_rnd->getRandomNumber(kNumCrazy - 1)]);
+						}
+					}
+				}
+				if (_dlvsInfo.go2) {
+					if (_dlvsInfo.delay2 < g_hdb->getTimeSlice()) {
+						// Draw TO
+						_gfxArrowTo->drawMasked(_dlvsInfo.x + _dlvItemSpaceX * _dlvsInfo.selected + 8, drawY + kTileHeight);
+
+						g_hdb->_gfx->setCursor(centerX - g_hdb->_gfx->stringLength("to") / 2, g_hdb->_window->_dlvItemTextY + 12);
+						g_hdb->_gfx->drawText("to");
+						if (!_dlvsInfo.go3) {
+							_dlvsInfo.go3 = true;
+							_dlvsInfo.delay3 = g_hdb->getTimeSlice() + 500;
+							g_hdb->_sound->playSound(crazySounds[g_hdb->_rnd->getRandomNumber(kNumCrazy - 1)]);
+						}
+					}
+				}
+				if (_dlvsInfo.go3) {
+					if (_dlvsInfo.delay3 < g_hdb->getTimeSlice()) {
+						// Draw Delivery
+						_gfxIndent->draw(drawX, drawY + kTileHeight + 16);
+						if (d->destGfx)
+							d->destGfx->drawMasked(drawX, drawY + kTileHeight + 16);
+
+						g_hdb->_gfx->setCursor(centerX - (g_hdb->_gfx->stringLength(d->destTextName) + g_hdb->_gfx->stringLength("to")) / 2, g_hdb->_window->_dlvItemTextY + 12);
+						g_hdb->_gfx->drawText("to ");
+						g_hdb->_gfx->drawText(d->destTextName);
+
 						g_hdb->_sound->playSound(crazySounds[g_hdb->_rnd->getRandomNumber(kNumCrazy - 1)]);
+						_dlvsInfo.animate = false;
 					}
 				}
-			}
-			if (_dlvsInfo.go3) {
-				if (_dlvsInfo.delay3 < g_hdb->getTimeSlice()) {
-					// Draw Delivery
-					_gfxIndent->draw(drawX, drawY + kTileHeight + 16);
-					if (d->destGfx)
-						d->destGfx->drawMasked(drawX, drawY + kTileHeight + 16);
-
-					g_hdb->_gfx->setCursor(centerX - (g_hdb->_gfx->stringLength(d->destTextName) + g_hdb->_gfx->stringLength("to")) / 2, g_hdb->_window->_dlvItemTextY + 12);
+
+			} else {
+				// Draw Item
+				_gfxIndent->draw(drawX, drawY);
+				if (d->itemGfx)
+					d->itemGfx->drawMasked(drawX, drawY);
+				// Draw Delivery
+				_gfxIndent->draw(drawX, drawY + kTileHeight + 16);
+				if (d->destGfx)
+					d->destGfx->drawMasked(drawX, drawY + kTileHeight + 16);
+
+				if (!_dlvsInfo.animate && inv == _dlvsInfo.selected) {
+					g_hdb->_gfx->setCursor(centerX - g_hdb->_gfx->stringLength(d->itemTextName) / 2, g_hdb->_window->_dlvItemTextY);
+					g_hdb->_gfx->drawText(d->itemTextName);
+					g_hdb->_gfx->setCursor(centerX - (g_hdb->_gfx->stringLength(d->destTextName) + g_hdb->_gfx->stringLength("to ")) / 2, g_hdb->_window->_dlvItemTextY + 12);
 					g_hdb->_gfx->drawText("to ");
 					g_hdb->_gfx->drawText(d->destTextName);
-
-					g_hdb->_sound->playSound(crazySounds[g_hdb->_rnd->getRandomNumber(kNumCrazy - 1)]);
-					_dlvsInfo.animate = false;
 				}
-			}
 
-		} else {
-			// Draw Item
-			_gfxIndent->draw(drawX, drawY);
-			if (d->itemGfx)
-				d->itemGfx->drawMasked(drawX, drawY);
-			// Draw Delivery
-			_gfxIndent->draw(drawX, drawY + kTileHeight + 16);
-			if (d->destGfx)
-				d->destGfx->drawMasked(drawX, drawY + kTileHeight + 16);
-
-			if (!_dlvsInfo.animate && inv == _dlvsInfo.selected) {
-				g_hdb->_gfx->setCursor(centerX - g_hdb->_gfx->stringLength(d->itemTextName)/2, g_hdb->_window->_dlvItemTextY);
-				g_hdb->_gfx->drawText(d->itemTextName);
-				g_hdb->_gfx->setCursor(centerX - (g_hdb->_gfx->stringLength(d->destTextName) + g_hdb->_gfx->stringLength("to ")) / 2, g_hdb->_window->_dlvItemTextY + 12);
-				g_hdb->_gfx->drawText("to ");
-				g_hdb->_gfx->drawText(d->destTextName);
-			}
-
-			drawX += _dlvItemSpaceX;
-			if (drawX >= g_hdb->_screenWidth) {
-				drawX = baseX;
-				drawY += _dlvItemSpaceY + 8;
+				drawX += _dlvItemSpaceX;
+				if (drawX >= g_hdb->_screenWidth) {
+					drawX = baseX;
+					drawY += _dlvItemSpaceY + 8;
+				}
 			}
 		}
-	}
 
-	// Draw "No Deliveries" or the arrow that points to the currently selected one
-	if (!inv) {
-		g_hdb->_gfx->setCursor(baseX + 16, _dlvsInfo.y);
-		g_hdb->_gfx->drawText("No Deliveries");
-	} else if (!_dlvsInfo.animate) {
-		int dx, dy, rowtwo;
-
-		rowtwo = _dlvsInfo.selected > 2;
-		dx = 8 + _dlvsInfo.x + _dlvItemSpaceX * (_dlvsInfo.selected % 3);
-		dy = _dlvsInfo.y + kTileHeight + (_dlvItemSpaceY + 8) * rowtwo;
-		_gfxArrowTo->drawMasked(dx, dy);
-	}
+		// Draw "No Deliveries" or the arrow that points to the currently selected one
+		if (!inv) {
+			g_hdb->_gfx->setCursor(baseX + 16, _dlvsInfo.y);
+			g_hdb->_gfx->drawText("No Deliveries");
+		} else if (!_dlvsInfo.animate) {
+			int dx, dy, rowtwo;
+
+			rowtwo = _dlvsInfo.selected > 2;
+			dx = 8 + _dlvsInfo.x + _dlvItemSpaceX * (_dlvsInfo.selected % 3);
+			dy = _dlvsInfo.y + kTileHeight + (_dlvItemSpaceY + 8) * rowtwo;
+			_gfxArrowTo->drawMasked(dx, dy);
+		}
 
-	// If the infobar is dimmed out, this where we dim the whole thing
-	if (_infobarDimmed) {
-		for (int j = 0; j < g_hdb->_screenHeight; j += kTileHeight) {
-			for (int i = (g_hdb->_screenWidth - _gfxInfobar->_width); i < g_hdb->_screenWidth; i += kTileWidth)
-				_gfxDarken->drawMasked(i, j);
+		// If the infobar is dimmed out, this where we dim the whole thing
+		if (_infobarDimmed) {
+			for (int j = 0; j < g_hdb->_screenHeight; j += kTileHeight) {
+				for (int i = (g_hdb->_screenWidth - _gfxInfobar->_width); i < g_hdb->_screenWidth; i += kTileWidth)
+					_gfxDarken->drawMasked(i, j);
+			}
 		}
 	}
 }
@@ -1323,6 +1644,47 @@ void Window::checkDlvSelect(int x, int y) {
 	}
 }
 
+bool Window::checkDlvsClose(int x, int y) {
+	if (!g_hdb->isPPC())
+		return false;
+
+	if (_dlvsInfo.animate)
+		return false;
+
+	int amt = g_hdb->_ai->getDeliveriesAmount();
+
+	// click on a delivery to select it for inspection?
+	if (x >= _dlvsInfo.x + 16 && x < _dlvsInfo.x + 16 + amt * _invItemSpace &&
+		y >= _dlvsInfo.y && y < _dlvsInfo.y + _invItemSpace * 3) {
+		setSelectedDelivery(((x - _dlvsInfo.x + 16) / _invItemSpace) - 1);
+	} else if (g_hdb->_ai->getInvAmount() &&
+		x >= g_hdb->_screenWidth - _gfxHandright->_width &&
+		y >= _dlvsInfo.y && y < _dlvsInfo.y + _invItemSpace * 3) {
+		// click on HAND?
+		closeDlvs();
+		openInventory();
+		return true;
+	} else if (x >= _dlvsInfo.x && x < _dlvsInfo.x + _dlvsInfo.width &&
+		y >= _dlvsInfo.y && y < _dlvsInfo.y + _dlvsInfo.height) {
+		// click anywhere else in window to close it?
+		closeDlvs();
+		return true;
+	}
+
+	return false;
+}
+
+void Window::closeDlvs() {
+	if (!g_hdb->isPPC())
+		return;
+
+	if (_dlvsInfo.animate)
+		return;
+
+	g_hdb->_sound->playSound(SND_DIALOG_CLOSE);
+	_dlvsInfo.active = false;
+}
+
 void Window::drawTryAgain() {
 	if (!g_hdb->_ai->playerDead())
 		return;
diff --git a/engines/hdb/window.h b/engines/hdb/window.h
index 682a4e4..b511ba3 100644
--- a/engines/hdb/window.h
+++ b/engines/hdb/window.h
@@ -236,6 +236,10 @@ public:
 	bool inventoryActive() {
 		return _invWinInfo.active;
 	}
+	// PPC Inventory
+	void openInventory();
+	bool checkInvClose(int x, int y);
+	void closeInv();
 
 	// Deliveries Functions
 	void openDeliveries(bool animate);
@@ -248,6 +252,12 @@ public:
 		return _dlvsInfo.animate;
 	}
 	void checkDlvSelect(int x, int y);
+	// PPC Deliveries
+	bool checkDlvsClose(int x, int y);
+	void closeDlvs();
+	bool deliveriesActive() {
+		return _dlvsInfo.active;
+	}
 
 	// Try Again Functions
 	void drawTryAgain();
@@ -332,6 +342,7 @@ private:
 	Picture *_mstoneGfx;
 
 	// Info Bar
+	Picture *_gfxResources, *_gfxDeliveries;
 	Picture *_gfxInfobar, *_gfxDarken;
 	int _infobarDimmed;
 };


Commit: 878eefceb5e2937512c060385a3464a1c38b2def
    https://github.com/scummvm/scummvm/commit/878eefceb5e2937512c060385a3464a1c38b2def
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:31+02:00

Commit Message:
HDB: Integrate PPC version of Menu and Gfx

Changed paths:
    engines/hdb/gfx.cpp
    engines/hdb/gfx.h
    engines/hdb/menu.cpp


diff --git a/engines/hdb/gfx.cpp b/engines/hdb/gfx.cpp
index 4dbd705..4e9d3f9 100644
--- a/engines/hdb/gfx.cpp
+++ b/engines/hdb/gfx.cpp
@@ -157,23 +157,25 @@ bool Gfx::init() {
 	_tileSkyClouds = getTileIndex(TILE_SKY_CLOUDS); // Not completely sure about this filename.
 	_skyClouds = NULL;
 
-	// Load Mouse Pointer and Display Cursor
-	_mousePointer[0] = loadPic(PIC_MOUSE_CURSOR1);
-	_mousePointer[1] = loadPic(PIC_MOUSE_CURSOR2);
-	_mousePointer[2] = loadPic(PIC_MOUSE_CURSOR3);
-	_mousePointer[3] = loadPic(PIC_MOUSE_CURSOR4);
-	_mousePointer[4] = loadPic(PIC_MOUSE_CURSOR5);
-	_mousePointer[5] = loadPic(PIC_MOUSE_CURSOR6);
-	_mousePointer[6] = loadPic(PIC_MOUSE_CURSOR7);
-	_mousePointer[7] = loadPic(PIC_MOUSE_CURSOR8);
-	_showCursor = true;
-
-	// Load all 4 levels of star colors
-	_starField[0] = getPicture(PIC_STAR64);
-	_starField[1] = getPicture(PIC_STAR128);
-	_starField[2] = getPicture(PIC_STAR192);
-	_starField[3] = getPicture(PIC_STAR256);
-	_snowflake = getPicture(PIC_SNOWFLAKE);
+	if (!g_hdb->isPPC()) {
+		// Load Mouse Pointer and Display Cursor
+		_mousePointer[0] = loadPic(PIC_MOUSE_CURSOR1);
+		_mousePointer[1] = loadPic(PIC_MOUSE_CURSOR2);
+		_mousePointer[2] = loadPic(PIC_MOUSE_CURSOR3);
+		_mousePointer[3] = loadPic(PIC_MOUSE_CURSOR4);
+		_mousePointer[4] = loadPic(PIC_MOUSE_CURSOR5);
+		_mousePointer[5] = loadPic(PIC_MOUSE_CURSOR6);
+		_mousePointer[6] = loadPic(PIC_MOUSE_CURSOR7);
+		_mousePointer[7] = loadPic(PIC_MOUSE_CURSOR8);
+		_showCursor = true;
+
+		// Load all 4 levels of star colors
+		_starField[0] = getPicture(PIC_STAR64);
+		_starField[1] = getPicture(PIC_STAR128);
+		_starField[2] = getPicture(PIC_STAR192);
+		_starField[3] = getPicture(PIC_STAR256);
+		_snowflake = getPicture(PIC_SNOWFLAKE);
+	}
 
 	_systemInit = true;
 	return true;
@@ -448,6 +450,12 @@ Tile *Gfx::loadIcon(const char *tileName) {
 	return tile;
 }
 
+void Gfx::setPixel(int x, int y, uint16 color) {
+	uint16 *ptr = (uint16 *)_globalSurface.getBasePtr(0, y);
+	ptr += x;
+	*ptr = color;
+}
+
 Tile *Gfx::getTile(int index) {
 	if (index < 0 || index > _numTiles) {
 		if (index != 0xFFFF)
@@ -650,8 +658,12 @@ void Gfx::setup3DStars() {
 		_stars3D[i].x = g_hdb->_rnd->getRandomNumber(g_hdb->_screenWidth - 1);
 		_stars3D[i].y = g_hdb->_rnd->getRandomNumber(g_hdb->_screenHeight - 1);
 		_stars3D[i].speed = g_hdb->_rnd->getRandomNumber(255);
-		_stars3D[i].speed >>= 1;
-		_stars3D[i].color = _stars3D[i].speed / 64;
+		if (g_hdb->isPPC()) {
+			_stars3D[i].color = g_hdb->_format.RGBToColor(_stars3D[i].speed, _stars3D[i].speed, _stars3D[i].speed);
+		} else {
+			_stars3D[i].speed >>= 1;
+			_stars3D[i].color = _stars3D[i].speed / 64;
+		}
 	}
 }
 
@@ -660,15 +672,23 @@ void Gfx::setup3DStarsLeft() {
 		_stars3DSlow[i].x = g_hdb->_rnd->getRandomNumber(g_hdb->_screenWidth - 1);
 		_stars3DSlow[i].y = g_hdb->_rnd->getRandomNumber(g_hdb->_screenHeight - 1);
 		_stars3DSlow[i].speed = ((double) (1 + g_hdb->_rnd->getRandomNumber(4))) / 6.0;
-		_stars3DSlow[i].color = (int) (_stars3DSlow[i].speed * 4.00);
+		if (g_hdb->isPPC())
+			_stars3DSlow[i].color = g_hdb->_format.RGBToColor((int)(_stars3DSlow[i].speed * 250), (int)(_stars3DSlow[i].speed * 250), (int)(_stars3DSlow[i].speed * 250));
+		else
+			_stars3DSlow[i].color = (int) (_stars3DSlow[i].speed * 4.00);
 	}
 }
 
 void Gfx::draw3DStars() {
 	fillScreen(0);
 	for (int i = 0; i < kNum3DStars; i++) {
-		_starField[_stars3D[i].color]->drawMasked((int)_stars3D[i].x, (int)_stars3D[i].y);
-		_stars3D[i].y += (_stars3D[i].speed >> 5) + 1;
+		if (g_hdb->isPPC()) {
+			setPixel((int)_stars3D[i].x, (int)_stars3D[i].y, _stars3D[i].color);
+			_stars3D[i].y += (_stars3D[i].speed >> 5);
+		} else {
+			_starField[_stars3D[i].color]->drawMasked((int)_stars3D[i].x, (int)_stars3D[i].y);
+			_stars3D[i].y += (_stars3D[i].speed >> 5) + 1;
+		}
 		if (_stars3D[i].y > g_hdb->_screenHeight) {
 			_stars3D[i].y = 0;
 		}
@@ -678,7 +698,10 @@ void Gfx::draw3DStars() {
 void Gfx::draw3DStarsLeft() {
 	fillScreen(0);
 	for (int i = 0; i < kNum3DStars; i++) {
-		_starField[_stars3DSlow[i].color]->drawMasked((int)_stars3DSlow[i].x, (int)_stars3DSlow[i].y);
+		if (g_hdb->isPPC())
+			setPixel((int)_stars3DSlow[i].x, (int)_stars3DSlow[i].y, _stars3DSlow[i].color);
+		else
+			_starField[_stars3DSlow[i].color]->drawMasked((int)_stars3DSlow[i].x, (int)_stars3DSlow[i].y);
 		_stars3DSlow[i].x -= _stars3DSlow[i].speed;
 		if (_stars3DSlow[i].x < 0) {
 			_stars3DSlow[i].x = g_hdb->_screenWidth - 1;
@@ -718,7 +741,14 @@ void Gfx::drawSnow() {
 		return;
 
 	for (i = 0; i < MAX_SNOW; i++) {
-		_snowflake->drawMasked((int)_snowInfo.x[i], (int)_snowInfo.y[i]);
+		if (g_hdb->isPPC()) {
+			uint16 color = g_hdb->_format.RGBToColor(160, 160, 160);
+			setPixel((int)_snowInfo.x[i] + 1, (int)_snowInfo.y[i], color);
+			setPixel((int)_snowInfo.x[i] - 1, (int)_snowInfo.y[i], color);
+			setPixel((int)_snowInfo.x[i], (int)_snowInfo.y[i] + 1, color);
+			setPixel((int)_snowInfo.x[i], (int)_snowInfo.y[i] - 1, color);
+		} else
+			_snowflake->drawMasked((int)_snowInfo.x[i], (int)_snowInfo.y[i]);
 		_snowInfo.x[i] += snowXVList[_snowInfo.xvindex[i]++];
 		_snowInfo.y[i] += _snowInfo.yv[i];
 		if (_snowInfo.xvindex[i] == MAX_SNOW_XV)
@@ -893,7 +923,7 @@ void Gfx::getDimensions(const char *string, int *pixelsWide, int *lines) {
 				width -= _charInfoBlocks[c]->width + _fontHeader.kerning + kFontIncrement;
 				i--;
 			}
-			if (!i) {
+			if (!i && !g_hdb->isPPC()) {
 				maxWidth = oldWidth;
 				break;
 			}
@@ -1014,10 +1044,17 @@ void Gfx::drawBonusStars() {
 	int h = _starsInfo.gfx[0]->_height / 2;
 
 	for (int i = 0; i < 10; i++) {
-		_starsInfo.gfx[_starsInfo.anim]->drawMasked(
-			(int)(g_hdb->_screenDrawWidth / 2 + ((float)_starsInfo.radius / 2)) + (int)((double)_starsInfo.radius * _cosines->at(_starsInfo.starAngle[i]) - w),
-			(g_hdb->_screenDrawHeight / 2) + (int)((double)_starsInfo.radius * _sines->at(_starsInfo.starAngle[i]) - h)
-		);
+		if (g_hdb->isPPC()) {
+			_starsInfo.gfx[_starsInfo.anim]->drawMasked(
+				(g_hdb->_screenWidth / 2) + (int)((double)_starsInfo.radius * _cosines->at(_starsInfo.starAngle[i]) - w),
+				(g_hdb->_screenHeight / 2) + (int)((double)_starsInfo.radius * _sines->at(_starsInfo.starAngle[i]) - h)
+				);
+		} else {
+			_starsInfo.gfx[_starsInfo.anim]->drawMasked(
+				(int)(g_hdb->_screenDrawWidth / 2 + ((float)_starsInfo.radius / 2)) + (int)((double)_starsInfo.radius * _cosines->at(_starsInfo.starAngle[i]) - w),
+				(g_hdb->_screenDrawHeight / 2) + (int)((double)_starsInfo.radius * _sines->at(_starsInfo.starAngle[i]) - h)
+			);
+		}
 
 		int angle = (int)(_starsInfo.starAngle[i] + _starsInfo.angleSpeed);
 		if (angle >= 360)
diff --git a/engines/hdb/gfx.h b/engines/hdb/gfx.h
index 923b5b7..a138e9f 100644
--- a/engines/hdb/gfx.h
+++ b/engines/hdb/gfx.h
@@ -102,6 +102,7 @@ public:
 	Picture *loadPic(const char *picName);
 	Tile *loadTile(const char *tileName);
 	Tile *loadIcon(const char *tileName);
+	void setPixel(int x, int y, uint16 color);
 
 	Tile *getTile(int index);
 	void cacheTileSequence(int index, int count);
diff --git a/engines/hdb/menu.cpp b/engines/hdb/menu.cpp
index 6302427..136d6b5 100644
--- a/engines/hdb/menu.cpp
+++ b/engines/hdb/menu.cpp
@@ -289,8 +289,6 @@ bool Menu::init() {
 		}
 		else
 			_hdbLogoScreen = g_hdb->_gfx->loadPic(TITLESCREEN);
-
-
 	} else {
 		_gCheckEmpty = g_hdb->_gfx->loadPic(G_CHECK_EMPTY);
 		_gCheckOff = g_hdb->_gfx->loadPic(G_CHECK_OFF);


Commit: 7ad5cf9d30ca24ace6709b43fe4549897505c8ab
    https://github.com/scummvm/scummvm/commit/7ad5cf9d30ca24ace6709b43fe4549897505c8ab
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:31+02:00

Commit Message:
HDB: Add new PPC-specific code

Changed paths:
    engines/hdb/ai-funcs.cpp
    engines/hdb/hdb.cpp
    engines/hdb/input.cpp
    engines/hdb/menu.cpp
    engines/hdb/window.cpp


diff --git a/engines/hdb/ai-funcs.cpp b/engines/hdb/ai-funcs.cpp
index 7faa888..73e0b8e 100644
--- a/engines/hdb/ai-funcs.cpp
+++ b/engines/hdb/ai-funcs.cpp
@@ -784,6 +784,11 @@ void AI::killPlayer(Death method) {
 	g_hdb->_window->closeDialogChoice();
 	g_hdb->_window->stopPanicZone();
 
+	if (g_hdb->isPPC()) {
+		g_hdb->_window->closeDlvs();
+		g_hdb->_window->closeInv();
+	}
+
 	switch (method) {
 	case DEATH_NORMAL:
 		_player->state = STATE_DYING;
@@ -811,8 +816,10 @@ void AI::killPlayer(Death method) {
 		g_hdb->_sound->playSound(SND_PANIC_DEATH);
 		break;
 	case DEATH_PLUMMET:
-		_player->state = STATE_PLUMMET;
-		g_hdb->_sound->playSound(SND_GUY_PLUMMET);
+		if (!g_hdb->isDemo()) {
+			_player->state = STATE_PLUMMET;
+			g_hdb->_sound->playSound(SND_GUY_PLUMMET);
+		}
 		break;
 	}
 
@@ -2312,6 +2319,15 @@ void AI::movePlayer(uint16 buttons) {
 
 	// Just trying to put away a dialog?
 	if (buttons & kButtonB) {
+		if (g_hdb->isPPC()) {
+			if (g_hdb->_window->deliveriesActive()) {
+				g_hdb->_window->closeDlvs();
+				return;
+			} else if (g_hdb->_window->inventoryActive()) {
+				g_hdb->_window->closeInv();
+				return;
+			}
+		}
 		if (g_hdb->_window->dialogActive()) {
 			g_hdb->_window->closeDialog();
 			return;
@@ -2471,6 +2487,13 @@ void AI::movePlayer(uint16 buttons) {
 	if (_player->touchpWait > kPlayerTouchPWait / 4)
 		return;
 
+	if (g_hdb->isPPC()) {
+		// Are the Deliveries active?
+		if (g_hdb->_window->deliveriesActive())
+			if (!g_hdb->_ai->cinematicsActive())
+				return;
+	}
+
 	// Is a dialog active?
 	if (g_hdb->_window->dialogActive()) {
 		if (!cinematicsActive())
@@ -2483,6 +2506,13 @@ void AI::movePlayer(uint16 buttons) {
 			return;
 	}
 
+	if (g_hdb->isPPC()) {
+		// Is the Inventory active?
+		if (g_hdb->_window->inventoryActive())
+			if (!g_hdb->_ai->cinematicsActive())
+				return;
+	}
+
 	// In a cinematic?
 	if (_playerLock || _numWaypoints)
 		return;
diff --git a/engines/hdb/hdb.cpp b/engines/hdb/hdb.cpp
index 5cd5615..f1ff789 100644
--- a/engines/hdb/hdb.cpp
+++ b/engines/hdb/hdb.cpp
@@ -393,8 +393,18 @@ void HDBGame::setTargetXY(int x, int y) {
 		return;
 
 	// Double-Clicking on the player to open inventory?
-	if (g_hdb->isPPC())
-		warning("STUB: Add double-click to inventory functionality for PPC version");
+	if (g_hdb->isPPC()) {
+		if (x == px && y == py) {
+			static uint32 dblClickTimer = 0;
+
+			if (dblClickTimer && ((int)(g_system->getMillis() - dblClickTimer) < (int)(kGameFPS * 5))) {
+				g_hdb->_window->openInventory();
+				dblClickTimer = 0;
+			} else
+				dblClickTimer = g_system->getMillis();
+			return;
+		}
+	}
 
 	// If we're attacking...don't do anything else
 	AIState stateList[] = {
diff --git a/engines/hdb/input.cpp b/engines/hdb/input.cpp
index be34fad..505948c 100644
--- a/engines/hdb/input.cpp
+++ b/engines/hdb/input.cpp
@@ -77,6 +77,20 @@ void Input::setButtons(uint16 b) {
 		g_hdb->changeGameState();
 	}
 
+	if (g_hdb->isPPC()) {
+		if (_buttons & kButtonD) {
+			if (g_hdb->_window->inventoryActive()) {
+				g_hdb->_window->closeInv();
+				g_hdb->_window->openDeliveries(false);
+			} else if (g_hdb->_window->deliveriesActive()) {
+				g_hdb->_window->closeDlvs();
+			} else {
+				g_hdb->_window->openInventory();
+			}
+			return;
+		}
+	}
+
 	// Debug Mode Cycling
 	if ((_buttons & kButtonExit) && g_hdb->getCheatingOn()) {
 		int	debugFlag = g_hdb->getDebug();
@@ -108,6 +122,138 @@ void Input::setButtons(uint16 b) {
 			return;
 		}
 
+		if (g_hdb->isPPC()) {
+			// Deliveries screen?
+			if (g_hdb->_window->deliveriesActive() && !g_hdb->_window->animatingDelivery()) {
+				if (_buttons & kButtonLeft) {
+					int	amount = g_hdb->_ai->getDeliveriesAmount();
+					int	current = g_hdb->_window->getSelectedDelivery();
+
+					if (!current)
+						current = amount - 1;
+					else
+						current--;
+
+					g_hdb->_window->setSelectedDelivery(current);
+				} else if (_buttons & kButtonRight) {
+					int		amount = g_hdb->_ai->getDeliveriesAmount();
+					int		current = g_hdb->_window->getSelectedDelivery();
+
+					current++;
+					if (current == amount)
+						current = 0;
+
+					g_hdb->_window->setSelectedDelivery(current);
+				} else if (_buttons & kButtonB)
+					g_hdb->_window->closeDlvs();
+				return;
+			}
+
+			//
+			// Resources screen?  Move select cursor around
+			//
+			if (g_hdb->_window->inventoryActive()) {
+				// select weapon?
+				if (_buttons & kButtonB) {
+					static AIType lastWeaponSelected = AI_NONE;
+					Tile *gfx;
+
+					if (!g_hdb->getActionMode()) {
+						g_hdb->_window->closeInv();
+						return;
+					}
+
+					AIType t = g_hdb->_ai->getInvItemType(g_hdb->_window->getInvSelect());
+					gfx = g_hdb->_ai->getInvItemGfx(g_hdb->_window->getInvSelect());
+
+					switch (t) {
+					case ITEM_CLUB:
+					case ITEM_ROBOSTUNNER:
+					case ITEM_SLUGSLINGER:
+						g_hdb->_ai->setPlayerWeapon(t, gfx);
+						if (t == lastWeaponSelected) {
+							g_hdb->_window->closeInv();
+							return;
+						}
+						lastWeaponSelected = t;
+						g_hdb->_sound->playSound(SND_MENU_ACCEPT);
+						return;
+					}
+					g_hdb->_sound->playSound(SND_CELLHOLDER_USE_REJECT);
+					return;
+				}
+
+
+				if (_buttons & kButtonLeft) {
+					int	amount = g_hdb->_ai->getInvMax();
+					int	current = g_hdb->_window->getInvSelect();
+
+					if (!amount)
+						return;
+
+					if (current == 5)
+						current = amount - 1;
+					else if (!current && amount > 5)
+						current = 4;
+					else if (!current)
+						current = amount - 1;
+					else
+						current--;
+
+					g_hdb->_sound->playSound(SND_MENU_SLIDER);
+					g_hdb->_window->setInvSelect(current);
+				} else if (_buttons & kButtonRight) {
+					int		amount = g_hdb->_ai->getInvMax();
+					int		current = g_hdb->_window->getInvSelect();
+
+					if (!amount)
+						return;
+
+					if (amount > 5) {
+						if (current == amount - 1)
+							current = 5;
+						else if (current == 4)
+							current = 0;
+						else
+							current++;
+					} else if (current == amount - 1)
+						current = 0;
+					else
+						current++;
+
+					g_hdb->_sound->playSound(SND_MENU_SLIDER);
+					g_hdb->_window->setInvSelect(current);
+				} else if (_buttons & kButtonUp) {
+					int		amount = g_hdb->_ai->getInvMax();
+					int		current = g_hdb->_window->getInvSelect();
+
+					if (!amount || amount < 6)
+						return;
+
+					if (current - 5 >= 0)
+						current -= 5;
+
+					g_hdb->_sound->playSound(SND_MENU_SLIDER);
+					g_hdb->_window->setInvSelect(current);
+				} else if (_buttons & kButtonDown) {
+					int		amount = g_hdb->_ai->getInvMax();
+					int		current = g_hdb->_window->getInvSelect();
+
+					if (!amount || amount < 6)
+						return;
+
+					if (current + 5 < amount)
+						current += 5;
+					else if (current < 5)
+						current = amount - 1;
+
+					g_hdb->_sound->playSound(SND_MENU_SLIDER);
+					g_hdb->_window->setInvSelect(current);
+				}
+				return;
+			}
+		}
+
 		// Choose from DialogChoice
 		if (g_hdb->_window->dialogChoiceActive()) {
 			if (_buttons & kButtonUp)
@@ -165,7 +311,21 @@ void Input::stylusDown(int x, int y) {
 		}
 
 		if (g_hdb->isPPC()) {
-			warning("STUB: Add PPC code for Deliveries\\Inventory");
+			// is Deliveries active?
+			if (g_hdb->_window->deliveriesActive()) {
+				if (!g_hdb->_window->checkDlvsClose(x, y))
+					return;
+				if (!g_hdb->_ai->cinematicsActive())
+					return;
+			}
+
+			// is Inventory active?
+			if (g_hdb->_window->inventoryActive()) {
+				if (!g_hdb->_window->checkInvClose(x, y))
+					return;
+				if (!g_hdb->_ai->cinematicsActive())
+					return;
+			}
 		}
 
 		// Is Dialog Active?
diff --git a/engines/hdb/menu.cpp b/engines/hdb/menu.cpp
index 136d6b5..1094b46 100644
--- a/engines/hdb/menu.cpp
+++ b/engines/hdb/menu.cpp
@@ -915,8 +915,10 @@ void Menu::freeMenu() {
 		delete _demoPlaqueGfx;
 	_demoPlaqueGfx = NULL;
 
-	if (g_hdb->isPPC()) {
-		warning("FIXME: When handangoGfx is added, free it here");
+	if (g_hdb->isPPC() && g_hdb->isHandango()) {
+		if (_handangoGfx)
+			delete _handangoGfx;
+		_handangoGfx = NULL;
 	}
 
 	if (_nebulaGfx[0]) {
@@ -1454,7 +1456,6 @@ void Menu::processInput(int x, int y) {
 					return;
 				}
 			}
-
 		}
 
 		int i = 0;
diff --git a/engines/hdb/window.cpp b/engines/hdb/window.cpp
index 0d74c59..f0aefdb 100644
--- a/engines/hdb/window.cpp
+++ b/engines/hdb/window.cpp
@@ -567,6 +567,11 @@ void Window::closeAll() {
 	closeDialogChoice();
 	closeMsg();
 	closeTextOut();
+
+	if (g_hdb->isPPC()) {
+		g_hdb->_window->closeDlvs();
+		g_hdb->_window->closeInv();
+	}
 }
 
 void Window::openDialog(const char *title, int tileIndex, const char *string, int more, const char *luaMore) {


Commit: c63d716180aa18bafb58636a3982d35d4acf1b9f
    https://github.com/scummvm/scummvm/commit/c63d716180aa18bafb58636a3982d35d4acf1b9f
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:31+02:00

Commit Message:
HDB: Rewind played-out sounds

Changed paths:
    engines/hdb/sound.cpp


diff --git a/engines/hdb/sound.cpp b/engines/hdb/sound.cpp
index f713fe8..ca7659c 100644
--- a/engines/hdb/sound.cpp
+++ b/engines/hdb/sound.cpp
@@ -1500,6 +1500,8 @@ bool Sound::playSound(int index) {
 			_soundCache[index].audioStream = Audio::makeWAVStream(stream, DisposeAfterUse::YES);
 			_soundCache[index].loaded = 1;
 		}
+	} else {
+		_soundCache[index].audioStream->rewind();
 	}
 
 	int soundChannel = 0;
@@ -1529,6 +1531,7 @@ bool Sound::playSound(int index) {
 		false,
 		false
 	);
+
 	return true;
 }
 
@@ -1559,6 +1562,8 @@ bool Sound::playSoundEx(int index, int channel, bool loop) {
 			_soundCache[index].audioStream = Audio::makeWAVStream(stream, DisposeAfterUse::YES);
 			_soundCache[index].loaded = 1;
 		}
+	} else {
+		_soundCache[index].audioStream->rewind();
 	}
 
 	g_hdb->_mixer->setChannelVolume(_handles[channel], _sfxVolume);


Commit: ee0445e557d1f89853a1fbd23f72abc12b5cedff
    https://github.com/scummvm/scummvm/commit/ee0445e557d1f89853a1fbd23f72abc12b5cedff
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:31+02:00

Commit Message:
HDB: Sync sound settings with config at the startup

Changed paths:
    engines/hdb/hdb.cpp


diff --git a/engines/hdb/hdb.cpp b/engines/hdb/hdb.cpp
index f1ff789..6fbafa9 100644
--- a/engines/hdb/hdb.cpp
+++ b/engines/hdb/hdb.cpp
@@ -88,6 +88,8 @@ HDBGame::HDBGame(OSystem *syst, const ADGameDescription *gameDesc) : Engine(syst
 	_monkeystone7 = STARS_MONKEYSTONE_7_FAKE;
 	_monkeystone14 = STARS_MONKEYSTONE_14_FAKE;
 	_monkeystone21 = STARS_MONKEYSTONE_21_FAKE;
+
+	syncSoundSettings();
 }
 
 HDBGame::~HDBGame() {


Commit: 9247adefec2de2978d28a9099afdf87239b8e9d4
    https://github.com/scummvm/scummvm/commit/9247adefec2de2978d28a9099afdf87239b8e9d4
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:31+02:00

Commit Message:
HDB: Fix isPPC() check

Changed paths:
    engines/hdb/detection.cpp


diff --git a/engines/hdb/detection.cpp b/engines/hdb/detection.cpp
index 9b6f411..974d831 100644
--- a/engines/hdb/detection.cpp
+++ b/engines/hdb/detection.cpp
@@ -49,7 +49,7 @@ bool HDBGame::isDemo() const {
 }
 
 bool HDBGame::isPPC() const {
-	return (getPlatform() & Common::kPlatformPocketPC);
+	return (getPlatform() == Common::kPlatformPocketPC);
 }
 
 bool HDBGame::isHandango() const {


Commit: 7916f2c86b8e837ccdc9baa9af2109c30f859d9d
    https://github.com/scummvm/scummvm/commit/7916f2c86b8e837ccdc9baa9af2109c30f859d9d
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:31+02:00

Commit Message:
HDB: Fix warnings

Changed paths:
    engines/hdb/input.cpp
    engines/hdb/window.cpp


diff --git a/engines/hdb/input.cpp b/engines/hdb/input.cpp
index 505948c..99506a5 100644
--- a/engines/hdb/input.cpp
+++ b/engines/hdb/input.cpp
@@ -178,6 +178,8 @@ void Input::setButtons(uint16 b) {
 						lastWeaponSelected = t;
 						g_hdb->_sound->playSound(SND_MENU_ACCEPT);
 						return;
+					default:
+						break;
 					}
 					g_hdb->_sound->playSound(SND_CELLHOLDER_USE_REJECT);
 					return;
diff --git a/engines/hdb/window.cpp b/engines/hdb/window.cpp
index f0aefdb..58211d6 100644
--- a/engines/hdb/window.cpp
+++ b/engines/hdb/window.cpp
@@ -1311,6 +1311,8 @@ bool Window::checkInvClose(int x, int y) {
 			lastWeaponSelected = t;
 			g_hdb->_sound->playSound(SND_MENU_ACCEPT);
 			return true;
+		default:
+			break;
 		}
 		g_hdb->_sound->playSound(SND_CELLHOLDER_USE_REJECT);
 	}


Commit: 25eaaf38fba239ad88786e16b8546a6d5de18ebc
    https://github.com/scummvm/scummvm/commit/25eaaf38fba239ad88786e16b8546a6d5de18ebc
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:31+02:00

Commit Message:
HDB: Fix inconsistency in platform-specific code

This led to crash in destructors

Changed paths:
    engines/hdb/window.cpp


diff --git a/engines/hdb/window.cpp b/engines/hdb/window.cpp
index 58211d6..9a3c1b7 100644
--- a/engines/hdb/window.cpp
+++ b/engines/hdb/window.cpp
@@ -118,13 +118,13 @@ Window::~Window() {
 	delete _gfxHandright;
 
 	if (g_hdb->isPPC()) {
+		delete _gfxResources;
+		delete _gfxDeliveries;
+	} else {
 		delete _gfxInfobar;
 		delete _gfxDarken;
 		delete _gfxPausePlaque;
 		delete _mstoneGfx;
-	} else {
-		delete _gfxResources;
-		delete _gfxDeliveries;
 	}
 
 


Commit: c4495e5449cdc1fe8d09a4fef3200567b6a7f548
    https://github.com/scummvm/scummvm/commit/c4495e5449cdc1fe8d09a4fef3200567b6a7f548
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:31+02:00

Commit Message:
HDB: Added commented out credits debugging patch

Changed paths:
    engines/hdb/lua-script.cpp


diff --git a/engines/hdb/lua-script.cpp b/engines/hdb/lua-script.cpp
index a34028c..495d30c 100644
--- a/engines/hdb/lua-script.cpp
+++ b/engines/hdb/lua-script.cpp
@@ -94,6 +94,9 @@ struct ScriptPatch {
 	{"MAP30", "rots = 13 + random( 4 )", "rots = 13 + math.random( 4 )"}, // line 258
 	{"MAP30", "if i3 > getn(tiles)", "if i3 > #tiles"}, // line 261
 
+	// Jump straight to credits
+	//{"CINE_OUTRO", "-- delegate", "-- delegate\nCine_FadeOutBlack( 40 )\nCredits()"},
+
 	{NULL, NULL, NULL}
 };
 


Commit: d4f1d41275d687d800e8cffb96643c58d0e6e9e8
    https://github.com/scummvm/scummvm/commit/d4f1d41275d687d800e8cffb96643c58d0e6e9e8
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:31+02:00

Commit Message:
HDB: Fix fade rendering. No artifacts, yay!

Changed paths:
    engines/hdb/gfx.cpp


diff --git a/engines/hdb/gfx.cpp b/engines/hdb/gfx.cpp
index 4e9d3f9..55c69f4 100644
--- a/engines/hdb/gfx.cpp
+++ b/engines/hdb/gfx.cpp
@@ -359,6 +359,7 @@ void Gfx::updateFade() {
 		}
 
 		_globalSurface.blitFrom(_fadeBuffer1);
+		g_system->copyRectToScreen(_globalSurface.getBasePtr(0, 0), _globalSurface.pitch, 0, 0, _globalSurface.w, _globalSurface.h);
 
 		// step the fading values to the next one and
 		// see if we're done yet
@@ -389,8 +390,6 @@ void Gfx::updateFade() {
 			return;
 		}
 
-		g_system->copyRectToScreen(_globalSurface.getBasePtr(0, 0), _globalSurface.pitch, 0, 0, _globalSurface.w, _globalSurface.h);
-
 		g_system->updateScreen();
 		if (g_hdb->getDebug()) {
 			g_hdb->_frames.push_back(g_system->getMillis());


Commit: 08d486981c4146e816cfecb3c74bed59a21c8f38
    https://github.com/scummvm/scummvm/commit/08d486981c4146e816cfecb3c74bed59a21c8f38
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:31+02:00

Commit Message:
HDB: Check map hitting code

Changed paths:
    engines/hdb/map.cpp


diff --git a/engines/hdb/map.cpp b/engines/hdb/map.cpp
index 898a2c7..cd605a9 100644
--- a/engines/hdb/map.cpp
+++ b/engines/hdb/map.cpp
@@ -1188,11 +1188,11 @@ void Map::centerMapXY(int x, int y) {
 }
 
 bool Map::checkEntOnScreen(AIEntity *e) {
-	return ((e->x > _mapX - 32) && (e->x < _mapX + g_hdb->_map->_screenXTiles * kTileWidth) && (e->y > _mapY - 32) && (e->y < g_hdb->_map->_screenYTiles * kTileHeight));
+	return ((e->x > _mapX - 32) && (e->x < _mapX + g_hdb->_map->_screenXTiles * kTileWidth) && (e->y > _mapY - 32) && (e->y < _mapY + g_hdb->_map->_screenYTiles * kTileHeight));
 }
 
 bool Map::checkXYOnScreen(int x, int y) {
-	return ((x > _mapX - 32) && (x < _mapX + g_hdb->_map->_screenXTiles * kTileWidth) && (y > _mapY - 32) && (y < g_hdb->_map->_screenYTiles * kTileHeight));
+	return ((x > _mapX - 32) && (x < _mapX + g_hdb->_map->_screenXTiles * kTileWidth) && (y > _mapY - 32) && (y < _mapY + g_hdb->_map->_screenYTiles * kTileHeight));
 }
 
 bool Map::checkOneTileExistInRange(int tileIndex, int count) {


Commit: 43ad1af61e2c2840379234fadaf32e27d83ffba8
    https://github.com/scummvm/scummvm/commit/43ad1af61e2c2840379234fadaf32e27d83ffba8
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:31+02:00

Commit Message:
HDB: Draw Pointer only for Windows version

Temporarily until pointer is not adapted to PPC

Changed paths:
    engines/hdb/gfx.cpp


diff --git a/engines/hdb/gfx.cpp b/engines/hdb/gfx.cpp
index 55c69f4..2a8a98a 100644
--- a/engines/hdb/gfx.cpp
+++ b/engines/hdb/gfx.cpp
@@ -278,8 +278,12 @@ void Gfx::drawPointer() {
 		return;
 
 	// If we are in game and the cursor should be displayed, draw it
-	if (_showCursor || g_hdb->getGameState() != GAME_PLAY)
-		_mousePointer[anim]->drawMasked(g_hdb->_input->getMouseX() - 16, g_hdb->_input->getMouseY() - 16);
+	if (g_hdb->isPPC()) {
+		debug(9, "STUB: Draw Pointer in PPC");
+	} else {
+		if (_showCursor || g_hdb->getGameState() != GAME_PLAY)
+			_mousePointer[anim]->drawMasked(g_hdb->_input->getMouseX() - 16, g_hdb->_input->getMouseY() - 16);
+	}
 }
 
 void Gfx::setPointerState(int value) {


Commit: 16fd2269027c5ccaa398baef8f1c841c2b2f2940
    https://github.com/scummvm/scummvm/commit/16fd2269027c5ccaa398baef8f1c841c2b2f2940
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:32+02:00

Commit Message:
HDB: Remove NULL deletes

Changed paths:
    engines/hdb/gfx.cpp


diff --git a/engines/hdb/gfx.cpp b/engines/hdb/gfx.cpp
index 2a8a98a..16c5879 100644
--- a/engines/hdb/gfx.cpp
+++ b/engines/hdb/gfx.cpp
@@ -421,7 +421,6 @@ Picture *Gfx::loadPic(const char *picName) {
 	Picture *pic = new Picture;
 	Common::SeekableReadStream *stream = g_hdb->_fileMan->findFirstData(picName, TYPE_PIC);
 	if (!stream) {
-		delete stream;
 		return NULL;
 	}
 	pic->load(stream);
@@ -433,7 +432,6 @@ Tile *Gfx::loadTile(const char *tileName) {
 	Tile *tile = new Tile;
 	Common::SeekableReadStream *stream = g_hdb->_fileMan->findFirstData(tileName, TYPE_TILE32);
 	if (!stream) {
-		delete stream;
 		return NULL;
 	}
 	tile->load(stream);
@@ -445,7 +443,6 @@ Tile *Gfx::loadIcon(const char *tileName) {
 	Tile *tile = new Tile;
 	Common::SeekableReadStream *stream = g_hdb->_fileMan->findFirstData(tileName, TYPE_ICON32);
 	if (!stream) {
-		delete stream;
 		return NULL;
 	}
 	tile->load(stream);


Commit: 1d1ace6ab51656c2d8b9cddf1a99f180ce6fd999
    https://github.com/scummvm/scummvm/commit/1d1ace6ab51656c2d8b9cddf1a99f180ce6fd999
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:32+02:00

Commit Message:
HDB: Simplify setPixel()

Changed paths:
    engines/hdb/gfx.cpp


diff --git a/engines/hdb/gfx.cpp b/engines/hdb/gfx.cpp
index 16c5879..7a08657 100644
--- a/engines/hdb/gfx.cpp
+++ b/engines/hdb/gfx.cpp
@@ -451,9 +451,7 @@ Tile *Gfx::loadIcon(const char *tileName) {
 }
 
 void Gfx::setPixel(int x, int y, uint16 color) {
-	uint16 *ptr = (uint16 *)_globalSurface.getBasePtr(0, y);
-	ptr += x;
-	*ptr = color;
+	*(uint16 *)_globalSurface.getBasePtr(x, y) = color;
 }
 
 Tile *Gfx::getTile(int index) {


Commit: 9c2d639a35c4308d288399e8468fd4228da2b408
    https://github.com/scummvm/scummvm/commit/9c2d639a35c4308d288399e8468fd4228da2b408
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:32+02:00

Commit Message:
HDB: Adapt loadFont, Picture::load, Tile::load for

PPC

Changed paths:
    engines/hdb/gfx.cpp


diff --git a/engines/hdb/gfx.cpp b/engines/hdb/gfx.cpp
index 7a08657..36ce3d9 100644
--- a/engines/hdb/gfx.cpp
+++ b/engines/hdb/gfx.cpp
@@ -787,6 +787,7 @@ bool Gfx::loadFont(const char *string) {
 
 	// Position after _fontHeader
 	int startPos = stream->pos();
+	uint16 *ptr;
 	for (int i = 0; i < _fontHeader.numChars; i++) {
 		CharInfo *cInfo = new CharInfo;
 		cInfo->width = (int16)stream->readUint32LE();
@@ -797,16 +798,32 @@ bool Gfx::loadFont(const char *string) {
 		// Position after reading cInfo
 		int curPos = stream->pos();
 
-		_fontSurfaces[i].create(cInfo->width, _fontHeader.height, g_hdb->_format);
+		if (g_hdb->isPPC())
+			_fontSurfaces[i].create(_fontHeader.height, cInfo->width, g_hdb->_format);
+		else
+			_fontSurfaces[i].create(cInfo->width, _fontHeader.height, g_hdb->_format);
 
 		// Go to character location
 		stream->seek(startPos+cInfo->offset);
 
-		for (int y = 0; y < _fontHeader.height; y++) {
-			uint16 *ptr = (uint16 *)_fontSurfaces[i].getBasePtr(0, y);
-			for (int x = 0; x < cInfo->width; x++) {
-				*ptr = TO_LE_16(stream->readUint16LE());
-				ptr++;
+		if (g_hdb->isPPC()) {
+
+			for (int y = 0; y < _fontHeader.height; y++) {
+				for (int x = 0; x < cInfo->width; x++) {
+					int u, v;
+					u = y;
+					v = _fontHeader.height - x - 1;
+					ptr = (uint16 *)_fontSurfaces[i].getBasePtr(u, v);
+					*ptr = TO_LE_16(stream->readUint16LE());
+				}
+			}
+		} else {
+			for (int y = 0; y < _fontHeader.height; y++) {
+				ptr = (uint16 *)_fontSurfaces[i].getBasePtr(0, y);
+				for (int x = 0; x < cInfo->width; x++) {
+					*ptr = TO_LE_16(stream->readUint16LE());
+					ptr++;
+				}
 			}
 		}
 
@@ -1124,14 +1141,31 @@ Graphics::Surface Picture::load(Common::SeekableReadStream *stream) {
 	debug(8, "Picture: _width: %d, _height: %d", _width, _height);
 	debug(8, "Picture: _name: %s", _name);
 
-	_surface.create(_width, _height, g_hdb->_format);
-	stream->readUint32LE(); // Skip Win32 Surface
+	if (g_hdb->isPPC()) {
+		_surface.create(_height, _width, g_hdb->_format);
+
+		uint16 *ptr;
+
+		for (int y = 0; y < _height; y++) {
+			for (int x = 0; x < _width; x++) {
+				int u, v;
+				u = y;
+				v = _height - x - 1;
+				ptr = (uint16 *)_surface.getBasePtr(u, v);
+				*ptr = TO_LE_16(stream->readUint16LE());
+			}
+		}
+
+	} else {
+		_surface.create(_width, _height, g_hdb->_format);
+		stream->readUint32LE(); // Skip Win32 Surface
 
-	for (int y = 0; y < _height; y++) {
-		uint16 *ptr = (uint16 *)_surface.getBasePtr(0, y);
-		for (int x = 0; x < _width; x++) {
-			*ptr = TO_LE_16(stream->readUint16LE());
-			ptr++;
+		for (int y = 0; y < _height; y++) {
+			uint16 *ptr = (uint16 *)_surface.getBasePtr(0, y);
+			for (int x = 0; x < _width; x++) {
+				*ptr = TO_LE_16(stream->readUint16LE());
+				ptr++;
+			}
 		}
 	}
 
@@ -1177,13 +1211,26 @@ Graphics::Surface Tile::load(Common::SeekableReadStream *stream) {
 	stream->read(_name, 64);
 
 	_surface.create(32, 32, g_hdb->_format);
-	stream->readUint32LE(); // Skip Win32 Surface
-
-	for (uint y = 0; y < 32; y++) {
-		uint16 *ptr = (uint16 *)_surface.getBasePtr(0, y);
-		for (uint x = 0; x < 32; x++) {
-			*ptr = TO_LE_16(stream->readUint16LE());
-			ptr++;
+	if (g_hdb->isPPC()) {
+		uint16 *ptr;
+
+		for (int y = 0; y < 32; y++) {
+			for (int x = 0; x < 32; x++) {
+				int u, v;
+				u = y;
+				v = 32 - x - 1;
+				ptr = (uint16 *)_surface.getBasePtr(u, v);
+				*ptr = TO_LE_16(stream->readUint16LE());
+			}
+		}
+	} else {
+		stream->readUint32LE(); // Skip Win32 Surface
+		for (uint y = 0; y < 32; y++) {
+			uint16 *ptr = (uint16 *)_surface.getBasePtr(0, y);
+			for (uint x = 0; x < 32; x++) {
+				*ptr = TO_LE_16(stream->readUint16LE());
+				ptr++;
+			}
 		}
 	}
 


Commit: cb8976b65af38a7548c25e48e10b9b0f65d8aafd
    https://github.com/scummvm/scummvm/commit/cb8976b65af38a7548c25e48e10b9b0f65d8aafd
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:32+02:00

Commit Message:
HDB: Add Handango GFX and Demo Title Screen

Changed paths:
    engines/hdb/menu.cpp
    engines/hdb/mpc.h


diff --git a/engines/hdb/menu.cpp b/engines/hdb/menu.cpp
index 1094b46..caaa475 100644
--- a/engines/hdb/menu.cpp
+++ b/engines/hdb/menu.cpp
@@ -283,9 +283,9 @@ bool Menu::init() {
 
 	if (g_hdb->isPPC()) {
 		if (g_hdb->isDemo()) {
-			warning("STUB: Load DEMOTITLESCREEN");
+			_hdbLogoScreen = g_hdb->_gfx->loadPic(DEMOTITLESCREEN);
 			if (g_hdb->isHandango())
-				warning("STUB: Load PIC_HANDANGO");
+				_handangoGfx = g_hdb->_gfx->loadPic(PIC_HANDANGO);
 		}
 		else
 			_hdbLogoScreen = g_hdb->_gfx->loadPic(TITLESCREEN);
diff --git a/engines/hdb/mpc.h b/engines/hdb/mpc.h
index f308139..7b651cd 100644
--- a/engines/hdb/mpc.h
+++ b/engines/hdb/mpc.h
@@ -700,6 +700,10 @@ namespace HDB {
 #define		PIC_SNOWFLAKE		"pic_snowflake"
 #define		PIC_INFOBAR		"pic_infobar"
 #define		PIC_LOADSCREEN		"pic_loadscreen"
+
+#define		PIC_HANDANGO	"pic_handango"
+#define		DEMOTITLESCREEN	"demotitlescreen"
+
 #define		BUZZFLY_AMBIENT_WAV		"BUZZFLY_AMBIENT_WAV"
 #define		CHICKEN_AMBIENT_WAV		"CHICKEN_AMBIENT_WAV"
 #define		CHICKEN_BAGAWK_WAV		"CHICKEN_BAGAWK_WAV"


Commit: 22251ec2a77445d09f9f1100cd2752339acd075f
    https://github.com/scummvm/scummvm/commit/22251ec2a77445d09f9f1100cd2752339acd075f
Author: Strangerke (strangerke at scummvm.org)
Date: 2019-09-03T17:17:32+02:00

Commit Message:
HDB: Introduce two new enums for the sound

Changed paths:
    engines/hdb/sound.cpp
    engines/hdb/sound.h


diff --git a/engines/hdb/sound.cpp b/engines/hdb/sound.cpp
index ca7659c..e744af6 100644
--- a/engines/hdb/sound.cpp
+++ b/engines/hdb/sound.cpp
@@ -1427,14 +1427,14 @@ bool Sound::init() {
 	int index = 0;
 	while (soundList[index].idx != LAST_SOUND) {
 		int index2 = soundList[index].idx;
-		_soundCache[index2].loaded = 0;
+		_soundCache[index2].loaded = SNDMEM_NOTCACHED;
 		_soundCache[index2].name = soundList[index].name;
 		_soundCache[index2].luaName = soundList[index].luaName;
 		if (index2 <= SND_UNLOCKED_ITEM || index2 == SND_BEEPBEEPBEEP)
-			_soundCache[index2].ext = -1;	// WAV
+			_soundCache[index2].ext = SNDTYPE_WAV;
 		else
-			_soundCache[index2].ext = 1;		// MP3
-		debug(9, "Registering sound: sName: %s, \tsLuaName: %s, \tExtension: %s", soundList[index].name, soundList[index].luaName, _soundCache[index].ext == 1 ? "MP3" : "WAV");
+			_soundCache[index2].ext = SNDTYPE_MP3;
+		debug(9, "Registering sound: sName: %s, \tsLuaName: %s, \tExtension: %s", soundList[index].name, soundList[index].luaName, _soundCache[index].ext == SNDTYPE_MP3 ? "MP3" : "WAV");
 		index++;
 		if (index > kMaxSounds)
 			error("Reached MAX_SOUNDS in Sound::Init() !");
@@ -1481,24 +1481,24 @@ bool Sound::playSound(int index) {
 		return false;
 
 	// is sound in memory at least?
-	if (_soundCache[index].loaded == -1)
-		_soundCache[index].loaded = 1;
+	if (_soundCache[index].loaded == SNDMEM_FREEABLE)
+		_soundCache[index].loaded = SNDMEM_LOADED;
 
 	// is sound marked as cached?
-	if (!_soundCache[index].loaded) {
+	if (_soundCache[index].loaded == SNDMEM_NOTCACHED) {
 
 		Common::SeekableReadStream *stream = g_hdb->_fileMan->findFirstData(_soundCache[index].name, TYPE_BINARY);
 		if (stream == nullptr)
 			return false;
 
-		if (_soundCache[index].ext == 1) {
+		if (_soundCache[index].ext == SNDTYPE_MP3) {
 #ifdef USE_MAD
 			_soundCache[index].audioStream = Audio::makeMP3Stream(stream, DisposeAfterUse::YES);
-			_soundCache[index].loaded = 1;
+			_soundCache[index].loaded = SNDMEM_LOADED;
 #endif // USE_MAD
 		} else {
 			_soundCache[index].audioStream = Audio::makeWAVStream(stream, DisposeAfterUse::YES);
-			_soundCache[index].loaded = 1;
+			_soundCache[index].loaded = SNDMEM_LOADED;
 		}
 	} else {
 		_soundCache[index].audioStream->rewind();
@@ -1543,24 +1543,24 @@ bool Sound::playSoundEx(int index, int channel, bool loop) {
 		return false;
 
 	// is sound in memory at least?
-	if (_soundCache[index].loaded == -1)
-		_soundCache[index].loaded = 1;
+	if (_soundCache[index].loaded == SNDMEM_FREEABLE)
+		_soundCache[index].loaded = SNDMEM_LOADED;
 
 	// is sound marked as cached?
-	if (!_soundCache[index].loaded) {
+	if (_soundCache[index].loaded == SNDMEM_NOTCACHED) {
 
 		Common::SeekableReadStream *stream = g_hdb->_fileMan->findFirstData(_soundCache[index].name, TYPE_BINARY);
 		if (stream == nullptr)
 			return false;
 
-		if (_soundCache[index].ext == 1) {
+		if (_soundCache[index].ext == SNDTYPE_MP3) {
 #ifdef USE_MAD
 			_soundCache[index].audioStream = Audio::makeMP3Stream(stream, DisposeAfterUse::YES);
-			_soundCache[index].loaded = 1;
+			_soundCache[index].loaded = SNDMEM_LOADED;
 #endif // USE_MAD
 		} else {
 			_soundCache[index].audioStream = Audio::makeWAVStream(stream, DisposeAfterUse::YES);
-			_soundCache[index].loaded = 1;
+			_soundCache[index].loaded = SNDMEM_LOADED;
 		}
 	} else {
 		_soundCache[index].audioStream->rewind();
@@ -1606,9 +1606,8 @@ bool Sound::playVoice(int index, int actor) {
 		return false;
 
 	// is voice channel already active?  if so, shut 'er down (automagically called StopVoice via callback)
-	if (_voices[actor].active) {
+	if (_voices[actor].active)
 		g_hdb->_mixer->stopHandle(*_voices[actor].handle);
-	}
 
 #ifdef USE_MAD
 	Common::SeekableReadStream *stream = g_hdb->_fileMan->findFirstData(soundList[index].name, TYPE_BINARY);
@@ -1831,8 +1830,7 @@ void Sound::updateMusic() {
 }
 
 int Sound::registerSound(const char *name) {
-	int		index = 0;
-
+	int index = 0;
 	while (_soundCache[index].name) {
 		index++;
 		if (index == kMaxSounds)
@@ -1840,14 +1838,14 @@ int Sound::registerSound(const char *name) {
 	}
 
 	_soundCache[index].name = name;
-	_soundCache[index].loaded = 0;		// just to be sure!
+	_soundCache[index].loaded = SNDMEM_NOTCACHED;   // just to be sure!
 	return index;
 }
 
 bool Sound::freeSound(int index) {
-	if (_soundCache[index].loaded == 1) {
-		_soundCache[index].loaded = 0;
-		_soundCache[index].ext = 0;
+	if (_soundCache[index].loaded == SNDMEM_LOADED) {
+		_soundCache[index].loaded = SNDMEM_NOTCACHED;
+		_soundCache[index].ext = SNDTYPE_NONE;
 		return true;
 	}
 	return false;
@@ -1885,8 +1883,8 @@ SoundType Sound::whatSongIsPlaying() {
 void Sound::markSoundCacheFreeable() {
 	int	i;
 	for (i = 0; i < kMaxSounds; i++) {
-		if (_soundCache[i].loaded == 1)
-			_soundCache[i].loaded = -1;
+		if (_soundCache[i].loaded == SNDMEM_LOADED)
+			_soundCache[i].loaded = SNDMEM_FREEABLE;
 	}
 }
 
diff --git a/engines/hdb/sound.h b/engines/hdb/sound.h
index 9e04dad..516df9b 100644
--- a/engines/hdb/sound.h
+++ b/engines/hdb/sound.h
@@ -1434,15 +1434,27 @@ struct Voice {
 	}
 };
 
+enum SndMem {
+	SNDMEM_FREEABLE = -1,
+	SNDMEM_NOTCACHED = 0,
+	SNDMEM_LOADED = 1
+};
+
+enum SndType {
+	SNDTYPE_NONE = 0,
+	SNDTYPE_WAV = -1,
+	SNDTYPE_MP3 = 1
+};
+
 struct SoundCache {
-	int	loaded;				// -1 = freeable; in memory, 0 = not cached, 1 = cached
+	SndMem loaded; // -1 = freeable; in memory, 0 = not cached, 1 = cached
 	int32 size;				// size of sound
 	const char *name;				// filename / MSD name
 	const char *luaName;			// name used by Lua for i.d.
-	int ext;				// 0 = Uninitialized, -1 = WAV, 1 = MP3
+	SndType ext;				// 0 = Uninitialized, -1 = WAV, 1 = MP3
 	Audio::SeekableAudioStream *audioStream;
 
-	SoundCache() : loaded(0), size(0), name(nullptr), luaName(nullptr), ext(0), audioStream(nullptr) {}
+	SoundCache() : loaded(SNDMEM_NOTCACHED), size(0), name(nullptr), luaName(nullptr), ext(SNDTYPE_NONE), audioStream(nullptr) {}
 };
 
 struct Song {


Commit: 161553db9bbfb9f08f936f7b38e2f2ddcf793e07
    https://github.com/scummvm/scummvm/commit/161553db9bbfb9f08f936f7b38e2f2ddcf793e07
Author: Strangerke (strangerke at scummvm.org)
Date: 2019-09-03T17:17:32+02:00

Commit Message:
HDB: Reduce some more variable scopes, simplify a couple of checks in input.cpp

Changed paths:
    engines/hdb/gfx.cpp
    engines/hdb/input.cpp


diff --git a/engines/hdb/gfx.cpp b/engines/hdb/gfx.cpp
index 36ce3d9..8a6e353 100644
--- a/engines/hdb/gfx.cpp
+++ b/engines/hdb/gfx.cpp
@@ -1144,14 +1144,11 @@ Graphics::Surface Picture::load(Common::SeekableReadStream *stream) {
 	if (g_hdb->isPPC()) {
 		_surface.create(_height, _width, g_hdb->_format);
 
-		uint16 *ptr;
-
 		for (int y = 0; y < _height; y++) {
 			for (int x = 0; x < _width; x++) {
-				int u, v;
-				u = y;
-				v = _height - x - 1;
-				ptr = (uint16 *)_surface.getBasePtr(u, v);
+				int u = y;
+				int v = _height - x - 1;
+				uint16 *ptr = (uint16 *)_surface.getBasePtr(u, v);
 				*ptr = TO_LE_16(stream->readUint16LE());
 			}
 		}
@@ -1212,14 +1209,11 @@ Graphics::Surface Tile::load(Common::SeekableReadStream *stream) {
 
 	_surface.create(32, 32, g_hdb->_format);
 	if (g_hdb->isPPC()) {
-		uint16 *ptr;
-
 		for (int y = 0; y < 32; y++) {
 			for (int x = 0; x < 32; x++) {
-				int u, v;
-				u = y;
-				v = 32 - x - 1;
-				ptr = (uint16 *)_surface.getBasePtr(u, v);
+				int u = y;
+				int v = 32 - x - 1;
+				uint16 *ptr = (uint16 *)_surface.getBasePtr(u, v);
 				*ptr = TO_LE_16(stream->readUint16LE());
 			}
 		}
diff --git a/engines/hdb/input.cpp b/engines/hdb/input.cpp
index 99506a5..fb7f127 100644
--- a/engines/hdb/input.cpp
+++ b/engines/hdb/input.cpp
@@ -136,8 +136,8 @@ void Input::setButtons(uint16 b) {
 
 					g_hdb->_window->setSelectedDelivery(current);
 				} else if (_buttons & kButtonRight) {
-					int		amount = g_hdb->_ai->getDeliveriesAmount();
-					int		current = g_hdb->_window->getSelectedDelivery();
+					int amount = g_hdb->_ai->getDeliveriesAmount();
+					int current = g_hdb->_window->getSelectedDelivery();
 
 					current++;
 					if (current == amount)
@@ -156,7 +156,6 @@ void Input::setButtons(uint16 b) {
 				// select weapon?
 				if (_buttons & kButtonB) {
 					static AIType lastWeaponSelected = AI_NONE;
-					Tile *gfx;
 
 					if (!g_hdb->getActionMode()) {
 						g_hdb->_window->closeInv();
@@ -164,7 +163,7 @@ void Input::setButtons(uint16 b) {
 					}
 
 					AIType t = g_hdb->_ai->getInvItemType(g_hdb->_window->getInvSelect());
-					gfx = g_hdb->_ai->getInvItemGfx(g_hdb->_window->getInvSelect());
+					Tile *gfx = g_hdb->_ai->getInvItemGfx(g_hdb->_window->getInvSelect());
 
 					switch (t) {
 					case ITEM_CLUB:
@@ -205,8 +204,8 @@ void Input::setButtons(uint16 b) {
 					g_hdb->_sound->playSound(SND_MENU_SLIDER);
 					g_hdb->_window->setInvSelect(current);
 				} else if (_buttons & kButtonRight) {
-					int		amount = g_hdb->_ai->getInvMax();
-					int		current = g_hdb->_window->getInvSelect();
+					int amount = g_hdb->_ai->getInvMax();
+					int current = g_hdb->_window->getInvSelect();
 
 					if (!amount)
 						return;
@@ -226,10 +225,10 @@ void Input::setButtons(uint16 b) {
 					g_hdb->_sound->playSound(SND_MENU_SLIDER);
 					g_hdb->_window->setInvSelect(current);
 				} else if (_buttons & kButtonUp) {
-					int		amount = g_hdb->_ai->getInvMax();
-					int		current = g_hdb->_window->getInvSelect();
+					int	amount = g_hdb->_ai->getInvMax();
+					int	current = g_hdb->_window->getInvSelect();
 
-					if (!amount || amount < 6)
+					if (amount < 6)
 						return;
 
 					if (current - 5 >= 0)
@@ -238,10 +237,10 @@ void Input::setButtons(uint16 b) {
 					g_hdb->_sound->playSound(SND_MENU_SLIDER);
 					g_hdb->_window->setInvSelect(current);
 				} else if (_buttons & kButtonDown) {
-					int		amount = g_hdb->_ai->getInvMax();
-					int		current = g_hdb->_window->getInvSelect();
+					int amount = g_hdb->_ai->getInvMax();
+					int current = g_hdb->_window->getInvSelect();
 
-					if (!amount || amount < 6)
+					if (amount < 6)
 						return;
 
 					if (current + 5 < amount)
@@ -346,9 +345,10 @@ void Input::stylusDown(int x, int y) {
 		}
 
 		// Is MessageBar active?
-		if (g_hdb->_window->msgBarActive())
+		if (g_hdb->_window->msgBarActive()) {
 			if (g_hdb->_window->checkMsgClose(x, y))
 				return;
+		}
 
 		// In a cinematic?
 		if (g_hdb->_ai->playerLocked())
@@ -380,8 +380,8 @@ void Input::stylusDown(int x, int y) {
 		}
 
 		// Toggle Walk Speed if we clicked Player
-		int nx, ny;
 		static uint32 lastRunning = g_system->getMillis();
+		int nx, ny;
 		g_hdb->_ai->getPlayerXY(&nx, &ny);
 		if (nx == worldX && ny == worldY) {
 			if (lastRunning > g_system->getMillis())
@@ -426,7 +426,6 @@ void Input::stylusMove(int x, int y) {
 }
 
 void Input::updateMouse(int newX, int newY) {
-
 	if (g_hdb->isPPC())
 		return;
 
@@ -579,11 +578,10 @@ void Input::updateKeys(Common::Event event, bool keyDown) {
 			g_hdb->_menu->setMenuKey(0);
 		}
 	} else if (event.kbd.keycode == _keyDebug) {
-		if (keyDown) {
+		if (keyDown)
 			buttons |= kButtonExit;
-		} else {
+		else
 			buttons &= ~kButtonExit;
-		}
 	}
 
 	setButtons(buttons);


Commit: 361f47ff54a981bc5d506a2c18b3ff2a040a0637
    https://github.com/scummvm/scummvm/commit/361f47ff54a981bc5d506a2c18b3ff2a040a0637
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:32+02:00

Commit Message:
HDB: Prevent Backwards Seeking in GZipReadStream

Changed paths:
    engines/hdb/gfx.cpp


diff --git a/engines/hdb/gfx.cpp b/engines/hdb/gfx.cpp
index 8a6e353..8e2898f 100644
--- a/engines/hdb/gfx.cpp
+++ b/engines/hdb/gfx.cpp
@@ -23,6 +23,7 @@
 #include "common/cosinetables.h"
 #include "common/sinetables.h"
 #include "common/random.h"
+#include "common/memstream.h"
 
 #include "hdb/hdb.h"
 #include "hdb/ai.h"
@@ -769,44 +770,47 @@ bool Gfx::loadFont(const char *string) {
 		return false;
 	}
 
-	// Loading _fontHeader
-	_fontHeader.type = (int)stream->readUint32LE();
-	_fontHeader.numChars = (int)stream->readUint32LE();
-	_fontHeader.height = (int)stream->readUint32LE();
-	_fontHeader.kerning = (int)stream->readUint32LE();
-	_fontHeader.leading = (int)stream->readUint32LE();
+	if (g_hdb->isPPC()) {
+		const int32 ulength = g_hdb->_fileMan->getLength(string, TYPE_FONT);
+		byte *buffer = new byte[ulength];
+		stream->read(buffer, ulength);
+		Common::MemoryReadStream memoryStream(buffer, ulength, DisposeAfterUse::YES);
+		delete stream;
+		stream = &memoryStream;
 
-	debug(3, "Loaded _fontHeader with following data");
-	debug(3, "type: %d", _fontHeader.type);
-	debug(3, "numChars: %d", _fontHeader.numChars);
-	debug(3, "height: %d", _fontHeader.height);
-	debug(3, "kerning: %d", _fontHeader.kerning);
-	debug(3, "leading: %d", _fontHeader.leading);
+		// Loading _fontHeader
+		_fontHeader.type = (int)stream->readUint32LE();
+		_fontHeader.numChars = (int)stream->readUint32LE();
+		_fontHeader.height = (int)stream->readUint32LE();
+		_fontHeader.kerning = (int)stream->readUint32LE();
+		_fontHeader.leading = (int)stream->readUint32LE();
 
-	// Loading _charInfoBlocks & creating character surfaces
+		debug(3, "Loaded _fontHeader with following data");
+		debug(3, "type: %d", _fontHeader.type);
+		debug(3, "numChars: %d", _fontHeader.numChars);
+		debug(3, "height: %d", _fontHeader.height);
+		debug(3, "kerning: %d", _fontHeader.kerning);
+		debug(3, "leading: %d", _fontHeader.leading);
 
-	// Position after _fontHeader
-	int startPos = stream->pos();
-	uint16 *ptr;
-	for (int i = 0; i < _fontHeader.numChars; i++) {
-		CharInfo *cInfo = new CharInfo;
-		cInfo->width = (int16)stream->readUint32LE();
-		cInfo->offset = (int32)stream->readUint32LE();
+		// Loading _charInfoBlocks & creating character surfaces
 
-		debug(3, "Loaded _charInfoBlocks[%d]: width: %d, offset: %d", i, cInfo->width, cInfo->offset);
+		// Position after _fontHeader
+		int startPos = stream->pos();
+		uint16 *ptr;
+		for (int i = 0; i < _fontHeader.numChars; i++) {
+			CharInfo *cInfo = new CharInfo;
+			cInfo->width = (int16)stream->readUint32LE();
+			cInfo->offset = (int32)stream->readUint32LE();
 
-		// Position after reading cInfo
-		int curPos = stream->pos();
+			debug(3, "Loaded _charInfoBlocks[%d]: width: %d, offset: %d", i, cInfo->width, cInfo->offset);
+
+			// Position after reading cInfo
+			int curPos = stream->pos();
 
-		if (g_hdb->isPPC())
 			_fontSurfaces[i].create(_fontHeader.height, cInfo->width, g_hdb->_format);
-		else
-			_fontSurfaces[i].create(cInfo->width, _fontHeader.height, g_hdb->_format);
 
-		// Go to character location
-		stream->seek(startPos+cInfo->offset);
-
-		if (g_hdb->isPPC()) {
+			// Go to character location
+			stream->seek(startPos + cInfo->offset);
 
 			for (int y = 0; y < _fontHeader.height; y++) {
 				for (int x = 0; x < cInfo->width; x++) {
@@ -817,7 +821,50 @@ bool Gfx::loadFont(const char *string) {
 					*ptr = TO_LE_16(stream->readUint16LE());
 				}
 			}
-		} else {
+
+			stream->seek(curPos);
+
+			_charInfoBlocks.push_back(cInfo);
+		}
+
+		// Loading _fontGfx
+		_fontGfx = stream->readUint16LE();
+		delete stream;
+	} else {
+		// Loading _fontHeader
+		_fontHeader.type = (int)stream->readUint32LE();
+		_fontHeader.numChars = (int)stream->readUint32LE();
+		_fontHeader.height = (int)stream->readUint32LE();
+		_fontHeader.kerning = (int)stream->readUint32LE();
+		_fontHeader.leading = (int)stream->readUint32LE();
+
+		debug(3, "Loaded _fontHeader with following data");
+		debug(3, "type: %d", _fontHeader.type);
+		debug(3, "numChars: %d", _fontHeader.numChars);
+		debug(3, "height: %d", _fontHeader.height);
+		debug(3, "kerning: %d", _fontHeader.kerning);
+		debug(3, "leading: %d", _fontHeader.leading);
+
+		// Loading _charInfoBlocks & creating character surfaces
+
+		// Position after _fontHeader
+		int startPos = stream->pos();
+		uint16 *ptr;
+		for (int i = 0; i < _fontHeader.numChars; i++) {
+			CharInfo *cInfo = new CharInfo;
+			cInfo->width = (int16)stream->readUint32LE();
+			cInfo->offset = (int32)stream->readUint32LE();
+
+			debug(3, "Loaded _charInfoBlocks[%d]: width: %d, offset: %d", i, cInfo->width, cInfo->offset);
+
+			// Position after reading cInfo
+			int curPos = stream->pos();
+
+			_fontSurfaces[i].create(cInfo->width, _fontHeader.height, g_hdb->_format);
+
+			// Go to character location
+			stream->seek(startPos + cInfo->offset);
+
 			for (int y = 0; y < _fontHeader.height; y++) {
 				ptr = (uint16 *)_fontSurfaces[i].getBasePtr(0, y);
 				for (int x = 0; x < cInfo->width; x++) {
@@ -825,16 +872,16 @@ bool Gfx::loadFont(const char *string) {
 					ptr++;
 				}
 			}
-		}
 
-		stream->seek(curPos);
+			stream->seek(curPos);
 
-		_charInfoBlocks.push_back(cInfo);
-	}
+			_charInfoBlocks.push_back(cInfo);
+		}
 
-	// Loading _fontGfx
-	_fontGfx = stream->readUint16LE();
-	delete stream;
+		// Loading _fontGfx
+		_fontGfx = stream->readUint16LE();
+		delete stream;
+	}
 
 	return true;
 }


Commit: f11c3afea9542144e6e629e371ea097e622c3d59
    https://github.com/scummvm/scummvm/commit/f11c3afea9542144e6e629e371ea097e622c3d59
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:32+02:00

Commit Message:
HDB: Fix file len usage in compressed MSD files

Changed paths:
    engines/hdb/file-manager.cpp


diff --git a/engines/hdb/file-manager.cpp b/engines/hdb/file-manager.cpp
index c437cfd..cafc9cd 100644
--- a/engines/hdb/file-manager.cpp
+++ b/engines/hdb/file-manager.cpp
@@ -53,8 +53,7 @@ bool FileMan::openMPC(const Common::String &filename) {
 		_compressed = true;
 		debug("COMPRESSED MPC FILE");
 		return false;
-	}
-	else if (_dataHeader.id == MKTAG('M', 'P', 'C', 'U')) {
+	} else if (_dataHeader.id == MKTAG('M', 'P', 'C', 'U')) {
 		_compressed = false;
 
 		offset = _mpcFile->readUint32LE();
@@ -79,6 +78,8 @@ bool FileMan::openMPC(const Common::String &filename) {
 			dirEntry->ulength = _mpcFile->readUint32LE();
 			dirEntry->type = (DataType)_mpcFile->readUint32LE();
 
+			debug(9, "%d: %s off:%d len:%d ulen: %d type: %d", fileIndex, dirEntry->filename, dirEntry->offset, dirEntry->length, dirEntry->ulength, dirEntry->type);
+
 			_dir.push_back(dirEntry);
 		}
 
@@ -108,6 +109,8 @@ bool FileMan::openMPC(const Common::String &filename) {
 			dirEntry->ulength = _mpcFile->readUint32LE();
 			dirEntry->type = (DataType)_mpcFile->readUint32LE();
 
+			debug(9, "%d: %s off:%d len:%d ulen: %d type: %d", fileIndex, dirEntry->filename, dirEntry->offset, dirEntry->length, dirEntry->ulength, dirEntry->type);
+
 			_dir.push_back(dirEntry);
 		}
 
@@ -166,16 +169,16 @@ Common::SeekableReadStream *FileMan::findFirstData(const char *string, DataType
 
 	// Load corresponding file into a buffer
 	_mpcFile->seek(file->offset);
-	byte *buffer = (byte *)malloc(file->ulength * sizeof(byte));
+	byte *buffer = (byte *)malloc(file->length);
 
-	_mpcFile->read(buffer, file->ulength);
+	_mpcFile->read(buffer, file->length);
 
 	// Return buffer wrapped in a MemoryReadStream
 
 	if (_compressed)
-		return Common::wrapCompressedReadStream(new Common::MemoryReadStream(buffer, file->ulength, DisposeAfterUse::YES));
+		return Common::wrapCompressedReadStream(new Common::MemoryReadStream(buffer, file->length, DisposeAfterUse::YES));
 	else
-		return new Common::MemoryReadStream(buffer, file->ulength, DisposeAfterUse::YES);
+		return new Common::MemoryReadStream(buffer, file->length, DisposeAfterUse::YES);
 }
 
 int32 FileMan::getLength(const char *string, DataType type) {


Commit: c95682dc5015f7975581d1082ccad54dc32f0caf
    https://github.com/scummvm/scummvm/commit/c95682dc5015f7975581d1082ccad54dc32f0caf
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:32+02:00

Commit Message:
HDB: Remove redundant TO_16_LE() calls

Changed paths:
    engines/hdb/gfx.cpp


diff --git a/engines/hdb/gfx.cpp b/engines/hdb/gfx.cpp
index 8e2898f..29e1c55 100644
--- a/engines/hdb/gfx.cpp
+++ b/engines/hdb/gfx.cpp
@@ -818,7 +818,7 @@ bool Gfx::loadFont(const char *string) {
 					u = y;
 					v = _fontHeader.height - x - 1;
 					ptr = (uint16 *)_fontSurfaces[i].getBasePtr(u, v);
-					*ptr = TO_LE_16(stream->readUint16LE());
+					*ptr = stream->readUint16LE();
 				}
 			}
 
@@ -868,7 +868,7 @@ bool Gfx::loadFont(const char *string) {
 			for (int y = 0; y < _fontHeader.height; y++) {
 				ptr = (uint16 *)_fontSurfaces[i].getBasePtr(0, y);
 				for (int x = 0; x < cInfo->width; x++) {
-					*ptr = TO_LE_16(stream->readUint16LE());
+					*ptr = stream->readUint16LE();
 					ptr++;
 				}
 			}
@@ -1196,7 +1196,7 @@ Graphics::Surface Picture::load(Common::SeekableReadStream *stream) {
 				int u = y;
 				int v = _height - x - 1;
 				uint16 *ptr = (uint16 *)_surface.getBasePtr(u, v);
-				*ptr = TO_LE_16(stream->readUint16LE());
+				*ptr = stream->readUint16LE();
 			}
 		}
 
@@ -1207,7 +1207,7 @@ Graphics::Surface Picture::load(Common::SeekableReadStream *stream) {
 		for (int y = 0; y < _height; y++) {
 			uint16 *ptr = (uint16 *)_surface.getBasePtr(0, y);
 			for (int x = 0; x < _width; x++) {
-				*ptr = TO_LE_16(stream->readUint16LE());
+				*ptr = stream->readUint16LE();
 				ptr++;
 			}
 		}
@@ -1261,7 +1261,7 @@ Graphics::Surface Tile::load(Common::SeekableReadStream *stream) {
 				int u = y;
 				int v = 32 - x - 1;
 				uint16 *ptr = (uint16 *)_surface.getBasePtr(u, v);
-				*ptr = TO_LE_16(stream->readUint16LE());
+				*ptr = stream->readUint16LE();
 			}
 		}
 	} else {
@@ -1269,7 +1269,7 @@ Graphics::Surface Tile::load(Common::SeekableReadStream *stream) {
 		for (uint y = 0; y < 32; y++) {
 			uint16 *ptr = (uint16 *)_surface.getBasePtr(0, y);
 			for (uint x = 0; x < 32; x++) {
-				*ptr = TO_LE_16(stream->readUint16LE());
+				*ptr = stream->readUint16LE();
 				ptr++;
 			}
 		}


Commit: 6581e482300b0665a5af5aa75c5bf87cd33228ed
    https://github.com/scummvm/scummvm/commit/6581e482300b0665a5af5aa75c5bf87cd33228ed
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:32+02:00

Commit Message:
HDB: Add OGG Support for Linux

Changed paths:
    engines/hdb/sound.cpp
    engines/hdb/sound.h


diff --git a/engines/hdb/sound.cpp b/engines/hdb/sound.cpp
index e744af6..7be1e2a 100644
--- a/engines/hdb/sound.cpp
+++ b/engines/hdb/sound.cpp
@@ -1430,10 +1430,14 @@ bool Sound::init() {
 		_soundCache[index2].loaded = SNDMEM_NOTCACHED;
 		_soundCache[index2].name = soundList[index].name;
 		_soundCache[index2].luaName = soundList[index].luaName;
-		if (index2 <= SND_UNLOCKED_ITEM || index2 == SND_BEEPBEEPBEEP)
-			_soundCache[index2].ext = SNDTYPE_WAV;
-		else
-			_soundCache[index2].ext = SNDTYPE_MP3;
+		if (g_hdb->getPlatform() == Common::Platform::kPlatformLinux)
+			_soundCache[index2].ext = SNDTYPE_OGG;
+		else {
+			if (index2 <= SND_UNLOCKED_ITEM || index2 == SND_BEEPBEEPBEEP)
+				_soundCache[index2].ext = SNDTYPE_WAV;
+			else
+				_soundCache[index2].ext = SNDTYPE_MP3;
+		}
 		debug(9, "Registering sound: sName: %s, \tsLuaName: %s, \tExtension: %s", soundList[index].name, soundList[index].luaName, _soundCache[index].ext == SNDTYPE_MP3 ? "MP3" : "WAV");
 		index++;
 		if (index > kMaxSounds)
@@ -1487,7 +1491,14 @@ bool Sound::playSound(int index) {
 	// is sound marked as cached?
 	if (_soundCache[index].loaded == SNDMEM_NOTCACHED) {
 
-		Common::SeekableReadStream *stream = g_hdb->_fileMan->findFirstData(_soundCache[index].name, TYPE_BINARY);
+		Common::SeekableReadStream *stream = nullptr;
+		if (g_hdb->getPlatform() == Common::Platform::kPlatformLinux) {
+			Common::String updatedName(_soundCache[index].name);
+			updatedName.replace(updatedName.begin() + updatedName.size() - 4, updatedName.end(), "_OGG");
+			stream = g_hdb->_fileMan->findFirstData(updatedName.c_str(), TYPE_BINARY);
+		} else
+			stream = g_hdb->_fileMan->findFirstData(_soundCache[index].name, TYPE_BINARY);
+
 		if (stream == nullptr)
 			return false;
 
@@ -1496,6 +1507,11 @@ bool Sound::playSound(int index) {
 			_soundCache[index].audioStream = Audio::makeMP3Stream(stream, DisposeAfterUse::YES);
 			_soundCache[index].loaded = SNDMEM_LOADED;
 #endif // USE_MAD
+		} else if (_soundCache[index].ext == SNDTYPE_OGG) {
+#ifdef USE_VORBIS
+			_soundCache[index].audioStream = Audio::makeVorbisStream(stream, DisposeAfterUse::YES);
+			_soundCache[index].loaded = SNDMEM_LOADED;
+#endif // USE_VORBIS
 		} else {
 			_soundCache[index].audioStream = Audio::makeWAVStream(stream, DisposeAfterUse::YES);
 			_soundCache[index].loaded = SNDMEM_LOADED;
@@ -1549,7 +1565,14 @@ bool Sound::playSoundEx(int index, int channel, bool loop) {
 	// is sound marked as cached?
 	if (_soundCache[index].loaded == SNDMEM_NOTCACHED) {
 
-		Common::SeekableReadStream *stream = g_hdb->_fileMan->findFirstData(_soundCache[index].name, TYPE_BINARY);
+		Common::SeekableReadStream *stream = nullptr;
+		if (g_hdb->getPlatform() == Common::Platform::kPlatformLinux) {
+			Common::String updatedName(_soundCache[index].name);
+			updatedName.replace(updatedName.begin() + updatedName.size() - 4, updatedName.end(), "_OGG");
+			stream = g_hdb->_fileMan->findFirstData(updatedName.c_str(), TYPE_BINARY);
+		} else
+			stream = g_hdb->_fileMan->findFirstData(_soundCache[index].name, TYPE_BINARY);
+
 		if (stream == nullptr)
 			return false;
 
@@ -1558,6 +1581,11 @@ bool Sound::playSoundEx(int index, int channel, bool loop) {
 			_soundCache[index].audioStream = Audio::makeMP3Stream(stream, DisposeAfterUse::YES);
 			_soundCache[index].loaded = SNDMEM_LOADED;
 #endif // USE_MAD
+		} else if (_soundCache[index].ext == SNDTYPE_OGG) {
+#ifdef USE_VORBIS
+			_soundCache[index].audioStream = Audio::makeVorbisStream(stream, DisposeAfterUse::YES);
+			_soundCache[index].loaded = SNDMEM_LOADED;
+#endif // USE_VORBIS
 		} else {
 			_soundCache[index].audioStream = Audio::makeWAVStream(stream, DisposeAfterUse::YES);
 			_soundCache[index].loaded = SNDMEM_LOADED;
@@ -1609,34 +1637,66 @@ bool Sound::playVoice(int index, int actor) {
 	if (_voices[actor].active)
 		g_hdb->_mixer->stopHandle(*_voices[actor].handle);
 
-#ifdef USE_MAD
-	Common::SeekableReadStream *stream = g_hdb->_fileMan->findFirstData(soundList[index].name, TYPE_BINARY);
+	Common::SeekableReadStream *stream = nullptr;
+	if (g_hdb->getPlatform() == Common::Platform::kPlatformLinux) {
+		Common::String updatedName(soundList[index].name);
+		updatedName.replace(updatedName.begin() + updatedName.size() - 4, updatedName.end(), "_OGG");
+		stream = g_hdb->_fileMan->findFirstData(updatedName.c_str(), TYPE_BINARY);
+	} else
+		stream = g_hdb->_fileMan->findFirstData(soundList[index].name, TYPE_BINARY);
+
 	if (stream == nullptr)
 		return false;
-	Audio::AudioStream *audioStream = Audio::makeMP3Stream(stream, DisposeAfterUse::YES);
-	if (audioStream == nullptr) {
-		delete stream;
-		return false;
-	}
 
-	g_hdb->_mixer->setChannelVolume(*_voices[actor].handle, _sfxVolume);
+	if (g_hdb->getPlatform() == Common::Platform::kPlatformLinux) {
+#ifdef USE_VORBIS
+		Audio::AudioStream *audioStream = Audio::makeVorbisStream(stream, DisposeAfterUse::YES);
+		if (audioStream == nullptr) {
+			delete stream;
+			return false;
+		}
 
-	g_hdb->_mixer->playStream(
-		Audio::Mixer::kSpeechSoundType,
-		_voices[actor].handle,
-		audioStream,
-		-1,
-		Audio::Mixer::kMaxChannelVolume,
-		0,
-		DisposeAfterUse::YES,
-		false,
-		false
-	);
+		g_hdb->_mixer->setChannelVolume(*_voices[actor].handle, _sfxVolume);
+
+		g_hdb->_mixer->playStream(
+			Audio::Mixer::kSpeechSoundType,
+			_voices[actor].handle,
+			audioStream,
+			-1,
+			Audio::Mixer::kMaxChannelVolume,
+			0,
+			DisposeAfterUse::YES,
+			false,
+			false
+		);
+#endif
+	} else {
+#ifdef USE_MAD
+		Audio::AudioStream *audioStream = Audio::makeMP3Stream(stream, DisposeAfterUse::YES);
+		if (audioStream == nullptr) {
+			delete stream;
+			return false;
+		}
+
+		g_hdb->_mixer->setChannelVolume(*_voices[actor].handle, _sfxVolume);
+
+		g_hdb->_mixer->playStream(
+			Audio::Mixer::kSpeechSoundType,
+			_voices[actor].handle,
+			audioStream,
+			-1,
+			Audio::Mixer::kMaxChannelVolume,
+			0,
+			DisposeAfterUse::YES,
+			false,
+			false
+		);
+#endif
+	}
 
 	_voices[actor].active = true;
 	_voicePlayed[index - FIRST_VOICE] = 1;
 
-#endif
 	return true;
 }
 
@@ -1699,7 +1759,14 @@ void Sound::stopMusic() {
 }
 
 bool Sound::beginMusic(SoundType song, bool fadeIn, int ramp) {
-	const char *songName = soundList[song].name;
+	const char *songName = nullptr;
+
+	if (g_hdb->getPlatform() == Common::Platform::kPlatformLinux) {
+		Common::String updatedName(soundList[song].name);
+		updatedName.replace(updatedName.begin() + updatedName.size() - 4, updatedName.end(), ".ogg");
+		songName = updatedName.c_str();
+	} else
+		songName = soundList[song].name;
 
 	if (g_hdb->isPPC()) {
 		switch (song) {
@@ -1726,37 +1793,68 @@ bool Sound::beginMusic(SoundType song, bool fadeIn, int ramp) {
 		}
 
 		// Load up the song
-#ifdef USE_MAD
+
 		Common::SeekableReadStream *stream = SearchMan.createReadStreamForMember(songName);
 		if (stream == nullptr)
 			return false;
 
-		Audio::SeekableAudioStream *audioStream = Audio::makeMP3Stream(stream, DisposeAfterUse::YES);
-		Audio::AudioStream *loopingStream = new Audio::LoopingAudioStream(audioStream, 0, DisposeAfterUse::YES);
-
-		g_hdb->_mixer->setChannelVolume(*_song1.handle, _musicVolume);
-
-		// do we need to fade-in this song?
-		if (fadeIn) {
-			_song1.fadeInRamp = ramp;
-			_song1.fadingIn = true;
-			_song1.fadeInVol = 0;
-			g_hdb->_mixer->setChannelVolume(*_song1.handle, 0);
-		}
-
-		g_hdb->_mixer->playStream(
-			Audio::Mixer::kMusicSoundType,
-			_song1.handle,
-			loopingStream,
-			-1,
-			Audio::Mixer::kMaxChannelVolume,
-			0,
-			DisposeAfterUse::YES,
-			false,
-			false
-		);
-		_song1.playing = true;
+		if (g_hdb->getPlatform() != Common::Platform::kPlatformLinux) {
+#ifdef USE_MAD
+			Audio::SeekableAudioStream *audioStream = Audio::makeMP3Stream(stream, DisposeAfterUse::YES);
+			Audio::AudioStream *loopingStream = new Audio::LoopingAudioStream(audioStream, 0, DisposeAfterUse::YES);
+
+			g_hdb->_mixer->setChannelVolume(*_song1.handle, _musicVolume);
+
+			// do we need to fade-in this song?
+			if (fadeIn) {
+				_song1.fadeInRamp = ramp;
+				_song1.fadingIn = true;
+				_song1.fadeInVol = 0;
+				g_hdb->_mixer->setChannelVolume(*_song1.handle, 0);
+			}
+
+			g_hdb->_mixer->playStream(
+				Audio::Mixer::kMusicSoundType,
+				_song1.handle,
+				loopingStream,
+				-1,
+				Audio::Mixer::kMaxChannelVolume,
+				0,
+				DisposeAfterUse::YES,
+				false,
+				false
+			);
+			_song1.playing = true;
 #endif
+		} else {
+#ifdef USE_VORBIS
+			Audio::SeekableAudioStream *audioStream = Audio::makeVorbisStream(stream, DisposeAfterUse::YES);
+			Audio::AudioStream *loopingStream = new Audio::LoopingAudioStream(audioStream, 0, DisposeAfterUse::YES);
+
+			g_hdb->_mixer->setChannelVolume(*_song1.handle, _musicVolume);
+
+			// do we need to fade-in this song?
+			if (fadeIn) {
+				_song1.fadeInRamp = ramp;
+				_song1.fadingIn = true;
+				_song1.fadeInVol = 0;
+				g_hdb->_mixer->setChannelVolume(*_song1.handle, 0);
+			}
+
+			g_hdb->_mixer->playStream(
+				Audio::Mixer::kMusicSoundType,
+				_song1.handle,
+				loopingStream,
+				-1,
+				Audio::Mixer::kMaxChannelVolume,
+				0,
+				DisposeAfterUse::YES,
+				false,
+				false
+			);
+			_song1.playing = true;
+#endif
+		}
 	} else if (!_song2.playing) {
 		// Start fading out SONG1 if its playing
 		if (_song1.playing) {
@@ -1766,37 +1864,69 @@ bool Sound::beginMusic(SoundType song, bool fadeIn, int ramp) {
 		}
 
 		// Load up the song
-#ifdef USE_MAD
+
 		Common::SeekableReadStream *stream = SearchMan.createReadStreamForMember(songName);
 		if (stream == nullptr)
 			return false;
 
-		Audio::SeekableAudioStream *audioStream = Audio::makeMP3Stream(stream, DisposeAfterUse::YES);
-		Audio::AudioStream *loopingStream = new Audio::LoopingAudioStream(audioStream, 0, DisposeAfterUse::YES);
-
-		g_hdb->_mixer->setChannelVolume(*_song2.handle, _musicVolume);
-
-		// do we need to fade-in this song?
-		if (fadeIn) {
-			_song2.fadeInRamp = ramp;
-			_song2.fadingIn = true;
-			_song2.fadeInVol = 0;
-			g_hdb->_mixer->setChannelVolume(*_song2.handle, 0);
-		}
+		if (g_hdb->getPlatform() != Common::Platform::kPlatformLinux) {
+#ifdef USE_MAD
 
-		g_hdb->_mixer->playStream(
-			Audio::Mixer::kMusicSoundType,
-			_song2.handle,
-			loopingStream,
-			-1,
-			Audio::Mixer::kMaxChannelVolume,
-			0,
-			DisposeAfterUse::YES,
-			false,
-			false
-		);
-		_song2.playing = true;
+			Audio::SeekableAudioStream *audioStream = Audio::makeMP3Stream(stream, DisposeAfterUse::YES);
+			Audio::AudioStream *loopingStream = new Audio::LoopingAudioStream(audioStream, 0, DisposeAfterUse::YES);
+
+			g_hdb->_mixer->setChannelVolume(*_song2.handle, _musicVolume);
+
+			// do we need to fade-in this song?
+			if (fadeIn) {
+				_song2.fadeInRamp = ramp;
+				_song2.fadingIn = true;
+				_song2.fadeInVol = 0;
+				g_hdb->_mixer->setChannelVolume(*_song2.handle, 0);
+			}
+
+			g_hdb->_mixer->playStream(
+				Audio::Mixer::kMusicSoundType,
+				_song2.handle,
+				loopingStream,
+				-1,
+				Audio::Mixer::kMaxChannelVolume,
+				0,
+				DisposeAfterUse::YES,
+				false,
+				false
+			);
+			_song2.playing = true;
 #endif
+		} else {
+#ifdef USE_VORBIS
+			Audio::SeekableAudioStream *audioStream = Audio::makeVorbisStream(stream, DisposeAfterUse::YES);
+			Audio::AudioStream *loopingStream = new Audio::LoopingAudioStream(audioStream, 0, DisposeAfterUse::YES);
+
+			g_hdb->_mixer->setChannelVolume(*_song2.handle, _musicVolume);
+
+			// do we need to fade-in this song?
+			if (fadeIn) {
+				_song2.fadeInRamp = ramp;
+				_song2.fadingIn = true;
+				_song2.fadeInVol = 0;
+				g_hdb->_mixer->setChannelVolume(*_song2.handle, 0);
+			}
+
+			g_hdb->_mixer->playStream(
+				Audio::Mixer::kMusicSoundType,
+				_song2.handle,
+				loopingStream,
+				-1,
+				Audio::Mixer::kMaxChannelVolume,
+				0,
+				DisposeAfterUse::YES,
+				false,
+				false
+			);
+			_song2.playing = true;
+#endif
+		}
 	} else
 		return false;
 
diff --git a/engines/hdb/sound.h b/engines/hdb/sound.h
index 516df9b..c9c2eed 100644
--- a/engines/hdb/sound.h
+++ b/engines/hdb/sound.h
@@ -51,6 +51,7 @@
 #include "audio/mixer.h"
 #include "audio/decoders/wave.h"
 #include "audio/decoders/mp3.h"
+#include "audio/decoders/vorbis.h"
 
 namespace HDB {
 
@@ -1443,7 +1444,8 @@ enum SndMem {
 enum SndType {
 	SNDTYPE_NONE = 0,
 	SNDTYPE_WAV = -1,
-	SNDTYPE_MP3 = 1
+	SNDTYPE_MP3 = 1,
+	SNDTYPE_OGG = 2
 };
 
 struct SoundCache {


Commit: da005a61185506e5b62df096d92740fb2166808c
    https://github.com/scummvm/scummvm/commit/da005a61185506e5b62df096d92740fb2166808c
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:32+02:00

Commit Message:
HDB: Portability fixes

Changed paths:
    engines/hdb/sound.cpp


diff --git a/engines/hdb/sound.cpp b/engines/hdb/sound.cpp
index 7be1e2a..25f13d9 100644
--- a/engines/hdb/sound.cpp
+++ b/engines/hdb/sound.cpp
@@ -1430,7 +1430,7 @@ bool Sound::init() {
 		_soundCache[index2].loaded = SNDMEM_NOTCACHED;
 		_soundCache[index2].name = soundList[index].name;
 		_soundCache[index2].luaName = soundList[index].luaName;
-		if (g_hdb->getPlatform() == Common::Platform::kPlatformLinux)
+		if (g_hdb->getPlatform() == Common::kPlatformLinux)
 			_soundCache[index2].ext = SNDTYPE_OGG;
 		else {
 			if (index2 <= SND_UNLOCKED_ITEM || index2 == SND_BEEPBEEPBEEP)
@@ -1492,7 +1492,7 @@ bool Sound::playSound(int index) {
 	if (_soundCache[index].loaded == SNDMEM_NOTCACHED) {
 
 		Common::SeekableReadStream *stream = nullptr;
-		if (g_hdb->getPlatform() == Common::Platform::kPlatformLinux) {
+		if (g_hdb->getPlatform() == Common::kPlatformLinux) {
 			Common::String updatedName(_soundCache[index].name);
 			updatedName.replace(updatedName.begin() + updatedName.size() - 4, updatedName.end(), "_OGG");
 			stream = g_hdb->_fileMan->findFirstData(updatedName.c_str(), TYPE_BINARY);
@@ -1566,7 +1566,7 @@ bool Sound::playSoundEx(int index, int channel, bool loop) {
 	if (_soundCache[index].loaded == SNDMEM_NOTCACHED) {
 
 		Common::SeekableReadStream *stream = nullptr;
-		if (g_hdb->getPlatform() == Common::Platform::kPlatformLinux) {
+		if (g_hdb->getPlatform() == Common::kPlatformLinux) {
 			Common::String updatedName(_soundCache[index].name);
 			updatedName.replace(updatedName.begin() + updatedName.size() - 4, updatedName.end(), "_OGG");
 			stream = g_hdb->_fileMan->findFirstData(updatedName.c_str(), TYPE_BINARY);
@@ -1638,7 +1638,7 @@ bool Sound::playVoice(int index, int actor) {
 		g_hdb->_mixer->stopHandle(*_voices[actor].handle);
 
 	Common::SeekableReadStream *stream = nullptr;
-	if (g_hdb->getPlatform() == Common::Platform::kPlatformLinux) {
+	if (g_hdb->getPlatform() == Common::kPlatformLinux) {
 		Common::String updatedName(soundList[index].name);
 		updatedName.replace(updatedName.begin() + updatedName.size() - 4, updatedName.end(), "_OGG");
 		stream = g_hdb->_fileMan->findFirstData(updatedName.c_str(), TYPE_BINARY);
@@ -1648,7 +1648,7 @@ bool Sound::playVoice(int index, int actor) {
 	if (stream == nullptr)
 		return false;
 
-	if (g_hdb->getPlatform() == Common::Platform::kPlatformLinux) {
+	if (g_hdb->getPlatform() == Common::kPlatformLinux) {
 #ifdef USE_VORBIS
 		Audio::AudioStream *audioStream = Audio::makeVorbisStream(stream, DisposeAfterUse::YES);
 		if (audioStream == nullptr) {
@@ -1761,7 +1761,7 @@ void Sound::stopMusic() {
 bool Sound::beginMusic(SoundType song, bool fadeIn, int ramp) {
 	const char *songName = nullptr;
 
-	if (g_hdb->getPlatform() == Common::Platform::kPlatformLinux) {
+	if (g_hdb->getPlatform() == Common::kPlatformLinux) {
 		Common::String updatedName(soundList[song].name);
 		updatedName.replace(updatedName.begin() + updatedName.size() - 4, updatedName.end(), ".ogg");
 		songName = updatedName.c_str();
@@ -1798,7 +1798,7 @@ bool Sound::beginMusic(SoundType song, bool fadeIn, int ramp) {
 		if (stream == nullptr)
 			return false;
 
-		if (g_hdb->getPlatform() != Common::Platform::kPlatformLinux) {
+		if (g_hdb->getPlatform() != Common::kPlatformLinux) {
 #ifdef USE_MAD
 			Audio::SeekableAudioStream *audioStream = Audio::makeMP3Stream(stream, DisposeAfterUse::YES);
 			Audio::AudioStream *loopingStream = new Audio::LoopingAudioStream(audioStream, 0, DisposeAfterUse::YES);
@@ -1869,7 +1869,7 @@ bool Sound::beginMusic(SoundType song, bool fadeIn, int ramp) {
 		if (stream == nullptr)
 			return false;
 
-		if (g_hdb->getPlatform() != Common::Platform::kPlatformLinux) {
+		if (g_hdb->getPlatform() != Common::kPlatformLinux) {
 #ifdef USE_MAD
 
 			Audio::SeekableAudioStream *audioStream = Audio::makeMP3Stream(stream, DisposeAfterUse::YES);


Commit: 1658fc806347187be46c132acda6e4dac26c37da
    https://github.com/scummvm/scummvm/commit/1658fc806347187be46c132acda6e4dac26c37da
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:32+02:00

Commit Message:
HDB: Do not use dereferencing for GZip stream

Changed paths:
    engines/hdb/gfx.cpp


diff --git a/engines/hdb/gfx.cpp b/engines/hdb/gfx.cpp
index 29e1c55..217d6bb 100644
--- a/engines/hdb/gfx.cpp
+++ b/engines/hdb/gfx.cpp
@@ -776,14 +776,13 @@ bool Gfx::loadFont(const char *string) {
 		stream->read(buffer, ulength);
 		Common::MemoryReadStream memoryStream(buffer, ulength, DisposeAfterUse::YES);
 		delete stream;
-		stream = &memoryStream;
 
 		// Loading _fontHeader
-		_fontHeader.type = (int)stream->readUint32LE();
-		_fontHeader.numChars = (int)stream->readUint32LE();
-		_fontHeader.height = (int)stream->readUint32LE();
-		_fontHeader.kerning = (int)stream->readUint32LE();
-		_fontHeader.leading = (int)stream->readUint32LE();
+		_fontHeader.type = (int)memoryStream.readUint32LE();
+		_fontHeader.numChars = (int)memoryStream.readUint32LE();
+		_fontHeader.height = (int)memoryStream.readUint32LE();
+		_fontHeader.kerning = (int)memoryStream.readUint32LE();
+		_fontHeader.leading = (int)memoryStream.readUint32LE();
 
 		debug(3, "Loaded _fontHeader with following data");
 		debug(3, "type: %d", _fontHeader.type);
@@ -795,22 +794,22 @@ bool Gfx::loadFont(const char *string) {
 		// Loading _charInfoBlocks & creating character surfaces
 
 		// Position after _fontHeader
-		int startPos = stream->pos();
+		int startPos = memoryStream.pos();
 		uint16 *ptr;
 		for (int i = 0; i < _fontHeader.numChars; i++) {
 			CharInfo *cInfo = new CharInfo;
-			cInfo->width = (int16)stream->readUint32LE();
-			cInfo->offset = (int32)stream->readUint32LE();
+			cInfo->width = (int16)memoryStream.readUint32LE();
+			cInfo->offset = (int32)memoryStream.readUint32LE();
 
 			debug(3, "Loaded _charInfoBlocks[%d]: width: %d, offset: %d", i, cInfo->width, cInfo->offset);
 
 			// Position after reading cInfo
-			int curPos = stream->pos();
+			int curPos = memoryStream.pos();
 
 			_fontSurfaces[i].create(_fontHeader.height, cInfo->width, g_hdb->_format);
 
 			// Go to character location
-			stream->seek(startPos + cInfo->offset);
+			memoryStream.seek(startPos + cInfo->offset);
 
 			for (int y = 0; y < _fontHeader.height; y++) {
 				for (int x = 0; x < cInfo->width; x++) {
@@ -818,18 +817,17 @@ bool Gfx::loadFont(const char *string) {
 					u = y;
 					v = _fontHeader.height - x - 1;
 					ptr = (uint16 *)_fontSurfaces[i].getBasePtr(u, v);
-					*ptr = stream->readUint16LE();
+					*ptr = memoryStream.readUint16LE();
 				}
 			}
 
-			stream->seek(curPos);
+			memoryStream.seek(curPos);
 
 			_charInfoBlocks.push_back(cInfo);
 		}
 
 		// Loading _fontGfx
-		_fontGfx = stream->readUint16LE();
-		delete stream;
+		_fontGfx = memoryStream.readUint16LE();
 	} else {
 		// Loading _fontHeader
 		_fontHeader.type = (int)stream->readUint32LE();


Commit: d548d1dfb8f44b9c3c8071518ac4616c961a79fa
    https://github.com/scummvm/scummvm/commit/d548d1dfb8f44b9c3c8071518ac4616c961a79fa
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:32+02:00

Commit Message:
HDB: Simplify findFirstData()

Changed paths:
    engines/hdb/file-manager.cpp


diff --git a/engines/hdb/file-manager.cpp b/engines/hdb/file-manager.cpp
index cafc9cd..c7f39f7 100644
--- a/engines/hdb/file-manager.cpp
+++ b/engines/hdb/file-manager.cpp
@@ -173,12 +173,9 @@ Common::SeekableReadStream *FileMan::findFirstData(const char *string, DataType
 
 	_mpcFile->read(buffer, file->length);
 
-	// Return buffer wrapped in a MemoryReadStream
-
-	if (_compressed)
-		return Common::wrapCompressedReadStream(new Common::MemoryReadStream(buffer, file->length, DisposeAfterUse::YES));
-	else
-		return new Common::MemoryReadStream(buffer, file->length, DisposeAfterUse::YES);
+	// Return buffer wrapped in a MemoryReadStream, automatically
+	// uncompressed if it is zlib-compressed
+	return Common::wrapCompressedReadStream(new Common::MemoryReadStream(buffer, file->length, DisposeAfterUse::NO), file->length);
 }
 
 int32 FileMan::getLength(const char *string, DataType type) {


Commit: 1f02749874d2047d8694ccd5f142326848c54e6c
    https://github.com/scummvm/scummvm/commit/1f02749874d2047d8694ccd5f142326848c54e6c
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:32+02:00

Commit Message:
HDB: Simplify openMPC()

Changed paths:
    engines/hdb/file-manager.cpp
    engines/hdb/file-manager.h


diff --git a/engines/hdb/file-manager.cpp b/engines/hdb/file-manager.cpp
index c7f39f7..3af8066 100644
--- a/engines/hdb/file-manager.cpp
+++ b/engines/hdb/file-manager.cpp
@@ -50,79 +50,49 @@ bool FileMan::openMPC(const Common::String &filename) {
 	_dataHeader.id = _mpcFile->readUint32BE();
 
 	if (_dataHeader.id == MKTAG('M', 'P', 'C', 'C')) {
-		_compressed = true;
 		debug("COMPRESSED MPC FILE");
 		return false;
 	} else if (_dataHeader.id == MKTAG('M', 'P', 'C', 'U')) {
-		_compressed = false;
-
-		offset = _mpcFile->readUint32LE();
-		_mpcFile->seek((int32)offset);
-
-		// Note: The MPC archive format assumes the offset to be uint32,
-		// but Common::File::seek() takes the offset as int32.
-
-		_dataHeader.dirSize = _mpcFile->readUint32LE();
-
-		debug(8, "MPCU: Read %d entries", _dataHeader.dirSize);
-
-		for (uint32 fileIndex = 0; fileIndex < _dataHeader.dirSize; fileIndex++) {
-			MPCEntry *dirEntry = new MPCEntry();
-
-			for (int i = 0; i < 64; i++) {
-				dirEntry->filename[i] = tolower(_mpcFile->readByte());
-			}
-
-			dirEntry->offset = _mpcFile->readUint32LE();
-			dirEntry->length = _mpcFile->readUint32LE();
-			dirEntry->ulength = _mpcFile->readUint32LE();
-			dirEntry->type = (DataType)_mpcFile->readUint32LE();
-
-			debug(9, "%d: %s off:%d len:%d ulen: %d type: %d", fileIndex, dirEntry->filename, dirEntry->offset, dirEntry->length, dirEntry->ulength, dirEntry->type);
-
-			_dir.push_back(dirEntry);
-		}
-
-		return true;
+		// we're fine
 	} else if (_dataHeader.id == MKTAG('M', 'S', 'D', 'C')) {
-		_compressed = true;
-
-		offset = _mpcFile->readUint32LE();
-		_mpcFile->seek((int32)offset);
+		// we're fine
+	} else if (_dataHeader.id == MKTAG('M', 'S', 'D', 'U')) {
+		debug("UNCOMPRESSED MSD FILE");
+		return false;
+	} else {
+		error("Invalid MPC/MSD File.");
+		return false;
+	}
 
-		// Note: The MPC archive format assumes the offset to be uint32,
-		// but Common::File::seek() takes the offset as int32.
+	// read the directory
+	offset = _mpcFile->readUint32LE();
+	_mpcFile->seek((int32)offset);
 
-		_dataHeader.dirSize = _mpcFile->readUint32LE();
+	// Note: The MPC archive format assumes the offset to be uint32,
+	// but Common::File::seek() takes the offset as int32.
 
-		debug(8, "MSDC: Read %d entries", _dataHeader.dirSize);
+	_dataHeader.dirSize = _mpcFile->readUint32LE();
 
-		for (uint32 fileIndex = 0; fileIndex < _dataHeader.dirSize; fileIndex++) {
-			MPCEntry *dirEntry = new MPCEntry();
+	debug(8, "MPCU: Read %d entries", _dataHeader.dirSize);
 
-			for (int i = 0; i < 64; i++) {
-				dirEntry->filename[i] = tolower(_mpcFile->readByte());
-			}
+	for (uint32 fileIndex = 0; fileIndex < _dataHeader.dirSize; fileIndex++) {
+		MPCEntry *dirEntry = new MPCEntry();
 
-			dirEntry->offset = _mpcFile->readUint32LE();
-			dirEntry->length = _mpcFile->readUint32LE();
-			dirEntry->ulength = _mpcFile->readUint32LE();
-			dirEntry->type = (DataType)_mpcFile->readUint32LE();
+		for (int i = 0; i < 64; i++) {
+			dirEntry->filename[i] = tolower(_mpcFile->readByte());
+		}
 
-			debug(9, "%d: %s off:%d len:%d ulen: %d type: %d", fileIndex, dirEntry->filename, dirEntry->offset, dirEntry->length, dirEntry->ulength, dirEntry->type);
+		dirEntry->offset = _mpcFile->readUint32LE();
+		dirEntry->length = _mpcFile->readUint32LE();
+		dirEntry->ulength = _mpcFile->readUint32LE();
+		dirEntry->type = (DataType)_mpcFile->readUint32LE();
 
-			_dir.push_back(dirEntry);
-		}
+		debug(9, "%d: %s off:%d len:%d ulen: %d type: %d", fileIndex, dirEntry->filename, dirEntry->offset, dirEntry->length, dirEntry->ulength, dirEntry->type);
 
-		return true;
-	} else if (_dataHeader.id == MKTAG('M', 'S', 'D', 'U')) {
-		_compressed = false;
-		debug("UNCOMPRESSED MSD FILE");
-		return false;
+		_dir.push_back(dirEntry);
 	}
 
-	error("Invalid MPC/MSD File.");
-	return false;
+	return true;
 }
 
 void FileMan::closeMPC() {
diff --git a/engines/hdb/file-manager.h b/engines/hdb/file-manager.h
index d4cae4d..faa8e84 100644
--- a/engines/hdb/file-manager.h
+++ b/engines/hdb/file-manager.h
@@ -57,7 +57,6 @@ private:
 
 	Common::File *_mpcFile;
 	Common::Array<MPCEntry *> _dir;
-	bool _compressed;
 
 public:
 


Commit: e514a6c8c1f16f1f81a9b66a5c4d88ac39d49bc6
    https://github.com/scummvm/scummvm/commit/e514a6c8c1f16f1f81a9b66a5c4d88ac39d49bc6
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:32+02:00

Commit Message:
HDB: Better error messages

Changed paths:
    engines/hdb/file-manager.cpp
    engines/hdb/hdb.cpp


diff --git a/engines/hdb/file-manager.cpp b/engines/hdb/file-manager.cpp
index 3af8066..1e23032 100644
--- a/engines/hdb/file-manager.cpp
+++ b/engines/hdb/file-manager.cpp
@@ -43,7 +43,7 @@ bool FileMan::openMPC(const Common::String &filename) {
 	uint32 offset;
 
 	if (!_mpcFile->open(filename)) {
-		error("FileMan::openMPC(): Error reading the MSD/MPC file");
+		error("FileMan::openMPC(): Error reading the MSD/MPC file %s", filename.c_str());
 		return false;
 	}
 
diff --git a/engines/hdb/hdb.cpp b/engines/hdb/hdb.cpp
index 6fbafa9..f620bd3 100644
--- a/engines/hdb/hdb.cpp
+++ b/engines/hdb/hdb.cpp
@@ -126,7 +126,7 @@ bool HDBGame::init() {
 	// Init fileMan
 
 	if (!_fileMan->openMPC(getGameFile())) {
-		error("FileMan::openMPC: Cannot find the hyperspace.mpc data file.");
+		error("FileMan::openMPC: Cannot find the %s data file", getGameFile());
 	}
 	if (!_gfx->init()) {
 		error("Gfx::init: Couldn't initialize Gfx");


Commit: 4406d89743edf6ee8c97bfa87442b02d60196868
    https://github.com/scummvm/scummvm/commit/4406d89743edf6ee8c97bfa87442b02d60196868
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:32+02:00

Commit Message:
HDB: Move heavy lifting out of HDBGame constructor

Changed paths:
    engines/hdb/hdb.cpp


diff --git a/engines/hdb/hdb.cpp b/engines/hdb/hdb.cpp
index f620bd3..f64ef4e 100644
--- a/engines/hdb/hdb.cpp
+++ b/engines/hdb/hdb.cpp
@@ -44,6 +44,7 @@ namespace HDB {
 HDBGame* g_hdb;
 
 HDBGame::HDBGame(OSystem *syst, const ADGameDescription *gameDesc) : Engine(syst), _gameDescription(gameDesc) {
+	g_hdb = this;
 	if (isPPC()) {
 		_screenWidth = 240;
 		_screenHeight = 320;
@@ -60,16 +61,16 @@ HDBGame::HDBGame(OSystem *syst, const ADGameDescription *gameDesc) : Engine(syst
 
 	_format = Graphics::PixelFormat(2, 5, 6, 5, 0, 11, 5, 0, 0);
 	_systemInit = false;
-	g_hdb = this;
-	_fileMan = new FileMan;
-	_gfx = new Gfx;
-	_lua = new LuaScript;
-	_menu = new Menu;
-	_map = new Map;
-	_ai = new AI;
-	_input = new Input;
-	_sound = new Sound;
-	_window = new Window;
+
+	_fileMan = nullptr;
+	_gfx = nullptr;
+	_lua = nullptr;
+	_menu = nullptr;
+	_map = nullptr;
+	_ai = nullptr;
+	_input = nullptr;
+	_sound = nullptr;
+	_window = nullptr;
 	_rnd = new Common::RandomSource("hdb");
 
 	_cheating = false;
@@ -123,6 +124,17 @@ bool HDBGame::init() {
 		Game Subsystem Initializations
 	*/
 
+	_systemInit = false;
+	_fileMan = new FileMan;
+	_gfx = new Gfx;
+	_lua = new LuaScript;
+	_menu = new Menu;
+	_map = new Map;
+	_ai = new AI;
+	_input = new Input;
+	_sound = new Sound;
+	_window = new Window;
+
 	// Init fileMan
 
 	if (!_fileMan->openMPC(getGameFile())) {


Commit: 5a0305bb9a5b1e1a57f2c648101312e2935992a8
    https://github.com/scummvm/scummvm/commit/5a0305bb9a5b1e1a57f2c648101312e2935992a8
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:32+02:00

Commit Message:
HDB: Fix warnings

Changed paths:
    engines/hdb/ai-funcs.cpp
    engines/hdb/map.cpp


diff --git a/engines/hdb/ai-funcs.cpp b/engines/hdb/ai-funcs.cpp
index 73e0b8e..a633952 100644
--- a/engines/hdb/ai-funcs.cpp
+++ b/engines/hdb/ai-funcs.cpp
@@ -2238,7 +2238,7 @@ void AI::getItemSound(AIType type) {
 				g_hdb->_sound->playSound(SND_GET_THING);
 			break;
 		}
-		// fall through if it is PPC
+		// fall through
 	default: g_hdb->_sound->playSound(SND_GET_THING);
 	}
 }
diff --git a/engines/hdb/map.cpp b/engines/hdb/map.cpp
index cd605a9..5defd86 100644
--- a/engines/hdb/map.cpp
+++ b/engines/hdb/map.cpp
@@ -632,6 +632,7 @@ bool Map::load(Common::SeekableReadStream *stream) {
 			case AI_DEADEYE:
 				if (_iconList[i].value1 == 1)	// For non-moving DeadEyes
 					break;
+				// fall through
 			case AI_FOURFIRER:
 			case AI_LISTENBOT:
 			case ITEM_CLUB:


Commit: b89f14360b2d4aadaf153624c0e2eca53140773d
    https://github.com/scummvm/scummvm/commit/b89f14360b2d4aadaf153624c0e2eca53140773d
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:32+02:00

Commit Message:
HDB: Fix crash in gfx loading

Changed paths:
    engines/hdb/gfx.cpp


diff --git a/engines/hdb/gfx.cpp b/engines/hdb/gfx.cpp
index 217d6bb..8805da0 100644
--- a/engines/hdb/gfx.cpp
+++ b/engines/hdb/gfx.cpp
@@ -815,7 +815,7 @@ bool Gfx::loadFont(const char *string) {
 				for (int x = 0; x < cInfo->width; x++) {
 					int u, v;
 					u = y;
-					v = _fontHeader.height - x - 1;
+					v = cInfo->width - x - 1;
 					ptr = (uint16 *)_fontSurfaces[i].getBasePtr(u, v);
 					*ptr = memoryStream.readUint16LE();
 				}
@@ -1192,7 +1192,7 @@ Graphics::Surface Picture::load(Common::SeekableReadStream *stream) {
 		for (int y = 0; y < _height; y++) {
 			for (int x = 0; x < _width; x++) {
 				int u = y;
-				int v = _height - x - 1;
+				int v = _width - x - 1;
 				uint16 *ptr = (uint16 *)_surface.getBasePtr(u, v);
 				*ptr = stream->readUint16LE();
 			}


Commit: 1fd83bf7a2e0783683e73012c002b6e3ea978981
    https://github.com/scummvm/scummvm/commit/1fd83bf7a2e0783683e73012c002b6e3ea978981
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:32+02:00

Commit Message:
HDB: Initialise skipped variables in PPC mode

Changed paths:
    engines/hdb/gfx.cpp


diff --git a/engines/hdb/gfx.cpp b/engines/hdb/gfx.cpp
index 8805da0..f1b1012 100644
--- a/engines/hdb/gfx.cpp
+++ b/engines/hdb/gfx.cpp
@@ -176,6 +176,16 @@ bool Gfx::init() {
 		_starField[2] = getPicture(PIC_STAR192);
 		_starField[3] = getPicture(PIC_STAR256);
 		_snowflake = getPicture(PIC_SNOWFLAKE);
+	} else {
+		for (int i = 0; i < 7; i++)
+			_mousePointer[i] = NULL;
+
+		for (int i = 0; i < 4; i++)
+			_starField[i] = NULL;
+
+		_snowflake = NULL;
+
+		_showCursor = false;
 	}
 
 	_systemInit = true;


Commit: 41696e9efd58da9065f98a2a879e3fea3303cacb
    https://github.com/scummvm/scummvm/commit/41696e9efd58da9065f98a2a879e3fea3303cacb
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:32+02:00

Commit Message:
HDB: Fix PPC screen dimensions

Changed paths:
    engines/hdb/hdb.cpp


diff --git a/engines/hdb/hdb.cpp b/engines/hdb/hdb.cpp
index f64ef4e..cfe57cc 100644
--- a/engines/hdb/hdb.cpp
+++ b/engines/hdb/hdb.cpp
@@ -46,10 +46,10 @@ HDBGame* g_hdb;
 HDBGame::HDBGame(OSystem *syst, const ADGameDescription *gameDesc) : Engine(syst), _gameDescription(gameDesc) {
 	g_hdb = this;
 	if (isPPC()) {
-		_screenWidth = 240;
-		_screenHeight = 320;
-		_screenDrawWidth = 240;
-		_screenDrawHeight = 320;
+		_screenWidth = 320;
+		_screenHeight = 240;
+		_screenDrawWidth = 320;
+		_screenDrawHeight = 240;
 		_progressY = 280;
 	} else {
 		_screenWidth = 640;


Commit: 5570f784b6880c94e0dcfa433ea8ffcb53d4d79f
    https://github.com/scummvm/scummvm/commit/5570f784b6880c94e0dcfa433ea8ffcb53d4d79f
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:32+02:00

Commit Message:
HDB: Initialise more variables

Changed paths:
    engines/hdb/gfx.cpp
    engines/hdb/hdb.cpp


diff --git a/engines/hdb/gfx.cpp b/engines/hdb/gfx.cpp
index f1b1012..e0ded0f 100644
--- a/engines/hdb/gfx.cpp
+++ b/engines/hdb/gfx.cpp
@@ -177,7 +177,7 @@ bool Gfx::init() {
 		_starField[3] = getPicture(PIC_STAR256);
 		_snowflake = getPicture(PIC_SNOWFLAKE);
 	} else {
-		for (int i = 0; i < 7; i++)
+		for (int i = 0; i < 8; i++)
 			_mousePointer[i] = NULL;
 
 		for (int i = 0; i < 4; i++)
diff --git a/engines/hdb/hdb.cpp b/engines/hdb/hdb.cpp
index cfe57cc..630766e 100644
--- a/engines/hdb/hdb.cpp
+++ b/engines/hdb/hdb.cpp
@@ -177,6 +177,8 @@ bool HDBGame::init() {
 	_systemInit = true;
 	if (!g_hdb->isPPC())
 		_loadingScreenGfx = _gfx->loadPic(PIC_LOADSCREEN);
+	else
+		_loadingScreenGfx = NULL;
 
 	return true;
 }


Commit: 1157a88cca189e18153088e35ae9bdfec9d629e9
    https://github.com/scummvm/scummvm/commit/1157a88cca189e18153088e35ae9bdfec9d629e9
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:32+02:00

Commit Message:
HDB: Fix mismatched delete

Changed paths:
    engines/hdb/gfx.cpp


diff --git a/engines/hdb/gfx.cpp b/engines/hdb/gfx.cpp
index e0ded0f..e44b96e 100644
--- a/engines/hdb/gfx.cpp
+++ b/engines/hdb/gfx.cpp
@@ -782,7 +782,7 @@ bool Gfx::loadFont(const char *string) {
 
 	if (g_hdb->isPPC()) {
 		const int32 ulength = g_hdb->_fileMan->getLength(string, TYPE_FONT);
-		byte *buffer = new byte[ulength];
+		byte *buffer = (byte *)malloc(ulength);
 		stream->read(buffer, ulength);
 		Common::MemoryReadStream memoryStream(buffer, ulength, DisposeAfterUse::YES);
 		delete stream;


Commit: c12a068bcc8d4b593f0475401577c316c71c0104
    https://github.com/scummvm/scummvm/commit/c12a068bcc8d4b593f0475401577c316c71c0104
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:33+02:00

Commit Message:
HDB: Better Lua tracing

Changed paths:
    engines/hdb/lua-script.cpp


diff --git a/engines/hdb/lua-script.cpp b/engines/hdb/lua-script.cpp
index 495d30c..57fedcf 100644
--- a/engines/hdb/lua-script.cpp
+++ b/engines/hdb/lua-script.cpp
@@ -1829,15 +1829,15 @@ bool LuaScript::initScript(Common::SeekableReadStream *stream, const char *scrip
 
 	// Make sure we start from the beginning
 	_globalLuaStream->seek(0);
-	if (!executeMPC(_globalLuaStream, "global code", "GLOBAL.LUA", _globalLuaLength)) {
+	if (!executeMPC(_globalLuaStream, "GLOBAL.LUA", "GLOBAL.LUA", _globalLuaLength)) {
 		error("LuaScript::initScript: 'global code' failed to execute");
 		return false;
 	}
 
 	// Load script and execute it
 
-	if (!executeMPC(stream, "level code", scriptName, length)) {
-		error("LuaScript::initScript: 'level code' failed to execute");
+	if (!executeMPC(stream, scriptName, scriptName, length)) {
+		error("LuaScript::initScript: %s failed to execute", scriptName);
 		return false;
 	}
 


Commit: fab015edd29d78e9286ac2021987e4b804a4a6bc
    https://github.com/scummvm/scummvm/commit/fab015edd29d78e9286ac2021987e4b804a4a6bc
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:33+02:00

Commit Message:
HDB: Fix script patch for MAP01

Changed paths:
    engines/hdb/lua-script.cpp


diff --git a/engines/hdb/lua-script.cpp b/engines/hdb/lua-script.cpp
index 57fedcf..98b6dc3 100644
--- a/engines/hdb/lua-script.cpp
+++ b/engines/hdb/lua-script.cpp
@@ -64,7 +64,7 @@ struct ScriptPatch {
 
 	{"MAP01", "strsub(", "string.sub("}, // line 23
 	{"MAP01", "if( covert_index < getn(covert_dialog) ) then", "if( covert_index < #covert_dialog ) then"}, // line 766
-	{"MAP01", "if( chiste_index < getn( chiste_dialog ) )then", "if( covert_index < #covert_dialog ) then"}, // 845
+	{"MAP01", "if( chiste_index < getn( chiste_dialog ) )then", "if( covert_index < #chiste_dialog ) then"}, // 845
 
 	{"MAP10", "if( getn( beds ) == 0 ) then", "if( #beds == 0 ) then"}, // line 119
 	{"MAP10", "emptybed_use( %x, %y, %v1, %v2 )", "emptybed_use( x, y, v1, v2 )"}, // line 121


Commit: 53534edc8fe31c5d640328a083506bbe5b0dacb0
    https://github.com/scummvm/scummvm/commit/53534edc8fe31c5d640328a083506bbe5b0dacb0
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:33+02:00

Commit Message:
HDB: Fix PPC controls

Changed paths:
    engines/hdb/input.cpp


diff --git a/engines/hdb/input.cpp b/engines/hdb/input.cpp
index fb7f127..15ba7fc 100644
--- a/engines/hdb/input.cpp
+++ b/engines/hdb/input.cpp
@@ -45,9 +45,6 @@ bool Input::init() {
 	_keyDebug = Common::KEYCODE_F1;
 	_keyQuit = Common::KEYCODE_F10;
 
-	if (g_hdb->isPPC())
-		return true;
-
 	_mouseX = g_hdb->_screenWidth / 2;
 	_mouseY = g_hdb->_screenHeight / 2;
 
@@ -426,9 +423,6 @@ void Input::stylusMove(int x, int y) {
 }
 
 void Input::updateMouse(int newX, int newY) {
-	if (g_hdb->isPPC())
-		return;
-
 	_mouseX = newX;
 	_mouseY = newY;
 
@@ -454,10 +448,6 @@ void Input::updateMouse(int newX, int newY) {
 }
 
 void Input::updateMouseButtons(int l, int m, int r) {
-
-	if (g_hdb->isPPC())
-		return;
-
 	_mouseLButton += l;
 	_mouseMButton += m;
 	_mouseRButton += r;
@@ -500,10 +490,6 @@ void Input::updateMouseButtons(int l, int m, int r) {
 }
 
 void Input::updateKeys(Common::Event event, bool keyDown) {
-
-	if (g_hdb->isPPC())
-		return;
-
 	static int current = 0, last = 0;
 
 	if (keyDown && event.kbd.keycode == _keyQuit) {


Commit: fb95542a860d9633902e4b249b213c0e855e7340
    https://github.com/scummvm/scummvm/commit/fb95542a860d9633902e4b249b213c0e855e7340
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:33+02:00

Commit Message:
HDB: Fix drawDeliveries()

Changed paths:
    engines/hdb/window.cpp


diff --git a/engines/hdb/window.cpp b/engines/hdb/window.cpp
index 9a3c1b7..9b55d26 100644
--- a/engines/hdb/window.cpp
+++ b/engines/hdb/window.cpp
@@ -1444,7 +1444,7 @@ void Window::drawDeliveries() {
 
 		// Draw delivery items
 		int inv;
-		for (inv = 0; inv < g_hdb->_ai->getInvAmount(); inv++) {
+		for (inv = 0; inv < g_hdb->_ai->getDeliveriesAmount(); inv++) {
 			d = g_hdb->_ai->getDeliveryItem(inv);
 			if (_dlvsInfo.animate && inv == g_hdb->_ai->getDeliveriesAmount() - 1) {
 				if (_dlvsInfo.go1) {


Commit: bbbeaec131d51da6b1cc0690b96e8f96c4506b62
    https://github.com/scummvm/scummvm/commit/bbbeaec131d51da6b1cc0690b96e8f96c4506b62
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:33+02:00

Commit Message:
HDB: Save function pointers

It is bug in the original, which led to broken dialog with
Chiste on Map01

Changed paths:
    engines/hdb/lua-script.cpp


diff --git a/engines/hdb/lua-script.cpp b/engines/hdb/lua-script.cpp
index 98b6dc3..13ea536 100644
--- a/engines/hdb/lua-script.cpp
+++ b/engines/hdb/lua-script.cpp
@@ -44,7 +44,10 @@ struct ScriptPatch {
 } scriptPatches[] = {
 	{"GLOBAL", "return gsub( s, \"\\n\", \"\\\\\\n\" )", "return string.gsub( s, \"\\n\", \"\\\\\\n\" )"}, // line 10
 	{"GLOBAL", "strsub(", "string.sub("}, // line 15
-	{"GLOBAL", "if type(v) == 'userdata' or type(v) == 'function' then return end", "if type(v) == 'userdata' or type(v) == 'function' or i == 'package' or i == 'os' or i == 'io' or i == 'string' or i == 'table' or i == 'debug' or i == 'math' or i == 'coroutine' then return end" }, // Line 16
+	{"GLOBAL", "function save( i,v, nest )", "function func_namelookup(func)\nfor i,v in pairs(_G) do\nif type(v) == 'function' and v == func then\nreturn i\nend\nend\nend\nfunction save( i,v, nest )"}, // line 13
+	{"GLOBAL", "if type(v) == 'userdata' or type(v) == 'function' then return end", "if type(v) == 'userdata' or i == 'package' or i == 'os' or i == 'io' or i == 'string' or i == 'table' or i == 'debug' or i == 'math' or i == 'coroutine' then return end" }, // Line 16
+	{"GLOBAL", "local t=type(v)", "local t=type(v)\nif (t == 'function' and nest == 0) then return end"}, // line 18
+	{"GLOBAL", "then write_record(v, nest + 1)", "then write_record(v, nest + 1)\nelseif t=='function'    then write(savefile, func_namelookup(v)) if nest > 0 then write(savefile, ',' ) end"}, // line 32
 	{"GLOBAL", "for i,v in t do", "for i,v in pairs(t) do"},  // line 43
 	{"GLOBAL", "for i,v in globals() do", "for i,v in pairs(_G) do"}, // line 52
 	{"GLOBAL", "for npcname,npcdata in npcs do", "for npcname,npcdata in pairs(npcs) do"}, // Line 66


Commit: 24da0a245c11d7ff6ac1d331610d6879e12beb71
    https://github.com/scummvm/scummvm/commit/24da0a245c11d7ff6ac1d331610d6879e12beb71
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:33+02:00

Commit Message:
HDB: Add PPC cursor

Changed paths:
    engines/hdb/gfx.cpp


diff --git a/engines/hdb/gfx.cpp b/engines/hdb/gfx.cpp
index e44b96e..869790b 100644
--- a/engines/hdb/gfx.cpp
+++ b/engines/hdb/gfx.cpp
@@ -24,6 +24,9 @@
 #include "common/sinetables.h"
 #include "common/random.h"
 #include "common/memstream.h"
+#include "graphics/cursor.h"
+#include "graphics/wincursor.h"
+#include "graphics/cursorman.h"
 
 #include "hdb/hdb.h"
 #include "hdb/ai.h"
@@ -87,6 +90,14 @@ bool Gfx::init() {
 	// Set the default cursor pos & char clipping
 	setCursor(0, 0);
 
+	if (g_hdb->isPPC()) {
+		Graphics::Cursor *cursor = Graphics::makeDefaultWinCursor();
+
+		CursorMan.replaceCursor(cursor->getSurface(), cursor->getWidth(), cursor->getHeight(), cursor->getHotspotX(), cursor->getHotspotY(), cursor->getKeyColor());
+		CursorMan.replaceCursorPalette(cursor->getPalette(), cursor->getPaletteStartIndex(), cursor->getPaletteCount());
+		delete cursor;
+	}
+
 	_eLeft = 0;
 	_eRight = g_hdb->_screenWidth;
 	_eTop = 0;
@@ -289,11 +300,12 @@ void Gfx::drawPointer() {
 		return;
 
 	// If we are in game and the cursor should be displayed, draw it
-	if (g_hdb->isPPC()) {
-		debug(9, "STUB: Draw Pointer in PPC");
-	} else {
-		if (_showCursor || g_hdb->getGameState() != GAME_PLAY)
+	if (_showCursor || g_hdb->getGameState() != GAME_PLAY) {
+		if (g_hdb->isPPC()) {
+			CursorMan.showMouse(true);
+		} else {
 			_mousePointer[anim]->drawMasked(g_hdb->_input->getMouseX() - 16, g_hdb->_input->getMouseY() - 16);
+		}
 	}
 }
 


Commit: 0536d53dbe30378071a29a47ed164062b27ec6d3
    https://github.com/scummvm/scummvm/commit/0536d53dbe30378071a29a47ed164062b27ec6d3
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:33+02:00

Commit Message:
HDB: Fix copy/paste error in script patch for MAP01

Changed paths:
    engines/hdb/lua-script.cpp


diff --git a/engines/hdb/lua-script.cpp b/engines/hdb/lua-script.cpp
index 13ea536..3ad3bdb 100644
--- a/engines/hdb/lua-script.cpp
+++ b/engines/hdb/lua-script.cpp
@@ -67,7 +67,7 @@ struct ScriptPatch {
 
 	{"MAP01", "strsub(", "string.sub("}, // line 23
 	{"MAP01", "if( covert_index < getn(covert_dialog) ) then", "if( covert_index < #covert_dialog ) then"}, // line 766
-	{"MAP01", "if( chiste_index < getn( chiste_dialog ) )then", "if( covert_index < #chiste_dialog ) then"}, // 845
+	{"MAP01", "if( chiste_index < getn( chiste_dialog ) )then", "if( chiste_index < #chiste_dialog ) then"}, // 845
 
 	{"MAP10", "if( getn( beds ) == 0 ) then", "if( #beds == 0 ) then"}, // line 119
 	{"MAP10", "emptybed_use( %x, %y, %v1, %v2 )", "emptybed_use( x, y, v1, v2 )"}, // line 121


Commit: eecd232132529b48789a7317f2ebddc46ac6d596
    https://github.com/scummvm/scummvm/commit/eecd232132529b48789a7317f2ebddc46ac6d596
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:33+02:00

Commit Message:
HDB: First attempt to fix PPC graphics

Changed paths:
    engines/hdb/gfx.cpp


diff --git a/engines/hdb/gfx.cpp b/engines/hdb/gfx.cpp
index 869790b..8edc006 100644
--- a/engines/hdb/gfx.cpp
+++ b/engines/hdb/gfx.cpp
@@ -833,11 +833,11 @@ bool Gfx::loadFont(const char *string) {
 			// Go to character location
 			memoryStream.seek(startPos + cInfo->offset);
 
-			for (int y = 0; y < _fontHeader.height; y++) {
-				for (int x = 0; x < cInfo->width; x++) {
+			for (int x = 0; x < cInfo->width; x++) {
+				for (int y = 0; y < _fontHeader.height; y++) {
 					int u, v;
 					u = y;
-					v = cInfo->width - x - 1;
+					v = x;
 					ptr = (uint16 *)_fontSurfaces[i].getBasePtr(u, v);
 					*ptr = memoryStream.readUint16LE();
 				}
@@ -1211,10 +1211,10 @@ Graphics::Surface Picture::load(Common::SeekableReadStream *stream) {
 	if (g_hdb->isPPC()) {
 		_surface.create(_height, _width, g_hdb->_format);
 
-		for (int y = 0; y < _height; y++) {
-			for (int x = 0; x < _width; x++) {
+		for (int x = 0; x < _width; x++) {
+			for (int y = 0; y < _height; y++) {
 				int u = y;
-				int v = _width - x - 1;
+				int v = x;
 				uint16 *ptr = (uint16 *)_surface.getBasePtr(u, v);
 				*ptr = stream->readUint16LE();
 			}


Commit: adc41ff141767dae27933ee246c19922491fb4c7
    https://github.com/scummvm/scummvm/commit/adc41ff141767dae27933ee246c19922491fb4c7
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:33+02:00

Commit Message:
HDB: Fix PPC screen dimensions once more

Changed paths:
    engines/hdb/hdb.cpp


diff --git a/engines/hdb/hdb.cpp b/engines/hdb/hdb.cpp
index 630766e..c310533 100644
--- a/engines/hdb/hdb.cpp
+++ b/engines/hdb/hdb.cpp
@@ -46,10 +46,10 @@ HDBGame* g_hdb;
 HDBGame::HDBGame(OSystem *syst, const ADGameDescription *gameDesc) : Engine(syst), _gameDescription(gameDesc) {
 	g_hdb = this;
 	if (isPPC()) {
-		_screenWidth = 320;
-		_screenHeight = 240;
-		_screenDrawWidth = 320;
-		_screenDrawHeight = 240;
+		_screenWidth = 240;
+		_screenHeight = 320;
+		_screenDrawWidth = 240;
+		_screenDrawHeight = 320;
 		_progressY = 280;
 	} else {
 		_screenWidth = 640;


Commit: bccb8178120c383710ca9f05a6a77e1e48689473
    https://github.com/scummvm/scummvm/commit/bccb8178120c383710ca9f05a6a77e1e48689473
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:33+02:00

Commit Message:
HDB: Rotate pictures on load

Changed paths:
    engines/hdb/gfx.cpp


diff --git a/engines/hdb/gfx.cpp b/engines/hdb/gfx.cpp
index 8edc006..6514b59 100644
--- a/engines/hdb/gfx.cpp
+++ b/engines/hdb/gfx.cpp
@@ -828,7 +828,7 @@ bool Gfx::loadFont(const char *string) {
 			// Position after reading cInfo
 			int curPos = memoryStream.pos();
 
-			_fontSurfaces[i].create(_fontHeader.height, cInfo->width, g_hdb->_format);
+			_fontSurfaces[i].create(cInfo->width, _fontHeader.height, g_hdb->_format);
 
 			// Go to character location
 			memoryStream.seek(startPos + cInfo->offset);
@@ -836,8 +836,8 @@ bool Gfx::loadFont(const char *string) {
 			for (int x = 0; x < cInfo->width; x++) {
 				for (int y = 0; y < _fontHeader.height; y++) {
 					int u, v;
-					u = y;
-					v = x;
+					u = x;
+					v = _fontHeader.height - y - 1;
 					ptr = (uint16 *)_fontSurfaces[i].getBasePtr(u, v);
 					*ptr = memoryStream.readUint16LE();
 				}
@@ -1209,12 +1209,12 @@ Graphics::Surface Picture::load(Common::SeekableReadStream *stream) {
 	debug(8, "Picture: _name: %s", _name);
 
 	if (g_hdb->isPPC()) {
-		_surface.create(_height, _width, g_hdb->_format);
+		_surface.create(_width, _height, g_hdb->_format);
 
 		for (int x = 0; x < _width; x++) {
 			for (int y = 0; y < _height; y++) {
-				int u = y;
-				int v = x;
+				int u = x;
+				int v = _height - y - 1;
 				uint16 *ptr = (uint16 *)_surface.getBasePtr(u, v);
 				*ptr = stream->readUint16LE();
 			}


Commit: 8198a5d99e778c37c9c185e79629b072151e36d2
    https://github.com/scummvm/scummvm/commit/8198a5d99e778c37c9c185e79629b072151e36d2
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:33+02:00

Commit Message:
HDB: Fix crash in start menu in PPC version

Changed paths:
    engines/hdb/input.cpp


diff --git a/engines/hdb/input.cpp b/engines/hdb/input.cpp
index 15ba7fc..0a3cfb2 100644
--- a/engines/hdb/input.cpp
+++ b/engines/hdb/input.cpp
@@ -455,6 +455,10 @@ void Input::updateMouseButtons(int l, int m, int r) {
 	// Check if LButton has been pressed
 	// Check if LButton has been lifted
 	if (_mouseLButton) {
+		if (g_hdb->isPPC()) {
+			stylusDown(_mouseX, _mouseY);
+			return;
+		}
 		if (_mouseX > (g_hdb->_screenWidth - 32 * 5) && _mouseY < 240) {
 			g_hdb->_window->checkInvSelect(_mouseX, _mouseY);
 		} else if (_mouseX > (g_hdb->_screenWidth - 32 * 5) && _mouseY >= 240) {


Commit: febdd3beee5c0434552b1993787de9378d3332c9
    https://github.com/scummvm/scummvm/commit/febdd3beee5c0434552b1993787de9378d3332c9
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:33+02:00

Commit Message:
HDB: Fix crashes in PPC demo

Changed paths:
    engines/hdb/menu.cpp


diff --git a/engines/hdb/menu.cpp b/engines/hdb/menu.cpp
index caaa475..7305773 100644
--- a/engines/hdb/menu.cpp
+++ b/engines/hdb/menu.cpp
@@ -536,9 +536,10 @@ void Menu::drawMenu() {
 		drawRocketAndSelections();
 
 		// draw version #
-		_versionGfx->drawMasked(g_hdb->_screenWidth - 6 * 8, g_hdb->_screenHeight - 8);
+		if (_versionGfx)
+			_versionGfx->drawMasked(g_hdb->_screenWidth - 6 * 8, g_hdb->_screenHeight - 8);
 
-		if (g_hdb->isDemo()) {
+		if (g_hdb->isDemo() && _demoPlaqueGfx) {
 			_demoPlaqueGfx->drawMasked(g_hdb->_screenWidth / 2 - _demoPlaqueGfx->_width / 2, 2);
 		}
 


Commit: e08a1ec37db7f9333931c48cd353e077ab7b5f61
    https://github.com/scummvm/scummvm/commit/e08a1ec37db7f9333931c48cd353e077ab7b5f61
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:33+02:00

Commit Message:
HDB: Implement Handango differences

Changed paths:
    engines/hdb/menu.cpp


diff --git a/engines/hdb/menu.cpp b/engines/hdb/menu.cpp
index 7305773..1023993 100644
--- a/engines/hdb/menu.cpp
+++ b/engines/hdb/menu.cpp
@@ -1061,6 +1061,13 @@ void Menu::drawTitle() {
 		_titleScreen->draw(0, 0);
 		break;
 
+	case 20: // fadein Handango title screen
+	case 21: // wait
+	case 22: // fadeout Handango title screen
+	case 23:
+		_handangoGfx->draw(0, 0);
+		break;
+
 	case 5: // fadein HDB title screen
 	case 6: // wait
 	case 7: // fadeout HDB title screen
@@ -1118,23 +1125,23 @@ void Menu::drawTitle() {
 	// change title state...
 	//-------------------------------------------------------------------
 	switch (_titleCycle) {
-		//-------------------------------------------------------------------
-		// MONKEYSTONE LOGO
-		//-------------------------------------------------------------------
-		// time to OOH OOH
+	//-------------------------------------------------------------------
+	// MONKEYSTONE LOGO
+	//-------------------------------------------------------------------
+	// time to OOH OOH
 	case 1:
 		_titleDelay = (uint32)(g_system->getMillis() + 1000 * TITLE_DELAY2);
 		g_hdb->_sound->playSound(SND_MONKEY_OOHOOH);
 		_titleCycle++;
 		break;
 
-		// delay after OOH OOH
+	// delay after OOH OOH
 	case 2:
 		_titleDelay = g_system->getMillis() + 1000 * TITLE_DELAY3;
 		_titleCycle++;
 		break;
 
-		// done with delay; set up the fadeout...
+	// done with delay; set up the fadeout...
 	case 3:
 		time = g_hdb->getTimeSliceDelta();
 		g_hdb->_gfx->setFade(false, false, kScreenFade / time); // FADEOUT
@@ -1149,13 +1156,45 @@ void Menu::drawTitle() {
 
 		g_hdb->_gfx->setFade(true, false, kScreenFade / time); // FADEIN
 		g_hdb->_sound->startMusic(_titleSong);
-		_titleCycle++;
+
+		if (!g_hdb->isHandango())
+			_titleCycle++;
+		else
+			_titleCycle = 20;
 	break;
 
-		//-------------------------------------------------------------------
-		// HDB TITLE SCREEN
-		//-------------------------------------------------------------------
-		// wait for fadein to stop
+	//-------------------------------------------------------------------
+	// HANDANGO LOGO
+	//-------------------------------------------------------------------
+	case 20:        // fadein handango screen
+		if (g_hdb->_gfx->isFadeActive())
+			break;
+		_titleDelay = g_system->getMillis() + 750;
+		_titleCycle++;
+		break;
+
+	case 21:        // wait
+		g_hdb->_gfx->setFade(false, false, kScreenFade / time);                // FADEOUT
+		_titleCycle++;
+		break;
+
+	case 22:        // fadeout handango screen
+		if (g_hdb->_gfx->isFadeActive())
+			break;
+		_titleCycle++;
+		break;
+
+	case 23:        // fadein HDB title screen
+		if (g_hdb->_gfx->isFadeActive())
+			break;
+		g_hdb->_gfx->setFade(true, false, kScreenFade / time);         // FADEIN
+		_titleCycle = 5;
+		break;
+
+	//-------------------------------------------------------------------
+	// HDB TITLE SCREEN
+	//-------------------------------------------------------------------
+	// wait for fadein to stop
 	case 5:
 		if (g_hdb->_gfx->isFadeActive())
 			break;
@@ -1163,13 +1202,13 @@ void Menu::drawTitle() {
 		_titleCycle++;
 		break;
 
-		// set fadeout to stars
+	// set fadeout to stars
 	case 6:
 		g_hdb->_gfx->setFade(false, false, kScreenFade / time);		// FADEOUT
 		_titleCycle++;
 		break;
 
-		// get rocket ready
+	// get rocket ready
 	case 7:
 		if (g_hdb->_gfx->isFadeActive())
 			break;


Commit: 68765181e475816706639cdec1e9294719677e78
    https://github.com/scummvm/scummvm/commit/68765181e475816706639cdec1e9294719677e78
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:33+02:00

Commit Message:
HDB: Add engine dependencies

Changed paths:
    engines/hdb/configure.engine


diff --git a/engines/hdb/configure.engine b/engines/hdb/configure.engine
index b5565e9..fae5159 100644
--- a/engines/hdb/configure.engine
+++ b/engines/hdb/configure.engine
@@ -1,3 +1,3 @@
 # This file is included from the main "configure" script
 # add_engine [name] [desc] [build-by-default] [subengines] [base games] [deps]
-add_engine hdb "Hyperspace Delivery Boy!" yes
+add_engine hdb "Hyperspace Delivery Boy!" no "" "" "16bit zlib highres lua"


Commit: d399dc6f9ded81c5cb515e41c62b8658eeb1ba27
    https://github.com/scummvm/scummvm/commit/d399dc6f9ded81c5cb515e41c62b8658eeb1ba27
Author: Strangerke (strangerke at scummvm.org)
Date: 2019-09-03T17:17:33+02:00

Commit Message:
HDB: Reduce the scope of some variables in window

Changed paths:
    engines/hdb/window.cpp


diff --git a/engines/hdb/window.cpp b/engines/hdb/window.cpp
index 9b55d26..4d4f016 100644
--- a/engines/hdb/window.cpp
+++ b/engines/hdb/window.cpp
@@ -525,9 +525,9 @@ void Window::drawWeapon() {
 	if (!g_hdb->isPPC())
 		return;
 
-	int	 xoff = 40 * _pzInfo.active;
-	char word[3];
+	int xoff = 40 * _pzInfo.active;
 	if (ITEM_CLUB != g_hdb->_ai->getPlayerWeapon()) {
+		char word[3];
 		sprintf(word, "%d", g_hdb->_ai->getGemAmount());
 		g_hdb->_gfx->setCursor(_weaponX + 4 - xoff, _weaponY + kTileHeight + 2);
 		g_hdb->_gfx->drawText(word);
@@ -535,8 +535,7 @@ void Window::drawWeapon() {
 }
 
 void Window::chooseWeapon(AIType wType) {
-	static	AIType lastWeaponSelected = AI_NONE;
-	Tile *gfx;
+	static AIType lastWeaponSelected = AI_NONE;
 	int	slot = g_hdb->_ai->queryInventoryTypeSlot(wType);
 
 	g_hdb->_sound->playSound(SND_MENU_SLIDER);
@@ -544,7 +543,7 @@ void Window::chooseWeapon(AIType wType) {
 	if (!g_hdb->getActionMode())
 		return;
 
-	gfx = g_hdb->_ai->getInvItemGfx(slot);
+	Tile *gfx = g_hdb->_ai->getInvItemGfx(slot);
 
 	switch (wType) {
 	case ITEM_CLUB:
@@ -584,22 +583,21 @@ void Window::openDialog(const char *title, int tileIndex, const char *string, in
 	strcpy(_dialogInfo.title, title);
 	_dialogInfo.active = true;
 
-	int e1, e2, e3, e4;
-	int width, height;
-	int titleWidth, titleHeight;
-	int w;
-
 	if (strlen(string) > sizeof(_dialogInfo.string))
 		strncpy(_dialogInfo.string, string, sizeof(_dialogInfo.string) - 1);
 	else
 		strcpy(_dialogInfo.string, string);
+
+	int e1, e2, e3, e4;
 	g_hdb->_gfx->getTextEdges(&e1, &e2, &e3, &e4);
 	g_hdb->_gfx->setTextEdges(_dialogTextLeft, _dialogTextRight, 0, g_hdb->_screenDrawHeight);
+	int width, height;
 	g_hdb->_gfx->getDimensions(string, &width, &height);
+	int titleWidth, titleHeight;
 	g_hdb->_gfx->getDimensions(title, &titleWidth, &titleHeight);
 	g_hdb->_gfx->setTextEdges(e1, e2, e3, e4);
 	_dialogInfo.height = (height + 2) * 16;
-	w = _dialogInfo.width = width + 32;
+	int w = _dialogInfo.width = width + 32;
 	_dialogInfo.titleWidth = titleWidth;
 	if (titleWidth > w)
 		w = titleWidth;
@@ -1048,11 +1046,7 @@ void Window::closeMsg() {
 }
 
 void Window::drawInventory() {
-	int baseX, drawX, drawY;
 	static uint32 timer = g_hdb->getTimeSlice() + 300; // unused
-	AIEntity *e, *sel;
-	char string[8];
-	int gems, mstones;
 
 	if (g_hdb->isPPC()) {
 		if (!_invWinInfo.active)
@@ -1077,16 +1071,17 @@ void Window::drawInventory() {
 		if (timer < g_hdb->getTimeSlice())
 			timer = g_hdb->getTimeSlice() + 300;
 
-		baseX = drawX = _invWinInfo.x + 16;
-		drawY = _invWinInfo.y + 16;
+		int drawX = _invWinInfo.x + 16;
+		int baseX = drawX;
+		int drawY = _invWinInfo.y + 16;
 
 		// Draw Inv Items
-		sel = NULL;
+		AIEntity *sel = NULL;
 		if (_invWinInfo.selection >= g_hdb->_ai->getInvAmount())
 			_invWinInfo.selection = g_hdb->_ai->getInvAmount() - 1;
 
 		for (int inv = 0; inv < g_hdb->_ai->getInvAmount(); inv++) {
-			e = g_hdb->_ai->getInvItem(inv);
+			AIEntity *e = g_hdb->_ai->getInvItem(inv);
 			if (inv == _invWinInfo.selection)
 				sel = e;
 
@@ -1103,7 +1098,8 @@ void Window::drawInventory() {
 		drawY = _invWinInfo.y + 8 + _invItemSpace * 2;
 		drawX = baseX + _invItemSpace * 4 + 8;
 		_gemGfx->drawMasked(drawX, drawY);
-		gems = g_hdb->_ai->getGemAmount();
+		int gems = g_hdb->_ai->getGemAmount();
+		char string[8];
 		sprintf(string, "%d", gems);
 		g_hdb->_gfx->setCursor(drawX + 22, drawY + 8);
 		g_hdb->_gfx->drawText(string);
@@ -1141,16 +1137,17 @@ void Window::drawInventory() {
 
 		_gfxInfobar->draw(g_hdb->_screenWidth - _gfxInfobar->_width, 0);
 
-		baseX = drawX = _invWinInfo.x;
-		drawY = _invWinInfo.y;
+		int drawX = _invWinInfo.x;
+		int baseX = drawX;
+		int drawY = _invWinInfo.y;
 
 		// Draw Inv Items
-		sel = NULL;
+		AIEntity *sel = NULL;
 		if (_invWinInfo.selection >= g_hdb->_ai->getInvAmount())
 			_invWinInfo.selection = g_hdb->_ai->getInvAmount() - 1;
 
 		for (int inv = 0; inv < g_hdb->_ai->getInvAmount(); inv++) {
-			e = g_hdb->_ai->getInvItem(inv);
+			AIEntity *e = g_hdb->_ai->getInvItem(inv);
 			if (inv == _invWinInfo.selection)
 				sel = e;
 
@@ -1169,13 +1166,14 @@ void Window::drawInventory() {
 		_gemGfx->drawMasked(drawX, drawY);
 
 		// Draw the Gem Amount
-		gems = g_hdb->_ai->getGemAmount();
+		int gems = g_hdb->_ai->getGemAmount();
+		char string[8];
 		sprintf(string, "%d", gems);
 		g_hdb->_gfx->setCursor(drawX + 32, drawY + 8);
 		g_hdb->_gfx->drawText(string);
 
 		// Draw the mini monkeystone
-		mstones = g_hdb->_ai->getMonkeystoneAmount();
+		int mstones = g_hdb->_ai->getMonkeystoneAmount();
 		if (mstones) {
 			drawX = baseX + _invItemSpaceX * 2 - 8;
 			_mstoneGfx->drawMasked(drawX, drawY + 8);
@@ -1243,8 +1241,6 @@ void Window::openInventory() {
 	if (!g_hdb->isPPC())
 		return;
 
-	int	px, py;
-
 	if (_invWinInfo.active)
 		return;
 
@@ -1260,6 +1256,7 @@ void Window::openInventory() {
 
 	_invWinInfo.x = (g_hdb->_screenWidth >> 1) - (_invWinInfo.width >> 1) - 8;
 
+	int	px, py;
 	g_hdb->_ai->getPlayerXY(&px, &py);
 	if (py < (g_hdb->_screenHeight >> 1) - 16)
 		_invWinInfo.y = (g_hdb->_screenHeight >> 1) + 16;
@@ -1343,7 +1340,6 @@ void Window::openDeliveries(bool animate) {
 		_dlvsInfo.x = (g_hdb->_screenWidth >> 1) - (_dlvsInfo.width >> 1) - 8;
 
 		int px, py;
-
 		g_hdb->_ai->getPlayerXY(&px, &py);
 		if (py < (g_hdb->_screenHeight >> 1) - 16)
 			_dlvsInfo.y = (g_hdb->_screenHeight >> 1);
@@ -1371,9 +1367,7 @@ void Window::openDeliveries(bool animate) {
 
 void Window::drawDeliveries() {
 	static uint32 timer = g_hdb->getTimeSlice() + 300; //unused
-	int drawX, drawY, baseX;
-	DlvEnt *d;
-	int crazySounds[kNumCrazy] = {
+	static const int crazySounds[kNumCrazy] = {
 		SND_GUI_INPUT,
 		SND_MAIL_PROCESS,
 		SND_MONKEY_OOHOOH,
@@ -1439,13 +1433,14 @@ void Window::drawDeliveries() {
 				timer = g_hdb->getTimeSlice() + 300;
 		}
 
-		baseX = drawX = _dlvsInfo.x + 16;
-		drawY = _dlvsInfo.y + 16;
+		int drawX = _dlvsInfo.x + 16;
+		int drawY = _dlvsInfo.y + 16;
+		int baseX = drawX;
 
 		// Draw delivery items
-		int inv;
-		for (inv = 0; inv < g_hdb->_ai->getDeliveriesAmount(); inv++) {
-			d = g_hdb->_ai->getDeliveryItem(inv);
+		int inv = 0;
+		for (; inv < g_hdb->_ai->getInvAmount(); inv++) {
+			DlvEnt *d = g_hdb->_ai->getDeliveryItem(inv);
 			if (_dlvsInfo.animate && inv == g_hdb->_ai->getDeliveriesAmount() - 1) {
 				if (_dlvsInfo.go1) {
 					if (_dlvsInfo.delay1 < g_hdb->getTimeSlice()) {
@@ -1522,9 +1517,9 @@ void Window::drawDeliveries() {
 		if (_infobarDimmed > 1)
 			return;
 
-		baseX = _dlvsInfo.x;
-		drawX = _dlvsInfo.x;
-		drawY = _dlvsInfo.y;
+		int baseX = _dlvsInfo.x;
+		int drawX = _dlvsInfo.x;
+		int drawY = _dlvsInfo.y;
 
 		if (_dlvsInfo.selected >= g_hdb->_ai->getDeliveriesAmount())
 			_dlvsInfo.selected = g_hdb->_ai->getDeliveriesAmount() - 1;
@@ -1533,7 +1528,7 @@ void Window::drawDeliveries() {
 		int inv = 0;
 		for (; inv < g_hdb->_ai->getDeliveriesAmount(); inv++) {
 			int centerX = baseX + (g_hdb->_screenWidth - baseX) / 2;
-			d = g_hdb->_ai->getDeliveryItem(inv);
+			DlvEnt *d = g_hdb->_ai->getDeliveryItem(inv);
 			if (_dlvsInfo.animate && inv == g_hdb->_ai->getDeliveriesAmount() - 1) {
 				if (_dlvsInfo.go1) {
 					if (_dlvsInfo.delay1 < g_hdb->getTimeSlice()) {


Commit: e9970a20ddee1f7ddc92ada10cf86a99617c27b4
    https://github.com/scummvm/scummvm/commit/e9970a20ddee1f7ddc92ada10cf86a99617c27b4
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:33+02:00

Commit Message:
HDB: Implement PPC demo Lua differences for saving

Changed paths:
    engines/hdb/lua-script.cpp


diff --git a/engines/hdb/lua-script.cpp b/engines/hdb/lua-script.cpp
index 3ad3bdb..c180778 100644
--- a/engines/hdb/lua-script.cpp
+++ b/engines/hdb/lua-script.cpp
@@ -1370,13 +1370,31 @@ static int openFile(lua_State *L) {
 	return 1;
 }
 
+static int writeto(lua_State *L) {
+	g_hdb->_lua->checkParameters("writeto", 1);
+
+	lua_pop(L, 1);
+
+	return 1;
+}
+
 static int write(lua_State *L) {
 	Common::OutSaveFile *out = g_hdb->_currentOutSaveFile;
-	const char *data = lua_tostring(L, 2);
+	const char *data;
 
-	g_hdb->_lua->checkParameters("write", 2);
+	if (g_hdb->isDemo() && g_hdb->isPPC()) {
+		data = lua_tostring(L, 1);
 
-	lua_pop(L, 2);
+		g_hdb->_lua->checkParameters("write", 1);
+
+		lua_pop(L, 1);
+	} else {
+		data = lua_tostring(L, 2);
+
+		g_hdb->_lua->checkParameters("write", 2);
+
+		lua_pop(L, 2);
+	}
 
 	out->write(data, strlen(data));
 
@@ -1722,6 +1740,7 @@ struct FuncInit {
 	{	"write",				write,				},
 	{	"closefile",			closeFile,			},
 	{	"dofile",				dofile,				},
+	{	"writeto",				writeto,			},
 	{ NULL, NULL }
 };
 


Commit: 680aeba0a4af332391ddccb650a6d8e20e41d2f7
    https://github.com/scummvm/scummvm/commit/680aeba0a4af332391ddccb650a6d8e20e41d2f7
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:33+02:00

Commit Message:
HDB: Simplify conditional

Changed paths:
    engines/hdb/ai-funcs.cpp


diff --git a/engines/hdb/ai-funcs.cpp b/engines/hdb/ai-funcs.cpp
index a633952..afd6f3a 100644
--- a/engines/hdb/ai-funcs.cpp
+++ b/engines/hdb/ai-funcs.cpp
@@ -2351,7 +2351,7 @@ void AI::movePlayer(uint16 buttons) {
 		// there's a possibility that an actual entity and a LUA entity
 		// can share the same spot, so we need to be able to deal with
 		// the real entity first, then the LUA entity.
-		if (!hit || (hit && hit->type == AI_NONE)) {
+		if (!hit || hit->type == AI_NONE) {
 			switch (_player->state) {
 			case STATE_STANDUP:
 			case STATE_STANDDOWN:


Commit: ae17affac04d7cb1ed64592c87b3473bc5ad2d38
    https://github.com/scummvm/scummvm/commit/ae17affac04d7cb1ed64592c87b3473bc5ad2d38
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:33+02:00

Commit Message:
HDB: Fix centerPrint() Height

Changed paths:
    engines/hdb/gfx.cpp


diff --git a/engines/hdb/gfx.cpp b/engines/hdb/gfx.cpp
index 6514b59..515605f 100644
--- a/engines/hdb/gfx.cpp
+++ b/engines/hdb/gfx.cpp
@@ -1043,7 +1043,7 @@ void Gfx::centerPrint(const char *string) {
 			totalWidth += _charInfoBlocks[string[i]]->width;
 	}
 
-	setCursor(g_hdb->_screenWidth / 2 - totalWidth / 2, _cursorX);
+	setCursor(g_hdb->_screenWidth / 2 - totalWidth / 2, _cursorY);
 	drawText(string);
 }
 


Commit: a69f6afe1061ff7d8cc98d9e80a96fc9fb5b269e
    https://github.com/scummvm/scummvm/commit/a69f6afe1061ff7d8cc98d9e80a96fc9fb5b269e
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:33+02:00

Commit Message:
HDB: Convert FPS to Millis for double click check

Changed paths:
    engines/hdb/hdb.cpp


diff --git a/engines/hdb/hdb.cpp b/engines/hdb/hdb.cpp
index c310533..4b4bc86 100644
--- a/engines/hdb/hdb.cpp
+++ b/engines/hdb/hdb.cpp
@@ -413,7 +413,12 @@ void HDBGame::setTargetXY(int x, int y) {
 		if (x == px && y == py) {
 			static uint32 dblClickTimer = 0;
 
-			if (dblClickTimer && ((int)(g_system->getMillis() - dblClickTimer) < (int)(kGameFPS * 5))) {
+			if (dblClickTimer) {
+				debug("Double Click Timer: %d", dblClickTimer);
+				debug("Click Timer Diff: %d", (int)(g_system->getMillis() - dblClickTimer));
+			}
+
+			if (dblClickTimer && ((int)(g_system->getMillis() - dblClickTimer) < (int)(kGameFPS * 5 * 1000 / 60))) {
 				g_hdb->_window->openInventory();
 				dblClickTimer = 0;
 			} else


Commit: 83ceef1e97ec7091c69ceddf90927685c2f0ef08
    https://github.com/scummvm/scummvm/commit/83ceef1e97ec7091c69ceddf90927685c2f0ef08
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:33+02:00

Commit Message:
HDB: Fix PPC _quitYes and _quitNo co-ordinates

Changed paths:
    engines/hdb/menu.cpp


diff --git a/engines/hdb/menu.cpp b/engines/hdb/menu.cpp
index 1023993..9ed7291 100644
--- a/engines/hdb/menu.cpp
+++ b/engines/hdb/menu.cpp
@@ -74,14 +74,14 @@ Menu::Menu() {
 		_saveSlotY = 68;
 		_quitX = 0;
 		_quitY = 0;
-		_quitYesX1 = (146 - 16);
-		_quitYesX2 = (211 - 16);
-		_quitYesY1 = (287);
-		_quitYesY2 = (312);
-		_quitNoX1 = (65 - 16);
-		_quitNoX2 = (130 - 16);
+		_quitNoX1 = (146 - 16);
+		_quitNoX2 = (211 - 16);
 		_quitNoY1 = (287);
 		_quitNoY2 = (312);
+		_quitYesX1 = (65 - 16);
+		_quitYesX2 = (130 - 16);
+		_quitYesY1 = (287);
+		_quitYesY2 = (312);
 		_controlX = 0;
 		_controlY = 0;
 		_controlUpX = 0;


Commit: 8b1d05eefaff56da580f5abdaaf5c799ac8b7aaf
    https://github.com/scummvm/scummvm/commit/8b1d05eefaff56da580f5abdaaf5c799ac8b7aaf
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:33+02:00

Commit Message:
HDB: Fix PPC No Deliveries screen

Earlier the No Deliveries couldn't be exited
since _dlvsInfo.animate was true

Changed paths:
    engines/hdb/window.cpp


diff --git a/engines/hdb/window.cpp b/engines/hdb/window.cpp
index 4d4f016..e2ca2c2 100644
--- a/engines/hdb/window.cpp
+++ b/engines/hdb/window.cpp
@@ -1509,6 +1509,7 @@ void Window::drawDeliveries() {
 		if (!inv) {
 			g_hdb->_gfx->setCursor(baseX, _dlvsInfo.y + 32);
 			g_hdb->_gfx->drawText("No Deliveries");
+			_dlvsInfo.animate = false;
 		} else if (!_dlvsInfo.animate) {
 			// arrow TO...
 			_gfxArrowTo->drawMasked(_dlvsInfo.x + 24 + _invItemSpace * _dlvsInfo.selected, drawY + _invItemSpace);


Commit: bbcab297f72ff4a5f5d5e56cb2d86de355c97eae
    https://github.com/scummvm/scummvm/commit/bbcab297f72ff4a5f5d5e56cb2d86de355c97eae
Author: Strangerke (strangerke at scummvm.org)
Date: 2019-09-03T17:17:33+02:00

Commit Message:
HDB: Reduce the scope of some more variables in gfx

Changed paths:
    engines/hdb/gfx.cpp


diff --git a/engines/hdb/gfx.cpp b/engines/hdb/gfx.cpp
index 515605f..b92cb86 100644
--- a/engines/hdb/gfx.cpp
+++ b/engines/hdb/gfx.cpp
@@ -113,9 +113,8 @@ bool Gfx::init() {
 
 	// Read total number of tiles in game
 	_numTiles = g_hdb->_fileMan->getCount("t32_", TYPE_TILE32);
-	if (!_numTiles) {
+	if (!_numTiles)
 		return false;
-	}
 
 	// Setup Tile Lookup Array
 	_tLookupArray = new TileLookup[_numTiles];
@@ -279,9 +278,8 @@ void Gfx::updateVideo() {
 	Common::Rect clip(g_hdb->_progressGfx->getSurface()->getBounds());
 	clip.moveTo(left, g_hdb->_progressY);
 	clip.clip(g_hdb->_gfx->_globalSurface.getBounds());
-	if (!clip.isEmpty()) {
+	if (!clip.isEmpty())
 		g_system->copyRectToScreen(g_hdb->_gfx->_globalSurface.getBasePtr(clip.left, clip.top), g_hdb->_gfx->_globalSurface.pitch, clip.left, clip.top, clip.width(), clip.height());
-	}
 
 	g_system->updateScreen();
 }
@@ -301,11 +299,10 @@ void Gfx::drawPointer() {
 
 	// If we are in game and the cursor should be displayed, draw it
 	if (_showCursor || g_hdb->getGameState() != GAME_PLAY) {
-		if (g_hdb->isPPC()) {
+		if (g_hdb->isPPC())
 			CursorMan.showMouse(true);
-		} else {
+		else
 			_mousePointer[anim]->drawMasked(g_hdb->_input->getMouseX() - 16, g_hdb->_input->getMouseY() - 16);
-		}
 	}
 }
 
@@ -317,22 +314,20 @@ void Gfx::setFade(bool fadeIn, bool black, int steps) {
 	_fadeInfo.isFadeIn = fadeIn;
 	_fadeInfo.isBlack = black;
 
-	if (!steps) {
+	if (!steps)
 		steps = 1;
-	}
+
 	_fadeInfo.speed = steps;
 
-	if (fadeIn) {
+	if (fadeIn)
 		_fadeInfo.curStep = 0;
-	} else {
+	else
 		_fadeInfo.curStep = 255;
-	}
 
 	_fadeInfo.active = true;
 }
 
 void Gfx::updateFade() {
-	uint8 r, g, b;
 	static int waitAFrame = 0;
 
 	if (!_fadeInfo.active && !_fadeInfo.stayFaded)
@@ -348,17 +343,15 @@ void Gfx::updateFade() {
 		_fadeBuffer1.blitFrom(_fadeBuffer2);
 
 		// do the actual alphablending
-
-		uint16 *ptr, value;
-
 		if (!_fadeInfo.isBlack) {
 			// Black Fade
 
 			for (int y = 0; y < g_hdb->_screenHeight; y++) {
-				ptr = (uint16 *)_fadeBuffer1.getBasePtr(0, y);
+				uint16 *ptr = (uint16 *)_fadeBuffer1.getBasePtr(0, y);
 				for (int x = 0; x < g_hdb->_screenWidth; x++) {
-					value = *ptr;
+					uint16 value = *ptr;
 					if (value) {
+						uint8 r, g, b;
 						g_hdb->_format.colorToRGB(value, r, g, b);
 						r = (r * _fadeInfo.curStep) >> 8;
 						g = (g * _fadeInfo.curStep) >> 8;
@@ -372,9 +365,10 @@ void Gfx::updateFade() {
 			// White Fade
 
 			for (int y = 0; y < g_hdb->_screenHeight; y++) {
-				ptr = (uint16 *)_fadeBuffer1.getBasePtr(0, y);
+				uint16 *ptr = (uint16 *)_fadeBuffer1.getBasePtr(0, y);
 				for (int x = 0; x < g_hdb->_screenWidth; x++) {
-					value = *ptr;
+					uint16 value = *ptr;
+					uint8 r, g, b;
 					g_hdb->_format.colorToRGB(value, r, g, b);
 					r += (255 - r) * (256 - _fadeInfo.curStep) / 256;
 					g += (255 - g) * (256 - _fadeInfo.curStep) / 256;
@@ -400,7 +394,7 @@ void Gfx::updateFade() {
 				_fadeInfo.stayFaded = false;
 			}
 		} else {
-			if (_fadeInfo.active == true)
+			if (_fadeInfo.active)
 				_fadeInfo.curStep -= _fadeInfo.speed;
 
 			if (_fadeInfo.curStep < 1) {
@@ -441,33 +435,33 @@ void Gfx::turnOnSnow() {
 }
 
 Picture *Gfx::loadPic(const char *picName) {
-	Picture *pic = new Picture;
 	Common::SeekableReadStream *stream = g_hdb->_fileMan->findFirstData(picName, TYPE_PIC);
-	if (!stream) {
+	if (!stream)
 		return NULL;
-	}
+
+	Picture *pic = new Picture;
 	pic->load(stream);
 	delete stream;
 	return pic;
 }
 
 Tile *Gfx::loadTile(const char *tileName) {
-	Tile *tile = new Tile;
 	Common::SeekableReadStream *stream = g_hdb->_fileMan->findFirstData(tileName, TYPE_TILE32);
-	if (!stream) {
+	if (!stream)
 		return NULL;
-	}
+
+	Tile *tile = new Tile;
 	tile->load(stream);
 	delete stream;
 	return tile;
 }
 
 Tile *Gfx::loadIcon(const char *tileName) {
-	Tile *tile = new Tile;
 	Common::SeekableReadStream *stream = g_hdb->_fileMan->findFirstData(tileName, TYPE_ICON32);
-	if (!stream) {
+	if (!stream)
 		return NULL;
-	}
+
+	Tile *tile = new Tile;
 	tile->load(stream);
 	delete stream;
 	return tile;
@@ -510,13 +504,12 @@ void Gfx::cacheTileSequence(int tileIndex, int count) {
 }
 
 int Gfx::getTileIndex(const char *name) {
-	if (!name) {
+	if (!name)
 		return -1;
-	}
+
 	for (int i = 0; i < _numTiles; i++) {
-		if (Common::matchString(_tLookupArray[i].filename, name)) {
+		if (Common::matchString(_tLookupArray[i].filename, name))
 			return i;
-		}
 	}
 	return -1;
 }
@@ -525,6 +518,7 @@ Picture *Gfx::getPicture(const char *name) {
 	Common::SeekableReadStream *stream = g_hdb->_fileMan->findFirstData(name, TYPE_PIC);
 	if (stream == nullptr)
 		return nullptr;
+
 	Picture *picture = new Picture;
 	picture->load(stream);
 	delete stream;
@@ -638,14 +632,12 @@ Picture *Gfx::getPicGfx(const char *name, int32 size) {
 }
 
 int Gfx::isSky(int index) {
-	if (!index) {
+	if (!index)
 		return 0;
-	}
 
 	for (int i = 0; i < kMaxSkies; i++) {
-		if (_skyTiles[i] == index) {
+		if (_skyTiles[i] == index)
 			return i + 1; // The skyTiles are indexed from 1. 0 => No Sky tile
-		}
 	}
 
 	return 0;
@@ -757,11 +749,10 @@ static const int snowXVList[13] = {0, -1, -1, -2, -2, -1, 0, 0, 0, -1, -2, -1, 0
 
 
 void Gfx::drawSnow() {
-	int		i;
 	if (_snowInfo.active == false)
 		return;
 
-	for (i = 0; i < MAX_SNOW; i++) {
+	for (int i = 0; i < MAX_SNOW; i++) {
 		if (g_hdb->isPPC()) {
 			uint16 color = g_hdb->_format.RGBToColor(160, 160, 160);
 			setPixel((int)_snowInfo.x[i] + 1, (int)_snowInfo.y[i], color);
@@ -788,9 +779,8 @@ int Gfx::animateTile(int tileIndex) {
 bool Gfx::loadFont(const char *string) {
 
 	Common::SeekableReadStream *stream = g_hdb->_fileMan->findFirstData(string, TYPE_FONT);
-	if (!stream) {
+	if (!stream)
 		return false;
-	}
 
 	if (g_hdb->isPPC()) {
 		const int32 ulength = g_hdb->_fileMan->getLength(string, TYPE_FONT);
@@ -817,7 +807,6 @@ bool Gfx::loadFont(const char *string) {
 
 		// Position after _fontHeader
 		int startPos = memoryStream.pos();
-		uint16 *ptr;
 		for (int i = 0; i < _fontHeader.numChars; i++) {
 			CharInfo *cInfo = new CharInfo;
 			cInfo->width = (int16)memoryStream.readUint32LE();
@@ -835,10 +824,9 @@ bool Gfx::loadFont(const char *string) {
 
 			for (int x = 0; x < cInfo->width; x++) {
 				for (int y = 0; y < _fontHeader.height; y++) {
-					int u, v;
-					u = x;
-					v = _fontHeader.height - y - 1;
-					ptr = (uint16 *)_fontSurfaces[i].getBasePtr(u, v);
+					int u = x;
+					int v = _fontHeader.height - y - 1;
+					uint16 *ptr = (uint16 *)_fontSurfaces[i].getBasePtr(u, v);
 					*ptr = memoryStream.readUint16LE();
 				}
 			}
@@ -869,7 +857,6 @@ bool Gfx::loadFont(const char *string) {
 
 		// Position after _fontHeader
 		int startPos = stream->pos();
-		uint16 *ptr;
 		for (int i = 0; i < _fontHeader.numChars; i++) {
 			CharInfo *cInfo = new CharInfo;
 			cInfo->width = (int16)stream->readUint32LE();
@@ -886,7 +873,7 @@ bool Gfx::loadFont(const char *string) {
 			stream->seek(startPos + cInfo->offset);
 
 			for (int y = 0; y < _fontHeader.height; y++) {
-				ptr = (uint16 *)_fontSurfaces[i].getBasePtr(0, y);
+				uint16 *ptr = (uint16 *)_fontSurfaces[i].getBasePtr(0, y);
 				for (int x = 0; x < cInfo->width; x++) {
 					*ptr = stream->readUint16LE();
 					ptr++;


Commit: f14edf90d4f7ecc2b869274aeaad3aeed06ad524
    https://github.com/scummvm/scummvm/commit/f14edf90d4f7ecc2b869274aeaad3aeed06ad524
Author: Strangerke (strangerke at scummvm.org)
Date: 2019-09-03T17:17:33+02:00

Commit Message:
HDB: Remove two unused variables

Changed paths:
    engines/hdb/lua-script.cpp


diff --git a/engines/hdb/lua-script.cpp b/engines/hdb/lua-script.cpp
index c180778..c8f562d 100644
--- a/engines/hdb/lua-script.cpp
+++ b/engines/hdb/lua-script.cpp
@@ -1165,7 +1165,7 @@ static int startMusic(lua_State *L) {
 	g_hdb->_lua->checkParameters("startMusic", 1);
 
 	lua_pop(L, 1);
-	bool error = g_hdb->_sound->startMusic((SoundType)s1);
+	g_hdb->_sound->startMusic((SoundType)s1);
 
 	return 0;
 }
@@ -1180,7 +1180,7 @@ static int fadeInMusic(lua_State *L) {
 	g_hdb->_lua->checkParameters("fadeInMusic", 2);
 
 	lua_pop(L, 2);
-	bool error = g_hdb->_sound->fadeInMusic((SoundType)s1, ramp);
+	g_hdb->_sound->fadeInMusic((SoundType)s1, ramp);
 
 	return 0;
 }


Commit: eaa972347f42d4e6a5e0e47974ab7d360cdfe44b
    https://github.com/scummvm/scummvm/commit/eaa972347f42d4e6a5e0e47974ab7d360cdfe44b
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:33+02:00

Commit Message:
HDB: Increase number of slots to 99 and support saveload from the GMM

Changed paths:
    engines/hdb/detection.cpp
    engines/hdb/hdb.h
    engines/hdb/saveload.cpp


diff --git a/engines/hdb/detection.cpp b/engines/hdb/detection.cpp
index 974d831..5637bf0 100644
--- a/engines/hdb/detection.cpp
+++ b/engines/hdb/detection.cpp
@@ -188,7 +188,7 @@ void HDBMetaEngine::removeSaveState(const char *target, int slot) const {
 	g_system->getSavefileManager()->removeSavefile(fileName);
 }
 
-int HDBMetaEngine::getMaximumSaveSlot() const { return 9; }
+int HDBMetaEngine::getMaximumSaveSlot() const { return 99; }
 
 SaveStateList HDBMetaEngine::listSaves(const char *target) const {
 	Common::SaveFileManager *saveFileMan = g_system->getSavefileManager();
diff --git a/engines/hdb/hdb.h b/engines/hdb/hdb.h
index 3535d45..eb3a818 100644
--- a/engines/hdb/hdb.h
+++ b/engines/hdb/hdb.h
@@ -195,8 +195,10 @@ public:
 		_changeLevel = true;
 	}
 
-	Common::Error saveGameState(int slot, const Common::String &desc);
-	Common::Error loadGameState(int slot);
+	virtual Common::Error saveGameState(int slot, const Common::String &desc);
+	virtual Common::Error loadGameState(int slot);
+	virtual bool canLoadGameStateCurrently();
+	virtual bool canSaveGameStateCurrently();
 	void saveGame(Common::OutSaveFile *out);
 	void loadGame(Common::InSaveFile *in);
 
diff --git a/engines/hdb/saveload.cpp b/engines/hdb/saveload.cpp
index d53404b..618d9a9 100644
--- a/engines/hdb/saveload.cpp
+++ b/engines/hdb/saveload.cpp
@@ -32,6 +32,10 @@
 
 namespace HDB {
 
+bool HDBGame::canSaveGameStateCurrently() {
+	return (_gameState == GAME_PLAY && !_ai->cinematicsActive());
+}
+
 Common::Error HDBGame::saveGameState(int slot, const Common::String &desc) {
 
 	// If no map is loaded, don't try to save
@@ -79,6 +83,10 @@ Common::Error HDBGame::saveGameState(int slot, const Common::String &desc) {
 	return Common::kNoError;
 }
 
+bool HDBGame::canLoadGameStateCurrently() {
+	return _gameState == GAME_PLAY;
+}
+
 Common::Error HDBGame::loadGameState(int slot) {
 	Common::InSaveFile *in;
 


Commit: 29eb9dc9d61d15d673530b8aa6cbec02eb8ad30f
    https://github.com/scummvm/scummvm/commit/29eb9dc9d61d15d673530b8aa6cbec02eb8ad30f
Author: Strangerke (strangerke at scummvm.org)
Date: 2019-09-03T17:17:33+02:00

Commit Message:
HDB: Remove an unused member of Song, get rid of the return value of several sound functions

Changed paths:
    engines/hdb/ai-funcs.cpp
    engines/hdb/sound.cpp
    engines/hdb/sound.h


diff --git a/engines/hdb/ai-funcs.cpp b/engines/hdb/ai-funcs.cpp
index afd6f3a..137df1c 100644
--- a/engines/hdb/ai-funcs.cpp
+++ b/engines/hdb/ai-funcs.cpp
@@ -2191,7 +2191,8 @@ bool AI::walkThroughEnt(AIType type) {
 // Play special sound for every item you get
 void AI::getItemSound(AIType type) {
 	switch (type) {
-	case ITEM_GOO_CUP: g_hdb->_sound->playSound(SND_GET_GOO);
+	case ITEM_GOO_CUP:
+		g_hdb->_sound->playSound(SND_GET_GOO);
 		break;
 	case ITEM_GEM_WHITE:
 	case ITEM_GEM_BLUE:
@@ -2239,7 +2240,8 @@ void AI::getItemSound(AIType type) {
 			break;
 		}
 		// fall through
-	default: g_hdb->_sound->playSound(SND_GET_THING);
+	default:
+		g_hdb->_sound->playSound(SND_GET_THING);
 	}
 }
 
diff --git a/engines/hdb/sound.cpp b/engines/hdb/sound.cpp
index 25f13d9..b41622b 100644
--- a/engines/hdb/sound.cpp
+++ b/engines/hdb/sound.cpp
@@ -1480,9 +1480,9 @@ void Sound::setMusicVolume(int volume) {
 	}
 }
 
-bool Sound::playSound(int index) {
+void Sound::playSound(int index) {
 	if (index > _numSounds || !_sfxVolume)
-		return false;
+		return;
 
 	// is sound in memory at least?
 	if (_soundCache[index].loaded == SNDMEM_FREEABLE)
@@ -1500,7 +1500,7 @@ bool Sound::playSound(int index) {
 			stream = g_hdb->_fileMan->findFirstData(_soundCache[index].name, TYPE_BINARY);
 
 		if (stream == nullptr)
-			return false;
+			return;
 
 		if (_soundCache[index].ext == SNDTYPE_MP3) {
 #ifdef USE_MAD
@@ -1532,7 +1532,7 @@ bool Sound::playSound(int index) {
 
 	// If no free handles found
 	if (soundChannel == kLaserChannel)
-		return false;
+		return;
 
 	g_hdb->_mixer->setChannelVolume(_handles[soundChannel], _sfxVolume);
 
@@ -1547,16 +1547,14 @@ bool Sound::playSound(int index) {
 		false,
 		false
 	);
-
-	return true;
 }
 
-bool Sound::playSoundEx(int index, int channel, bool loop) {
+void Sound::playSoundEx(int index, int channel, bool loop) {
 	if (g_hdb->_mixer->isSoundHandleActive(_handles[channel]))
-		return false;
+		return;
 
 	if (index > _numSounds || !_sfxVolume)
-		return false;
+		return;
 
 	// is sound in memory at least?
 	if (_soundCache[index].loaded == SNDMEM_FREEABLE)
@@ -1574,7 +1572,7 @@ bool Sound::playSoundEx(int index, int channel, bool loop) {
 			stream = g_hdb->_fileMan->findFirstData(_soundCache[index].name, TYPE_BINARY);
 
 		if (stream == nullptr)
-			return false;
+			return;
 
 		if (_soundCache[index].ext == SNDTYPE_MP3) {
 #ifdef USE_MAD
@@ -1622,16 +1620,15 @@ bool Sound::playSoundEx(int index, int channel, bool loop) {
 			false
 		);
 	}
-	return true;
 }
 
-bool Sound::playVoice(int index, int actor) {
+void Sound::playVoice(int index, int actor) {
 	if (!_voicesOn || g_hdb->isPPC())
-		return false;
+		return;
 
 	// make sure we aren't playing a line more than once this time (only on CHANNEL 0)
 	if (!actor && _voicePlayed[index - FIRST_VOICE])
-		return false;
+		return;
 
 	// is voice channel already active?  if so, shut 'er down (automagically called StopVoice via callback)
 	if (_voices[actor].active)
@@ -1646,14 +1643,14 @@ bool Sound::playVoice(int index, int actor) {
 		stream = g_hdb->_fileMan->findFirstData(soundList[index].name, TYPE_BINARY);
 
 	if (stream == nullptr)
-		return false;
+		return;
 
 	if (g_hdb->getPlatform() == Common::kPlatformLinux) {
 #ifdef USE_VORBIS
 		Audio::AudioStream *audioStream = Audio::makeVorbisStream(stream, DisposeAfterUse::YES);
 		if (audioStream == nullptr) {
 			delete stream;
-			return false;
+			return;
 		}
 
 		g_hdb->_mixer->setChannelVolume(*_voices[actor].handle, _sfxVolume);
@@ -1675,7 +1672,7 @@ bool Sound::playVoice(int index, int actor) {
 		Audio::AudioStream *audioStream = Audio::makeMP3Stream(stream, DisposeAfterUse::YES);
 		if (audioStream == nullptr) {
 			delete stream;
-			return false;
+			return;
 		}
 
 		g_hdb->_mixer->setChannelVolume(*_voices[actor].handle, _sfxVolume);
@@ -1697,26 +1694,26 @@ bool Sound::playVoice(int index, int actor) {
 	_voices[actor].active = true;
 	_voicePlayed[index - FIRST_VOICE] = 1;
 
-	return true;
+	return;
 }
 
-bool Sound::startMusic(SoundType song) {
+void Sound::startMusic(SoundType song) {
 	g_hdb->_menu->saveSong(song);
 
 	if (!_musicVolume)
-		return false;
+		return;
 
-	return beginMusic(song, false, 0);
+	beginMusic(song, false, 0);
 }
 
-bool Sound::fadeInMusic(SoundType song, int ramp) {
+void Sound::fadeInMusic(SoundType song, int ramp) {
 	g_hdb->_menu->saveSong(song);
 
 	if (!_musicVolume)
-		return false;
+		return;
 
 	stopMusic();
-	return beginMusic(song, false, ramp);
+	beginMusic(song, false, ramp);
 }
 
 void Sound::fadeOutMusic(int ramp) {
@@ -1741,10 +1738,8 @@ bool Sound::songPlaying(SoundType song) {
 	return false;
 }
 
-bool Sound::stopChannel(int channel) {
+void Sound::stopChannel(int channel) {
 	g_hdb->_mixer->stopHandle(_handles[channel]);
-
-	return true;
 }
 
 void Sound::stopMusic() {
@@ -1758,7 +1753,7 @@ void Sound::stopMusic() {
 	}
 }
 
-bool Sound::beginMusic(SoundType song, bool fadeIn, int ramp) {
+void Sound::beginMusic(SoundType song, bool fadeIn, int ramp) {
 	const char *songName = nullptr;
 
 	if (g_hdb->getPlatform() == Common::kPlatformLinux) {
@@ -1796,7 +1791,7 @@ bool Sound::beginMusic(SoundType song, bool fadeIn, int ramp) {
 
 		Common::SeekableReadStream *stream = SearchMan.createReadStreamForMember(songName);
 		if (stream == nullptr)
-			return false;
+			return;
 
 		if (g_hdb->getPlatform() != Common::kPlatformLinux) {
 #ifdef USE_MAD
@@ -1867,7 +1862,7 @@ bool Sound::beginMusic(SoundType song, bool fadeIn, int ramp) {
 
 		Common::SeekableReadStream *stream = SearchMan.createReadStreamForMember(songName);
 		if (stream == nullptr)
-			return false;
+			return;
 
 		if (g_hdb->getPlatform() != Common::kPlatformLinux) {
 #ifdef USE_MAD
@@ -1927,10 +1922,7 @@ bool Sound::beginMusic(SoundType song, bool fadeIn, int ramp) {
 			_song2.playing = true;
 #endif
 		}
-	} else
-		return false;
-
-	return true;
+	}
 }
 
 void Sound::updateMusic() {
@@ -1972,13 +1964,11 @@ int Sound::registerSound(const char *name) {
 	return index;
 }
 
-bool Sound::freeSound(int index) {
+void Sound::freeSound(int index) {
 	if (_soundCache[index].loaded == SNDMEM_LOADED) {
 		_soundCache[index].loaded = SNDMEM_NOTCACHED;
 		_soundCache[index].ext = SNDTYPE_NONE;
-		return true;
 	}
-	return false;
 }
 
 const char *Sound::getSNDLuaName(int index) {
diff --git a/engines/hdb/sound.h b/engines/hdb/sound.h
index c9c2eed..d810cae 100644
--- a/engines/hdb/sound.h
+++ b/engines/hdb/sound.h
@@ -1462,7 +1462,6 @@ struct SoundCache {
 struct Song {
 	bool playing;
 	SoundType song;
-	const char *sndMusic;
 	Audio::SoundHandle *handle;
 
 	bool fadingOut;
@@ -1473,7 +1472,7 @@ struct Song {
 	int	fadeInVol;
 	int	fadeInRamp;
 
-	Song() : playing(false), song(SONG_NONE), sndMusic(nullptr), handle(new Audio::SoundHandle()),
+	Song() : playing(false), song(SONG_NONE), handle(new Audio::SoundHandle()),
 		fadingOut(false), fadeOutVol(0), fadeOutRamp(0),
 		fadingIn(false), fadeInVol(0), fadeInRamp(0) {}
 	~Song() {
@@ -1511,19 +1510,19 @@ public:
 		memset(&_voicePlayed[0], 0, sizeof(_voicePlayed));
 	}
 
-	bool playSound(int index);
-	bool playSoundEx(int index, int channel, bool loop);
-	bool playVoice(int index, int actor);
-	bool startMusic(SoundType song);
-	bool fadeInMusic(SoundType song, int ramp);
+	void playSound(int index);
+	void playSoundEx(int index, int channel, bool loop);
+	void playVoice(int index, int actor);
+	void startMusic(SoundType song);
+	void fadeInMusic(SoundType song, int ramp);
 	void fadeOutMusic(int ramp);
 	void stopMusic();
-	bool beginMusic(SoundType song, bool fadeIn, int ramp);
+	void beginMusic(SoundType song, bool fadeIn, int ramp);
 	void updateMusic();
 	bool songPlaying(SoundType song);
-	bool stopChannel(int channel);
+	void stopChannel(int channel);
 	int registerSound(const char *name);
-	bool freeSound(int index);
+	void freeSound(int index);
 	const char *getSNDLuaName(int index);
 	int getSNDIndex(const char *name);
 	int getNumSounds() {


Commit: a411d35b20d4937aa707c34dcfccffec7d3f3276
    https://github.com/scummvm/scummvm/commit/a411d35b20d4937aa707c34dcfccffec7d3f3276
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:34+02:00

Commit Message:
HDB: Add PPC version of updateFade()

Changed paths:
    engines/hdb/gfx.cpp


diff --git a/engines/hdb/gfx.cpp b/engines/hdb/gfx.cpp
index b92cb86..4ddf820 100644
--- a/engines/hdb/gfx.cpp
+++ b/engines/hdb/gfx.cpp
@@ -328,24 +328,17 @@ void Gfx::setFade(bool fadeIn, bool black, int steps) {
 }
 
 void Gfx::updateFade() {
+	uint8 r, g, b;
+	uint16 value;
+	uint16 *ptr;
 	static int waitAFrame = 0;
 
 	if (!_fadeInfo.active && !_fadeInfo.stayFaded)
 		return;
 
-	debug(7, "updateFade: active: %d stayFaded: %d isBlack: %d speed: %d isFadeIn: %d curStep: %d", _fadeInfo.active,
-			_fadeInfo.stayFaded, _fadeInfo.isBlack, _fadeInfo.speed, _fadeInfo.isFadeIn, _fadeInfo.curStep);
-
-	_fadeBuffer2.blitFrom(_globalSurface);
-
-	do {
-		// Copy pristine copy of background to modification buffer
-		_fadeBuffer1.blitFrom(_fadeBuffer2);
-
-		// do the actual alphablending
+	if (g_hdb->isPPC()) {
 		if (!_fadeInfo.isBlack) {
-			// Black Fade
-
+			// Black fade
 			for (int y = 0; y < g_hdb->_screenHeight; y++) {
 				uint16 *ptr = (uint16 *)_fadeBuffer1.getBasePtr(0, y);
 				for (int x = 0; x < g_hdb->_screenWidth; x++) {
@@ -361,9 +354,9 @@ void Gfx::updateFade() {
 					ptr++;
 				}
 			}
-		} else {
-			// White Fade
 
+		} else {
+			// White fade
 			for (int y = 0; y < g_hdb->_screenHeight; y++) {
 				uint16 *ptr = (uint16 *)_fadeBuffer1.getBasePtr(0, y);
 				for (int x = 0; x < g_hdb->_screenWidth; x++) {
@@ -379,11 +372,6 @@ void Gfx::updateFade() {
 			}
 		}
 
-		_globalSurface.blitFrom(_fadeBuffer1);
-		g_system->copyRectToScreen(_globalSurface.getBasePtr(0, 0), _globalSurface.pitch, 0, 0, _globalSurface.w, _globalSurface.h);
-
-		// step the fading values to the next one and
-		// see if we're done yet
 		if (_fadeInfo.isFadeIn) {
 			if (_fadeInfo.active)
 				_fadeInfo.curStep += _fadeInfo.speed;
@@ -400,28 +388,96 @@ void Gfx::updateFade() {
 			if (_fadeInfo.curStep < 1) {
 				_fadeInfo.curStep = 0;
 				_fadeInfo.active = false;
-				_fadeInfo.stayFaded = false;
+				_fadeInfo.stayFaded = true;
 			}
 		}
+	} else {
+		_fadeBuffer2.blitFrom(_globalSurface);
+
+		do {
+			// Copy pristine copy of background to modification buffer
+			_fadeBuffer1.blitFrom(_fadeBuffer2);
+
+			// do the actual alphablending
+
+			if (!_fadeInfo.isBlack) {
+				// Black Fade
+
+				for (int y = 0; y < g_hdb->_screenHeight; y++) {
+					ptr = (uint16 *)_fadeBuffer1.getBasePtr(0, y);
+					for (int x = 0; x < g_hdb->_screenWidth; x++) {
+						value = *ptr;
+						if (value) {
+							g_hdb->_format.colorToRGB(value, r, g, b);
+							r = (r * _fadeInfo.curStep) >> 8;
+							g = (g * _fadeInfo.curStep) >> 8;
+							b = (b * _fadeInfo.curStep) >> 8;
+							*ptr = g_hdb->_format.RGBToColor(r, g, b);
+						}
+						ptr++;
+					}
+				}
+			} else {
+				// White Fade
 
-		// make sure we wait one frame at least - some logic in the game
-		// doesn't draw the frame immediately
-		if (!waitAFrame) {
-			waitAFrame++;
-			return;
-		}
+				for (int y = 0; y < g_hdb->_screenHeight; y++) {
+					ptr = (uint16 *)_fadeBuffer1.getBasePtr(0, y);
+					for (int x = 0; x < g_hdb->_screenWidth; x++) {
+						value = *ptr;
+						g_hdb->_format.colorToRGB(value, r, g, b);
+						r += (255 - r) * (256 - _fadeInfo.curStep) / 256;
+						g += (255 - g) * (256 - _fadeInfo.curStep) / 256;
+						b += (255 - b) * (256 - _fadeInfo.curStep) / 256;
+						*ptr = g_hdb->_format.RGBToColor(r, g, b);
+						ptr++;
+					}
+				}
+			}
 
-		g_system->updateScreen();
-		if (g_hdb->getDebug()) {
-			g_hdb->_frames.push_back(g_system->getMillis());
-			while (g_hdb->_frames[0] < g_system->getMillis() - 1000)
-				g_hdb->_frames.remove_at(0);
-		}
-		g_system->delayMillis(1000 / kGameFPS);
+			_globalSurface.blitFrom(_fadeBuffer1);
+			g_system->copyRectToScreen(_globalSurface.getBasePtr(0, 0), _globalSurface.pitch, 0, 0, _globalSurface.w, _globalSurface.h);
+
+			// step the fading values to the next one and
+			// see if we're done yet
+			if (_fadeInfo.isFadeIn) {
+				if (_fadeInfo.active)
+					_fadeInfo.curStep += _fadeInfo.speed;
+
+				if (_fadeInfo.curStep > 255) {
+					_fadeInfo.curStep = 255;
+					_fadeInfo.active = false;
+					_fadeInfo.stayFaded = false;
+				}
+			} else {
+				if (_fadeInfo.active == true)
+					_fadeInfo.curStep -= _fadeInfo.speed;
+
+				if (_fadeInfo.curStep < 1) {
+					_fadeInfo.curStep = 0;
+					_fadeInfo.active = false;
+					_fadeInfo.stayFaded = false;
+				}
+			}
 
-	} while (_fadeInfo.active);
+			// make sure we wait one frame at least - some logic in the game
+			// doesn't draw the frame immediately
+			if (!waitAFrame) {
+				waitAFrame++;
+				return;
+			}
 
-	waitAFrame = 0;			// reset counter
+			g_system->updateScreen();
+			if (g_hdb->getDebug()) {
+				g_hdb->_frames.push_back(g_system->getMillis());
+				while (g_hdb->_frames[0] < g_system->getMillis() - 1000)
+					g_hdb->_frames.remove_at(0);
+			}
+			g_system->delayMillis(1000 / kGameFPS);
+
+		} while (_fadeInfo.active);
+
+		waitAFrame = 0;			// reset counter
+	}
 }
 
 void Gfx::turnOnSnow() {


Commit: a5f66ed1fe6f90857de53d84ee0f56932445bfac
    https://github.com/scummvm/scummvm/commit/a5f66ed1fe6f90857de53d84ee0f56932445bfac
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:34+02:00

Commit Message:
HDB: Fix warnings

Changed paths:
    engines/hdb/gfx.cpp


diff --git a/engines/hdb/gfx.cpp b/engines/hdb/gfx.cpp
index 4ddf820..4ebb052 100644
--- a/engines/hdb/gfx.cpp
+++ b/engines/hdb/gfx.cpp
@@ -340,11 +340,10 @@ void Gfx::updateFade() {
 		if (!_fadeInfo.isBlack) {
 			// Black fade
 			for (int y = 0; y < g_hdb->_screenHeight; y++) {
-				uint16 *ptr = (uint16 *)_fadeBuffer1.getBasePtr(0, y);
+				 ptr = (uint16 *)_fadeBuffer1.getBasePtr(0, y);
 				for (int x = 0; x < g_hdb->_screenWidth; x++) {
-					uint16 value = *ptr;
+					 value = *ptr;
 					if (value) {
-						uint8 r, g, b;
 						g_hdb->_format.colorToRGB(value, r, g, b);
 						r = (r * _fadeInfo.curStep) >> 8;
 						g = (g * _fadeInfo.curStep) >> 8;
@@ -358,10 +357,9 @@ void Gfx::updateFade() {
 		} else {
 			// White fade
 			for (int y = 0; y < g_hdb->_screenHeight; y++) {
-				uint16 *ptr = (uint16 *)_fadeBuffer1.getBasePtr(0, y);
+				ptr = (uint16 *)_fadeBuffer1.getBasePtr(0, y);
 				for (int x = 0; x < g_hdb->_screenWidth; x++) {
-					uint16 value = *ptr;
-					uint8 r, g, b;
+					value = *ptr;
 					g_hdb->_format.colorToRGB(value, r, g, b);
 					r += (255 - r) * (256 - _fadeInfo.curStep) / 256;
 					g += (255 - g) * (256 - _fadeInfo.curStep) / 256;


Commit: e1f05066426622f2ff42782e229209e2c368d53d
    https://github.com/scummvm/scummvm/commit/e1f05066426622f2ff42782e229209e2c368d53d
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:34+02:00

Commit Message:
HDB: Fix drawDeliveries() when carrying 2...

... or more delivery items

Changed paths:
    engines/hdb/window.cpp


diff --git a/engines/hdb/window.cpp b/engines/hdb/window.cpp
index e2ca2c2..929a366 100644
--- a/engines/hdb/window.cpp
+++ b/engines/hdb/window.cpp
@@ -1439,7 +1439,7 @@ void Window::drawDeliveries() {
 
 		// Draw delivery items
 		int inv = 0;
-		for (; inv < g_hdb->_ai->getInvAmount(); inv++) {
+		for (; inv < g_hdb->_ai->getDeliveriesAmount(); inv++) {
 			DlvEnt *d = g_hdb->_ai->getDeliveryItem(inv);
 			if (_dlvsInfo.animate && inv == g_hdb->_ai->getDeliveriesAmount() - 1) {
 				if (_dlvsInfo.go1) {


Commit: f0eb59cdee3f8ac0152b6075f68db6d6a9784f85
    https://github.com/scummvm/scummvm/commit/f0eb59cdee3f8ac0152b6075f68db6d6a9784f85
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:34+02:00

Commit Message:
HDB: Draw all stars/snow in PPC version.

Along the way, this caught a buffer overflow, so sanity checks
were also implemented

Changed paths:
    engines/hdb/gfx.cpp


diff --git a/engines/hdb/gfx.cpp b/engines/hdb/gfx.cpp
index 4ebb052..5d8f5ca 100644
--- a/engines/hdb/gfx.cpp
+++ b/engines/hdb/gfx.cpp
@@ -522,7 +522,11 @@ Tile *Gfx::loadIcon(const char *tileName) {
 }
 
 void Gfx::setPixel(int x, int y, uint16 color) {
+	if (x < 0 || y < 0 || x >= _globalSurface.w || y >= _globalSurface.h)
+		return;
+
 	*(uint16 *)_globalSurface.getBasePtr(x, y) = color;
+	g_system->copyRectToScreen(_globalSurface.getBasePtr(x, y), _globalSurface.pitch, x, y, 1, 1);
 }
 
 Tile *Gfx::getTile(int index) {


Commit: c2a8a0c2c4192eab5ff8cdf855a561755c957356
    https://github.com/scummvm/scummvm/commit/c2a8a0c2c4192eab5ff8cdf855a561755c957356
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:34+02:00

Commit Message:
HDB: Fix PPC Double Click code

Changed paths:
    engines/hdb/hdb.cpp
    engines/hdb/input.cpp


diff --git a/engines/hdb/hdb.cpp b/engines/hdb/hdb.cpp
index 4b4bc86..68f505b 100644
--- a/engines/hdb/hdb.cpp
+++ b/engines/hdb/hdb.cpp
@@ -408,25 +408,6 @@ void HDBGame::setTargetXY(int x, int y) {
 	if (p->touchpWait)
 		return;
 
-	// Double-Clicking on the player to open inventory?
-	if (g_hdb->isPPC()) {
-		if (x == px && y == py) {
-			static uint32 dblClickTimer = 0;
-
-			if (dblClickTimer) {
-				debug("Double Click Timer: %d", dblClickTimer);
-				debug("Click Timer Diff: %d", (int)(g_system->getMillis() - dblClickTimer));
-			}
-
-			if (dblClickTimer && ((int)(g_system->getMillis() - dblClickTimer) < (int)(kGameFPS * 5 * 1000 / 60))) {
-				g_hdb->_window->openInventory();
-				dblClickTimer = 0;
-			} else
-				dblClickTimer = g_system->getMillis();
-			return;
-		}
-	}
-
 	// If we're attacking...don't do anything else
 	AIState stateList[] = {
 		STATE_ATK_CLUB_UP,	STATE_ATK_CLUB_DOWN, STATE_ATK_CLUB_LEFT, STATE_ATK_CLUB_RIGHT,
diff --git a/engines/hdb/input.cpp b/engines/hdb/input.cpp
index 0a3cfb2..333c227 100644
--- a/engines/hdb/input.cpp
+++ b/engines/hdb/input.cpp
@@ -376,10 +376,30 @@ void Input::stylusDown(int x, int y) {
 				return;
 		}
 
-		// Toggle Walk Speed if we clicked Player
-		static uint32 lastRunning = g_system->getMillis();
+		// Double-Clicking on the player to open inventory?
 		int nx, ny;
 		g_hdb->_ai->getPlayerXY(&nx, &ny);
+		if (g_hdb->isPPC()) {
+			if (nx == worldX && ny == worldY) {
+				static uint32 dblClickTimer = 0;
+
+				if (dblClickTimer && ((int)(g_system->getMillis() - dblClickTimer) < (int)(kGameFPS * 1000 / 60))) {
+					g_hdb->_window->openInventory();
+					dblClickTimer = 0;
+					g_hdb->_ai->togglePlayerRunning();
+					if (g_hdb->_ai->playerRunning())
+						g_hdb->_window->centerTextOut("Running Speed", g_hdb->_screenHeight - 32, kRunToggleDelay * kGameFPS);
+					else
+						g_hdb->_window->centerTextOut("Walking Speed", g_hdb->_screenHeight - 32, kRunToggleDelay * kGameFPS);
+					g_hdb->_sound->playSound(SND_SWITCH_USE);
+					return;
+				} else
+					dblClickTimer = g_system->getMillis();
+			}
+		}
+
+		// Toggle Walk Speed if we clicked Player
+		static uint32 lastRunning = g_system->getMillis();
 		if (nx == worldX && ny == worldY) {
 			if (lastRunning > g_system->getMillis())
 				return;


Commit: 390152b0b87416ddf17e2a7b63bbcbf4daa21b84
    https://github.com/scummvm/scummvm/commit/390152b0b87416ddf17e2a7b63bbcbf4daa21b84
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:34+02:00

Commit Message:
HDB: Implement cheating as GUI option

Changed paths:
  A engines/hdb/POTFILES
    engines/hdb/detection.cpp


diff --git a/engines/hdb/POTFILES b/engines/hdb/POTFILES
new file mode 100644
index 0000000..5b8afe7
--- /dev/null
+++ b/engines/hdb/POTFILES
@@ -0,0 +1 @@
+engines/hdb/detection.cpp
diff --git a/engines/hdb/detection.cpp b/engines/hdb/detection.cpp
index 5637bf0..7da1e69 100644
--- a/engines/hdb/detection.cpp
+++ b/engines/hdb/detection.cpp
@@ -22,6 +22,8 @@
 
 #include "base/plugins.h"
 
+#include "common/translation.h"
+
 #include "engines/advancedDetector.h"
 #include "graphics/thumbnail.h"
 
@@ -63,6 +65,8 @@ static const PlainGameDescriptor hdbGames[] = {
 	{0, 0}
 };
 
+#define GAMEOPTION_CHEATMODE GUIO_GAMEOPTIONS1
+
 namespace HDB {
 static const ADGameDescription gameDescriptions[] = {
 	{
@@ -72,7 +76,7 @@ static const ADGameDescription gameDescriptions[] = {
 		Common::EN_ANY,
 		Common::kPlatformWindows,
 		ADGF_NO_FLAGS,
-		GUIO1(GUIO_NONE)
+		GAMEOPTION_CHEATMODE
 	},
 	{
 		"hdb",
@@ -81,7 +85,7 @@ static const ADGameDescription gameDescriptions[] = {
 		Common::EN_ANY,
 		Common::kPlatformLinux,
 		ADGF_NO_FLAGS,
-		GUIO1(GUIO_NONE)
+		GAMEOPTION_CHEATMODE
 	},
 	// PocketPC Arm
 	{
@@ -91,7 +95,7 @@ static const ADGameDescription gameDescriptions[] = {
 		Common::EN_ANY,
 		Common::kPlatformPocketPC,
 		ADGF_NO_FLAGS,
-		GUIO1(GUIO_NONE)
+		GAMEOPTION_CHEATMODE
 	},
 
 	// Demos
@@ -102,7 +106,7 @@ static const ADGameDescription gameDescriptions[] = {
 		Common::EN_ANY,
 		Common::kPlatformLinux,
 		ADGF_DEMO,
-		GUIO1(GUIO_NONE)
+		GAMEOPTION_CHEATMODE
 	},
 	{
 		"hdb",
@@ -111,7 +115,7 @@ static const ADGameDescription gameDescriptions[] = {
 		Common::EN_ANY,
 		Common::kPlatformWindows,
 		ADGF_DEMO,
-		GUIO1(GUIO_NONE)
+		GAMEOPTION_CHEATMODE
 	},
 	// provided by sev
 	{
@@ -121,7 +125,7 @@ static const ADGameDescription gameDescriptions[] = {
 		Common::EN_ANY,
 		Common::kPlatformWindows,
 		ADGF_DEMO,
-		GUIO1(GUIO_NONE)
+		GAMEOPTION_CHEATMODE
 	},
 	{
 		"hdb",
@@ -130,7 +134,7 @@ static const ADGameDescription gameDescriptions[] = {
 		Common::EN_ANY,
 		Common::kPlatformPocketPC,
 		ADGF_DEMO,
-		GUIO1(GUIO_NONE)
+		GAMEOPTION_CHEATMODE
 	},
 	{
 		"hdb",
@@ -139,15 +143,29 @@ static const ADGameDescription gameDescriptions[] = {
 		Common::EN_ANY,
 		Common::kPlatformPocketPC,
 		(ADGF_DEMO | GF_HANDANGO),
-		GUIO1(GUIO_NONE)
+		GAMEOPTION_CHEATMODE
 	},
 	AD_TABLE_END_MARKER
 };
 } // End of namespace HDB
 
+static const ADExtraGuiOptionsMap optionsList[] = {
+		{
+				GAMEOPTION_CHEATMODE,
+				{
+						_s("Enable cheat mode"),
+						_s("Debug info and level selection becomes available"),
+						"hypercheat",
+						false
+				}
+		},
+
+		AD_EXTRA_GUI_OPTIONS_TERMINATOR
+};
+
 class HDBMetaEngine : public AdvancedMetaEngine {
 public:
-	HDBMetaEngine() : AdvancedMetaEngine(HDB::gameDescriptions, sizeof(ADGameDescription), hdbGames) {
+	HDBMetaEngine() : AdvancedMetaEngine(HDB::gameDescriptions, sizeof(ADGameDescription), hdbGames, optionsList) {
 		_singleId = "hdb";
 	}
 


Commit: d7b1e9d38e493337146a231d7a6c0b3856708068
    https://github.com/scummvm/scummvm/commit/d7b1e9d38e493337146a231d7a6c0b3856708068
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:34+02:00

Commit Message:
HDB: Implement quit screenshot differences for the PPC demos

Changed paths:
    engines/hdb/menu.cpp


diff --git a/engines/hdb/menu.cpp b/engines/hdb/menu.cpp
index 9ed7291..3dc7d2f 100644
--- a/engines/hdb/menu.cpp
+++ b/engines/hdb/menu.cpp
@@ -437,10 +437,18 @@ void Menu::startMenu() {
 	_controlsGfx = g_hdb->_gfx->loadPic(PIC_CONTROLSSCREEN);
 
 	if (g_hdb->isDemo()) {
-		_screenshots1gfx = g_hdb->_gfx->loadPic(PIC_DEMOSCREEN);
-		_screenshots1agfx = g_hdb->_gfx->loadPic(PIC_DEMOSCREEN2);
-		_screenshots2gfx = g_hdb->_gfx->loadPic(PIC_DEMO_BUY);
-		_demoPlaqueGfx =  g_hdb->_gfx->loadPic(PIC_DEMO);
+
+		if (!g_hdb->isPPC()) {
+			_screenshots1gfx = g_hdb->_gfx->loadPic(PIC_DEMOSCREEN);
+			_screenshots1agfx = g_hdb->_gfx->loadPic(PIC_DEMOSCREEN2);
+			_screenshots2gfx = g_hdb->_gfx->loadPic(PIC_DEMO_BUY);
+			_demoPlaqueGfx =  g_hdb->_gfx->loadPic(PIC_DEMO);
+		} else {
+			_screenshots1agfx = g_hdb->_gfx->loadPic("pic_demoscreenshots");
+			_screenshots1gfx = g_hdb->_gfx->loadPic("pic_demoscreenshots2");
+			_screenshots2gfx = NULL;
+			_demoPlaqueGfx =  NULL;
+		}
 	}
 
 	_vortexian[0] = g_hdb->_gfx->loadTile(GROUP_ENT_VORTEXIAN_STANDDOWN"01");
@@ -535,12 +543,13 @@ void Menu::drawMenu() {
 	if (_menuActive) {
 		drawRocketAndSelections();
 
-		// draw version #
-		if (_versionGfx)
+		if (!g_hdb->isPPC()) {
+			// draw version #
 			_versionGfx->drawMasked(g_hdb->_screenWidth - 6 * 8, g_hdb->_screenHeight - 8);
 
-		if (g_hdb->isDemo() && _demoPlaqueGfx) {
-			_demoPlaqueGfx->drawMasked(g_hdb->_screenWidth / 2 - _demoPlaqueGfx->_width / 2, 2);
+			if (g_hdb->isDemo()) {
+				_demoPlaqueGfx->drawMasked(g_hdb->_screenWidth / 2 - _demoPlaqueGfx->_width / 2, 2);
+			}
 		}
 
 		//
@@ -847,11 +856,13 @@ void Menu::drawMenu() {
 			if (!_quitScreen)
 				_quitScreen = g_hdb->_gfx->loadPic(PIC_QUITSCREEN);
 			_quitScreen->drawMasked(_quitX, _quitY);
-		} else if (_quitActive == 2) { // XXXX
-			_screenshots1gfx->drawMasked(_quitX, _quitY);
-			_screenshots2gfx->drawMasked(_quitX, g_hdb->_screenHeight - _screenshots2gfx->_height);
 		} else if (_quitActive == 1) {
 			_screenshots1agfx->drawMasked(_quitX, _quitY);
+		} else if (_quitActive == 2) { // XXXX
+			_screenshots1gfx->drawMasked(_quitX, _quitY);
+
+			if (!g_hdb->isPPC())
+				_screenshots2gfx->drawMasked(_quitX, g_hdb->_screenHeight - _screenshots2gfx->_height);
 		}
 	}
 }


Commit: 45e49a6ba21408043677f68981bd239e5bf4f161
    https://github.com/scummvm/scummvm/commit/45e49a6ba21408043677f68981bd239e5bf4f161
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:34+02:00

Commit Message:
HDB: Support bootparams for demo

Changed paths:
    engines/hdb/hdb.cpp


diff --git a/engines/hdb/hdb.cpp b/engines/hdb/hdb.cpp
index 68f505b..1eaa102 100644
--- a/engines/hdb/hdb.cpp
+++ b/engines/hdb/hdb.cpp
@@ -925,7 +925,7 @@ Common::Error HDBGame::run() {
 #endif
 
 	if (ConfMan.hasKey("boot_param")) {
-		char mapname[11];
+		char mapname[20];
 		int arg = ConfMan.getInt("boot_param");
 		int actionMode = MIN(arg / 100, 1);
 		int level = MIN(arg % 100, 31);
@@ -937,6 +937,9 @@ Common::Error HDBGame::run() {
 		else
 			strcpy(mapname, "CINE_OUTRO");
 
+		if (isDemo())
+			strncat(mapname, "_DEMO", 20);
+
 		debug("Starting level %s in %s", mapname, getActionMode() ? "Action Mode" : "Puzzle Mode");
 
 		_ai->clearPersistent();


Commit: 5f2be7e99308eae5fee8ea7febf3f23afbe94e2c
    https://github.com/scummvm/scummvm/commit/5f2be7e99308eae5fee8ea7febf3f23afbe94e2c
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:34+02:00

Commit Message:
HDB: Remove unnecessary global references

Changed paths:
    engines/hdb/gfx.cpp


diff --git a/engines/hdb/gfx.cpp b/engines/hdb/gfx.cpp
index 5d8f5ca..8d352f7 100644
--- a/engines/hdb/gfx.cpp
+++ b/engines/hdb/gfx.cpp
@@ -277,9 +277,9 @@ void Gfx::updateVideo() {
 
 	Common::Rect clip(g_hdb->_progressGfx->getSurface()->getBounds());
 	clip.moveTo(left, g_hdb->_progressY);
-	clip.clip(g_hdb->_gfx->_globalSurface.getBounds());
+	clip.clip(_globalSurface.getBounds());
 	if (!clip.isEmpty())
-		g_system->copyRectToScreen(g_hdb->_gfx->_globalSurface.getBasePtr(clip.left, clip.top), g_hdb->_gfx->_globalSurface.pitch, clip.left, clip.top, clip.width(), clip.height());
+		g_system->copyRectToScreen(_globalSurface.getBasePtr(clip.left, clip.top), _globalSurface.pitch, clip.left, clip.top, clip.width(), clip.height());
 
 	g_system->updateScreen();
 }
@@ -999,13 +999,13 @@ void Gfx::drawText(const char *string) {
 			width = kFontSpace;
 
 		// Blit the character
-		g_hdb->_gfx->_globalSurface.transBlitFrom(_fontSurfaces[c], Common::Point(_cursorX, _cursorY), 0xf81f);
+		_globalSurface.transBlitFrom(_fontSurfaces[c], Common::Point(_cursorX, _cursorY), 0xf81f);
 
 		Common::Rect clip(0, 0, width, _fontHeader.height);
 		clip.moveTo(_cursorX, _cursorY);
 		clip.clip(_globalSurface.getBounds());
 		if (!clip.isEmpty()) {
-			g_system->copyRectToScreen(g_hdb->_gfx->_globalSurface.getBasePtr(clip.left, clip.top), g_hdb->_gfx->_globalSurface.pitch, clip.left, clip.top, clip.width(), clip.height());
+			g_system->copyRectToScreen(_globalSurface.getBasePtr(clip.left, clip.top), _globalSurface.pitch, clip.left, clip.top, clip.width(), clip.height());
 		}
 
 		// Advance the cursor


Commit: 0dbc63a31f03dba301a67bfa9a9b4fac5af4d781
    https://github.com/scummvm/scummvm/commit/0dbc63a31f03dba301a67bfa9a9b4fac5af4d781
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:34+02:00

Commit Message:
HDB: Remove redundant global references

Changed paths:
    engines/hdb/window.cpp


diff --git a/engines/hdb/window.cpp b/engines/hdb/window.cpp
index 929a366..5e629a5 100644
--- a/engines/hdb/window.cpp
+++ b/engines/hdb/window.cpp
@@ -510,12 +510,12 @@ void Window::drawPause() {
 	if (g_hdb->isPPC())
 		return;
 	if (g_hdb->getPause())
-		_gfxPausePlaque->drawMasked(g_hdb->_screenDrawWidth / 2 - _gfxPausePlaque->_width / 2, g_hdb->_window->_pauseY);
+		_gfxPausePlaque->drawMasked(g_hdb->_screenDrawWidth / 2 - _gfxPausePlaque->_width / 2, _pauseY);
 }
 
 void Window::checkPause(int x, int y) {
 	if (x >= g_hdb->_screenDrawWidth / 2 - _gfxPausePlaque->_width / 2 && g_hdb->_screenDrawWidth / 2 + _gfxPausePlaque->_width / 2 > x
-		&& y >= g_hdb->_window->_pauseY && y < g_hdb->_window->_pauseY + _gfxPausePlaque->_height) {
+		&& y >= _pauseY && y < _pauseY + _gfxPausePlaque->_height) {
 		g_hdb->togglePause();
 		g_hdb->_sound->playSound(SND_POP);
 	}
@@ -568,8 +568,8 @@ void Window::closeAll() {
 	closeTextOut();
 
 	if (g_hdb->isPPC()) {
-		g_hdb->_window->closeDlvs();
-		g_hdb->_window->closeInv();
+		closeDlvs();
+		closeInv();
 	}
 }
 
@@ -1538,7 +1538,7 @@ void Window::drawDeliveries() {
 						if (d->itemGfx)
 							d->itemGfx->drawMasked(drawX, drawY);
 
-						g_hdb->_gfx->setCursor(centerX - g_hdb->_gfx->stringLength(d->itemTextName) / 2, g_hdb->_window->_dlvItemTextY);
+						g_hdb->_gfx->setCursor(centerX - g_hdb->_gfx->stringLength(d->itemTextName) / 2, _dlvItemTextY);
 						g_hdb->_gfx->drawText(d->itemTextName);
 						if (!_dlvsInfo.go2) {
 							_dlvsInfo.go2 = true;
@@ -1552,7 +1552,7 @@ void Window::drawDeliveries() {
 						// Draw TO
 						_gfxArrowTo->drawMasked(_dlvsInfo.x + _dlvItemSpaceX * _dlvsInfo.selected + 8, drawY + kTileHeight);
 
-						g_hdb->_gfx->setCursor(centerX - g_hdb->_gfx->stringLength("to") / 2, g_hdb->_window->_dlvItemTextY + 12);
+						g_hdb->_gfx->setCursor(centerX - g_hdb->_gfx->stringLength("to") / 2, _dlvItemTextY + 12);
 						g_hdb->_gfx->drawText("to");
 						if (!_dlvsInfo.go3) {
 							_dlvsInfo.go3 = true;
@@ -1568,7 +1568,7 @@ void Window::drawDeliveries() {
 						if (d->destGfx)
 							d->destGfx->drawMasked(drawX, drawY + kTileHeight + 16);
 
-						g_hdb->_gfx->setCursor(centerX - (g_hdb->_gfx->stringLength(d->destTextName) + g_hdb->_gfx->stringLength("to")) / 2, g_hdb->_window->_dlvItemTextY + 12);
+						g_hdb->_gfx->setCursor(centerX - (g_hdb->_gfx->stringLength(d->destTextName) + g_hdb->_gfx->stringLength("to")) / 2, _dlvItemTextY + 12);
 						g_hdb->_gfx->drawText("to ");
 						g_hdb->_gfx->drawText(d->destTextName);
 
@@ -1588,9 +1588,9 @@ void Window::drawDeliveries() {
 					d->destGfx->drawMasked(drawX, drawY + kTileHeight + 16);
 
 				if (!_dlvsInfo.animate && inv == _dlvsInfo.selected) {
-					g_hdb->_gfx->setCursor(centerX - g_hdb->_gfx->stringLength(d->itemTextName) / 2, g_hdb->_window->_dlvItemTextY);
+					g_hdb->_gfx->setCursor(centerX - g_hdb->_gfx->stringLength(d->itemTextName) / 2, _dlvItemTextY);
 					g_hdb->_gfx->drawText(d->itemTextName);
-					g_hdb->_gfx->setCursor(centerX - (g_hdb->_gfx->stringLength(d->destTextName) + g_hdb->_gfx->stringLength("to ")) / 2, g_hdb->_window->_dlvItemTextY + 12);
+					g_hdb->_gfx->setCursor(centerX - (g_hdb->_gfx->stringLength(d->destTextName) + g_hdb->_gfx->stringLength("to ")) / 2, _dlvItemTextY + 12);
 					g_hdb->_gfx->drawText("to ");
 					g_hdb->_gfx->drawText(d->destTextName);
 				}
@@ -1697,8 +1697,8 @@ void Window::drawTryAgain() {
 		_gfxAgain = g_hdb->_gfx->loadPic(GAME_AGAIN);
 		_gfxLevelRestart = g_hdb->_gfx->loadPic(GAME_TA_LEVELRESTART);
 
-		_tryAgainInfo.y1 = g_hdb->_window->_tryY1;
-		_tryAgainInfo.y2 = g_hdb->_window->_tryY2;
+		_tryAgainInfo.y1 = _tryY1;
+		_tryAgainInfo.y2 = _tryY2;
 		_tryAgainInfo.x1 = g_hdb->_screenDrawWidth / 2 - _gfxTry->_width / 2;;
 		_tryAgainInfo.x2 = g_hdb->_screenDrawWidth / 2 - _gfxAgain->_width / 2;
 	}
@@ -1707,7 +1707,7 @@ void Window::drawTryAgain() {
 
 	_gfxTry->drawMasked((int)_tryAgainInfo.x1 + xv, (int)_tryAgainInfo.y1 + yv);
 	_gfxAgain->drawMasked((int)_tryAgainInfo.x2 + yv, (int)_tryAgainInfo.y2 + xv);
-	_gfxLevelRestart->drawMasked((int)(g_hdb->_screenDrawWidth / 2 - _gfxLevelRestart->_width + xv), g_hdb->_window->_tryRestartY + yv);
+	_gfxLevelRestart->drawMasked((int)(g_hdb->_screenDrawWidth / 2 - _gfxLevelRestart->_width + xv), _tryRestartY + yv);
 }
 
 void Window::clearTryAgain() {
@@ -1854,7 +1854,7 @@ void Window::textOut(const char *text, int x, int y, int timer) {
 	if (x < 0) {
 		int pw, lines;
 		g_hdb->_gfx->getDimensions(t->text, &pw, &lines);
-		t->x = g_hdb->_window->_textOutCenterX - pw / 2;
+		t->x = _textOutCenterX - pw / 2;
 	}
 
 	_textOutList.push_back(t);
@@ -1863,7 +1863,7 @@ void Window::textOut(const char *text, int x, int y, int timer) {
 void Window::centerTextOut(const char *text, int y, int timer) {
 	int width, lines;
 	g_hdb->_gfx->getDimensions(text, &width, &lines);
-	textOut(text, g_hdb->_window->_textOutCenterX - ((width - 8) >> 1), y, timer);
+	textOut(text, _textOutCenterX - ((width - 8) >> 1), y, timer);
 }
 
 void Window::drawTextOut() {


Commit: 7e0af9a2cbcc4b48cf30b507575014e87555eb1d
    https://github.com/scummvm/scummvm/commit/7e0af9a2cbcc4b48cf30b507575014e87555eb1d
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:34+02:00

Commit Message:
HDB: Fix Try Again position

Changed paths:
    engines/hdb/window.cpp


diff --git a/engines/hdb/window.cpp b/engines/hdb/window.cpp
index 5e629a5..853f4e6 100644
--- a/engines/hdb/window.cpp
+++ b/engines/hdb/window.cpp
@@ -1707,7 +1707,7 @@ void Window::drawTryAgain() {
 
 	_gfxTry->drawMasked((int)_tryAgainInfo.x1 + xv, (int)_tryAgainInfo.y1 + yv);
 	_gfxAgain->drawMasked((int)_tryAgainInfo.x2 + yv, (int)_tryAgainInfo.y2 + xv);
-	_gfxLevelRestart->drawMasked((int)(g_hdb->_screenDrawWidth / 2 - _gfxLevelRestart->_width + xv), _tryRestartY + yv);
+	_gfxLevelRestart->drawMasked((int)(g_hdb->_screenDrawWidth / 2 - _gfxLevelRestart->_width / 2 + xv), g_hdb->_window->_tryRestartY + yv);
 }
 
 void Window::clearTryAgain() {


Commit: 6fbadccf0874dffbe09be5908b523bd480805b83
    https://github.com/scummvm/scummvm/commit/6fbadccf0874dffbe09be5908b523bd480805b83
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:34+02:00

Commit Message:
HDB: Fix voice playing when no message on screen

Changed paths:
    engines/hdb/hdb.cpp
    engines/hdb/menu.cpp
    engines/hdb/sound.cpp
    engines/hdb/sound.h


diff --git a/engines/hdb/hdb.cpp b/engines/hdb/hdb.cpp
index 1eaa102..43b419a 100644
--- a/engines/hdb/hdb.cpp
+++ b/engines/hdb/hdb.cpp
@@ -214,6 +214,7 @@ void HDBGame::changeGameState() {
 		break;
 	case GAME_PLAY:
 		_menu->startMenu();
+		_sound->stopVoices();
 		_gameState = GAME_MENU;
 		break;
 	case GAME_LOADING:
@@ -1022,6 +1023,11 @@ Common::Error HDBGame::run() {
 			_map->drawForegrounds();
 			_ai->animateTargets();
 
+			// Check for voice to interrupt
+			if (!_window->dialogActive() && !_window->dialogChoiceActive() && !_window->msgBarActive()) {
+				_sound->stopVoices();
+			}
+
 			_window->drawDialog();
 			_window->drawDialogChoice();
 			_window->drawInventory();
diff --git a/engines/hdb/menu.cpp b/engines/hdb/menu.cpp
index 3dc7d2f..c1427c6 100644
--- a/engines/hdb/menu.cpp
+++ b/engines/hdb/menu.cpp
@@ -33,6 +33,7 @@
 #include "hdb/menu.h"
 #include "hdb/map.h"
 #include "hdb/mpc.h"
+#include "hdb/window.h"
 
 namespace HDB {
 
diff --git a/engines/hdb/sound.cpp b/engines/hdb/sound.cpp
index b41622b..28cee43 100644
--- a/engines/hdb/sound.cpp
+++ b/engines/hdb/sound.cpp
@@ -1626,14 +1626,14 @@ void Sound::playVoice(int index, int actor) {
 	if (!_voicesOn || g_hdb->isPPC())
 		return;
 
-	// make sure we aren't playing a line more than once this time (only on CHANNEL 0)
-	if (!actor && _voicePlayed[index - FIRST_VOICE])
-		return;
-
 	// is voice channel already active?  if so, shut 'er down (automagically called StopVoice via callback)
 	if (_voices[actor].active)
 		g_hdb->_mixer->stopHandle(*_voices[actor].handle);
 
+	// make sure we aren't playing a line more than once this time (only on CHANNEL 0)
+	if (!actor && _voicePlayed[index - FIRST_VOICE])
+		return;
+
 	Common::SeekableReadStream *stream = nullptr;
 	if (g_hdb->getPlatform() == Common::kPlatformLinux) {
 		Common::String updatedName(soundList[index].name);
diff --git a/engines/hdb/sound.h b/engines/hdb/sound.h
index d810cae..bbc4174 100644
--- a/engines/hdb/sound.h
+++ b/engines/hdb/sound.h
@@ -1513,6 +1513,16 @@ public:
 	void playSound(int index);
 	void playSoundEx(int index, int channel, bool loop);
 	void playVoice(int index, int actor);
+	void stopVoices() {
+		if (_voices[0].active) {
+			g_hdb->_mixer->stopHandle(*_voices[0].handle);
+			_voices[0].active = false;
+		}
+		if (_voices[1].active) {
+			g_hdb->_mixer->stopHandle(*_voices[1].handle);
+			_voices[1].active = false;
+		}
+	}
 	void startMusic(SoundType song);
 	void fadeInMusic(SoundType song, int ramp);
 	void fadeOutMusic(int ramp);


Commit: 62a0fb85519e8e2eefe08f7d51fd7dbb46bf365f
    https://github.com/scummvm/scummvm/commit/62a0fb85519e8e2eefe08f7d51fd7dbb46bf365f
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:34+02:00

Commit Message:
HDB: Remove unneeded include

Changed paths:
    engines/hdb/menu.cpp


diff --git a/engines/hdb/menu.cpp b/engines/hdb/menu.cpp
index c1427c6..3dc7d2f 100644
--- a/engines/hdb/menu.cpp
+++ b/engines/hdb/menu.cpp
@@ -33,7 +33,6 @@
 #include "hdb/menu.h"
 #include "hdb/map.h"
 #include "hdb/mpc.h"
-#include "hdb/window.h"
 
 namespace HDB {
 


Commit: 23c7dc8ebd6f6443f476de010129bb01aff210b4
    https://github.com/scummvm/scummvm/commit/23c7dc8ebd6f6443f476de010129bb01aff210b4
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:34+02:00

Commit Message:
HDB: Implement differences in rendering pipeline for the PPC demo

Changed paths:
    engines/hdb/hdb.cpp
    engines/hdb/map.cpp


diff --git a/engines/hdb/hdb.cpp b/engines/hdb/hdb.cpp
index 43b419a..4881581 100644
--- a/engines/hdb/hdb.cpp
+++ b/engines/hdb/hdb.cpp
@@ -1012,7 +1012,9 @@ Common::Error HDBGame::run() {
 			if (e && e->level < 2)
 				_ai->drawWayPoints();
 
-			_map->drawEnts();
+			if (!(g_hdb->isDemo() && g_hdb->isPPC()))
+				_map->drawEnts();
+
 			_map->drawGratings();
 
 			if (e && e->level == 2)
diff --git a/engines/hdb/map.cpp b/engines/hdb/map.cpp
index 5defd86..e4acff3 100644
--- a/engines/hdb/map.cpp
+++ b/engines/hdb/map.cpp
@@ -910,6 +910,9 @@ void Map::draw() {
 		screenY += kTileWidth;
 	}
 
+	if (g_hdb->isDemo() && g_hdb->isPPC())
+		drawEnts();
+
 	// Animate FAST Map Tiles
 	if (!(_animCycle % kAnimFastFrames)) {
 		for (Common::Array<uint32>::iterator it = _listBGAnimFast.begin(); it != _listBGAnimFast.end(); ++it) {


Commit: 2178770898938b5b13e5ece25ea8f0b26e0c728c
    https://github.com/scummvm/scummvm/commit/2178770898938b5b13e5ece25ea8f0b26e0c728c
Author: Strangerke (strangerke at scummvm.org)
Date: 2019-09-03T17:17:34+02:00

Commit Message:
HDB: Change init functions to handle errors

Changed paths:
    engines/hdb/ai-init.cpp
    engines/hdb/ai-inventory.cpp
    engines/hdb/ai.h
    engines/hdb/file-manager.cpp
    engines/hdb/file-manager.h
    engines/hdb/gfx.cpp
    engines/hdb/gfx.h
    engines/hdb/hdb.cpp
    engines/hdb/input.cpp
    engines/hdb/input.h
    engines/hdb/lua-script.cpp
    engines/hdb/lua-script.h
    engines/hdb/sound.cpp
    engines/hdb/sound.h
    engines/hdb/window.cpp
    engines/hdb/window.h


diff --git a/engines/hdb/ai-init.cpp b/engines/hdb/ai-init.cpp
index 1e6336e..32229d9 100644
--- a/engines/hdb/ai-init.cpp
+++ b/engines/hdb/ai-init.cpp
@@ -1012,7 +1012,7 @@ AI::~AI() {
 	}
 }
 
-bool AI::init() {
+void AI::init() {
 	_debugQMark = g_hdb->_gfx->loadIcon("icon_question_mark");
 
 	// Clear Waypoint list and load Waypoint graphics
@@ -1114,7 +1114,6 @@ bool AI::init() {
 	_weaponSelGfx = NULL;
 
 	restartSystem();
-	return true;
 }
 
 void AI::clearPersistent() {
diff --git a/engines/hdb/ai-inventory.cpp b/engines/hdb/ai-inventory.cpp
index 85fde5e..c67c11c 100644
--- a/engines/hdb/ai-inventory.cpp
+++ b/engines/hdb/ai-inventory.cpp
@@ -300,7 +300,7 @@ void AI::newDelivery(const char *itemTextName, const char *itemGfxName, const ch
 }
 
 bool AI::completeDelivery(const char *id) {
-	for (int i = 0; i < _numDeliveries; i++)
+	for (int i = 0; i < _numDeliveries; i++) {
 		if (!scumm_stricmp(_deliveries[i].id, id)) {
 			for (; i < _numDeliveries; i++)
 				memcpy(&_deliveries[i], &_deliveries[i + 1], sizeof(_deliveries[0]));
@@ -311,6 +311,7 @@ bool AI::completeDelivery(const char *id) {
 				g_hdb->_sound->playVoice(GUY_COMPLETED, 1);
 			return true;
 		}
+	}
 	return false;
 }
 
diff --git a/engines/hdb/ai.h b/engines/hdb/ai.h
index bd41890..572ab79 100644
--- a/engines/hdb/ai.h
+++ b/engines/hdb/ai.h
@@ -803,7 +803,7 @@ public:
 	AI();
 	~AI();
 
-	bool init();
+	void init();
 	void clearPersistent();
 	void restartSystem();
 	const char *funcLookUp(void(*function)(AIEntity *e));
diff --git a/engines/hdb/file-manager.cpp b/engines/hdb/file-manager.cpp
index 1e23032..e38d44f 100644
--- a/engines/hdb/file-manager.cpp
+++ b/engines/hdb/file-manager.cpp
@@ -39,33 +39,27 @@ FileMan::~FileMan() {
 		delete _dir[i];
 }
 
-bool FileMan::openMPC(const Common::String &filename) {
-	uint32 offset;
-
+void FileMan::openMPC(const Common::String &filename) {
 	if (!_mpcFile->open(filename)) {
 		error("FileMan::openMPC(): Error reading the MSD/MPC file %s", filename.c_str());
-		return false;
 	}
 
 	_dataHeader.id = _mpcFile->readUint32BE();
 
 	if (_dataHeader.id == MKTAG('M', 'P', 'C', 'C')) {
-		debug("COMPRESSED MPC FILE");
-		return false;
+		error("FileMan::openMPC: Compressed MPC File");
 	} else if (_dataHeader.id == MKTAG('M', 'P', 'C', 'U')) {
 		// we're fine
 	} else if (_dataHeader.id == MKTAG('M', 'S', 'D', 'C')) {
 		// we're fine
 	} else if (_dataHeader.id == MKTAG('M', 'S', 'D', 'U')) {
-		debug("UNCOMPRESSED MSD FILE");
-		return false;
+		error("FileMan::openMPC: Uncompressed MSD File");
 	} else {
-		error("Invalid MPC/MSD File.");
-		return false;
+		error("FileMan::openMPC: Invalid MPC/MSD File.");
 	}
 
 	// read the directory
-	offset = _mpcFile->readUint32LE();
+	uint32 offset = _mpcFile->readUint32LE();
 	_mpcFile->seek((int32)offset);
 
 	// Note: The MPC archive format assumes the offset to be uint32,
@@ -91,8 +85,6 @@ bool FileMan::openMPC(const Common::String &filename) {
 
 		_dir.push_back(dirEntry);
 	}
-
-	return true;
 }
 
 void FileMan::closeMPC() {
diff --git a/engines/hdb/file-manager.h b/engines/hdb/file-manager.h
index faa8e84..62caaad 100644
--- a/engines/hdb/file-manager.h
+++ b/engines/hdb/file-manager.h
@@ -68,7 +68,7 @@ public:
 		uint32 dirSize;
 	} _dataHeader;
 
-	bool openMPC(const Common::String &filename);
+	void openMPC(const Common::String &filename);
 	void closeMPC();
 	void seek(int32 offset, int flag);
 
diff --git a/engines/hdb/gfx.cpp b/engines/hdb/gfx.cpp
index 8d352f7..635157f 100644
--- a/engines/hdb/gfx.cpp
+++ b/engines/hdb/gfx.cpp
@@ -85,8 +85,7 @@ Gfx::~Gfx() {
 	delete _skyClouds;
 }
 
-bool Gfx::init() {
-
+void Gfx::init() {
 	// Set the default cursor pos & char clipping
 	setCursor(0, 0);
 
@@ -109,12 +108,12 @@ bool Gfx::init() {
 
 	// Load Game Font
 	if (!loadFont(HDB_FONT))
-		return false;
+		error("Gfx::init: Couldn't load fonts");
 
 	// Read total number of tiles in game
 	_numTiles = g_hdb->_fileMan->getCount("t32_", TYPE_TILE32);
 	if (!_numTiles)
-		return false;
+		error("Gfx::init: No tiles in game");
 
 	// Setup Tile Lookup Array
 	_tLookupArray = new TileLookup[_numTiles];
@@ -199,7 +198,6 @@ bool Gfx::init() {
 	}
 
 	_systemInit = true;
-	return true;
 }
 
 void Gfx::save(Common::OutSaveFile *out) {
@@ -835,7 +833,6 @@ int Gfx::animateTile(int tileIndex) {
 }
 
 bool Gfx::loadFont(const char *string) {
-
 	Common::SeekableReadStream *stream = g_hdb->_fileMan->findFirstData(string, TYPE_FONT);
 	if (!stream)
 		return false;
diff --git a/engines/hdb/gfx.h b/engines/hdb/gfx.h
index a138e9f..b0c4ca7 100644
--- a/engines/hdb/gfx.h
+++ b/engines/hdb/gfx.h
@@ -77,7 +77,7 @@ public:
 
 	Graphics::ManagedSurface _globalSurface;
 
-	bool init();
+	void init();
 	void save(Common::OutSaveFile *out);
 	void loadSaveFile(Common::InSaveFile *in);
 	void fillScreen(uint32 color);
diff --git a/engines/hdb/hdb.cpp b/engines/hdb/hdb.cpp
index 4881581..b1fbb6f 100644
--- a/engines/hdb/hdb.cpp
+++ b/engines/hdb/hdb.cpp
@@ -137,28 +137,14 @@ bool HDBGame::init() {
 
 	// Init fileMan
 
-	if (!_fileMan->openMPC(getGameFile())) {
-		error("FileMan::openMPC: Cannot find the %s data file", getGameFile());
-	}
-	if (!_gfx->init()) {
-		error("Gfx::init: Couldn't initialize Gfx");
-	}
-	if (!_sound->init()) {
-		error("Window::init: Couldn't initialize Sound");
-	}
-	if (!_ai->init()) {
-		error("AI::init: Couldn't initialize AI");
-	}
-	if (!_window->init()) {
-		error("Window::init: Couldn't initialize Window");
-	}
-	if (!_input->init()) {
-		error("Input::init: Couldn't initialize Input");
-	}
-	if (!_lua->init()) {
-		error("LuaScript::init: Couldn't load the GLOBAL.LUA code.");
-	}
+	_fileMan->openMPC(getGameFile());
 
+	_gfx->init();
+	_sound->init();
+	_ai->init();
+	_window->init();
+	_input->init();
+	_lua->init();
 	_menu->init();
 
 	_debugLogo = _gfx->loadIcon("icon_debug_logo");
diff --git a/engines/hdb/input.cpp b/engines/hdb/input.cpp
index 333c227..3078d69 100644
--- a/engines/hdb/input.cpp
+++ b/engines/hdb/input.cpp
@@ -31,7 +31,7 @@
 
 namespace HDB {
 
-bool Input::init() {
+void Input::init() {
 	_stylusDown = false;
 	_buttons = 0;
 
@@ -49,8 +49,6 @@ bool Input::init() {
 	_mouseY = g_hdb->_screenHeight / 2;
 
 	_mouseLButton = _mouseMButton = _mouseRButton = 0;
-
-	return true;
 }
 
 void Input::setButtons(uint16 b) {
diff --git a/engines/hdb/input.h b/engines/hdb/input.h
index 9ea364a..3d46994 100644
--- a/engines/hdb/input.h
+++ b/engines/hdb/input.h
@@ -42,7 +42,7 @@ enum Button {
 class Input {
 public:
 
-	bool init();
+	void init();
 
 	void setButtons(uint16 b);
 	uint16 getButtons();
diff --git a/engines/hdb/lua-script.cpp b/engines/hdb/lua-script.cpp
index c8f562d..b19feb6 100644
--- a/engines/hdb/lua-script.cpp
+++ b/engines/hdb/lua-script.cpp
@@ -125,16 +125,13 @@ LuaScript::~LuaScript() {
 		delete _globalLuaStream;
 }
 
-bool LuaScript::init() {
+void LuaScript::init() {
 	// Load Global Lua Code
 	_globalLuaStream = g_hdb->_fileMan->findFirstData("GLOBAL.LUA", TYPE_BINARY);
 	_globalLuaLength = g_hdb->_fileMan->getLength("GLOBAL.LUA", TYPE_BINARY);
 	if (_globalLuaStream == NULL || _globalLuaLength == 0) {
 		error("LuaScript::initScript: 'global code' failed to load");
-		return false;
 	}
-
-	return true;
 }
 
 bool LuaScript::loadLua(const char *name) {
diff --git a/engines/hdb/lua-script.h b/engines/hdb/lua-script.h
index a239aa2..362ad12 100644
--- a/engines/hdb/lua-script.h
+++ b/engines/hdb/lua-script.h
@@ -52,7 +52,7 @@ public:
 	void save(Common::OutSaveFile *out);
 	void loadSaveFile(Common::InSaveFile *in);
 
-	bool init();
+	void init();
 	bool initScript(Common::SeekableReadStream *stream, const char *scriptName, int32 length);
 
 	void pushInt(int value);
diff --git a/engines/hdb/sound.cpp b/engines/hdb/sound.cpp
index 28cee43..bcfcaac 100644
--- a/engines/hdb/sound.cpp
+++ b/engines/hdb/sound.cpp
@@ -1418,7 +1418,7 @@ void Sound::test() {
 	#endif
 }
 
-bool Sound::init() {
+void Sound::init() {
 	_song1.playing = _song2.playing = false;
 
 	//
@@ -1448,8 +1448,6 @@ bool Sound::init() {
 	// voices are on by default
 	_voicesOn = 1;
 	memset(&_voicePlayed[0], 0, sizeof(_voicePlayed));
-
-	return true;
 }
 
 void Sound::save(Common::OutSaveFile *out) {
diff --git a/engines/hdb/sound.h b/engines/hdb/sound.h
index bbc4174..b4661e4 100644
--- a/engines/hdb/sound.h
+++ b/engines/hdb/sound.h
@@ -1487,7 +1487,7 @@ public:
 
 	void test(); // FIXME. Remove
 
-	bool init();
+	void init();
 	void save(Common::OutSaveFile *out);
 	void loadSaveFile(Common::InSaveFile *in);
 	void setMusicVolume(int value);
diff --git a/engines/hdb/window.cpp b/engines/hdb/window.cpp
index 853f4e6..d10ccac 100644
--- a/engines/hdb/window.cpp
+++ b/engines/hdb/window.cpp
@@ -131,8 +131,7 @@ Window::~Window() {
 	delete _gemGfx;
 }
 
-bool Window::init() {
-
+void Window::init() {
 	_gfxTL = g_hdb->_gfx->loadPic(MENU_BACK_TOPLEFT);
 	_gfxTM = g_hdb->_gfx->loadPic(MENU_BACK_TOP);
 	_gfxTR = g_hdb->_gfx->loadPic(MENU_BACK_TOPRIGHT);
@@ -207,8 +206,6 @@ bool Window::init() {
 	_gemGfx = NULL;
 
 	restartSystem();
-
-	return true;
 }
 
 void Window::save(Common::OutSaveFile *out) {
diff --git a/engines/hdb/window.h b/engines/hdb/window.h
index b511ba3..d6b8384 100644
--- a/engines/hdb/window.h
+++ b/engines/hdb/window.h
@@ -171,7 +171,7 @@ public:
 	Window();
 	~Window();
 
-	bool init();
+	void init();
 	void save(Common::OutSaveFile *out);
 	void loadSaveFile(Common::InSaveFile *in);
 	void restartSystem();


Commit: 6500e81aab92124264caa5f4e15f0e3792762ca7
    https://github.com/scummvm/scummvm/commit/6500e81aab92124264caa5f4e15f0e3792762ca7
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:34+02:00

Commit Message:
HDB: Remove redundant STUBs

Changed paths:
    engines/hdb/menu.cpp


diff --git a/engines/hdb/menu.cpp b/engines/hdb/menu.cpp
index 3dc7d2f..c11821c 100644
--- a/engines/hdb/menu.cpp
+++ b/engines/hdb/menu.cpp
@@ -310,8 +310,6 @@ bool Menu::init() {
 }
 
 void Menu::readConfig() {
-	warning("STUB: readConfig: Music Config not implemented");
-
 	if (ConfMan.hasKey(CONFIG_MSTONE7)) {
 		g_hdb->setStarsMonkeystone7(ConfMan.getInt(CONFIG_MSTONE7));
 	} else {
@@ -374,8 +372,6 @@ void Menu::readConfig() {
 }
 
 void Menu::writeConfig() {
-	warning("STUB: writeConfig: Music Config not implemented");
-
 	int value;
 
 	value = g_hdb->getStarsMonkeystone7();


Commit: f934e0d094baedc3da39aaefbeb95e47241d30a1
    https://github.com/scummvm/scummvm/commit/f934e0d094baedc3da39aaefbeb95e47241d30a1
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:34+02:00

Commit Message:
HDB: Replace cursor in PPC version with the one from Win version

Changed paths:
    engines/hdb/gfx.cpp


diff --git a/engines/hdb/gfx.cpp b/engines/hdb/gfx.cpp
index 635157f..894a35f 100644
--- a/engines/hdb/gfx.cpp
+++ b/engines/hdb/gfx.cpp
@@ -85,16 +85,68 @@ Gfx::~Gfx() {
 	delete _skyClouds;
 }
 
+static const byte cursorPalette[16 * 3] = {
+	0x00, 0x01, 0x00,
+	0x09, 0x4E, 0xA2,
+	0x42, 0x3D, 0xBE,
+	0xFF, 0x00, 0xFD,
+	0x00, 0x57, 0xB8,
+	0x0C, 0x66, 0xCB,
+	0x0D, 0x65, 0xED,
+	0x01, 0x6A, 0xDE,
+	0x34, 0x59, 0xF1,
+	0x26, 0x5E, 0xEE,
+	0x00, 0x77, 0xFA,
+	0x23, 0x87, 0xFE,
+	0x47, 0x94, 0xFA,
+	0x69, 0xAF, 0xFC,
+	0x9F, 0xCD, 0xFE,
+	0xDE, 0xEE, 0xFD
+};
+
+static const byte cursorData[] = {
+ 3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,
+ 3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,
+ 3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,
+ 3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  0,  0,  0,  0,  0,  0,  0,  0,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,
+ 3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  0,  0, 11, 11, 11, 10, 10, 10, 10,  6,  0,  0,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,
+ 3,  3,  3,  3,  3,  3,  3,  3,  3,  0, 13, 13, 12, 12, 11, 10, 10, 10, 10, 10, 10,  8,  0,  3,  3,  3,  3,  3,  3,  3,  3,  3,
+ 3,  3,  3,  3,  3,  3,  3,  3,  0, 14, 13, 13, 13, 12, 11,  7,  7, 10, 10, 10, 10, 10,  6,  0,  3,  3,  3,  3,  3,  3,  3,  3,
+ 3,  3,  3,  3,  3,  3,  3,  0, 14, 14, 14, 13, 12,  0,  0,  0,  0,  0,  0,  7, 10, 10, 10, 10,  0,  3,  3,  3,  3,  3,  3,  3,
+ 3,  3,  3,  3,  3,  3,  0, 14, 15, 14, 13,  0,  0,  3,  3,  3,  3,  3,  3,  0,  0,  7, 10, 10,  6,  0,  3,  3,  3,  3,  3,  3,
+ 3,  3,  3,  3,  3,  0, 13, 14, 14, 13,  0,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  0,  7,  7,  7,  8,  0,  3,  3,  3,  3,  3,
+ 3,  3,  3,  3,  3,  0, 13, 14, 13,  0,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  0,  7,  7,  7,  0,  3,  3,  3,  3,  3,
+ 3,  3,  3,  3,  0, 12, 13, 13,  5,  0,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  0,  7,  7,  7,  8,  0,  3,  3,  3,  3,
+ 3,  3,  3,  3,  0, 12, 13, 13,  0,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  0,  7,  5,  6,  0,  3,  3,  3,  3,
+ 3,  3,  3,  3,  0, 12, 12, 12,  0,  3,  3,  3,  3,  3,  3,  0,  0,  3,  3,  3,  3,  3,  3,  0,  5,  5,  5,  0,  3,  3,  3,  3,
+ 3,  3,  3,  3,  0, 11, 11,  5,  0,  3,  3,  3,  3,  3,  0, 15, 15,  0,  3,  3,  3,  3,  3,  0,  5,  4,  4,  0,  3,  3,  3,  3,
+ 3,  3,  3,  3,  0, 10, 11,  5,  0,  3,  3,  3,  3,  0, 15, 15, 13, 13,  0,  3,  3,  3,  3,  0,  7,  4,  4,  0,  3,  3,  3,  3,
+ 3,  3,  3,  3,  0, 10, 11,  5,  0,  3,  3,  3,  3,  0, 15, 13, 13,  7,  0,  3,  3,  3,  3,  0,  7,  4,  4,  0,  3,  3,  3,  3,
+ 3,  3,  3,  3,  0, 10, 10,  7,  0,  3,  3,  3,  3,  3,  0, 13,  7,  0,  3,  3,  3,  3,  3,  0,  5,  4,  4,  0,  3,  3,  3,  3,
+ 3,  3,  3,  3,  0, 10, 10,  7,  0,  3,  3,  3,  3,  3,  3,  0,  0,  3,  3,  3,  3,  3,  3,  0,  4,  4,  4,  0,  3,  3,  3,  3,
+ 3,  3,  3,  3,  0, 10, 10, 10,  0,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  0,  4,  4,  4,  0,  3,  3,  3,  3,
+ 3,  3,  3,  3,  0,  9, 10, 10,  7,  0,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  0,  5,  1,  1,  2,  0,  3,  3,  3,  3,
+ 3,  3,  3,  3,  3,  0, 10, 10, 10,  0,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  0,  1,  1,  1,  0,  3,  3,  3,  3,  3,
+ 3,  3,  3,  3,  3,  0,  8, 10, 10,  7,  0,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  0,  1,  1,  1,  2,  0,  3,  3,  3,  3,  3,
+ 3,  3,  3,  3,  3,  3,  0,  6, 10,  7,  7,  0,  0,  3,  3,  3,  3,  3,  3,  0,  0,  1,  1,  1,  4,  0,  3,  3,  3,  3,  3,  3,
+ 3,  3,  3,  3,  3,  3,  3,  0, 10,  7,  7,  7,  7,  0,  0,  0,  0,  0,  0,  5,  1,  1,  1,  1,  0,  3,  3,  3,  3,  3,  3,  3,
+ 3,  3,  3,  3,  3,  3,  3,  3,  0,  6,  7,  7,  7,  5,  5,  4,  4,  4,  4,  1,  1,  1,  4,  0,  3,  3,  3,  3,  3,  3,  3,  3,
+ 3,  3,  3,  3,  3,  3,  3,  3,  3,  0,  9,  7,  5,  5,  4,  4,  4,  4,  4,  1,  1,  2,  0,  3,  3,  3,  3,  3,  3,  3,  3,  3,
+ 3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  0,  0,  9,  7,  4,  4,  4,  4,  4,  2,  0,  0,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,
+ 3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  0,  0,  0,  0,  0,  0,  0,  0,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,
+ 3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,
+ 3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,
+ 3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3
+};
+
+
 void Gfx::init() {
 	// Set the default cursor pos & char clipping
 	setCursor(0, 0);
 
 	if (g_hdb->isPPC()) {
-		Graphics::Cursor *cursor = Graphics::makeDefaultWinCursor();
-
-		CursorMan.replaceCursor(cursor->getSurface(), cursor->getWidth(), cursor->getHeight(), cursor->getHotspotX(), cursor->getHotspotY(), cursor->getKeyColor());
-		CursorMan.replaceCursorPalette(cursor->getPalette(), cursor->getPaletteStartIndex(), cursor->getPaletteCount());
-		delete cursor;
+		CursorMan.replaceCursorPalette(cursorPalette, 0, 16);
+		CursorMan.replaceCursor(cursorData, 32, 32, 16, 16, 3);
 	}
 
 	_eLeft = 0;


Commit: 1e25bf5fbe79e025a59fe6ad902c8c21546f524b
    https://github.com/scummvm/scummvm/commit/1e25bf5fbe79e025a59fe6ad902c8c21546f524b
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:34+02:00

Commit Message:
HDB: Re-add updateFade() debug output

Changed paths:
    engines/hdb/gfx.cpp


diff --git a/engines/hdb/gfx.cpp b/engines/hdb/gfx.cpp
index 894a35f..83061ac 100644
--- a/engines/hdb/gfx.cpp
+++ b/engines/hdb/gfx.cpp
@@ -386,6 +386,9 @@ void Gfx::updateFade() {
 	if (!_fadeInfo.active && !_fadeInfo.stayFaded)
 		return;
 
+	debug(7, "updateFade: active: %d stayFaded: %d isBlack: %d speed: %d isFadeIn: %d curStep: %d",
+		_fadeInfo.active, _fadeInfo.stayFaded, _fadeInfo.isBlack, _fadeInfo.speed, _fadeInfo.isFadeIn, _fadeInfo.curStep);
+
 	if (g_hdb->isPPC()) {
 		if (!_fadeInfo.isBlack) {
 			// Black fade


Commit: 0ca9c2fbccab01e06f9fa637a50dfae8b34599b7
    https://github.com/scummvm/scummvm/commit/0ca9c2fbccab01e06f9fa637a50dfae8b34599b7
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:34+02:00

Commit Message:
HDB: Remove unnecessary warnings

Changed paths:
    engines/hdb/ai-bots.cpp
    engines/hdb/ai-cinematic.cpp
    engines/hdb/ai-funcs.cpp
    engines/hdb/ai-lists.cpp
    engines/hdb/ai-player.cpp


diff --git a/engines/hdb/ai-bots.cpp b/engines/hdb/ai-bots.cpp
index 8e06e94..33a15c0 100644
--- a/engines/hdb/ai-bots.cpp
+++ b/engines/hdb/ai-bots.cpp
@@ -114,7 +114,6 @@ void aiOmniBotAction(AIEntity *e) {
 					}
 					break;
 				case DIR_NONE:
-					warning("aiOmniBotAction: DIR_NONE found");
 					break;
 				}
 
@@ -450,7 +449,7 @@ void aiRightBotFindGoal(AIEntity *e) {
 				case DIR_LEFT: e->dir = DIR_UP; break;
 				case DIR_RIGHT: e->dir = DIR_DOWN; break;
 				case DIR_NONE:
-					warning("aiRightBotFindGoal: DIR_NONE found");
+					break;
 				}
 			} else if (!bg && !e1) {
 				switch (e->dir) {
@@ -459,7 +458,7 @@ void aiRightBotFindGoal(AIEntity *e) {
 				case DIR_LEFT: e->dir = DIR_DOWN; break;
 				case DIR_RIGHT: e->dir = DIR_UP; break;
 				case DIR_NONE:
-					warning("aiRightBotFindGoal: DIR_NONE found");
+					break;
 				}
 			} else {
 				switch (e->dir) {
@@ -484,7 +483,7 @@ void aiRightBotFindGoal(AIEntity *e) {
 					xv = -1;
 					break;
 				case DIR_NONE:
-					warning("aiRightBotFindGoal: DIR_NONE found");
+					break;
 				}
 				sx += xv;
 				sy += yv;
@@ -507,7 +506,6 @@ void aiRightBotFindGoal(AIEntity *e) {
 		e->state = STATE_MOVERIGHT;
 		break;
 	case DIR_NONE:
-		warning("aiRightBotFindGoal: DIR_NONE found");
 		break;
 	}
 
@@ -692,7 +690,6 @@ void aiRailRiderAction(AIEntity *e) {
 			case DIR_LEFT:	e->xVel = -1;	e->yVel = 0;	break;
 			case DIR_RIGHT:	e->xVel = 1;	e->yVel = 0;	break;
 			case DIR_NONE:
-				warning("aiRailRiderAction: DIR_NONE found");
 				break;
 			}
 		}
@@ -824,7 +821,6 @@ void aiRailRiderOnAction(AIEntity *e) {
 							g_hdb->_ai->setEntityGoal(p, e->tileX, e->tileY + 1);
 						break;
 					case DIR_NONE:
-						warning("aiRailRiderOnAction: DIR_NOW found");
 						break;
 					}
 					g_hdb->_ai->setPlayerInvisible(false);
@@ -1135,7 +1131,6 @@ void aiFourFirerAction(AIEntity *e) {
 		}
 		break;
 	case DIR_NONE:
-		warning("aiFourFirerAction: DIR_NONE found");
 		break;
 	}
 
@@ -1246,7 +1241,6 @@ void aiDeadEyeAction(AIEntity *e) {
 					nuts = true;
 				break;
 			case DIR_NONE:
-				warning("aiDeadEyeAction: DIR_NONE found");
 				break;
 			}
 
diff --git a/engines/hdb/ai-cinematic.cpp b/engines/hdb/ai-cinematic.cpp
index d2ce89a..5678ad4 100644
--- a/engines/hdb/ai-cinematic.cpp
+++ b/engines/hdb/ai-cinematic.cpp
@@ -281,7 +281,7 @@ void AI::processCines() {
 						e->state = STATE_STANDRIGHT;
 						break;
 					default:
-						warning("AI-CINEMATIC: processCines: DIR_NONE");
+						break;
 					}
 				} else
 					warning("Can't find %s to ENTITYFACE", _cine[i]->title);
diff --git a/engines/hdb/ai-funcs.cpp b/engines/hdb/ai-funcs.cpp
index 137df1c..7b2f148 100644
--- a/engines/hdb/ai-funcs.cpp
+++ b/engines/hdb/ai-funcs.cpp
@@ -1842,7 +1842,6 @@ void AI::animGrabbing() {
 		_player->draw = _getGfx[DIR_RIGHT];
 		break;
 	default:
-		warning("AI-FUNCS: animGrabbing: DIR_NONE found");
 		break;
 	}
 
@@ -1951,7 +1950,6 @@ bool AI::findPath(AIEntity *e) {
 		xv = 1;
 		break;
 	case DIR_NONE:
-		warning("findPath: DIR_NONE found");
 		break;
 	}
 
@@ -2294,7 +2292,7 @@ void AI::lookAtXY(int x, int y) {
 		_player->draw = _getGfx[DIR_RIGHT];
 		break;
 	default:
-		warning("AI-FUNCS: lookAtXY: DIR_NONE");
+		break;
 	}
 }
 
diff --git a/engines/hdb/ai-lists.cpp b/engines/hdb/ai-lists.cpp
index 638d351..fd6a0fd 100644
--- a/engines/hdb/ai-lists.cpp
+++ b/engines/hdb/ai-lists.cpp
@@ -748,7 +748,6 @@ bool AI::checkTeleportList(AIEntity *e, int x, int y) {
 				setEntityGoal(e, e->tileX + 1, e->tileY);
 				break;
 			case DIR_NONE:
-				warning("checkTeleporterList: DIR_NONE found");
 				break;
 			}
 
diff --git a/engines/hdb/ai-player.cpp b/engines/hdb/ai-player.cpp
index b93133f..46d9dfc 100644
--- a/engines/hdb/ai-player.cpp
+++ b/engines/hdb/ai-player.cpp
@@ -55,7 +55,6 @@ void aiPlayerInit(AIEntity *e) {
 		e->state = STATE_STANDRIGHT;
 		break;
 	case DIR_NONE:
-		warning("AI-PLAYER: aiPlayerInit: DIR_NONE found");
 		break;
 	}
 
@@ -435,7 +434,6 @@ void aiPlayerDraw(AIEntity *e, int mx, int my) {
 		g_hdb->_ai->_clubRightGfx[e->animFrame]->drawMasked(e->x + e->drawXOff - mx, e->y + e->drawYOff - my);
 		break;
 	default:
-		warning("AI-PLAYER: aiPlayerDraw: Unintended State");
 		break;
 	}
 
@@ -459,7 +457,6 @@ void aiPlayerDraw(AIEntity *e, int mx, int my) {
 			g_hdb->_ai->_stunLightningGfx[frame]->drawMasked(e->x + 64 - mx, e->y - my);
 			break;
 		case DIR_NONE:
-			warning("AI-PLAYER: aiPlayerDraw: DIR_NONE found");
 			break;
 		}
 


Commit: 429bb7af4d4f333cf7304fa27b8bec05c8cfaa04
    https://github.com/scummvm/scummvm/commit/429bb7af4d4f333cf7304fa27b8bec05c8cfaa04
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:34+02:00

Commit Message:
HDB: Fix Sound caching to prevent Vorbis crash

Changed paths:
    engines/hdb/sound.cpp
    engines/hdb/sound.h


diff --git a/engines/hdb/sound.cpp b/engines/hdb/sound.cpp
index bcfcaac..d1dc45b 100644
--- a/engines/hdb/sound.cpp
+++ b/engines/hdb/sound.cpp
@@ -1489,33 +1489,16 @@ void Sound::playSound(int index) {
 	// is sound marked as cached?
 	if (_soundCache[index].loaded == SNDMEM_NOTCACHED) {
 
-		Common::SeekableReadStream *stream = nullptr;
 		if (g_hdb->getPlatform() == Common::kPlatformLinux) {
 			Common::String updatedName(_soundCache[index].name);
 			updatedName.replace(updatedName.begin() + updatedName.size() - 4, updatedName.end(), "_OGG");
-			stream = g_hdb->_fileMan->findFirstData(updatedName.c_str(), TYPE_BINARY);
+			_soundCache[index].data = g_hdb->_fileMan->findFirstData(updatedName.c_str(), TYPE_BINARY);
 		} else
-			stream = g_hdb->_fileMan->findFirstData(_soundCache[index].name, TYPE_BINARY);
+			_soundCache[index].data = g_hdb->_fileMan->findFirstData(_soundCache[index].name, TYPE_BINARY);
 
-		if (stream == nullptr)
-			return;
-
-		if (_soundCache[index].ext == SNDTYPE_MP3) {
-#ifdef USE_MAD
-			_soundCache[index].audioStream = Audio::makeMP3Stream(stream, DisposeAfterUse::YES);
-			_soundCache[index].loaded = SNDMEM_LOADED;
-#endif // USE_MAD
-		} else if (_soundCache[index].ext == SNDTYPE_OGG) {
-#ifdef USE_VORBIS
-			_soundCache[index].audioStream = Audio::makeVorbisStream(stream, DisposeAfterUse::YES);
-			_soundCache[index].loaded = SNDMEM_LOADED;
-#endif // USE_VORBIS
-		} else {
-			_soundCache[index].audioStream = Audio::makeWAVStream(stream, DisposeAfterUse::YES);
-			_soundCache[index].loaded = SNDMEM_LOADED;
-		}
+		_soundCache[index].loaded = SNDMEM_LOADED;
 	} else {
-		_soundCache[index].audioStream->rewind();
+		_soundCache[index].data->seek(0);
 	}
 
 	int soundChannel = 0;
@@ -1534,10 +1517,27 @@ void Sound::playSound(int index) {
 
 	g_hdb->_mixer->setChannelVolume(_handles[soundChannel], _sfxVolume);
 
+	if (_soundCache[index].data == nullptr)
+		return;
+
+	Audio::SeekableAudioStream *audioStream = nullptr;
+
+	if (_soundCache[index].ext == SNDTYPE_MP3) {
+#ifdef USE_MAD
+		audioStream = Audio::makeMP3Stream(_soundCache[index].data, DisposeAfterUse::NO);
+#endif // USE_MAD
+	} else if (_soundCache[index].ext == SNDTYPE_OGG) {
+#ifdef USE_VORBIS
+		audioStream = Audio::makeVorbisStream(_soundCache[index].data, DisposeAfterUse::NO);
+#endif // USE_VORBIS
+	} else {
+		audioStream = Audio::makeWAVStream(_soundCache[index].data, DisposeAfterUse::NO);
+	}
+
 	g_hdb->_mixer->playStream(
 		Audio::Mixer::kSFXSoundType,
 		&_handles[soundChannel],
-		_soundCache[index].audioStream,
+		audioStream,
 		-1,
 		Audio::Mixer::kMaxChannelVolume,
 		0,
@@ -1561,39 +1561,40 @@ void Sound::playSoundEx(int index, int channel, bool loop) {
 	// is sound marked as cached?
 	if (_soundCache[index].loaded == SNDMEM_NOTCACHED) {
 
-		Common::SeekableReadStream *stream = nullptr;
 		if (g_hdb->getPlatform() == Common::kPlatformLinux) {
 			Common::String updatedName(_soundCache[index].name);
 			updatedName.replace(updatedName.begin() + updatedName.size() - 4, updatedName.end(), "_OGG");
-			stream = g_hdb->_fileMan->findFirstData(updatedName.c_str(), TYPE_BINARY);
+			_soundCache[index].data = g_hdb->_fileMan->findFirstData(updatedName.c_str(), TYPE_BINARY);
 		} else
-			stream = g_hdb->_fileMan->findFirstData(_soundCache[index].name, TYPE_BINARY);
+			_soundCache[index].data = g_hdb->_fileMan->findFirstData(_soundCache[index].name, TYPE_BINARY);
 
-		if (stream == nullptr)
-			return;
+		_soundCache[index].loaded = SNDMEM_LOADED;
+	} else {
+		_soundCache[index].data->seek(0);
+	}
+
+	g_hdb->_mixer->setChannelVolume(_handles[channel], _sfxVolume);
 
-		if (_soundCache[index].ext == SNDTYPE_MP3) {
+
+	if (_soundCache[index].data == nullptr)
+		return;
+
+	Audio::SeekableAudioStream *audioStream = nullptr;
+
+	if (_soundCache[index].ext == SNDTYPE_MP3) {
 #ifdef USE_MAD
-			_soundCache[index].audioStream = Audio::makeMP3Stream(stream, DisposeAfterUse::YES);
-			_soundCache[index].loaded = SNDMEM_LOADED;
+		audioStream = Audio::makeMP3Stream(_soundCache[index].data, DisposeAfterUse::NO);
 #endif // USE_MAD
-		} else if (_soundCache[index].ext == SNDTYPE_OGG) {
+	} else if (_soundCache[index].ext == SNDTYPE_OGG) {
 #ifdef USE_VORBIS
-			_soundCache[index].audioStream = Audio::makeVorbisStream(stream, DisposeAfterUse::YES);
-			_soundCache[index].loaded = SNDMEM_LOADED;
+		audioStream = Audio::makeVorbisStream(_soundCache[index].data, DisposeAfterUse::NO);
 #endif // USE_VORBIS
-		} else {
-			_soundCache[index].audioStream = Audio::makeWAVStream(stream, DisposeAfterUse::YES);
-			_soundCache[index].loaded = SNDMEM_LOADED;
-		}
 	} else {
-		_soundCache[index].audioStream->rewind();
+		audioStream = Audio::makeWAVStream(_soundCache[index].data, DisposeAfterUse::NO);
 	}
 
-	g_hdb->_mixer->setChannelVolume(_handles[channel], _sfxVolume);
-
 	if (loop) {
-		Audio::AudioStream *loopingStream = new Audio::LoopingAudioStream(_soundCache[index].audioStream, 0, DisposeAfterUse::YES);
+		Audio::AudioStream *loopingStream = new Audio::LoopingAudioStream(audioStream, 0, DisposeAfterUse::YES);
 		g_hdb->_mixer->playStream(
 			Audio::Mixer::kSFXSoundType,
 			&_handles[channel],
@@ -1609,7 +1610,7 @@ void Sound::playSoundEx(int index, int channel, bool loop) {
 		g_hdb->_mixer->playStream(
 			Audio::Mixer::kSFXSoundType,
 			&_handles[channel],
-			_soundCache[index].audioStream,
+			audioStream,
 			-1,
 			Audio::Mixer::kMaxChannelVolume,
 			0,
diff --git a/engines/hdb/sound.h b/engines/hdb/sound.h
index b4661e4..e5c3e5f 100644
--- a/engines/hdb/sound.h
+++ b/engines/hdb/sound.h
@@ -1454,9 +1454,9 @@ struct SoundCache {
 	const char *name;				// filename / MSD name
 	const char *luaName;			// name used by Lua for i.d.
 	SndType ext;				// 0 = Uninitialized, -1 = WAV, 1 = MP3
-	Audio::SeekableAudioStream *audioStream;
+	Common::SeekableReadStream *data;
 
-	SoundCache() : loaded(SNDMEM_NOTCACHED), size(0), name(nullptr), luaName(nullptr), ext(SNDTYPE_NONE), audioStream(nullptr) {}
+	SoundCache() : loaded(SNDMEM_NOTCACHED), size(0), name(nullptr), luaName(nullptr), ext(SNDTYPE_NONE), data(nullptr) {}
 };
 
 struct Song {


Commit: af8df1bd56324ef5d90d33b9574c494c30b3c1cc
    https://github.com/scummvm/scummvm/commit/af8df1bd56324ef5d90d33b9574c494c30b3c1cc
Author: Nipun Garg (nipun at nipungarg.me)
Date: 2019-09-03T17:17:34+02:00

Commit Message:
JANITORIAL: Remove unnecessary whitespace

Changed paths:
    engines/hdb/sound.h


diff --git a/engines/hdb/sound.h b/engines/hdb/sound.h
index e5c3e5f..6578faa 100644
--- a/engines/hdb/sound.h
+++ b/engines/hdb/sound.h
@@ -44,8 +44,8 @@
 #define SFNAME_DARKVIB		"vibracious_(Dark_Delivery_Mix).mp3"
 #define SFNAME_EXPER		"experimentatus_(extended).mp3"
 
-#define		FIRST_VOICE		V00_AIRLOCK_01
-#define		NUM_VOICES		( LAST_SOUND - FIRST_VOICE )
+#define	FIRST_VOICE		V00_AIRLOCK_01
+#define	NUM_VOICES		( LAST_SOUND - FIRST_VOICE )
 
 #include "audio/audiostream.h"
 #include "audio/mixer.h"


Commit: cf3c1f099759df4e6c6787949bffbd707bad328b
    https://github.com/scummvm/scummvm/commit/cf3c1f099759df4e6c6787949bffbd707bad328b
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:34+02:00

Commit Message:
HDB: Added optional length parameter for querying from FindFirstData

Changed paths:
    engines/hdb/file-manager.cpp
    engines/hdb/file-manager.h


diff --git a/engines/hdb/file-manager.cpp b/engines/hdb/file-manager.cpp
index e38d44f..bc75174 100644
--- a/engines/hdb/file-manager.cpp
+++ b/engines/hdb/file-manager.cpp
@@ -96,7 +96,7 @@ void FileMan::seek(int32 offset, int flag) {
 	_mpcFile->seek(offset, flag);
 }
 
-Common::SeekableReadStream *FileMan::findFirstData(const char *string, DataType type) {
+Common::SeekableReadStream *FileMan::findFirstData(const char *string, DataType type, int *length) {
 	Common::String fileString;
 	MPCEntry *file = NULL;
 
@@ -135,6 +135,9 @@ Common::SeekableReadStream *FileMan::findFirstData(const char *string, DataType
 
 	_mpcFile->read(buffer, file->length);
 
+	if (length)
+		*length = file->ulength;
+
 	// Return buffer wrapped in a MemoryReadStream, automatically
 	// uncompressed if it is zlib-compressed
 	return Common::wrapCompressedReadStream(new Common::MemoryReadStream(buffer, file->length, DisposeAfterUse::NO), file->length);
diff --git a/engines/hdb/file-manager.h b/engines/hdb/file-manager.h
index 62caaad..f3a65bb 100644
--- a/engines/hdb/file-manager.h
+++ b/engines/hdb/file-manager.h
@@ -72,7 +72,7 @@ public:
 	void closeMPC();
 	void seek(int32 offset, int flag);
 
-	Common::SeekableReadStream *findFirstData(const char *string, DataType type);
+	Common::SeekableReadStream *findFirstData(const char *string, DataType type, int *length = NULL);
 	int32 getLength(const char *string, DataType type);
 	int getCount(const char *subString, DataType type);
 	Common::Array<const char *> *findFiles(const char *string, DataType type);


Commit: 9907ebed0a81c0e8af377edac0f3c3653ffbe024
    https://github.com/scummvm/scummvm/commit/9907ebed0a81c0e8af377edac0f3c3653ffbe024
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:34+02:00

Commit Message:
HDB: Simplified sound loading code

Changed paths:
    engines/hdb/sound.cpp


diff --git a/engines/hdb/sound.cpp b/engines/hdb/sound.cpp
index d1dc45b..b2c3602 100644
--- a/engines/hdb/sound.cpp
+++ b/engines/hdb/sound.cpp
@@ -1488,14 +1488,12 @@ void Sound::playSound(int index) {
 
 	// is sound marked as cached?
 	if (_soundCache[index].loaded == SNDMEM_NOTCACHED) {
+		Common::String updatedName(_soundCache[index].name);
 
-		if (g_hdb->getPlatform() == Common::kPlatformLinux) {
-			Common::String updatedName(_soundCache[index].name);
+		if (g_hdb->getPlatform() == Common::kPlatformLinux)
 			updatedName.replace(updatedName.begin() + updatedName.size() - 4, updatedName.end(), "_OGG");
-			_soundCache[index].data = g_hdb->_fileMan->findFirstData(updatedName.c_str(), TYPE_BINARY);
-		} else
-			_soundCache[index].data = g_hdb->_fileMan->findFirstData(_soundCache[index].name, TYPE_BINARY);
 
+		_soundCache[index].data = g_hdb->_fileMan->findFirstData(updatedName.c_str(), TYPE_BINARY);
 		_soundCache[index].loaded = SNDMEM_LOADED;
 	} else {
 		_soundCache[index].data->seek(0);


Commit: d1ef6fc0082c76993fa6288f2564c845ae35a7b3
    https://github.com/scummvm/scummvm/commit/d1ef6fc0082c76993fa6288f2564c845ae35a7b3
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:34+02:00

Commit Message:
HDB: Cache sounds as data pointers. This fixes problem with distorted sounds

Changed paths:
    engines/hdb/sound.cpp
    engines/hdb/sound.h


diff --git a/engines/hdb/sound.cpp b/engines/hdb/sound.cpp
index b2c3602..2d260bf 100644
--- a/engines/hdb/sound.cpp
+++ b/engines/hdb/sound.cpp
@@ -23,6 +23,7 @@
 #include "common/debug.h"
 #include "common/file.h"
 #include "common/fs.h"
+#include "common/memstream.h"
 
 #include "hdb/hdb.h"
 #include "hdb/file-manager.h"
@@ -1493,10 +1494,12 @@ void Sound::playSound(int index) {
 		if (g_hdb->getPlatform() == Common::kPlatformLinux)
 			updatedName.replace(updatedName.begin() + updatedName.size() - 4, updatedName.end(), "_OGG");
 
-		_soundCache[index].data = g_hdb->_fileMan->findFirstData(updatedName.c_str(), TYPE_BINARY);
+		Common::SeekableReadStream *stream = g_hdb->_fileMan->findFirstData(updatedName.c_str(), TYPE_BINARY, &_soundCache[index].size);
+
+		_soundCache[index].data = (byte *)malloc(_soundCache[index].size);
+		stream->read(_soundCache[index].data, _soundCache[index].size);
+
 		_soundCache[index].loaded = SNDMEM_LOADED;
-	} else {
-		_soundCache[index].data->seek(0);
 	}
 
 	int soundChannel = 0;
@@ -1519,17 +1522,18 @@ void Sound::playSound(int index) {
 		return;
 
 	Audio::SeekableAudioStream *audioStream = nullptr;
+	Common::MemoryReadStream *stream = new Common::MemoryReadStream(_soundCache[index].data, _soundCache[index].size, DisposeAfterUse::NO);
 
 	if (_soundCache[index].ext == SNDTYPE_MP3) {
 #ifdef USE_MAD
-		audioStream = Audio::makeMP3Stream(_soundCache[index].data, DisposeAfterUse::NO);
+		audioStream = Audio::makeMP3Stream(stream, DisposeAfterUse::YES);
 #endif // USE_MAD
 	} else if (_soundCache[index].ext == SNDTYPE_OGG) {
 #ifdef USE_VORBIS
-		audioStream = Audio::makeVorbisStream(_soundCache[index].data, DisposeAfterUse::NO);
+		audioStream = Audio::makeVorbisStream(stream, DisposeAfterUse::YES);
 #endif // USE_VORBIS
 	} else {
-		audioStream = Audio::makeWAVStream(_soundCache[index].data, DisposeAfterUse::NO);
+		audioStream = Audio::makeWAVStream(stream, DisposeAfterUse::YES);
 	}
 
 	g_hdb->_mixer->playStream(
@@ -1558,17 +1562,16 @@ void Sound::playSoundEx(int index, int channel, bool loop) {
 
 	// is sound marked as cached?
 	if (_soundCache[index].loaded == SNDMEM_NOTCACHED) {
+		Common::String updatedName(_soundCache[index].name);
 
-		if (g_hdb->getPlatform() == Common::kPlatformLinux) {
-			Common::String updatedName(_soundCache[index].name);
+		if (g_hdb->getPlatform() == Common::kPlatformLinux)
 			updatedName.replace(updatedName.begin() + updatedName.size() - 4, updatedName.end(), "_OGG");
-			_soundCache[index].data = g_hdb->_fileMan->findFirstData(updatedName.c_str(), TYPE_BINARY);
-		} else
-			_soundCache[index].data = g_hdb->_fileMan->findFirstData(_soundCache[index].name, TYPE_BINARY);
 
+		Common::SeekableReadStream *stream = g_hdb->_fileMan->findFirstData(updatedName.c_str(), TYPE_BINARY, &_soundCache[index].size);
+
+		_soundCache[index].data = (byte *)malloc(_soundCache[index].size);
+		stream->read(_soundCache[index].data, _soundCache[index].size);
 		_soundCache[index].loaded = SNDMEM_LOADED;
-	} else {
-		_soundCache[index].data->seek(0);
 	}
 
 	g_hdb->_mixer->setChannelVolume(_handles[channel], _sfxVolume);
@@ -1578,17 +1581,18 @@ void Sound::playSoundEx(int index, int channel, bool loop) {
 		return;
 
 	Audio::SeekableAudioStream *audioStream = nullptr;
+	Common::MemoryReadStream *stream = new Common::MemoryReadStream(_soundCache[index].data, _soundCache[index].size, DisposeAfterUse::NO);
 
 	if (_soundCache[index].ext == SNDTYPE_MP3) {
 #ifdef USE_MAD
-		audioStream = Audio::makeMP3Stream(_soundCache[index].data, DisposeAfterUse::NO);
+		audioStream = Audio::makeMP3Stream(stream, DisposeAfterUse::YES);
 #endif // USE_MAD
 	} else if (_soundCache[index].ext == SNDTYPE_OGG) {
 #ifdef USE_VORBIS
-		audioStream = Audio::makeVorbisStream(_soundCache[index].data, DisposeAfterUse::NO);
+		audioStream = Audio::makeVorbisStream(stream, DisposeAfterUse::YES);
 #endif // USE_VORBIS
 	} else {
-		audioStream = Audio::makeWAVStream(_soundCache[index].data, DisposeAfterUse::NO);
+		audioStream = Audio::makeWAVStream(stream, DisposeAfterUse::YES);
 	}
 
 	if (loop) {
diff --git a/engines/hdb/sound.h b/engines/hdb/sound.h
index 6578faa..6797808 100644
--- a/engines/hdb/sound.h
+++ b/engines/hdb/sound.h
@@ -1454,7 +1454,7 @@ struct SoundCache {
 	const char *name;				// filename / MSD name
 	const char *luaName;			// name used by Lua for i.d.
 	SndType ext;				// 0 = Uninitialized, -1 = WAV, 1 = MP3
-	Common::SeekableReadStream *data;
+	byte *data;
 
 	SoundCache() : loaded(SNDMEM_NOTCACHED), size(0), name(nullptr), luaName(nullptr), ext(SNDTYPE_NONE), data(nullptr) {}
 };


Commit: 43f39b30de51ffc7d357322eac0f7b9b93a08498
    https://github.com/scummvm/scummvm/commit/43f39b30de51ffc7d357322eac0f7b9b93a08498
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:35+02:00

Commit Message:
HDB: FUrther simplification of sound code

Changed paths:
    engines/hdb/sound.cpp


diff --git a/engines/hdb/sound.cpp b/engines/hdb/sound.cpp
index 2d260bf..85e20f0 100644
--- a/engines/hdb/sound.cpp
+++ b/engines/hdb/sound.cpp
@@ -1636,13 +1636,11 @@ void Sound::playVoice(int index, int actor) {
 		return;
 
 	Common::SeekableReadStream *stream = nullptr;
-	if (g_hdb->getPlatform() == Common::kPlatformLinux) {
-		Common::String updatedName(soundList[index].name);
+	Common::String updatedName(soundList[index].name);
+	if (g_hdb->getPlatform() == Common::kPlatformLinux)
 		updatedName.replace(updatedName.begin() + updatedName.size() - 4, updatedName.end(), "_OGG");
-		stream = g_hdb->_fileMan->findFirstData(updatedName.c_str(), TYPE_BINARY);
-	} else
-		stream = g_hdb->_fileMan->findFirstData(soundList[index].name, TYPE_BINARY);
 
+	stream = g_hdb->_fileMan->findFirstData(updatedName.c_str(), TYPE_BINARY);
 	if (stream == nullptr)
 		return;
 


Commit: c3032f7742f48551eb1d00f771c56f2b03f0931d
    https://github.com/scummvm/scummvm/commit/c3032f7742f48551eb1d00f771c56f2b03f0931d
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:35+02:00

Commit Message:
HDB: Remove excess calls to stopVoices()

Changed paths:
    engines/hdb/hdb.cpp


diff --git a/engines/hdb/hdb.cpp b/engines/hdb/hdb.cpp
index b1fbb6f..1a8c811 100644
--- a/engines/hdb/hdb.cpp
+++ b/engines/hdb/hdb.cpp
@@ -200,7 +200,6 @@ void HDBGame::changeGameState() {
 		break;
 	case GAME_PLAY:
 		_menu->startMenu();
-		_sound->stopVoices();
 		_gameState = GAME_MENU;
 		break;
 	case GAME_LOADING:
@@ -1011,11 +1010,6 @@ Common::Error HDBGame::run() {
 			_map->drawForegrounds();
 			_ai->animateTargets();
 
-			// Check for voice to interrupt
-			if (!_window->dialogActive() && !_window->dialogChoiceActive() && !_window->msgBarActive()) {
-				_sound->stopVoices();
-			}
-
 			_window->drawDialog();
 			_window->drawDialogChoice();
 			_window->drawInventory();


Commit: 73b6724b929c78bdc4724b6648b03ed66a29bab7
    https://github.com/scummvm/scummvm/commit/73b6724b929c78bdc4724b6648b03ed66a29bab7
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:35+02:00

Commit Message:
HDB: Do not allocate sound handles dynamically

Changed paths:
    engines/hdb/sound.cpp
    engines/hdb/sound.h


diff --git a/engines/hdb/sound.cpp b/engines/hdb/sound.cpp
index 85e20f0..c1a7025 100644
--- a/engines/hdb/sound.cpp
+++ b/engines/hdb/sound.cpp
@@ -1469,13 +1469,13 @@ void Sound::setMusicVolume(int volume) {
 		if (_song1.fadingIn)
 			_song1.fadeInVol = volume;
 		if (!_song1.fadingOut)
-			g_hdb->_mixer->setChannelVolume(*_song1.handle, volume);
+			g_hdb->_mixer->setChannelVolume(_song1.handle, volume);
 	}
 	if (_song2.playing) {
 		if (_song2.fadingIn)
 			_song1.fadeInVol = volume;
 		if (!_song2.fadingOut)
-			g_hdb->_mixer->setChannelVolume(*_song2.handle, volume);
+			g_hdb->_mixer->setChannelVolume(_song2.handle, volume);
 	}
 }
 
@@ -1629,7 +1629,7 @@ void Sound::playVoice(int index, int actor) {
 
 	// is voice channel already active?  if so, shut 'er down (automagically called StopVoice via callback)
 	if (_voices[actor].active)
-		g_hdb->_mixer->stopHandle(*_voices[actor].handle);
+		g_hdb->_mixer->stopHandle(_voices[actor].handle);
 
 	// make sure we aren't playing a line more than once this time (only on CHANNEL 0)
 	if (!actor && _voicePlayed[index - FIRST_VOICE])
@@ -1652,11 +1652,11 @@ void Sound::playVoice(int index, int actor) {
 			return;
 		}
 
-		g_hdb->_mixer->setChannelVolume(*_voices[actor].handle, _sfxVolume);
+		g_hdb->_mixer->setChannelVolume(_voices[actor].handle, _sfxVolume);
 
 		g_hdb->_mixer->playStream(
 			Audio::Mixer::kSpeechSoundType,
-			_voices[actor].handle,
+			&_voices[actor].handle,
 			audioStream,
 			-1,
 			Audio::Mixer::kMaxChannelVolume,
@@ -1674,11 +1674,11 @@ void Sound::playVoice(int index, int actor) {
 			return;
 		}
 
-		g_hdb->_mixer->setChannelVolume(*_voices[actor].handle, _sfxVolume);
+		g_hdb->_mixer->setChannelVolume(_voices[actor].handle, _sfxVolume);
 
 		g_hdb->_mixer->playStream(
 			Audio::Mixer::kSpeechSoundType,
-			_voices[actor].handle,
+			&_voices[actor].handle,
 			audioStream,
 			-1,
 			Audio::Mixer::kMaxChannelVolume,
@@ -1744,11 +1744,11 @@ void Sound::stopChannel(int channel) {
 void Sound::stopMusic() {
 	if (_song1.playing) {
 		_song1.playing = false;
-		g_hdb->_mixer->stopHandle(*_song1.handle);
+		g_hdb->_mixer->stopHandle(_song1.handle);
 	}
 	if (_song2.playing) {
 		_song2.playing = false;
-		g_hdb->_mixer->stopHandle(*_song2.handle);
+		g_hdb->_mixer->stopHandle(_song2.handle);
 	}
 }
 
@@ -1797,19 +1797,19 @@ void Sound::beginMusic(SoundType song, bool fadeIn, int ramp) {
 			Audio::SeekableAudioStream *audioStream = Audio::makeMP3Stream(stream, DisposeAfterUse::YES);
 			Audio::AudioStream *loopingStream = new Audio::LoopingAudioStream(audioStream, 0, DisposeAfterUse::YES);
 
-			g_hdb->_mixer->setChannelVolume(*_song1.handle, _musicVolume);
+			g_hdb->_mixer->setChannelVolume(_song1.handle, _musicVolume);
 
 			// do we need to fade-in this song?
 			if (fadeIn) {
 				_song1.fadeInRamp = ramp;
 				_song1.fadingIn = true;
 				_song1.fadeInVol = 0;
-				g_hdb->_mixer->setChannelVolume(*_song1.handle, 0);
+				g_hdb->_mixer->setChannelVolume(_song1.handle, 0);
 			}
 
 			g_hdb->_mixer->playStream(
 				Audio::Mixer::kMusicSoundType,
-				_song1.handle,
+				&_song1.handle,
 				loopingStream,
 				-1,
 				Audio::Mixer::kMaxChannelVolume,
@@ -1825,19 +1825,19 @@ void Sound::beginMusic(SoundType song, bool fadeIn, int ramp) {
 			Audio::SeekableAudioStream *audioStream = Audio::makeVorbisStream(stream, DisposeAfterUse::YES);
 			Audio::AudioStream *loopingStream = new Audio::LoopingAudioStream(audioStream, 0, DisposeAfterUse::YES);
 
-			g_hdb->_mixer->setChannelVolume(*_song1.handle, _musicVolume);
+			g_hdb->_mixer->setChannelVolume(_song1.handle, _musicVolume);
 
 			// do we need to fade-in this song?
 			if (fadeIn) {
 				_song1.fadeInRamp = ramp;
 				_song1.fadingIn = true;
 				_song1.fadeInVol = 0;
-				g_hdb->_mixer->setChannelVolume(*_song1.handle, 0);
+				g_hdb->_mixer->setChannelVolume(_song1.handle, 0);
 			}
 
 			g_hdb->_mixer->playStream(
 				Audio::Mixer::kMusicSoundType,
-				_song1.handle,
+				&_song1.handle,
 				loopingStream,
 				-1,
 				Audio::Mixer::kMaxChannelVolume,
@@ -1869,19 +1869,19 @@ void Sound::beginMusic(SoundType song, bool fadeIn, int ramp) {
 			Audio::SeekableAudioStream *audioStream = Audio::makeMP3Stream(stream, DisposeAfterUse::YES);
 			Audio::AudioStream *loopingStream = new Audio::LoopingAudioStream(audioStream, 0, DisposeAfterUse::YES);
 
-			g_hdb->_mixer->setChannelVolume(*_song2.handle, _musicVolume);
+			g_hdb->_mixer->setChannelVolume(_song2.handle, _musicVolume);
 
 			// do we need to fade-in this song?
 			if (fadeIn) {
 				_song2.fadeInRamp = ramp;
 				_song2.fadingIn = true;
 				_song2.fadeInVol = 0;
-				g_hdb->_mixer->setChannelVolume(*_song2.handle, 0);
+				g_hdb->_mixer->setChannelVolume(_song2.handle, 0);
 			}
 
 			g_hdb->_mixer->playStream(
 				Audio::Mixer::kMusicSoundType,
-				_song2.handle,
+				&_song2.handle,
 				loopingStream,
 				-1,
 				Audio::Mixer::kMaxChannelVolume,
@@ -1897,19 +1897,19 @@ void Sound::beginMusic(SoundType song, bool fadeIn, int ramp) {
 			Audio::SeekableAudioStream *audioStream = Audio::makeVorbisStream(stream, DisposeAfterUse::YES);
 			Audio::AudioStream *loopingStream = new Audio::LoopingAudioStream(audioStream, 0, DisposeAfterUse::YES);
 
-			g_hdb->_mixer->setChannelVolume(*_song2.handle, _musicVolume);
+			g_hdb->_mixer->setChannelVolume(_song2.handle, _musicVolume);
 
 			// do we need to fade-in this song?
 			if (fadeIn) {
 				_song2.fadeInRamp = ramp;
 				_song2.fadingIn = true;
 				_song2.fadeInVol = 0;
-				g_hdb->_mixer->setChannelVolume(*_song2.handle, 0);
+				g_hdb->_mixer->setChannelVolume(_song2.handle, 0);
 			}
 
 			g_hdb->_mixer->playStream(
 				Audio::Mixer::kMusicSoundType,
-				_song2.handle,
+				&_song2.handle,
 				loopingStream,
 				-1,
 				Audio::Mixer::kMaxChannelVolume,
@@ -1930,7 +1930,7 @@ void Sound::updateMusic() {
 		if (_song1.fadingOut) {
 			_song1.fadeOutVol = 0;
 			_song1.playing = false;
-			g_hdb->_mixer->stopHandle(*_song1.handle);
+			g_hdb->_mixer->stopHandle(_song1.handle);
 		} else if (_song1.fadingIn) {
 			_song1.fadeInVol = _musicVolume;
 			_song1.fadingIn = false;
@@ -1941,7 +1941,7 @@ void Sound::updateMusic() {
 		if (_song2.fadingOut) {
 			_song2.fadeOutVol = 0;
 			_song2.playing = false;
-			g_hdb->_mixer->stopHandle(*_song2.handle);
+			g_hdb->_mixer->stopHandle(_song2.handle);
 		} else if (_song2.fadingIn) {
 			_song2.fadeInVol = _musicVolume;
 			_song2.fadingIn = false;
diff --git a/engines/hdb/sound.h b/engines/hdb/sound.h
index 6797808..4d2e6ee 100644
--- a/engines/hdb/sound.h
+++ b/engines/hdb/sound.h
@@ -1427,12 +1427,9 @@ struct SoundLookUp {
 
 struct Voice {
 	bool active;
-	Audio::SoundHandle *handle;
+	Audio::SoundHandle handle;
 
-	Voice() : active(false), handle(new Audio::SoundHandle) {}
-	~Voice() {
-		delete handle;
-	}
+	Voice() : active(false) {}
 };
 
 enum SndMem {
@@ -1462,7 +1459,7 @@ struct SoundCache {
 struct Song {
 	bool playing;
 	SoundType song;
-	Audio::SoundHandle *handle;
+	Audio::SoundHandle handle;
 
 	bool fadingOut;
 	int fadeOutVol;
@@ -1472,12 +1469,9 @@ struct Song {
 	int	fadeInVol;
 	int	fadeInRamp;
 
-	Song() : playing(false), song(SONG_NONE), handle(new Audio::SoundHandle()),
+	Song() : playing(false), song(SONG_NONE),
 		fadingOut(false), fadeOutVol(0), fadeOutRamp(0),
 		fadingIn(false), fadeInVol(0), fadeInRamp(0) {}
-	~Song() {
-		delete handle;
-	}
 };
 
 class Sound {
@@ -1515,11 +1509,11 @@ public:
 	void playVoice(int index, int actor);
 	void stopVoices() {
 		if (_voices[0].active) {
-			g_hdb->_mixer->stopHandle(*_voices[0].handle);
+			g_hdb->_mixer->stopHandle(_voices[0].handle);
 			_voices[0].active = false;
 		}
 		if (_voices[1].active) {
-			g_hdb->_mixer->stopHandle(*_voices[1].handle);
+			g_hdb->_mixer->stopHandle(_voices[1].handle);
 			_voices[1].active = false;
 		}
 	}


Commit: 036ef5fdfd819cf3ddb1fef7e02575a97a8e2f53
    https://github.com/scummvm/scummvm/commit/036ef5fdfd819cf3ddb1fef7e02575a97a8e2f53
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:35+02:00

Commit Message:
HDB: Mark autosave slots with 'Auto:' in the GUI

Changed paths:
    engines/hdb/detection.cpp


diff --git a/engines/hdb/detection.cpp b/engines/hdb/detection.cpp
index 7da1e69..e0d1059 100644
--- a/engines/hdb/detection.cpp
+++ b/engines/hdb/detection.cpp
@@ -22,6 +22,7 @@
 
 #include "base/plugins.h"
 
+#include "common/debug.h"
 #include "common/translation.h"
 
 #include "engines/advancedDetector.h"
@@ -236,11 +237,15 @@ SaveStateList HDBMetaEngine::listSaves(const char *target) const {
 				uint32 timeSeconds = in->readUint32LE();;
 				in->read(mapName, 32);
 
-				warning("mapName: %s playtime: %d", mapName, timeSeconds);
+				debug(1, "mapName: %s playtime: %d", mapName, timeSeconds);
 
 				desc.setSaveSlot(slotNum);
 				desc.setPlayTime(timeSeconds * 1000);
-				desc.setDescription(mapName);
+
+				if (slotNum < 8)
+					desc.setDescription(Common::String::format("Auto: %s", mapName));
+				else
+					desc.setDescription(mapName);
 
 				saveList.push_back(desc);
 			}


Commit: 93f05fa32c1ad35b38441a52bc343fc2856af235
    https://github.com/scummvm/scummvm/commit/93f05fa32c1ad35b38441a52bc343fc2856af235
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:35+02:00

Commit Message:
HDB: Added debug info to entity loading

Changed paths:
    engines/hdb/map.cpp


diff --git a/engines/hdb/map.cpp b/engines/hdb/map.cpp
index e4acff3..aa8de26 100644
--- a/engines/hdb/map.cpp
+++ b/engines/hdb/map.cpp
@@ -624,6 +624,10 @@ bool Map::load(Common::SeekableReadStream *stream) {
 	// Scan all icons and init all Entities
 	g_hdb->setupProgressBar(_iconNum);
 	for (int i = 0; i < _iconNum; i++) {
+		debug(5, "%s, %d,%d,%s,%s,%s,%d,%d,%d,%d", AIType2Str(aiInfo[_iconList[i].icon].type), _iconList[i].x, _iconList[i].y, _iconList[i].funcInit,
+				_iconList[i].funcAction, _iconList[i].funcUse, _iconList[i].dir, _iconList[i].level,
+				_iconList[i].value1, _iconList[i].value2);
+
 		g_hdb->makeProgress();
 
 		// Don't spawn Action Mode Entities in Puzzle Mode


Commit: e5883e999b81a771d78c43fc69fe1249dfee0124
    https://github.com/scummvm/scummvm/commit/e5883e999b81a771d78c43fc69fe1249dfee0124
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:35+02:00

Commit Message:
HDB: Fix teleporter on MAP29 in PPC version.

It was fixed later in the Win version, as it was transferring
Guy to a wrong level.

Changed paths:
    engines/hdb/map.cpp


diff --git a/engines/hdb/map.cpp b/engines/hdb/map.cpp
index aa8de26..e309b57 100644
--- a/engines/hdb/map.cpp
+++ b/engines/hdb/map.cpp
@@ -748,6 +748,17 @@ bool Map::load(Common::SeekableReadStream *stream) {
 		case INFO_TELEPORTER18:
 		case INFO_TELEPORTER19:
 		case INFO_TELEPORTER20:
+
+			if (aiInfo[_iconList[i].icon].type == INFO_TELEPORTER8) {
+				if (g_hdb->isPPC() && !scumm_stricmp(g_hdb->currentMapName(), "MAP29.MSM")) {
+					if (_iconList[i].x == 45 && _iconList[i].y == 116) {
+						warning("PATCHED Teleporter8 in MAP29");
+
+						_iconList[i].level = 1;
+					}
+				}
+			}
+
 			g_hdb->_ai->addToTeleportList(
 				aiInfo[_iconList[i].icon].type - INFO_TELEPORTER1,
 				_iconList[i].x,


Commit: 4d186571d543a9e52afc62920ac00b7ebe5a35bd
    https://github.com/scummvm/scummvm/commit/4d186571d543a9e52afc62920ac00b7ebe5a35bd
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:35+02:00

Commit Message:
HDB: Fix closed loops with laser beams

Nipun was able to construct such position in Map28 which led to a closed
loop and the game hung.

We're inserting a watchdog here now.

Changed paths:
    engines/hdb/ai-bots.cpp


diff --git a/engines/hdb/ai-bots.cpp b/engines/hdb/ai-bots.cpp
index 33a15c0..ac4b241 100644
--- a/engines/hdb/ai-bots.cpp
+++ b/engines/hdb/ai-bots.cpp
@@ -1407,6 +1407,8 @@ void aiLaserAction(AIEntity *e) {
 
 	AIEntity *hit = e;
 	int moveOK = 0;
+	int moveCount = 0;
+
 	do {
 		int nx = hit->tileX;
 		int ny = hit->tileY;
@@ -1541,6 +1543,13 @@ void aiLaserAction(AIEntity *e) {
 					hit = NULL;
 			}
 		}
+
+		moveCount++;
+
+		// It is possible to set a configuration which leads to a closed loop.
+		// Thus, we're breaking it here
+		if (moveCount > 1000)
+			hit = NULL;
 	} while (hit && hit->type == AI_DIVERTER);
 }
 


Commit: 83d3af60091263d78df05121d67c8945fca76a5a
    https://github.com/scummvm/scummvm/commit/83d3af60091263d78df05121d67c8945fca76a5a
Author: Strangerke (strangerke at scummvm.org)
Date: 2019-09-03T17:17:35+02:00

Commit Message:
HDB: Make the frame delay variable in order to have a more stable frame rate

Changed paths:
    engines/hdb/hdb.cpp


diff --git a/engines/hdb/hdb.cpp b/engines/hdb/hdb.cpp
index 1a8c811..62e2ec8 100644
--- a/engines/hdb/hdb.cpp
+++ b/engines/hdb/hdb.cpp
@@ -803,14 +803,12 @@ void HDBGame::drawProgressBar() {
 }
 
 void HDBGame::checkProgress() {
-	int x, i;
-
 	if (!_progressActive)
 		return;
 
-	x = _screenWidth / 2 - _progressGfx->_width / 2;
+	int x = _screenWidth / 2 - _progressGfx->_width / 2;
 	_progressGfx->drawMasked(x, g_hdb->_progressY);
-	for (i = x; i < _progressXOffset; i += _progressMarkGfx->_width)
+	for (int i = x; i < _progressXOffset; i += _progressMarkGfx->_width)
 		_progressMarkGfx->drawMasked(i, g_hdb->_progressY);
 	_progressMarkGfx->drawMasked(_progressXOffset, g_hdb->_progressY);
 }
@@ -943,6 +941,7 @@ Common::Error HDBGame::run() {
 	lua->executeFile("test.lua");
 #endif
 
+	uint32 lastTime = g_system->getMillis();
 	while (!shouldQuit()) {
 		Common::Event event;
 		while (g_system->getEventManager()->pollEvent(event)) {
@@ -1053,7 +1052,15 @@ Common::Error HDBGame::run() {
 			while (g_hdb->_frames[0] < g_system->getMillis() - 1000)
 				g_hdb->_frames.remove_at(0);
 		}
-		g_system->delayMillis(1000 / kGameFPS);
+		uint32 curTime = g_system->getMillis();
+		uint32 frameTime = curTime - lastTime;
+
+		uint32 frameCap = 1000 / kGameFPS;
+		if (frameTime < frameCap) {
+			g_system->delayMillis(frameCap - frameTime);
+		}
+
+		lastTime = g_system->getMillis();
 	}
 
 	return Common::kNoError;


Commit: 36c2b15ab92ba84e4de0353b2622272606491684
    https://github.com/scummvm/scummvm/commit/36c2b15ab92ba84e4de0353b2622272606491684
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:35+02:00

Commit Message:
HDB: Fix out-of-bound access when on the edge of map

Changed paths:
    engines/hdb/map.cpp


diff --git a/engines/hdb/map.cpp b/engines/hdb/map.cpp
index e309b57..9f62fb8 100644
--- a/engines/hdb/map.cpp
+++ b/engines/hdb/map.cpp
@@ -868,10 +868,14 @@ void Map::draw() {
 	int maxTileX = (_mapTileXOff >= -8) ? g_hdb->_map->_screenXTiles - 1 : g_hdb->_map->_screenXTiles;
 	int maxTileY = (!_mapTileYOff) ? g_hdb->_map->_screenYTiles - 1 : g_hdb->_map->_screenYTiles;
 
-	if (matrixY + (maxTileY - 1)*_width > _height * _width) {
+	if (matrixY + (maxTileY - 1) * _width > _height * _width) {
 		return;
 	}
 
+	// Sometimes we're 1 beyond the map, so avoid it
+	if (_mapTileX + maxTileX - 1 >= _width)
+		maxTileX--;
+
 	_numForegrounds = _numGratings = 0;
 
 	for (int j = 0; j < maxTileY; j++) {
@@ -886,7 +890,11 @@ void Map::draw() {
 
 			// Draw if not a sky tile
 			if (!g_hdb->_gfx->isSky(tileIndex)) {
-				g_hdb->_gfx->getTile(tileIndex)->draw(screenX, screenY);
+				Tile *tile = g_hdb->_gfx->getTile(tileIndex);
+				if (tile)
+					tile->draw(screenX, screenY);
+				else
+					warning("Cannot find tile with index %d at %d,%d", tileIndex, _mapTileX + i, _mapTileY + j);
 			}
 
 			// Draw Foreground Tile


Commit: b29317c0b0f9d90b7f8f85eb682b2621d78656fb
    https://github.com/scummvm/scummvm/commit/b29317c0b0f9d90b7f8f85eb682b2621d78656fb
Author: Strangerke (strangerke at scummvm.org)
Date: 2019-09-03T17:17:35+02:00

Commit Message:
HDB: Janitorial - Fix some code formatting

Changed paths:
    engines/hdb/ai-bots.cpp
    engines/hdb/ai-funcs.cpp
    engines/hdb/ai-player.cpp
    engines/hdb/hdb.cpp
    engines/hdb/menu.cpp


diff --git a/engines/hdb/ai-bots.cpp b/engines/hdb/ai-bots.cpp
index ac4b241..6e99419 100644
--- a/engines/hdb/ai-bots.cpp
+++ b/engines/hdb/ai-bots.cpp
@@ -444,19 +444,35 @@ void aiRightBotFindGoal(AIEntity *e) {
 			// If neither, go backwards
 			if (!bg2 && !e2) {
 				switch (e->dir) {
-				case DIR_UP: e->dir = DIR_RIGHT; break;
-				case DIR_DOWN: e->dir = DIR_LEFT; break;
-				case DIR_LEFT: e->dir = DIR_UP; break;
-				case DIR_RIGHT: e->dir = DIR_DOWN; break;
+				case DIR_UP:
+					e->dir = DIR_RIGHT;
+					break;
+				case DIR_DOWN:
+					e->dir = DIR_LEFT;
+					break;
+				case DIR_LEFT:
+					e->dir = DIR_UP;
+					break;
+				case DIR_RIGHT:
+					e->dir = DIR_DOWN;
+					break;
 				case DIR_NONE:
 					break;
 				}
 			} else if (!bg && !e1) {
 				switch (e->dir) {
-				case DIR_UP: e->dir = DIR_LEFT; break;
-				case DIR_DOWN: e->dir = DIR_RIGHT; break;
-				case DIR_LEFT: e->dir = DIR_DOWN; break;
-				case DIR_RIGHT: e->dir = DIR_UP; break;
+				case DIR_UP:
+					e->dir = DIR_LEFT;
+					break;
+				case DIR_DOWN:
+					e->dir = DIR_RIGHT;
+					break;
+				case DIR_LEFT:
+					e->dir = DIR_DOWN;
+					break;
+				case DIR_RIGHT:
+					e->dir = DIR_UP;
+					break;
 				case DIR_NONE:
 					break;
 				}
@@ -685,10 +701,22 @@ void aiRailRiderAction(AIEntity *e) {
 		if (!g_hdb->_window->dialogActive()) {
 			e->sequence = 2;
 			switch (e->dir) {
-			case DIR_UP:	e->xVel = 0;	e->yVel = -1;	break;
-			case DIR_DOWN:	e->xVel = 0;	e->yVel = 1;	break;
-			case DIR_LEFT:	e->xVel = -1;	e->yVel = 0;	break;
-			case DIR_RIGHT:	e->xVel = 1;	e->yVel = 0;	break;
+			case DIR_UP:
+				e->xVel = 0;
+				e->yVel = -1;
+				break;
+			case DIR_DOWN:
+				e->xVel = 0;
+				e->yVel = 1;
+				break;
+			case DIR_LEFT:
+				e->xVel = -1;
+				e->yVel = 0;
+				break;
+			case DIR_RIGHT:
+				e->xVel = 1;
+				e->yVel = 0;
+				break;
 			case DIR_NONE:
 				break;
 			}
@@ -841,11 +869,20 @@ void aiRailRiderOnAction(AIEntity *e) {
 		p->y = e->y;
 		g_hdb->_ai->animateEntity(e);
 		switch (e->dir) {
-		case DIR_UP:	e->draw = e->moveupGfx[0]; break;
-		case DIR_DOWN:	e->draw = e->movedownGfx[0]; break;
-		case DIR_LEFT:	e->draw = e->moveleftGfx[0]; break;
-		case DIR_RIGHT: e->draw = e->moverightGfx[0]; break;
-		default: break; // DIR_NONE
+		case DIR_UP:
+			e->draw = e->moveupGfx[0];
+			break;
+		case DIR_DOWN:
+			e->draw = e->movedownGfx[0];
+			break;
+		case DIR_LEFT:
+			e->draw = e->moveleftGfx[0];
+			break;
+		case DIR_RIGHT:
+			e->draw = e->moverightGfx[0];
+			break;
+		default:
+			break; // DIR_NONE
 		}
 		g_hdb->_map->centerMapXY(e->x + 16, e->y + 16);
 
@@ -1562,8 +1599,8 @@ void aiLaserDraw(AIEntity *e, int mx, int my) {
 	case DIR_UP:
 	{
 		for (i = e->value1 - 1; i > e->value2; i--)
-			onScreen += g_hdb->_ai->_gfxLaserbeamUD[frame]->drawMasked(e->x - mx, i*kTileWidth - my);
-		onScreen += g_hdb->_ai->_gfxLaserbeamUDBottom[frame & 3]->drawMasked(e->x - mx, i*kTileWidth - my);
+			onScreen += g_hdb->_ai->_gfxLaserbeamUD[frame]->drawMasked(e->x - mx, i * kTileWidth - my);
+		onScreen += g_hdb->_ai->_gfxLaserbeamUDBottom[frame & 3]->drawMasked(e->x - mx, i * kTileWidth - my);
 		if (onScreen) {
 			g_hdb->_sound->playSoundEx(SND_LASER_LOOP, kLaserChannel, true);
 			g_hdb->_ai->_laserOnScreen = true;
@@ -1573,8 +1610,8 @@ void aiLaserDraw(AIEntity *e, int mx, int my) {
 	case DIR_DOWN:
 	{
 		for (i = e->value1 + 1; i < e->value2; i++)
-			onScreen += g_hdb->_ai->_gfxLaserbeamUD[frame]->drawMasked(e->x - mx, i*kTileWidth - my);
-		onScreen += g_hdb->_ai->_gfxLaserbeamUDBottom[frame]->drawMasked(e->x - mx, i*kTileWidth - my);
+			onScreen += g_hdb->_ai->_gfxLaserbeamUD[frame]->drawMasked(e->x - mx, i * kTileWidth - my);
+		onScreen += g_hdb->_ai->_gfxLaserbeamUDBottom[frame]->drawMasked(e->x - mx, i * kTileWidth - my);
 		if (onScreen) {
 			g_hdb->_sound->playSoundEx(SND_LASER_LOOP, kLaserChannel, true);
 			g_hdb->_ai->_laserOnScreen = true;
@@ -1584,8 +1621,8 @@ void aiLaserDraw(AIEntity *e, int mx, int my) {
 	case DIR_LEFT:
 	{
 		for (i = e->value1 - 1; i > e->value2; i--)
-			onScreen += g_hdb->_ai->_gfxLaserbeamLR[frame]->drawMasked(i*kTileWidth - mx, e->y - my);
-		onScreen += g_hdb->_ai->_gfxLaserbeamLRRight[frame]->drawMasked(i*kTileWidth - mx, e->y - my);
+			onScreen += g_hdb->_ai->_gfxLaserbeamLR[frame]->drawMasked(i * kTileWidth - mx, e->y - my);
+		onScreen += g_hdb->_ai->_gfxLaserbeamLRRight[frame]->drawMasked(i * kTileWidth - mx, e->y - my);
 		if (onScreen) {
 			g_hdb->_sound->playSoundEx(SND_LASER_LOOP, kLaserChannel, true);
 			g_hdb->_ai->_laserOnScreen = true;
@@ -1595,8 +1632,8 @@ void aiLaserDraw(AIEntity *e, int mx, int my) {
 	case DIR_RIGHT:
 	{
 		for (i = e->value1 + 1; i < e->value2; i++)
-			onScreen += g_hdb->_ai->_gfxLaserbeamLR[frame]->drawMasked(i*kTileWidth - mx, e->y - my);
-		onScreen += g_hdb->_ai->_gfxLaserbeamLRLeft[frame]->drawMasked(i*kTileWidth - mx, e->y - my);
+			onScreen += g_hdb->_ai->_gfxLaserbeamLR[frame]->drawMasked(i * kTileWidth - mx, e->y - my);
+		onScreen += g_hdb->_ai->_gfxLaserbeamLRLeft[frame]->drawMasked(i * kTileWidth - mx, e->y - my);
 		if (onScreen) {
 			g_hdb->_sound->playSoundEx(SND_LASER_LOOP, kLaserChannel, true);
 			g_hdb->_ai->_laserOnScreen = true;
diff --git a/engines/hdb/ai-funcs.cpp b/engines/hdb/ai-funcs.cpp
index 7b2f148..255e058 100644
--- a/engines/hdb/ai-funcs.cpp
+++ b/engines/hdb/ai-funcs.cpp
@@ -908,8 +908,6 @@ void AI::animateEntity(AIEntity *e) {
 	static const int xva[5] = {9, 0, 0, -1, 1};
 	static const int yva[5] = {9, -1, 1, 0, 0};
 
-	int bgTileFlags, fgTileFlags;
-
 	// Move entity if player is not dead
 	debug(9, "Before animateEntity, e->x: %d, e->y: %d", e->x, e->y);
 	debug(9, "Before animateEntity, e->tileX: %d, e->tileY: %d", e->tileX, e->tileY);
@@ -960,8 +958,8 @@ void AI::animateEntity(AIEntity *e) {
 		}
 
 		// Are we on ice?
-		bgTileFlags = g_hdb->_map->getMapBGTileFlags(e->tileX, e->tileY);
-		fgTileFlags = g_hdb->_map->getMapFGTileFlags(e->tileX, e->tileY);
+		int bgTileFlags = g_hdb->_map->getMapBGTileFlags(e->tileX, e->tileY);
+		int fgTileFlags = g_hdb->_map->getMapFGTileFlags(e->tileX, e->tileY);
 
 		if (e->level == 1 ? ((bgTileFlags & kFlagIce) == kFlagIce) : (((bgTileFlags & kFlagIce) == kFlagIce) && !(fgTileFlags & kFlagGrating))) {
 			int nx, ny, moveOK = 0;
@@ -1027,11 +1025,20 @@ void AI::animateEntity(AIEntity *e) {
 			if (!result) {
 				int xv = 0, yv = 0;
 				switch (e->dir) {
-				case DIR_UP:	yv = -1;	break;
-				case DIR_DOWN:	yv = 1;		break;
-				case DIR_LEFT:	xv = -1;	break;
-				case DIR_RIGHT: xv = 1;		break;
-				case DIR_NONE:	break;
+				case DIR_UP:
+					yv = -1;
+					break;
+				case DIR_DOWN:
+					yv = 1;
+					break;
+				case DIR_LEFT:
+					xv = -1;
+					break;
+				case DIR_RIGHT:
+					xv = 1;
+					break;
+				case DIR_NONE:
+					break;
 				}
 
 				bgTileFlags = g_hdb->_map->getMapBGTileFlags(e->tileX + xv, e->tileY + yv);
@@ -1053,8 +1060,8 @@ void AI::animateEntity(AIEntity *e) {
 		// Check for bad tiles (DEATH)
 		int cx = (e->x + 16) / kTileWidth;
 		int cy = (e->y + 16) / kTileHeight;
-		bgTileFlags = g_hdb->_map->getMapBGTileFlags(cx, cy);
-		fgTileFlags = g_hdb->_map->getMapFGTileFlags(cx, cy);
+		int bgTileFlags = g_hdb->_map->getMapBGTileFlags(cx, cy);
+		int fgTileFlags = g_hdb->_map->getMapFGTileFlags(cx, cy);
 		if ((bgTileFlags & kFlagPlayerDie) && !(checkFloating(cx, cy)) && !(fgTileFlags & kFlagGrating)) {
 			if ((bgTileFlags & kFlagEnergyFloor) == kFlagEnergyFloor)
 				killPlayer(DEATH_SHOCKED);
@@ -1105,9 +1112,9 @@ void AI::animateEntity(AIEntity *e) {
 	}
 
 	// Check for moving up/down stair levels
-	int bgTileIndex = g_hdb->_map->getMapBGTileIndex(e->tileX, e->tileY); // CHECKME: unused?
-	bgTileFlags = g_hdb->_map->getMapBGTileFlags(e->tileX, e->tileY);
-	fgTileFlags = g_hdb->_map->getMapFGTileFlags(e->tileX, e->tileY); // CHECKME: unused?
+//	int bgTileIndex = g_hdb->_map->getMapBGTileIndex(e->tileX, e->tileY); // CHECKME: unused?
+	int bgTileFlags = g_hdb->_map->getMapBGTileFlags(e->tileX, e->tileY);
+//	fgTileFlags = g_hdb->_map->getMapFGTileFlags(e->tileX, e->tileY); // CHECKME: unused?
 	if (bgTileFlags & kFlagStairTop)
 		e->level = 2;
 	else if (bgTileFlags & kFlagStairBot)
@@ -1153,11 +1160,32 @@ void AI::animateEntity(AIEntity *e) {
 					AIEntity *hit = legalMove(nx, ny, e->level, &result2);
 					if (!hit && result2) {
 						switch (e->dir) {
-						case DIR_UP:	e->goalY = ny;	e->xVel = 0; e->yVel = -kPlayerMoveSpeed; e->state = STATE_MOVEUP; break;
-						case DIR_DOWN:	e->goalY = ny;  e->xVel = 0; e->yVel =  kPlayerMoveSpeed; e->state = STATE_MOVEDOWN; break;
-						case DIR_LEFT:	e->goalX = nx;  e->yVel = 0; e->xVel = -kPlayerMoveSpeed; e->state = STATE_MOVELEFT; break;
-						case DIR_RIGHT: e->goalX = nx;  e->yVel = 0; e->xVel =  kPlayerMoveSpeed; e->state = STATE_MOVERIGHT; break;
-						case DIR_NONE:	break;
+						case DIR_UP:
+							e->goalY = ny;
+							e->xVel = 0;
+							e->yVel = -kPlayerMoveSpeed;
+							e->state = STATE_MOVEUP;
+							break;
+						case DIR_DOWN:
+							e->goalY = ny;
+							e->xVel = 0;
+							e->yVel = kPlayerMoveSpeed;
+							e->state = STATE_MOVEDOWN;
+							break;
+						case DIR_LEFT:
+							e->goalX = nx;
+							e->yVel = 0;
+							e->xVel = -kPlayerMoveSpeed;
+							e->state = STATE_MOVELEFT;
+							break;
+						case DIR_RIGHT:
+							e->goalX = nx;
+							e->yVel = 0;
+							e->xVel = kPlayerMoveSpeed;
+							e->state = STATE_MOVERIGHT;
+							break;
+						case DIR_NONE:
+							break;
 						}
 						if (_playerRunning) {
 							e->xVel = e->xVel << 1;
diff --git a/engines/hdb/ai-player.cpp b/engines/hdb/ai-player.cpp
index 46d9dfc..84bfa8e 100644
--- a/engines/hdb/ai-player.cpp
+++ b/engines/hdb/ai-player.cpp
@@ -201,10 +201,22 @@ void aiPlayerAction(AIEntity *e) {
 		if (!e->animFrame--) {
 			// Done with the Grabbing Animation, switch to standing
 			switch (e->state) {
-			case STATE_GRABUP:		e->draw = e->standupGfx[0];	e->state = STATE_STANDUP; break;
-			case STATE_GRABDOWN:	e->draw = e->standdownGfx[0];	e->state = STATE_STANDDOWN; break;
-			case STATE_GRABLEFT:	e->draw = e->standleftGfx[0];	e->state = STATE_STANDLEFT; break;
-			case STATE_GRABRIGHT:	e->draw = e->standrightGfx[0];	e->state = STATE_STANDRIGHT; break;
+			case STATE_GRABUP:
+				e->draw = e->standupGfx[0];
+				e->state = STATE_STANDUP;
+				break;
+			case STATE_GRABDOWN:
+				e->draw = e->standdownGfx[0];
+				e->state = STATE_STANDDOWN;
+				break;
+			case STATE_GRABLEFT:
+				e->draw = e->standleftGfx[0];
+				e->state = STATE_STANDLEFT;
+				break;
+			case STATE_GRABRIGHT:
+				e->draw = e->standrightGfx[0];
+				e->state = STATE_STANDRIGHT;
+				break;
 			default:
 				break;
 			}
@@ -221,20 +233,36 @@ void aiPlayerAction(AIEntity *e) {
 		e->drawXOff = xOff[e->state - STATE_ATK_CLUB_UP];
 		e->drawYOff = yOff[e->state - STATE_ATK_CLUB_UP];
 		switch (e->state) {
-		case STATE_ATK_CLUB_UP:		cycleFrames(e, g_hdb->_ai->_clubUpFrames); break;
-		case STATE_ATK_CLUB_DOWN:	cycleFrames(e, g_hdb->_ai->_clubDownFrames); break;
-		case STATE_ATK_CLUB_LEFT:	cycleFrames(e, g_hdb->_ai->_clubLeftFrames); break;
-		case STATE_ATK_CLUB_RIGHT:	cycleFrames(e, g_hdb->_ai->_clubRightFrames); break;
+		case STATE_ATK_CLUB_UP:
+			cycleFrames(e, g_hdb->_ai->_clubUpFrames);
+			break;
+		case STATE_ATK_CLUB_DOWN:
+			cycleFrames(e, g_hdb->_ai->_clubDownFrames);
+			break;
+		case STATE_ATK_CLUB_LEFT:
+			cycleFrames(e, g_hdb->_ai->_clubLeftFrames);
+			break;
+		case STATE_ATK_CLUB_RIGHT:
+			cycleFrames(e, g_hdb->_ai->_clubRightFrames);
+			break;
 		default:
 			break;
 		}
 		// Whack!
 		if ((e->animFrame >= 1) && (e->animDelay == e->animCycle)) {
 			switch (e->dir) {
-			case DIR_UP:	hit = g_hdb->_ai->playerCollision(32, 0, 16, 16); break;
-			case DIR_DOWN:	hit = g_hdb->_ai->playerCollision(0, 32, 16, 16); break;
-			case DIR_LEFT:	hit = g_hdb->_ai->playerCollision(16, 16, 32, 0); break;
-			case DIR_RIGHT:	hit = g_hdb->_ai->playerCollision(16, 16, 0, 32); break;
+			case DIR_UP:
+				hit = g_hdb->_ai->playerCollision(32, 0, 16, 16);
+				break;
+			case DIR_DOWN:
+				hit = g_hdb->_ai->playerCollision(0, 32, 16, 16);
+				break;
+			case DIR_LEFT:
+				hit = g_hdb->_ai->playerCollision(16, 16, 32, 0);
+				break;
+			case DIR_RIGHT:
+				hit = g_hdb->_ai->playerCollision(16, 16, 0, 32);
+				break;
 			default:
 				break;
 			}
@@ -280,10 +308,18 @@ void aiPlayerAction(AIEntity *e) {
 			e->state = stand[e->dir];
 			e->aiDraw = NULL;
 			switch (e->state) {
-			case STATE_ATK_CLUB_UP:		e->draw = e->standupGfx[0]; break;
-			case STATE_ATK_CLUB_DOWN:	e->draw = e->standdownGfx[0]; break;
-			case STATE_ATK_CLUB_LEFT:	e->draw = e->standleftGfx[0]; break;
-			case STATE_ATK_CLUB_RIGHT:	e->draw = e->standrightGfx[0]; break;
+			case STATE_ATK_CLUB_UP:
+				e->draw = e->standupGfx[0];
+				break;
+			case STATE_ATK_CLUB_DOWN:
+				e->draw = e->standdownGfx[0];
+				break;
+			case STATE_ATK_CLUB_LEFT:
+				e->draw = e->standleftGfx[0];
+				break;
+			case STATE_ATK_CLUB_RIGHT:
+				e->draw = e->standrightGfx[0];
+				break;
 			default:
 				break;
 			}
@@ -922,9 +958,8 @@ void aiScientistInit2(AIEntity *e) {
 }
 
 void aiSlugAttackAction(AIEntity *e) {
-	int xv[5] = {9, 0, 0, -1, 1}, yv[5] = {9, -1, 1, 0, 0};
-	AIEntity *hit;
-	int	result;
+	static const int xv[5] = {9, 0, 0, -1, 1};
+	static const int yv[5] = {9, -1, 1, 0, 0};
 
 	if (e->goalX)
 		g_hdb->_ai->animateEntity(e);
@@ -932,7 +967,7 @@ void aiSlugAttackAction(AIEntity *e) {
 	g_hdb->_ai->checkActionList(e, e->tileX, e->tileY, false);
 	g_hdb->_ai->checkAutoList(e, e->tileX, e->tileY);
 
-	hit = g_hdb->_ai->findEntityIgnore(e->tileX, e->tileY, e);
+	AIEntity *hit = g_hdb->_ai->findEntityIgnore(e->tileX, e->tileY, e);
 	if (hit && hit->type == AI_GUY)
 		hit = NULL;
 
@@ -946,7 +981,7 @@ void aiSlugAttackAction(AIEntity *e) {
 
 	uint32 bg_flags = g_hdb->_map->getMapBGTileFlags(e->tileX, e->tileY);
 	uint32 fg_flags = g_hdb->_map->getMapFGTileFlags(e->tileX, e->tileY);
-	result = (e->level == 1 ? (bg_flags & (kFlagSolid)) : !(fg_flags & kFlagGrating) && (bg_flags & (kFlagSolid)));
+	int	result = (e->level == 1 ? (bg_flags & (kFlagSolid)) : !(fg_flags & kFlagGrating) && (bg_flags & (kFlagSolid)));
 	if (hit) {
 		g_hdb->_sound->playSound(SND_SLUG_HIT);
 		g_hdb->_sound->playSound(g_hdb->_ai->metalOrFleshSND(hit));
@@ -1052,10 +1087,12 @@ void aiSlugAttackDraw(AIEntity *e, int mx, int my) {
 }
 
 void aiSlugAttackInit(AIEntity *e) {
+	static const int xv[5] = {9,  0, 0, -1, 1};
+	static const int yv[5] = {9, -1, 1,  0, 0};
+
 	if (g_hdb->isDemo())
 		return;
 
-	int xv[5] = {9, 0, 0, -1, 1}, yv[5] = {9, -1, 1, 0, 0};
 	e->moveSpeed = kPlayerMoveSpeed << 1;
 	g_hdb->_ai->setEntityGoal(e, e->tileX + xv[e->dir], e->tileY + yv[e->dir]);
 	e->draw = NULL;					// use custom draw function
diff --git a/engines/hdb/hdb.cpp b/engines/hdb/hdb.cpp
index 62e2ec8..557c8ba 100644
--- a/engines/hdb/hdb.cpp
+++ b/engines/hdb/hdb.cpp
@@ -715,11 +715,20 @@ void HDBGame::useEntity(AIEntity *e) {
 		// Diverters are very special - don't mess with their direction & state!
 		if (e->type == AI_DIVERTER) {
 			switch (e->dir2) {
-			case DIR_DOWN: e->state = STATE_DIVERTER_BL; break;
-			case DIR_UP: e->state = STATE_DIVERTER_BR; break;
-			case DIR_LEFT: e->state = STATE_DIVERTER_TL; break;
-			case DIR_RIGHT: e->state = STATE_DIVERTER_TR; break;
-			case DIR_NONE: break;
+			case DIR_DOWN:
+				e->state = STATE_DIVERTER_BL;
+				break;
+			case DIR_UP:
+				e->state = STATE_DIVERTER_BR;
+				break;
+			case DIR_LEFT:
+				e->state = STATE_DIVERTER_TL;
+				break;
+			case DIR_RIGHT:
+				e->state = STATE_DIVERTER_TR;
+				break;
+			case DIR_NONE:
+				break;
 			}
 		}
 
@@ -737,11 +746,24 @@ void HDBGame::useEntity(AIEntity *e) {
 
 		// need to set the state AFTER the SetEntityGoal!
 		switch (p->dir) {
-		case DIR_UP:	p->state = STATE_PUSHUP;	p->drawYOff = -10; break;
-		case DIR_DOWN:	p->state = STATE_PUSHDOWN;	p->drawYOff = 9; break;
-		case DIR_LEFT:	p->state = STATE_PUSHLEFT;	p->drawXOff = -10; break;
-		case DIR_RIGHT:	p->state = STATE_PUSHRIGHT; p->drawXOff = 10; break;
-		case DIR_NONE: break;
+		case DIR_UP:
+			p->state = STATE_PUSHUP;
+			p->drawYOff = -10;
+			break;
+		case DIR_DOWN:
+			p->state = STATE_PUSHDOWN;
+			p->drawYOff = 9;
+			break;
+		case DIR_LEFT:
+			p->state = STATE_PUSHLEFT;
+			p->drawXOff = -10;
+			break;
+		case DIR_RIGHT:
+			p->state = STATE_PUSHRIGHT;
+			p->drawXOff = 10;
+			break;
+		case DIR_NONE:
+			break;
 		}
 
 		// if player is running, keep speed slow since we're pushing
@@ -752,17 +774,21 @@ void HDBGame::useEntity(AIEntity *e) {
 
 		switch (e->type) {
 		case AI_CRATE:
-			g_hdb->_sound->playSound(SND_CRATE_SLIDE); break;
+			g_hdb->_sound->playSound(SND_CRATE_SLIDE);
+			break;
 		case AI_LIGHTBARREL:
 		case AI_FROGSTATUE:
 		case AI_ICE_BLOCK:
-			g_hdb->_sound->playSound(SND_LIGHT_SLIDE); break;
+			g_hdb->_sound->playSound(SND_LIGHT_SLIDE);
+			break;
 		case AI_HEAVYBARREL:
 		case AI_MAGIC_EGG:
 		case AI_BOOMBARREL:
-			g_hdb->_sound->playSound(SND_HEAVY_SLIDE); break;
+			g_hdb->_sound->playSound(SND_HEAVY_SLIDE);
+			break;
 		case AI_DIVERTER:
-			g_hdb->_sound->playSound(SND_PUSH_DIVERTER); break;
+			g_hdb->_sound->playSound(SND_PUSH_DIVERTER);
+			break;
 		default:
 			break;
 		}
@@ -875,9 +901,8 @@ void HDBGame::setInMapName(const char *name) {
 Common::Error HDBGame::run() {
 
 	// Initialize System
-	if (!_systemInit) {
+	if (!_systemInit)
 		init();
-	}
 
 	// Initializes Graphics
 	initGraphics(_screenWidth, _screenHeight, &_format);
@@ -1056,9 +1081,8 @@ Common::Error HDBGame::run() {
 		uint32 frameTime = curTime - lastTime;
 
 		uint32 frameCap = 1000 / kGameFPS;
-		if (frameTime < frameCap) {
+		if (frameTime < frameCap)
 			g_system->delayMillis(frameCap - frameTime);
-		}
 
 		lastTime = g_system->getMillis();
 	}
diff --git a/engines/hdb/menu.cpp b/engines/hdb/menu.cpp
index c11821c..34c7c62 100644
--- a/engines/hdb/menu.cpp
+++ b/engines/hdb/menu.cpp
@@ -558,9 +558,15 @@ void Menu::drawMenu() {
 			_optionsXV += 3;
 			if (_optionsScrollX > g_hdb->_screenWidth + 10) {
 				switch (_nextScreen) {
-				case 0: _optionsActive = true; break;
-				case 1: _gamefilesActive = 1; break;
-				case 2: _newgameActive = true; break;
+				case 0:
+					_optionsActive = true;
+					break;
+				case 1:
+					_gamefilesActive = 1;
+					break;
+				case 2:
+					_newgameActive = true;
+					break;
 				}
 
 				_oBannerY = 0;
@@ -1662,9 +1668,15 @@ void Menu::drawRocketAndSelections() {
 
 	// top-down/up scrolling stuff
 	switch (_nextScreen) {
-	case 0: _optionsGfx->drawMasked(centerPic(_optionsGfx), _oBannerY); break;
-	case 1: _modeLoadGfx->drawMasked(centerPic(_modeLoadGfx), _oBannerY); break;
-	case 2: _newGfx->drawMasked(centerPic(_newGfx), _oBannerY); break;
+	case 0:
+		_optionsGfx->drawMasked(centerPic(_optionsGfx), _oBannerY);
+		break;
+	case 1:
+		_modeLoadGfx->drawMasked(centerPic(_modeLoadGfx), _oBannerY);
+		break;
+	case 2:
+		_newGfx->drawMasked(centerPic(_newGfx), _oBannerY);
+		break;
 	}
 
 	// menu items


Commit: 32969d3d7e3ead8f86cdb6028b109abdcefa4591
    https://github.com/scummvm/scummvm/commit/32969d3d7e3ead8f86cdb6028b109abdcefa4591
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:35+02:00

Commit Message:
HDB: Fix monkeystone star triggers

Changed paths:
    engines/hdb/menu.cpp


diff --git a/engines/hdb/menu.cpp b/engines/hdb/menu.cpp
index 34c7c62..33e07d5 100644
--- a/engines/hdb/menu.cpp
+++ b/engines/hdb/menu.cpp
@@ -389,6 +389,8 @@ void Menu::writeConfig() {
 
 	if (g_hdb->getCheatingOn())
 		ConfMan.set(CONFIG_CHEAT, "1");
+
+	ConfMan.flushToDisk();
 }
 
 static const char nebulaNames[kNebulaCount][32] = {


Commit: abbe16bf011739fae32d0fd9f23d551d20f472c7
    https://github.com/scummvm/scummvm/commit/abbe16bf011739fae32d0fd9f23d551d20f472c7
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:35+02:00

Commit Message:
HDB: Do not write config on every launch

Changed paths:
    engines/hdb/menu.cpp


diff --git a/engines/hdb/menu.cpp b/engines/hdb/menu.cpp
index 33e07d5..8e20653 100644
--- a/engines/hdb/menu.cpp
+++ b/engines/hdb/menu.cpp
@@ -310,22 +310,27 @@ bool Menu::init() {
 }
 
 void Menu::readConfig() {
+	bool needFlush = false;
+
 	if (ConfMan.hasKey(CONFIG_MSTONE7)) {
 		g_hdb->setStarsMonkeystone7(ConfMan.getInt(CONFIG_MSTONE7));
 	} else {
 		ConfMan.setInt(CONFIG_MSTONE7, STARS_MONKEYSTONE_7_FAKE);
+		needFlush = true;
 	}
 
 	if (ConfMan.hasKey(CONFIG_MSTONE14)) {
 		g_hdb->setStarsMonkeystone14(ConfMan.getInt(CONFIG_MSTONE14));
 	} else {
 		ConfMan.setInt(CONFIG_MSTONE14, STARS_MONKEYSTONE_14_FAKE);
+		needFlush = true;
 	}
 
 	if (ConfMan.hasKey(CONFIG_MSTONE21)) {
 		g_hdb->setStarsMonkeystone21(ConfMan.getInt(CONFIG_MSTONE21));
 	} else {
 		ConfMan.setInt(CONFIG_MSTONE21, STARS_MONKEYSTONE_21_FAKE);
+		needFlush = true;
 	}
 
 	if (ConfMan.hasKey(CONFIG_KEY_UP)) {
@@ -333,6 +338,7 @@ void Menu::readConfig() {
 		g_hdb->_input->assignKey(0, _keyAssignUp);
 	} else {
 		ConfMan.setInt(CONFIG_KEY_UP, _keyAssignUp);
+		needFlush = true;
 	}
 
 	if (ConfMan.hasKey(CONFIG_KEY_DOWN)) {
@@ -340,6 +346,7 @@ void Menu::readConfig() {
 		g_hdb->_input->assignKey(1, _keyAssignDown);
 	} else {
 		ConfMan.setInt(CONFIG_KEY_DOWN, _keyAssignDown);
+		needFlush = true;
 	}
 
 	if (ConfMan.hasKey(CONFIG_KEY_LEFT)) {
@@ -347,6 +354,7 @@ void Menu::readConfig() {
 		g_hdb->_input->assignKey(2, _keyAssignLeft);
 	} else {
 		ConfMan.setInt(CONFIG_KEY_LEFT, _keyAssignLeft);
+		needFlush = true;
 	}
 
 	if (ConfMan.hasKey(CONFIG_KEY_RIGHT)) {
@@ -354,6 +362,7 @@ void Menu::readConfig() {
 		g_hdb->_input->assignKey(3, _keyAssignRight);
 	} else {
 		ConfMan.setInt(CONFIG_KEY_RIGHT, _keyAssignRight);
+		needFlush = true;
 	}
 
 	if (ConfMan.hasKey(CONFIG_KEY_USE)) {
@@ -361,6 +370,7 @@ void Menu::readConfig() {
 		g_hdb->_input->assignKey(4, _keyAssignUse);
 	} else {
 		ConfMan.setInt(CONFIG_KEY_USE, _keyAssignUse);
+		needFlush = true;
 	}
 
 	if (ConfMan.hasKey(CONFIG_CHEAT)) {
@@ -368,7 +378,8 @@ void Menu::readConfig() {
 		debug("Cheating enabled");
 	}
 
-	ConfMan.flushToDisk();
+	if (needFlush)
+		ConfMan.flushToDisk();
 }
 
 void Menu::writeConfig() {


Commit: 373002d3039192b56b46b1ad09035f3cbfa13202
    https://github.com/scummvm/scummvm/commit/373002d3039192b56b46b1ad09035f3cbfa13202
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:35+02:00

Commit Message:
HDB: Added debug output for map loading

Changed paths:
    engines/hdb/hdb.cpp
    engines/hdb/saveload.cpp


diff --git a/engines/hdb/hdb.cpp b/engines/hdb/hdb.cpp
index 557c8ba..b8aa0fd 100644
--- a/engines/hdb/hdb.cpp
+++ b/engines/hdb/hdb.cpp
@@ -217,6 +217,8 @@ bool HDBGame::restartMap() {
 	if (!_currentMapname[0])
 		return false;
 
+	debug(0, "Starting map %s", _currentMapname);
+
 	_gfx->emptyGfxCaches();
 	_lua->callFunction("level_shutdown", 0);
 
diff --git a/engines/hdb/saveload.cpp b/engines/hdb/saveload.cpp
index 618d9a9..acf1092 100644
--- a/engines/hdb/saveload.cpp
+++ b/engines/hdb/saveload.cpp
@@ -217,6 +217,9 @@ void HDBGame::save(Common::OutSaveFile *out) {
 
 void HDBGame::loadSaveFile(Common::InSaveFile *in) {
 	in->read(_currentMapname, 64);
+
+	debug(0, "Loading map %s", _currentMapname);
+
 	in->read(_lastMapname, 64);
 	in->read(_currentLuaName, 64);
 	_actionMode = in->readSint32LE();


Commit: 100ea9ff0e2517d9c61dccd8378e74333b91cb2a
    https://github.com/scummvm/scummvm/commit/100ea9ff0e2517d9c61dccd8378e74333b91cb2a
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-09-03T17:17:35+02:00

Commit Message:
HDB: Fix warnings

Changed paths:
    engines/hdb/gfx.cpp
    engines/hdb/hdb.cpp
    engines/hdb/window.cpp


diff --git a/engines/hdb/gfx.cpp b/engines/hdb/gfx.cpp
index 83061ac..d7bb470 100644
--- a/engines/hdb/gfx.cpp
+++ b/engines/hdb/gfx.cpp
@@ -381,7 +381,6 @@ void Gfx::updateFade() {
 	uint8 r, g, b;
 	uint16 value;
 	uint16 *ptr;
-	static int waitAFrame = 0;
 
 	if (!_fadeInfo.active && !_fadeInfo.stayFaded)
 		return;
@@ -445,6 +444,8 @@ void Gfx::updateFade() {
 	} else {
 		_fadeBuffer2.blitFrom(_globalSurface);
 
+		static int waitAFrame = 0;
+
 		do {
 			// Copy pristine copy of background to modification buffer
 			_fadeBuffer1.blitFrom(_fadeBuffer2);
diff --git a/engines/hdb/hdb.cpp b/engines/hdb/hdb.cpp
index b8aa0fd..c7c206c 100644
--- a/engines/hdb/hdb.cpp
+++ b/engines/hdb/hdb.cpp
@@ -949,7 +949,7 @@ Common::Error HDBGame::run() {
 			strcpy(mapname, "CINE_OUTRO");
 
 		if (isDemo())
-			strncat(mapname, "_DEMO", 20);
+			strcat(mapname, "_DEMO");
 
 		debug("Starting level %s in %s", mapname, getActionMode() ? "Action Mode" : "Puzzle Mode");
 
diff --git a/engines/hdb/window.cpp b/engines/hdb/window.cpp
index d10ccac..044347c 100644
--- a/engines/hdb/window.cpp
+++ b/engines/hdb/window.cpp
@@ -474,8 +474,8 @@ void Window::loadSaveFile(Common::InSaveFile *in) {
 		in->read(t->text, 128);
 		t->x = in->readSint32LE();
 		t->y = in->readSint32LE();
-		t->timer = in->readUint32LE();
-		t->timer = g_system->getMillis() + 1000;
+		(void)in->readUint32LE(); // Skip timer value
+		t->timer = g_system->getMillis() + 1000; // And override it to a second
 
 		_textOutList.push_back(t);
 	}





More information about the Scummvm-git-logs mailing list